nsIWebVTTParserWrapper.idl (3367B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #include "nsISupports.idl" 6 7 interface nsIWebVTTListener; 8 interface mozIDOMWindow; 9 interface nsIVariant; 10 11 webidl DocumentFragment; 12 13 /** 14 * Interface for a wrapper of a JS WebVTT parser (vtt.js). 15 */ 16 [scriptable, uuid(8dfe016e-1701-4618-9f5e-9a6154e853f0)] 17 interface nsIWebVTTParserWrapper : nsISupports 18 { 19 /** 20 * Loads the JS WebVTTParser and sets it to use the passed window to create 21 * VTTRegions and VTTCues. This function must be called before calling 22 * parse, flush, or watch. 23 * 24 * @param window The window that the parser will use to create VTTCues and 25 * VTTRegions. 26 * 27 */ 28 void loadParser(in mozIDOMWindow window); 29 30 /** 31 * Attempts to parse the stream's data as WebVTT format. When it successfully 32 * parses a WebVTT region or WebVTT cue it will create a VTTRegion or VTTCue 33 * object and pass it back to the callee through its callbacks. 34 * 35 * @param data The buffer that contains the WebVTT data received by the 36 * Necko consumer so far. 37 */ 38 void parse(in ACString data); 39 40 /** 41 * Flush indicates that no more data is expected from the stream. As such the 42 * parser should try to parse any kind of partial data it has. 43 */ 44 void flush(); 45 46 /** 47 * Set this parser object to use an nsIWebVTTListener object for its onCue 48 * and onRegion callbacks. 49 * 50 * @param callback The nsIWebVTTListener object that exposes onCue and 51 * onRegion callbacks for the parser. 52 */ 53 void watch(in nsIWebVTTListener callback); 54 55 /** 56 * Cancel watching notifications which parser would send. 57 */ 58 void cancel(); 59 60 /** 61 * Convert the text content of a WebVTT cue to a document fragment so that 62 * we can display it on the page. 63 * 64 * @param window A window object with which the document fragment will be 65 * created. 66 * @param cue The cue whose content will be converted to a document 67 * fragment. 68 */ 69 DocumentFragment convertCueToDOMTree(in mozIDOMWindow window, 70 in nsISupports cue); 71 72 73 /** 74 * Compute the display state of the VTTCues in cues along with any VTTRegions 75 * that they might be in. First, it computes the positioning and styling of 76 * the cues and regions passed and converts them into a DOM tree rooted at 77 * a containing HTMLDivElement. It then adjusts those computed divs for 78 * overlap avoidance using the dimensions of 'overlay'. Finally, it adds the 79 * computed divs to the VTTCues display state property for use later. 80 * 81 * @param window A window object with which it will create the DOM tree 82 * and containing div element. 83 * @param cues An array of VTTCues who need there display state to be 84 * computed. 85 * @param overlay The HTMLElement that the cues will be displayed within. 86 * @param controls The video control element that will affect cues position. 87 */ 88 void processCues(in mozIDOMWindow window, in nsIVariant cues, 89 in nsISupports overlay, in nsISupports controls); 90 }; 91 92 %{C++ 93 #define NS_WEBVTTPARSERWRAPPER_CONTRACTID "@mozilla.org/webvttParserWrapper;1" 94 %}