1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/webvtt/nsIWebVTTParserWrapper.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,87 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "nsISupports.idl" 1.9 + 1.10 +interface nsIDOMHTMLElement; 1.11 +interface nsIWebVTTListener; 1.12 +interface nsIDOMWindow; 1.13 +interface nsIVariant; 1.14 + 1.15 +/** 1.16 + * Interface for a wrapper of a JS WebVTT parser (vtt.js). 1.17 + */ 1.18 +[scriptable, uuid(acf6e493-0092-4b26-b172-241e375c57ab)] 1.19 +interface nsIWebVTTParserWrapper : nsISupports 1.20 +{ 1.21 + /** 1.22 + * Loads the JS WebVTTParser and sets it to use the passed window to create 1.23 + * VTTRegions and VTTCues. This function must be called before calling 1.24 + * parse, flush, or watch. 1.25 + * 1.26 + * @param window The window that the parser will use to create VTTCues and 1.27 + * VTTRegions. 1.28 + * 1.29 + */ 1.30 + void loadParser(in nsIDOMWindow window); 1.31 + 1.32 + /** 1.33 + * Attempts to parse the stream's data as WebVTT format. When it successfully 1.34 + * parses a WebVTT region or WebVTT cue it will create a VTTRegion or VTTCue 1.35 + * object and pass it back to the callee through its callbacks. 1.36 + * 1.37 + * @param data The buffer that contains the WebVTT data received by the 1.38 + * Necko consumer so far. 1.39 + */ 1.40 + void parse(in ACString data); 1.41 + 1.42 + /** 1.43 + * Flush indicates that no more data is expected from the stream. As such the 1.44 + * parser should try to parse any kind of partial data it has. 1.45 + */ 1.46 + void flush(); 1.47 + 1.48 + /** 1.49 + * Set this parser object to use an nsIWebVTTListener object for its onCue 1.50 + * and onRegion callbacks. 1.51 + * 1.52 + * @param callback The nsIWebVTTListener object that exposes onCue and 1.53 + * onRegion callbacks for the parser. 1.54 + */ 1.55 + void watch(in nsIWebVTTListener callback); 1.56 + 1.57 + /** 1.58 + * Convert the text content of a WebVTT cue to a document fragment so that 1.59 + * we can display it on the page. 1.60 + * 1.61 + * @param window A window object with which the document fragment will be 1.62 + * created. 1.63 + * @param cue The cue whose content will be converted to a document 1.64 + * fragment. 1.65 + */ 1.66 + nsIDOMHTMLElement convertCueToDOMTree(in nsIDOMWindow window, 1.67 + in nsISupports cue); 1.68 + 1.69 + 1.70 + /** 1.71 + * Compute the display state of the VTTCues in cues along with any VTTRegions 1.72 + * that they might be in. First, it computes the positioning and styling of 1.73 + * the cues and regions passed and converts them into a DOM tree rooted at 1.74 + * a containing HTMLDivElement. It then adjusts those computed divs for 1.75 + * overlap avoidance using the dimensions of 'overlay'. Finally, it adds the 1.76 + * computed divs to the VTTCues display state property for use later. 1.77 + * 1.78 + * @param window A window object with which it will create the DOM tree 1.79 + * and containing div element. 1.80 + * @param cues An array of VTTCues who need there display state to be 1.81 + * computed. 1.82 + * @param overlay The HTMLElement that the cues will be displayed within. 1.83 + */ 1.84 + void processCues(in nsIDOMWindow window, in nsIVariant cues, 1.85 + in nsISupports overlay); 1.86 +}; 1.87 + 1.88 +%{C++ 1.89 +#define NS_WEBVTTPARSERWRAPPER_CONTRACTID "@mozilla.org/webvttParserWrapper;1" 1.90 +%}