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
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/.
5 *
6 * The origin of this IDL file is:
7 * http://dom.spec.whatwg.org/#interface-document
8 * http://www.whatwg.org/specs/web-apps/current-work/#the-document-object
9 * http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#api
10 * http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html#extensions-to-the-document-interface
11 * http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#sec-document-interface
12 * http://dev.w3.org/csswg/cssom/#extensions-to-the-document-interface
13 * http://dev.w3.org/csswg/cssom-view/#extensions-to-the-document-interface
14 *
15 * http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/core/nsIDOMDocument.idl
16 */
18 interface WindowProxy;
19 interface nsISupports;
20 interface URI;
21 interface nsIDocShell;
23 enum VisibilityState { "hidden", "visible" };
25 /* http://dom.spec.whatwg.org/#interface-document */
26 [Constructor]
27 interface Document : Node {
28 [Throws]
29 readonly attribute DOMImplementation implementation;
30 [Pure]
31 readonly attribute DOMString URL;
32 [Pure]
33 readonly attribute DOMString documentURI;
34 [Pure]
35 readonly attribute DOMString compatMode;
36 [Pure]
37 readonly attribute DOMString characterSet;
38 [Pure]
39 readonly attribute DOMString contentType;
41 [Pure]
42 readonly attribute DocumentType? doctype;
43 [Pure]
44 readonly attribute Element? documentElement;
45 [Pure]
46 HTMLCollection getElementsByTagName(DOMString localName);
47 [Pure, Throws]
48 HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
49 [Pure]
50 HTMLCollection getElementsByClassName(DOMString classNames);
51 [Pure]
52 Element? getElementById(DOMString elementId);
54 [NewObject, Throws]
55 Element createElement(DOMString localName);
56 [NewObject, Throws]
57 Element createElementNS(DOMString? namespace, DOMString qualifiedName);
58 [NewObject]
59 DocumentFragment createDocumentFragment();
60 [NewObject]
61 Text createTextNode(DOMString data);
62 [NewObject]
63 Comment createComment(DOMString data);
64 [NewObject, Throws]
65 ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
67 [Throws]
68 Node importNode(Node node, optional boolean deep = false);
69 [Throws]
70 Node adoptNode(Node node);
72 [NewObject, Throws]
73 Event createEvent(DOMString interface);
75 [NewObject, Throws]
76 Range createRange();
78 // NodeFilter.SHOW_ALL = 0xFFFFFFFF
79 [NewObject, Throws]
80 NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
81 [NewObject, Throws]
82 TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
84 // NEW
85 // No support for prepend/append yet
86 // void prepend((Node or DOMString)... nodes);
87 // void append((Node or DOMString)... nodes);
89 // These are not in the spec, but leave them for now for backwards compat.
90 // So sort of like Gecko extensions
91 [NewObject, Throws]
92 CDATASection createCDATASection(DOMString data);
93 [NewObject, Throws]
94 Attr createAttribute(DOMString name);
95 [NewObject, Throws]
96 Attr createAttributeNS(DOMString? namespace, DOMString name);
97 [Pure]
98 readonly attribute DOMString? inputEncoding;
99 };
101 // http://www.whatwg.org/specs/web-apps/current-work/#the-document-object
102 partial interface Document {
103 [PutForwards=href, Unforgeable] readonly attribute Location? location;
104 //(HTML only) attribute DOMString domain;
105 readonly attribute DOMString referrer;
106 //(HTML only) attribute DOMString cookie;
107 readonly attribute DOMString lastModified;
108 readonly attribute DOMString readyState;
110 // DOM tree accessors
111 //(Not proxy yet)getter object (DOMString name);
112 [SetterThrows, Pure]
113 attribute DOMString title;
114 [Pure]
115 attribute DOMString dir;
116 //(HTML only) attribute HTMLElement? body;
117 //(HTML only)readonly attribute HTMLHeadElement? head;
118 //(HTML only)readonly attribute HTMLCollection images;
119 //(HTML only)readonly attribute HTMLCollection embeds;
120 //(HTML only)readonly attribute HTMLCollection plugins;
121 //(HTML only)readonly attribute HTMLCollection links;
122 //(HTML only)readonly attribute HTMLCollection forms;
123 //(HTML only)readonly attribute HTMLCollection scripts;
124 //(HTML only)NodeList getElementsByName(DOMString elementName);
125 //(HTML only)NodeList getItems(optional DOMString typeNames); // microdata
126 //(Not implemented)readonly attribute DOMElementMap cssElementMap;
128 // dynamic markup insertion
129 //(HTML only)Document open(optional DOMString type, optional DOMString replace);
130 //(HTML only)WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace);
131 //(HTML only)void close();
132 //(HTML only)void write(DOMString... text);
133 //(HTML only)void writeln(DOMString... text);
135 // user interaction
136 [Pure]
137 readonly attribute WindowProxy? defaultView;
138 readonly attribute Element? activeElement;
139 [Throws]
140 boolean hasFocus();
141 //(HTML only) attribute DOMString designMode;
142 //(HTML only)boolean execCommand(DOMString commandId);
143 //(HTML only)boolean execCommand(DOMString commandId, boolean showUI);
144 //(HTML only)boolean execCommand(DOMString commandId, boolean showUI, DOMString value);
145 //(HTML only)boolean queryCommandEnabled(DOMString commandId);
146 //(HTML only)boolean queryCommandIndeterm(DOMString commandId);
147 //(HTML only)boolean queryCommandState(DOMString commandId);
148 //(HTML only)boolean queryCommandSupported(DOMString commandId);
149 //(HTML only)DOMString queryCommandValue(DOMString commandId);
150 //(Not implemented)readonly attribute HTMLCollection commands;
152 // special event handler IDL attributes that only apply to Document objects
153 [LenientThis] attribute EventHandler onreadystatechange;
155 // Gecko extensions?
156 attribute EventHandler onwheel;
157 attribute EventHandler oncopy;
158 attribute EventHandler oncut;
159 attribute EventHandler onpaste;
160 attribute EventHandler onbeforescriptexecute;
161 attribute EventHandler onafterscriptexecute;
162 /**
163 * True if this document is synthetic : stand alone image, video, audio file,
164 * etc.
165 */
166 [Func="IsChromeOrXBL"] readonly attribute boolean mozSyntheticDocument;
167 /**
168 * Returns the script element whose script is currently being processed.
169 *
170 * @see <https://developer.mozilla.org/en/DOM/document.currentScript>
171 */
172 [Pure]
173 readonly attribute Element? currentScript;
174 /**
175 * Release the current mouse capture if it is on an element within this
176 * document.
177 *
178 * @see <https://developer.mozilla.org/en/DOM/document.releaseCapture>
179 */
180 void releaseCapture();
181 /**
182 * Use the given DOM element as the source image of target |-moz-element()|.
183 *
184 * This function introduces a new special ID (called "image element ID"),
185 * which is only used by |-moz-element()|, and associates it with the given
186 * DOM element. Image elements ID's have the higher precedence than general
187 * HTML id's, so if |document.mozSetImageElement(<id>, <element>)| is called,
188 * |-moz-element(#<id>)| uses |<element>| as the source image even if there
189 * is another element with id attribute = |<id>|. To unregister an image
190 * element ID |<id>|, call |document.mozSetImageElement(<id>, null)|.
191 *
192 * Example:
193 * <script>
194 * canvas = document.createElement("canvas");
195 * canvas.setAttribute("width", 100);
196 * canvas.setAttribute("height", 100);
197 * // draw to canvas
198 * document.mozSetImageElement("canvasbg", canvas);
199 * </script>
200 * <div style="background-image: -moz-element(#canvasbg);"></div>
201 *
202 * @param aImageElementId an image element ID to associate with
203 * |aImageElement|
204 * @param aImageElement a DOM element to be used as the source image of
205 * |-moz-element(#aImageElementId)|. If this is null, the function will
206 * unregister the image element ID |aImageElementId|.
207 *
208 * @see <https://developer.mozilla.org/en/DOM/document.mozSetImageElement>
209 */
210 void mozSetImageElement(DOMString aImageElementId,
211 Element? aImageElement);
213 [ChromeOnly]
214 readonly attribute URI? documentURIObject;
216 };
218 // http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#api
219 partial interface Document {
220 // Note: Per spec the 'S' in these two is lowercase, but the "Moz"
221 // versions hve it uppercase.
222 readonly attribute boolean mozFullScreenEnabled;
223 [Throws]
224 readonly attribute Element? mozFullScreenElement;
226 //(Renamed?)void exitFullscreen();
228 // Gecko-specific fullscreen bits
229 readonly attribute boolean mozFullScreen;
230 void mozCancelFullScreen();
231 };
233 // http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html#extensions-to-the-document-interface
234 partial interface Document {
235 readonly attribute Element? mozPointerLockElement;
236 void mozExitPointerLock ();
237 };
239 //http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-document-register
240 partial interface Document {
241 [Throws, Func="nsDocument::IsRegisterElementEnabled"]
242 object registerElement(DOMString name, optional ElementRegistrationOptions options);
243 };
245 //http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-document-register
246 partial interface Document {
247 [NewObject, Throws]
248 Element createElement(DOMString localName, DOMString typeExtension);
249 [NewObject, Throws]
250 Element createElementNS(DOMString? namespace, DOMString qualifiedName, DOMString typeExtension);
251 };
253 // http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#sec-document-interface
254 partial interface Document {
255 readonly attribute boolean hidden;
256 readonly attribute boolean mozHidden;
257 readonly attribute VisibilityState visibilityState;
258 readonly attribute VisibilityState mozVisibilityState;
259 };
261 // http://dev.w3.org/csswg/cssom/#extensions-to-the-document-interface
262 partial interface Document {
263 [Constant]
264 readonly attribute StyleSheetList styleSheets;
265 attribute DOMString? selectedStyleSheetSet;
266 readonly attribute DOMString? lastStyleSheetSet;
267 readonly attribute DOMString? preferredStyleSheetSet;
268 [Constant]
269 readonly attribute DOMStringList styleSheetSets;
270 void enableStyleSheetsForSet (DOMString? name);
271 };
273 // http://dev.w3.org/csswg/cssom-view/#extensions-to-the-document-interface
274 partial interface Document {
275 Element? elementFromPoint (float x, float y);
277 CaretPosition? caretPositionFromPoint (float x, float y);
278 };
280 // http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html
281 partial interface Document {
282 [Pref="dom.undo_manager.enabled"]
283 readonly attribute UndoManager? undoManager;
284 };
286 // http://dev.w3.org/2006/webapi/selectors-api2/#interface-definitions
287 partial interface Document {
288 [Throws, Pure]
289 Element? querySelector(DOMString selectors);
290 [Throws, Pure]
291 NodeList querySelectorAll(DOMString selectors);
293 //(Not implemented)Element? find(DOMString selectors, optional (Element or sequence<Node>)? refNodes);
294 //(Not implemented)NodeList findAll(DOMString selectors, optional (Element or sequence<Node>)? refNodes);
295 };
297 // Mozilla extensions of various sorts
298 partial interface Document {
299 // nsIDOMDocumentXBL. Wish we could make these [ChromeOnly], but
300 // that would likely break bindings running with the page principal.
301 [Func="IsChromeOrXBL"]
302 NodeList? getAnonymousNodes(Element elt);
303 [Func="IsChromeOrXBL"]
304 Element? getAnonymousElementByAttribute(Element elt, DOMString attrName,
305 DOMString attrValue);
306 [Func="IsChromeOrXBL"]
307 Element? getBindingParent(Node node);
308 [Throws, Func="IsChromeOrXBL"]
309 void loadBindingDocument(DOMString documentURL);
311 // nsIDOMDocumentTouch
312 // XXXbz I can't find the sane spec for this stuff, so just cribbing
313 // from our xpidl for now.
314 [NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
315 Touch createTouch(optional Window? view = null,
316 optional EventTarget? target = null,
317 optional long identifier = 0,
318 optional long pageX = 0,
319 optional long pageY = 0,
320 optional long screenX = 0,
321 optional long screenY = 0,
322 optional long clientX = 0,
323 optional long clientY = 0,
324 optional long radiusX = 0,
325 optional long radiusY = 0,
326 optional float rotationAngle = 0,
327 optional float force = 0);
328 // XXXbz a hack to get around the fact that we don't support variadics as
329 // distinguishing arguments yet. Once this hack is removed. we can also
330 // remove the corresponding overload on nsIDocument, since Touch... and
331 // sequence<Touch> look the same in the C++.
332 [NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
333 TouchList createTouchList(Touch touch, Touch... touches);
334 // XXXbz and another hack for the fact that we can't usefully have optional
335 // distinguishing arguments but need a working zero-arg form of
336 // createTouchList().
337 [NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
338 TouchList createTouchList();
339 [NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
340 TouchList createTouchList(sequence<Touch> touches);
342 [ChromeOnly]
343 attribute boolean styleSheetChangeEventsEnabled;
345 [ChromeOnly, Throws]
346 void obsoleteSheet(URI sheetURI);
347 [ChromeOnly, Throws]
348 void obsoleteSheet(DOMString sheetURI);
350 [ChromeOnly] readonly attribute nsIDocShell? docShell;
352 [ChromeOnly] readonly attribute DOMString contentLanguage;
353 };
355 // Extension to give chrome JS the ability to determine when a document was
356 // created to satisfy an iframe with srcdoc attribute.
357 partial interface Document {
358 [ChromeOnly] readonly attribute boolean isSrcdocDocument;
359 };
361 Document implements XPathEvaluator;
362 Document implements GlobalEventHandlers;
363 Document implements TouchEventHandlers;
364 Document implements ParentNode;
365 Document implements OnErrorEventHandlerForNodes;