Backed out changeset f594e6f00208 (bug 1940883) for causing crashes in bug 1941164.
[gecko.git] / dom / media / webvtt / nsIWebVTTParserWrapper.idl
blob76725d568bb2eaa842f22c6bdee057cd3eccecae
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/. */
5 #include "nsISupports.idl"
7 interface nsIWebVTTListener;
8 interface mozIDOMWindow;
9 interface nsIVariant;
11 webidl DocumentFragment;
13 /**
14 * Interface for a wrapper of a JS WebVTT parser (vtt.js).
16 [scriptable, uuid(8dfe016e-1701-4618-9f5e-9a6154e853f0)]
17 interface nsIWebVTTParserWrapper : nsISupports
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.
24 * @param window The window that the parser will use to create VTTCues and
25 * VTTRegions.
28 void loadParser(in mozIDOMWindow window);
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.
35 * @param data The buffer that contains the WebVTT data received by the
36 * Necko consumer so far.
38 void parse(in ACString data);
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.
44 void flush();
46 /**
47 * Set this parser object to use an nsIWebVTTListener object for its onCue
48 * and onRegion callbacks.
50 * @param callback The nsIWebVTTListener object that exposes onCue and
51 * onRegion callbacks for the parser.
53 void watch(in nsIWebVTTListener callback);
55 /**
56 * Cancel watching notifications which parser would send.
58 void cancel();
60 /**
61 * Convert the text content of a WebVTT cue to a document fragment so that
62 * we can display it on the page.
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.
69 DocumentFragment convertCueToDOMTree(in mozIDOMWindow window,
70 in nsISupports cue);
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.
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.
88 void processCues(in mozIDOMWindow window, in nsIVariant cues,
89 in nsISupports overlay, in nsISupports controls);
92 %{C++
93 #define NS_WEBVTTPARSERWRAPPER_CONTRACTID "@mozilla.org/webvttParserWrapper;1"