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    CustomToJSObject,
23    JSGenerateToNativeObject,
24    JSInlineGetOwnPropertySlot
25] interface Document : Node {
26
27    // DOM Level 1 Core
28    readonly attribute DocumentType doctype;
29    readonly attribute DOMImplementation implementation;
30    readonly attribute Element documentElement;
31
32    [ReturnNewObject, RaisesException] Element createElement([TreatNullAs=NullString,Default=Undefined] optional DOMString tagName);
33    DocumentFragment   createDocumentFragment();
34    [ReturnNewObject] Text createTextNode([Default=Undefined] optional DOMString data);
35    [ReturnNewObject] Comment createComment([Default=Undefined] optional DOMString data);
36    [ReturnNewObject, RaisesException] CDATASection createCDATASection([Default=Undefined] optional DOMString data);
37    [ObjCLegacyUnnamedParameters, ReturnNewObject, RaisesException] ProcessingInstruction createProcessingInstruction([Default=Undefined] optional DOMString target,
38                                                                                 [Default=Undefined] optional DOMString data);
39    [ReturnNewObject, RaisesException] Attr createAttribute([Default=Undefined] optional DOMString name);
40    [ReturnNewObject, RaisesException] EntityReference createEntityReference([Default=Undefined] optional DOMString name);
41    NodeList getElementsByTagName([Default=Undefined] optional DOMString tagname);
42
43    // Introduced in DOM Level 2:
44
45    [ObjCLegacyUnnamedParameters, ReturnNewObject, RaisesException] Node importNode([Default=Undefined] optional Node importedNode,
46                    optional boolean deep);
47    [ObjCLegacyUnnamedParameters, ReturnNewObject, RaisesException] Element createElementNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
48                            [TreatNullAs=NullString,Default=Undefined] optional DOMString qualifiedName);
49    [ObjCLegacyUnnamedParameters, ReturnNewObject, RaisesException] Attr createAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
50                                                                          [TreatNullAs=NullString,Default=Undefined] optional DOMString qualifiedName);
51    [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
52                                                   [Default=Undefined] optional DOMString localName);
53    Element getElementById([Default=Undefined] optional DOMString elementId);
54
55    // DOM Level 3 Core
56
57    [TreatReturnedNullStringAs=Null] readonly attribute DOMString inputEncoding;
58
59    [TreatReturnedNullStringAs=Null] readonly attribute DOMString xmlEncoding;
60    [TreatReturnedNullStringAs=Null, TreatNullAs=NullString, SetterRaisesException] attribute DOMString xmlVersion;
61    [SetterRaisesException] attribute boolean xmlStandalone;
62
63    [RaisesException] Node               adoptNode([Default=Undefined] optional Node source);
64
65#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C || defined(LANGUAGE_GOBJECT) && LANGUAGE_GOBJECT
66    // document.documentURI was writable in DOM3 Core, but is read-only in DOM4
67    // (see http://www.w3.org/TR/2011/WD-dom-20110915/#document). We need to keep
68    // the writable version around for Objective C clients, but are moving to
69    // read-only for other clients.
70             [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString documentURI;
71#else
72    [TreatReturnedNullStringAs=Null] readonly attribute DOMString documentURI;
73#endif
74
75    // DOM Level 2 Events (DocumentEvents interface)
76
77    [RaisesException] Event              createEvent([Default=Undefined] optional DOMString eventType);
78
79    // DOM Level 2 Tranversal and Range (DocumentRange interface)
80
81    Range              createRange();
82
83    // DOM Level 2 Tranversal and Range (DocumentTraversal interface)
84
85    [ObjCLegacyUnnamedParameters, RaisesException] NodeIterator createNodeIterator([Default=Undefined] optional Node root,
86                                                   [Default=Undefined] optional unsigned long whatToShow,
87                                                   [Default=Undefined] optional NodeFilter filter,
88                                                   [Default=Undefined] optional boolean expandEntityReferences);
89    [ObjCLegacyUnnamedParameters, RaisesException] TreeWalker createTreeWalker([Default=Undefined] optional Node root,
90                                               [Default=Undefined] optional unsigned long whatToShow,
91                                               [Default=Undefined] optional NodeFilter filter,
92                                               [Default=Undefined] optional boolean expandEntityReferences);
93
94    // DOM Level 2 Abstract Views (DocumentView interface)
95
96    readonly attribute DOMWindow defaultView;
97
98    // DOM Level 2 Style (DocumentStyle interface)
99
100    readonly attribute StyleSheetList styleSheets;
101
102    // DOM Level 2 Style (DocumentCSS interface)
103
104    [ObjCLegacyUnnamedParameters] CSSStyleDeclaration getOverrideStyle([Default=Undefined] optional Element element,
105                                                        [Default=Undefined] optional DOMString pseudoElement);
106
107    // DOM Level 3 XPath (XPathEvaluator interface)
108    [ObjCLegacyUnnamedParameters, RaisesException] XPathExpression createExpression([Default=Undefined] optional DOMString expression,
109                                                    [Default=Undefined] optional XPathNSResolver resolver);
110    XPathNSResolver    createNSResolver(Node nodeResolver);
111    [ObjCLegacyUnnamedParameters, RaisesException] XPathResult evaluate([Default=Undefined] optional DOMString expression,
112                                                  [Default=Undefined] optional Node contextNode,
113                                                  [Default=Undefined] optional XPathNSResolver resolver,
114                                                  [Default=Undefined] optional unsigned short type,
115                                                  [Default=Undefined] optional XPathResult inResult);
116
117    // Common extensions
118    boolean            execCommand([Default=Undefined] optional DOMString command,
119                                   [Default=Undefined] optional boolean userInterface,
120                                   [TreatNullAs=NullString, TreatUndefinedAs=NullString, Default=Undefined] optional DOMString value);
121
122#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
123    // FIXME: remove the these two versions once optional is implemented for Objective-C.
124    boolean            execCommand(DOMString command,
125                                   boolean userInterface);
126    boolean            execCommand(DOMString command);
127#endif
128
129    boolean            queryCommandEnabled([Default=Undefined] optional DOMString command);
130    boolean            queryCommandIndeterm([Default=Undefined] optional DOMString command);
131    boolean            queryCommandState([Default=Undefined] optional DOMString command);
132    boolean            queryCommandSupported([Default=Undefined] optional DOMString command);
133    DOMString          queryCommandValue([Default=Undefined] optional DOMString command);
134
135    // Moved down from HTMLDocument
136
137             [TreatNullAs=NullString] attribute DOMString title;
138    readonly attribute DOMString referrer;
139#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
140    [TreatNullAs=NullString, SetterRaisesException] attribute DOMString domain;
141#else
142    readonly attribute DOMString domain;
143#endif
144    readonly attribute DOMString URL;
145
146    [TreatNullAs=NullString, GetterRaisesException, SetterRaisesException] attribute DOMString cookie;
147
148    [SetterRaisesException] attribute HTMLElement body;
149
150    readonly attribute HTMLHeadElement head;
151    readonly attribute HTMLCollection images;
152    readonly attribute HTMLCollection applets;
153    readonly attribute HTMLCollection links;
154    readonly attribute HTMLCollection forms;
155    readonly attribute HTMLCollection anchors;
156    readonly attribute DOMString lastModified;
157
158    NodeList getElementsByName([Default=Undefined] optional DOMString elementName);
159
160    [Conditional=MICRODATA] NodeList getItems([TreatNullAs=NullString, TreatUndefinedAs=NullString, Default=Undefined] optional DOMString typeNames);
161
162#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
163             [Custom] attribute Location location;
164#endif
165
166    // IE extensions
167
168             [TreatReturnedNullStringAs=Undefined, TreatNullAs=NullString] attribute DOMString charset;
169    [TreatReturnedNullStringAs=Undefined] readonly attribute DOMString defaultCharset;
170    [TreatReturnedNullStringAs=Undefined] readonly attribute DOMString readyState;
171
172    Element            elementFromPoint([Default=Undefined] optional long x,
173                                        [Default=Undefined] optional long y);
174    Range              caretRangeFromPoint([Default=Undefined] optional long x,
175                                           [Default=Undefined] optional long y);
176
177    // Mozilla extensions
178#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
179    DOMSelection       getSelection();
180#endif
181    [TreatReturnedNullStringAs=Null] readonly attribute DOMString characterSet;
182
183    // WebKit extensions
184
185    [TreatReturnedNullStringAs=Null] readonly attribute DOMString preferredStylesheetSet;
186             [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString selectedStylesheetSet;
187
188#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT
189    CSSStyleDeclaration createCSSStyleDeclaration();
190#endif
191
192#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
193    // DOM Level 2 Style Interface
194    [ObjCLegacyUnnamedParameters, ObjCUseDefaultView] CSSStyleDeclaration getComputedStyle(Element element,
195                                                                  DOMString pseudoElement);
196
197    // WebKit extension
198    // FIXME: remove the first version once optional is implemented for Objective-C.
199    [ObjCUseDefaultView] CSSRuleList getMatchedCSSRules(Element element,
200                                              DOMString pseudoElement);
201    [ObjCUseDefaultView] CSSRuleList getMatchedCSSRules(Element element,
202                                              DOMString pseudoElement,
203                                              optional boolean authorOnly);
204
205#endif
206
207#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
208#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
209    CanvasRenderingContext getCSSCanvasContext(DOMString contextId, DOMString name, long width, long height);
210#endif
211#endif
212
213    // HTML 5
214    NodeList getElementsByClassName([Default=Undefined] optional DOMString tagname);
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 webkitExitPointerLock();
236    [Conditional=POINTER_LOCK] readonly attribute Element webkitPointerLockElement;
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
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
280    // [NotEnumerable] attribute EventListener oncanplay;
281    // [NotEnumerable] attribute EventListener oncanplaythrough;
282    // [NotEnumerable] attribute EventListener ondurationchange;
283    // [NotEnumerable] attribute EventListener onemptied;
284    // [NotEnumerable] attribute EventListener onended;
285    // [NotEnumerable] attribute EventListener onloadeddata;
286    // [NotEnumerable] attribute EventListener onloadedmetadata;
287    // [NotEnumerable] attribute EventListener onloadstart;
288    // [NotEnumerable] attribute EventListener onpause;
289    // [NotEnumerable] attribute EventListener onplay;
290    // [NotEnumerable] attribute EventListener onplaying;
291    // [NotEnumerable] attribute EventListener onprogress;
292    // [NotEnumerable] attribute EventListener onratechange;
293    // [NotEnumerable] attribute EventListener onseeked;
294    // [NotEnumerable] attribute EventListener onseeking;
295    // [NotEnumerable] attribute EventListener onshow;
296    // [NotEnumerable] attribute EventListener onstalled;
297    // [NotEnumerable] attribute EventListener onsuspend;
298    // [NotEnumerable] attribute EventListener ontimeupdate;
299    // [NotEnumerable] attribute EventListener onvolumechange;
300    // [NotEnumerable] attribute EventListener onwaiting;
301
302    // WebKit extensions
303    [NotEnumerable] attribute EventListener onbeforecut;
304    [NotEnumerable] attribute EventListener oncut;
305    [NotEnumerable] attribute EventListener onbeforecopy;
306    [NotEnumerable] attribute EventListener oncopy;
307    [NotEnumerable] attribute EventListener onbeforepaste;
308    [NotEnumerable] attribute EventListener onpaste;
309    [NotEnumerable] attribute EventListener onreset;
310    [NotEnumerable] attribute EventListener onsearch;
311    [NotEnumerable] attribute EventListener onselectstart;
312    [NotEnumerable] attribute EventListener onselectionchange;
313    [NotEnumerable,Conditional=TOUCH_EVENTS] attribute EventListener ontouchstart;
314    [NotEnumerable,Conditional=TOUCH_EVENTS] attribute EventListener ontouchmove;
315    [NotEnumerable,Conditional=TOUCH_EVENTS] attribute EventListener ontouchend;
316    [NotEnumerable,Conditional=TOUCH_EVENTS] attribute EventListener ontouchcancel;
317    [NotEnumerable, Conditional=FULLSCREEN_API] attribute EventListener onwebkitfullscreenchange;
318    [NotEnumerable, Conditional=FULLSCREEN_API] attribute EventListener onwebkitfullscreenerror;
319    [NotEnumerable, Conditional=POINTER_LOCK] attribute EventListener onwebkitpointerlockchange;
320    [NotEnumerable, Conditional=POINTER_LOCK] attribute EventListener onwebkitpointerlockerror;
321    [NotEnumerable, Conditional=CSP_NEXT] attribute EventListener onsecuritypolicyviolation;
322#endif
323
324#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
325    [ReturnNewObject, RaisesException] Touch createTouch([Default=Undefined] optional DOMWindow window,
326                                                     [Default=Undefined] optional EventTarget target,
327                                                     [Default=Undefined] optional long identifier,
328                                                     [Default=Undefined] optional long pageX,
329                                                     [Default=Undefined] optional long pageY,
330                                                     [Default=Undefined] optional long screenX,
331                                                     [Default=Undefined] optional long screenY,
332                                                     [Default=Undefined] optional long webkitRadiusX,
333                                                     [Default=Undefined] optional long webkitRadiusY,
334                                                     [Default=Undefined] optional float webkitRotationAngle,
335                                                     [Default=Undefined] optional float webkitForce);
336    [ReturnNewObject, Custom, RaisesException] TouchList createTouchList();
337#endif
338
339#if defined(ENABLE_CUSTOM_ELEMENTS) && ENABLE_CUSTOM_ELEMENTS
340    [Conditional=CUSTOM_ELEMENTS, ImplementedAs=registerElement, CallWith=ScriptState, RaisesException] CustomElementConstructor webkitRegister(DOMString name, optional Dictionary options);
341    [ReturnNewObject, RaisesException] Element createElement(DOMString localName, [TreatNullAs=NullString] DOMString typeExtension);
342    [ReturnNewObject, RaisesException] Element createElementNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString qualifiedName,
343                            [TreatNullAs=NullString] DOMString typeExtension);
344#endif
345
346#if defined(LANGUAGE_CPP) && LANGUAGE_CPP
347    // Extra WebCore methods exposed to allow compile-time casting in C++
348    boolean isHTMLDocument();
349#endif
350
351    // Page visibility API.
352    [Conditional=PAGE_VISIBILITY_API] readonly attribute DOMString visibilityState;
353    [Conditional=PAGE_VISIBILITY_API] readonly attribute boolean hidden;
354
355    // Security Policy API: http://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html#script-interfaces
356    [Conditional=CSP_NEXT] readonly attribute DOMSecurityPolicy securityPolicy;
357
358};
359
360