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