content/media/webvtt/nsIWebVTTParserWrapper.idl

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

mercurial