1/*
2 * Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB.  If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21[
22    Constructor,
23    ConstructorCallWith=ScriptExecutionContext,
24    CustomToJSObject,
25    JSGenerateToNativeObject,
26] interface Document : Node {
27
28    // DOM Level 1 Core
29    readonly attribute DocumentType doctype;
30    readonly attribute DOMImplementation implementation;
31    readonly attribute Element documentElement;
32
33    [ReturnNewObject, RaisesException] Element createElement([TreatNullAs=NullString,Default=Undefined] optional DOMString tagName);
34    DocumentFragment   createDocumentFragment();
35    [ReturnNewObject] Text createTextNode([Default=Undefined] optional DOMString data);
36    [ReturnNewObject] Comment createComment([Default=Undefined] optional DOMString data);
37    [ReturnNewObject, RaisesException] CDATASection createCDATASection([Default=Undefined] optional DOMString data);
38    [ObjCLegacyUnnamedParameters, ReturnNewObject, RaisesException] ProcessingInstruction createProcessingInstruction([Default=Undefined] optional DOMString target,
39                                                                                 [Default=Undefined] optional DOMString data);
40    [ReturnNewObject, RaisesException] Attr createAttribute([Default=Undefined] optional DOMString name);
41    [ReturnNewObject, RaisesException] EntityReference createEntityReference([Default=Undefined] optional DOMString name);
42    NodeList getElementsByTagName([Default=Undefined] optional DOMString tagname);
43
44    // Introduced in DOM Level 2:
45
46    [ObjCLegacyUnnamedParameters, ReturnNewObject, RaisesException] Node importNode([Default=Undefined] optional Node importedNode,
47                    optional boolean deep);
48    [ObjCLegacyUnnamedParameters, ReturnNewObject, RaisesException] Element createElementNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
49                            [TreatNullAs=NullString,Default=Undefined] optional DOMString qualifiedName);
50    [ObjCLegacyUnnamedParameters, ReturnNewObject, RaisesException] Attr createAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
51                                                                          [TreatNullAs=NullString,Default=Undefined] optional DOMString qualifiedName);
52    [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
53                                                   [Default=Undefined] optional DOMString localName);
54    Element getElementById([Default=Undefined,ObjCExplicitAtomicString,RequiresExistingAtomicString] optional DOMString elementId);
55
56    // DOM Level 3 Core
57
58    [TreatReturnedNullStringAs=Null] readonly attribute DOMString inputEncoding;
59
60    [TreatReturnedNullStringAs=Null] readonly attribute DOMString xmlEncoding;
61    [TreatReturnedNullStringAs=Null, TreatNullAs=NullString, SetterRaisesException] attribute DOMString xmlVersion;
62    [SetterRaisesException] attribute boolean xmlStandalone;
63
64    [RaisesException] Node               adoptNode([Default=Undefined] optional Node source);
65
66#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT
67    // document.documentURI was writable in DOM3 Core, but is read-only in DOM4
68    // (see http://www.w3.org/TR/2011/WD-dom-20110915/#document). We need to keep
69    // the writable version around for Objective C clients, but are moving to
70    // read-only for other clients.
71             [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString documentURI;
72#else
73    [TreatReturnedNullStringAs=Null] readonly attribute DOMString documentURI;
74#endif
75
76    // DOM Level 2 Events (DocumentEvents interface)
77
78    [RaisesException] Event              createEvent([Default=Undefined] optional DOMString eventType);
79
80    // DOM Level 2 Tranversal and Range (DocumentRange interface)
81
82    Range              createRange();
83
84    // DOM Level 2 Tranversal and Range (DocumentTraversal interface)
85
86    [ObjCLegacyUnnamedParameters, RaisesException] NodeIterator createNodeIterator([Default=Undefined] optional Node root,
87                                                   [Default=Undefined] optional unsigned long whatToShow,
88                                                   [Default=Undefined] optional NodeFilter filter,
89                                                   [Default=Undefined] optional boolean expandEntityReferences);
90    [ObjCLegacyUnnamedParameters, RaisesException] TreeWalker createTreeWalker([Default=Undefined] optional Node root,
91                                               [Default=Undefined] optional unsigned long whatToShow,
92                                               [Default=Undefined] optional NodeFilter filter,
93                                               [Default=Undefined] optional boolean expandEntityReferences);
94
95    // DOM Level 2 Abstract Views (DocumentView interface)
96
97    readonly attribute DOMWindow defaultView;
98
99    // DOM Level 2 Style (DocumentStyle interface)
100
101    readonly attribute StyleSheetList styleSheets;
102
103    // DOM Level 2 Style (DocumentCSS interface)
104
105    [ObjCLegacyUnnamedParameters] CSSStyleDeclaration getOverrideStyle([Default=Undefined] optional Element element,
106                                                        [Default=Undefined] optional DOMString pseudoElement);
107
108    // DOM Level 3 XPath (XPathEvaluator interface)
109    [ObjCLegacyUnnamedParameters, RaisesException] XPathExpression createExpression([Default=Undefined] optional DOMString expression,
110                                                    [Default=Undefined] optional XPathNSResolver resolver);
111    XPathNSResolver    createNSResolver(Node nodeResolver);
112    [ObjCLegacyUnnamedParameters, RaisesException] XPathResult evaluate([Default=Undefined] optional DOMString expression,
113                                                  [Default=Undefined] optional Node contextNode,
114                                                  [Default=Undefined] optional XPathNSResolver resolver,
115                                                  [Default=Undefined] optional unsigned short type,
116                                                  [Default=Undefined] optional XPathResult inResult);
117
118    // Common extensions
119    boolean            execCommand([Default=Undefined] optional DOMString command,
120                                   [Default=Undefined] optional boolean userInterface,
121                                   [TreatNullAs=NullString, TreatUndefinedAs=NullString, Default=Undefined] optional DOMString value);
122
123#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
124    // FIXME: remove the these two versions once optional is implemented for Objective-C.
125    boolean            execCommand(DOMString command,
126                                   boolean userInterface);
127    boolean            execCommand(DOMString command);
128#endif
129
130    boolean            queryCommandEnabled([Default=Undefined] optional DOMString command);
131    boolean            queryCommandIndeterm([Default=Undefined] optional DOMString command);
132    boolean            queryCommandState([Default=Undefined] optional DOMString command);
133    boolean            queryCommandSupported([Default=Undefined] optional DOMString command);
134    DOMString          queryCommandValue([Default=Undefined] optional DOMString command);
135
136    // Moved down from HTMLDocument
137
138             [TreatNullAs=NullString] attribute DOMString title;
139    readonly attribute DOMString referrer;
140#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
141    [TreatNullAs=NullString, SetterRaisesException] attribute DOMString domain;
142#else
143    readonly attribute DOMString domain;
144#endif
145    readonly attribute DOMString URL;
146
147    [TreatNullAs=NullString, GetterRaisesException, SetterRaisesException] attribute DOMString cookie;
148
149    [SetterRaisesException] attribute HTMLElement body;
150
151    readonly attribute HTMLHeadElement head;
152    readonly attribute HTMLCollection images;
153    readonly attribute HTMLCollection applets;
154    readonly attribute HTMLCollection links;
155    readonly attribute HTMLCollection forms;
156    readonly attribute HTMLCollection anchors;
157    readonly attribute DOMString lastModified;
158
159    NodeList getElementsByName([Default=Undefined,AtomicString] optional DOMString elementName);
160
161#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
162             [Custom] attribute Location location;
163#endif
164
165    // IE extensions
166
167             [TreatReturnedNullStringAs=Undefined, TreatNullAs=NullString] attribute DOMString charset;
168    [TreatReturnedNullStringAs=Undefined] readonly attribute DOMString defaultCharset;
169    [TreatReturnedNullStringAs=Undefined] readonly attribute DOMString readyState;
170
171    Element            elementFromPoint([Default=Undefined] optional long x,
172                                        [Default=Undefined] optional long y);
173    Range              caretRangeFromPoint([Default=Undefined] optional long x,
174                                           [Default=Undefined] optional long y);
175
176    // Mozilla extensions
177#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
178    DOMSelection       getSelection();
179#endif
180    [TreatReturnedNullStringAs=Null] readonly attribute DOMString characterSet;
181
182    // WebKit extensions
183
184    [TreatReturnedNullStringAs=Null] readonly attribute DOMString preferredStylesheetSet;
185             [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString selectedStylesheetSet;
186
187#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT
188    CSSStyleDeclaration createCSSStyleDeclaration();
189#endif
190
191#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
192    // DOM Level 2 Style Interface
193    [ObjCLegacyUnnamedParameters, ObjCUseDefaultView] CSSStyleDeclaration getComputedStyle(Element element,
194                                                                  DOMString pseudoElement);
195
196    // WebKit extension
197    // FIXME: remove the first version once optional is implemented for Objective-C.
198    [ObjCUseDefaultView] CSSRuleList getMatchedCSSRules(Element element,
199                                              DOMString pseudoElement);
200    [ObjCUseDefaultView] CSSRuleList getMatchedCSSRules(Element element,
201                                              DOMString pseudoElement,
202                                              optional boolean authorOnly);
203
204#endif
205
206#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
207    CanvasRenderingContext getCSSCanvasContext(DOMString contextId, DOMString name, long width, long height);
208#endif
209
210    // HTML 5
211    NodeList getElementsByClassName([Default=Undefined] optional DOMString tagname);
212
213    readonly attribute Element activeElement;
214    boolean hasFocus();
215
216    readonly attribute DOMString compatMode;
217
218    // NodeSelector - Selector API
219    [RaisesException] Element querySelector(DOMString selectors);
220    [RaisesException] NodeList querySelectorAll(DOMString selectors);
221
222#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
223    // Mozilla version
224    readonly attribute boolean webkitIsFullScreen;
225    readonly attribute boolean webkitFullScreenKeyboardInputAllowed;
226    readonly attribute Element webkitCurrentFullScreenElement;
227    void webkitCancelFullScreen();
228
229    // W3C version
230    readonly attribute boolean webkitFullscreenEnabled;
231    readonly attribute Element webkitFullscreenElement;
232    void webkitExitFullscreen();
233#endif
234
235    [Conditional=POINTER_LOCK] void exitPointerLock();
236    [Conditional=POINTER_LOCK] readonly attribute Element pointerLockElement;
237
238    [Conditional=CSS_REGIONS] DOMNamedFlowCollection webkitGetNamedFlows();
239
240#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
241    [Conditional=FONT_LOAD_EVENTS] readonly attribute FontLoader fontloader;
242#endif
243
244#if (!defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C) && (!defined(LANGUAGE_GOBJECT) || !LANGUAGE_GOBJECT)
245    // Event handler DOM attributes
246    [NotEnumerable] attribute EventListener onabort;
247    [NotEnumerable] attribute EventListener onblur;
248    [NotEnumerable] attribute EventListener onchange;
249    [NotEnumerable] attribute EventListener onclick;
250    [NotEnumerable] attribute EventListener oncontextmenu;
251    [NotEnumerable] attribute EventListener ondblclick;
252    [NotEnumerable] attribute EventListener ondrag;
253    [NotEnumerable] attribute EventListener ondragend;
254    [NotEnumerable] attribute EventListener ondragenter;
255    [NotEnumerable] attribute EventListener ondragleave;
256    [NotEnumerable] attribute EventListener ondragover;
257    [NotEnumerable] attribute EventListener ondragstart;
258    [NotEnumerable] attribute EventListener ondrop;
259    [NotEnumerable] attribute EventListener onerror;
260    [NotEnumerable] attribute EventListener onfocus;
261    [NotEnumerable] attribute EventListener oninput;
262    [NotEnumerable] attribute EventListener oninvalid;
263    [NotEnumerable] attribute EventListener onkeydown;
264    [NotEnumerable] attribute EventListener onkeypress;
265    [NotEnumerable] attribute EventListener onkeyup;
266    [NotEnumerable] attribute EventListener onload;
267    [NotEnumerable] attribute EventListener onmousedown;
268    [NotEnumerable] attribute EventListener onmouseenter;
269    [NotEnumerable] attribute EventListener onmouseleave;
270    [NotEnumerable] attribute EventListener onmousemove;
271    [NotEnumerable] attribute EventListener onmouseout;
272    [NotEnumerable] attribute EventListener onmouseover;
273    [NotEnumerable] attribute EventListener onmouseup;
274    [NotEnumerable] attribute EventListener onmousewheel;
275    [NotEnumerable] attribute EventListener onreadystatechange;
276    [NotEnumerable] attribute EventListener onscroll;
277    [NotEnumerable] attribute EventListener onselect;
278    [NotEnumerable] attribute EventListener onsubmit;
279    [NotEnumerable] attribute EventListener onwheel;
280
281    // [NotEnumerable] attribute EventListener oncanplay;
282    // [NotEnumerable] attribute EventListener oncanplaythrough;
283    // [NotEnumerable] attribute EventListener ondurationchange;
284    // [NotEnumerable] attribute EventListener onemptied;
285    // [NotEnumerable] attribute EventListener onended;
286    // [NotEnumerable] attribute EventListener onloadeddata;
287    // [NotEnumerable] attribute EventListener onloadedmetadata;
288    // [NotEnumerable] attribute EventListener onloadstart;
289    // [NotEnumerable] attribute EventListener onpause;
290    // [NotEnumerable] attribute EventListener onplay;
291    // [NotEnumerable] attribute EventListener onplaying;
292    // [NotEnumerable] attribute EventListener onprogress;
293    // [NotEnumerable] attribute EventListener onratechange;
294    // [NotEnumerable] attribute EventListener onseeked;
295    // [NotEnumerable] attribute EventListener onseeking;
296    // [NotEnumerable] attribute EventListener onshow;
297    // [NotEnumerable] attribute EventListener onstalled;
298    // [NotEnumerable] attribute EventListener onsuspend;
299    // [NotEnumerable] attribute EventListener ontimeupdate;
300    // [NotEnumerable] attribute EventListener onvolumechange;
301    // [NotEnumerable] attribute EventListener onwaiting;
302
303    // WebKit extensions
304    [NotEnumerable] attribute EventListener onbeforecut;
305    [NotEnumerable] attribute EventListener oncut;
306    [NotEnumerable] attribute EventListener onbeforecopy;
307    [NotEnumerable] attribute EventListener oncopy;
308    [NotEnumerable] attribute EventListener onbeforepaste;
309    [NotEnumerable] attribute EventListener onpaste;
310    [NotEnumerable] attribute EventListener onreset;
311    [NotEnumerable] attribute EventListener onsearch;
312    [NotEnumerable] attribute EventListener onselectstart;
313    [NotEnumerable] attribute EventListener onselectionchange;
314    [NotEnumerable,Conditional=TOUCH_EVENTS] attribute EventListener ontouchstart;
315    [NotEnumerable,Conditional=TOUCH_EVENTS] attribute EventListener ontouchmove;
316    [NotEnumerable,Conditional=TOUCH_EVENTS] attribute EventListener ontouchend;
317    [NotEnumerable,Conditional=TOUCH_EVENTS] attribute EventListener ontouchcancel;
318    [NotEnumerable, Conditional=FULLSCREEN_API] attribute EventListener onwebkitfullscreenchange;
319    [NotEnumerable, Conditional=FULLSCREEN_API] attribute EventListener onwebkitfullscreenerror;
320    [NotEnumerable, Conditional=POINTER_LOCK] attribute EventListener onpointerlockchange;
321    [NotEnumerable, Conditional=POINTER_LOCK] attribute EventListener onpointerlockerror;
322    [NotEnumerable, Conditional=CSP_NEXT] attribute EventListener onsecuritypolicyviolation;
323    [NotEnumerable, Conditional=WILL_REVEAL_EDGE_EVENTS] attribute EventListener onwebkitwillrevealbottom;
324    [NotEnumerable, Conditional=WILL_REVEAL_EDGE_EVENTS] attribute EventListener onwebkitwillrevealleft;
325    [NotEnumerable, Conditional=WILL_REVEAL_EDGE_EVENTS] attribute EventListener onwebkitwillrevealright;
326    [NotEnumerable, Conditional=WILL_REVEAL_EDGE_EVENTS] attribute EventListener onwebkitwillrevealtop;
327#endif
328
329#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
330    // FIXME: Consider defining an ENABLE macro for iOS touch event code, say IOS_TOUCH_EVENTS,
331    // and/or modifying the bindings scripts to support generating more complicated conditional code.
332#if defined(WTF_PLATFORM_IOS) && WTF_PLATFORM_IOS
333#include <WebKitAdditions/DocumentIOS.idl>
334#else
335    [ReturnNewObject, RaisesException] Touch createTouch([Default=Undefined] optional DOMWindow window,
336                                                     [Default=Undefined] optional EventTarget target,
337                                                     [Default=Undefined] optional long identifier,
338                                                     [Default=Undefined] optional long pageX,
339                                                     [Default=Undefined] optional long pageY,
340                                                     [Default=Undefined] optional long screenX,
341                                                     [Default=Undefined] optional long screenY,
342                                                     [Default=Undefined] optional long webkitRadiusX,
343                                                     [Default=Undefined] optional long webkitRadiusY,
344                                                     [Default=Undefined] optional unrestricted float webkitRotationAngle,
345                                                     [Default=Undefined] optional unrestricted float webkitForce);
346    [ReturnNewObject, Custom, RaisesException] TouchList createTouchList();
347#endif // defined(WTF_PLATFORM_IOS) && WTF_PLATFORM_IOS
348#endif
349
350    // Page visibility API.
351    readonly attribute DOMString visibilityState;
352    readonly attribute boolean hidden;
353
354    // Security Policy API: http://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html#script-interfaces
355    [Conditional=CSP_NEXT] readonly attribute DOMSecurityPolicy securityPolicy;
356
357    // currentscript API: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#dom-document-currentscript
358    readonly attribute HTMLScriptElement currentScript;
359
360    // http://www.w3.org/TR/2014/WD-dom-20140204/#dom-document-origin
361    readonly attribute DOMString origin;
362};
363
364