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
21module core {
22
23    interface [
24        CustomToJS,
25        GenerateNativeConverter,
26        InlineGetOwnPropertySlot
27    ] Document : Node {
28
29        // DOM Level 1 Core
30        readonly attribute DocumentType doctype;
31        readonly attribute DOMImplementation implementation;
32        readonly attribute Element documentElement;
33
34        [ReturnsNew] Element createElement(in [ConvertNullToNullString] DOMString tagName)
35            raises (DOMException);
36        DocumentFragment   createDocumentFragment();
37        [ReturnsNew] Text createTextNode(in DOMString data);
38        [ReturnsNew] Comment createComment(in DOMString data);
39        [ReturnsNew] CDATASection createCDATASection(in DOMString data)
40            raises(DOMException);
41        [OldStyleObjC, ReturnsNew] ProcessingInstruction createProcessingInstruction(in DOMString target,
42                                                                                     in DOMString data)
43            raises (DOMException);
44        [ReturnsNew] Attr createAttribute(in DOMString name)
45            raises (DOMException);
46        [ReturnsNew] EntityReference createEntityReference(in DOMString name)
47            raises(DOMException);
48        NodeList           getElementsByTagName(in DOMString tagname);
49
50        // Introduced in DOM Level 2:
51
52        [OldStyleObjC, ReturnsNew] Node importNode(in Node importedNode,
53                                                   in boolean deep)
54            raises (DOMException);
55        [OldStyleObjC, ReturnsNew] Element createElementNS(in [ConvertNullToNullString] DOMString namespaceURI,
56                                                           in [ConvertNullToNullString] DOMString qualifiedName)
57            raises (DOMException);
58        [OldStyleObjC, ReturnsNew] Attr createAttributeNS(in [ConvertNullToNullString] DOMString namespaceURI,
59                                                          in [ConvertNullToNullString] DOMString qualifiedName)
60            raises (DOMException);
61        [OldStyleObjC] NodeList getElementsByTagNameNS(in [ConvertNullToNullString] DOMString namespaceURI,
62                                                       in DOMString localName);
63        Element            getElementById(in DOMString elementId);
64
65        // DOM Level 3 Core
66
67        readonly attribute [ConvertNullStringTo=Null] DOMString inputEncoding;
68
69        readonly attribute [ConvertNullStringTo=Null] DOMString xmlEncoding;
70                 attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString xmlVersion
71                    setter raises (DOMException);
72                 attribute boolean xmlStandalone
73                    setter raises (DOMException);
74
75        Node               adoptNode(in Node source)
76            raises (DOMException);
77
78                 attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString documentURI;
79
80        // DOM Level 2 Events (DocumentEvents interface)
81
82        Event              createEvent(in DOMString eventType)
83            raises(DOMException);
84
85        // DOM Level 2 Tranversal and Range (DocumentRange interface)
86
87        Range              createRange();
88
89        // DOM Level 2 Tranversal and Range (DocumentTraversal interface)
90
91        [OldStyleObjC] NodeIterator createNodeIterator(in Node root,
92                                                       in unsigned long whatToShow,
93                                                       in NodeFilter filter,
94                                                       in boolean expandEntityReferences)
95            raises(DOMException);
96        [OldStyleObjC] TreeWalker createTreeWalker(in Node root,
97                                                   in unsigned long whatToShow,
98                                                   in NodeFilter filter,
99                                                   in boolean expandEntityReferences)
100            raises(DOMException);
101
102        // DOM Level 2 Abstract Views (DocumentView interface)
103
104        readonly attribute DOMWindow defaultView;
105
106        // DOM Level 2 Style (DocumentStyle interface)
107
108        readonly attribute StyleSheetList styleSheets;
109
110        // DOM Level 2 Style (DocumentCSS interface)
111
112        [OldStyleObjC] CSSStyleDeclaration getOverrideStyle(in Element element,
113                                                            in DOMString pseudoElement);
114#if defined(ENABLE_XPATH) && ENABLE_XPATH
115        // DOM Level 3 XPath (XPathEvaluator interface)
116        [OldStyleObjC] XPathExpression createExpression(in DOMString expression,
117                                                        in XPathNSResolver resolver)
118            raises(DOMException);
119        XPathNSResolver    createNSResolver(in Node nodeResolver);
120        [OldStyleObjC, V8Custom] XPathResult evaluate(in DOMString expression,
121                                                      in Node contextNode,
122                                                      in XPathNSResolver resolver,
123                                                      in unsigned short type,
124                                                      in XPathResult inResult)
125            raises(DOMException);
126#endif // ENABLE_XPATH
127
128        // Common extensions
129
130        boolean            execCommand(in DOMString command,
131                                       in boolean userInterface,
132                                       in [ConvertUndefinedOrNullToNullString] DOMString value);
133
134#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
135        // FIXME: remove the these two versions once [Optional] is implemented for Objective-C.
136        boolean            execCommand(in DOMString command,
137                                       in boolean userInterface);
138        boolean            execCommand(in DOMString command);
139#endif
140
141        boolean            queryCommandEnabled(in DOMString command);
142        boolean            queryCommandIndeterm(in DOMString command);
143        boolean            queryCommandState(in DOMString command);
144        boolean            queryCommandSupported(in DOMString command);
145        [ConvertNullStringTo=False] DOMString queryCommandValue(in DOMString command);
146
147        // Moved down from HTMLDocument
148
149                 attribute [ConvertNullToNullString] DOMString title;
150        readonly attribute DOMString referrer;
151#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
152                 attribute [ConvertNullToNullString] DOMString domain
153                     setter raises (DOMException);
154#else
155        readonly attribute DOMString domain;
156#endif
157        readonly attribute DOMString URL;
158
159                 attribute [ConvertNullToNullString] DOMString cookie
160                     setter raises (DOMException),
161                     getter raises (DOMException);
162
163        // FIXME: the DOM spec does NOT have this attribute
164        // raising an exception.
165                 attribute HTMLElement body
166                     setter raises (DOMException);
167
168        readonly attribute HTMLHeadElement head;
169        readonly attribute HTMLCollection images;
170        readonly attribute HTMLCollection applets;
171        readonly attribute HTMLCollection links;
172        readonly attribute HTMLCollection forms;
173        readonly attribute HTMLCollection anchors;
174        readonly attribute DOMString lastModified;
175
176        NodeList getElementsByName(in DOMString elementName);
177
178#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
179                 attribute [Custom] Location location;
180#endif
181
182        // IE extensions
183
184                 attribute [ConvertNullStringTo=Undefined, ConvertNullToNullString] DOMString charset;
185        readonly attribute [ConvertNullStringTo=Undefined] DOMString defaultCharset;
186        readonly attribute [ConvertNullStringTo=Undefined] DOMString readyState;
187
188        Element            elementFromPoint(in long x, in long y);
189        Range              caretRangeFromPoint(in long x, in long y);
190
191        // Mozilla extensions
192#if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
193        DOMSelection       getSelection();
194#endif
195        readonly attribute [ConvertNullStringTo=Null] DOMString characterSet;
196
197        // WebKit extensions
198
199        readonly attribute [ConvertNullStringTo=Null] DOMString preferredStylesheetSet;
200                 attribute [ConvertNullStringTo=Null, ConvertNullToNullString] DOMString selectedStylesheetSet;
201
202#if !defined(LANGUAGE_JAVASCRIPT) || !LANGUAGE_JAVASCRIPT
203        CSSStyleDeclaration createCSSStyleDeclaration();
204#endif
205
206#if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
207        // DOM Level 2 Style Interface
208        [OldStyleObjC, UsesView] CSSStyleDeclaration getComputedStyle(in Element element,
209                                                                      in DOMString pseudoElement);
210
211        // WebKit extension
212        // FIXME: remove the first version once [Optional] is implemented for Objective-C.
213        [UsesView] CSSRuleList getMatchedCSSRules(in Element element,
214                                                  in DOMString pseudoElement);
215        [UsesView] CSSRuleList getMatchedCSSRules(in Element element,
216                                                  in DOMString pseudoElement,
217                                                  in [Optional] boolean authorOnly);
218
219#endif
220
221#if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP
222#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
223        [V8Custom] DOMObject getCSSCanvasContext(in DOMString contextId, in DOMString name, in long width, in long height);
224#endif
225#endif
226
227        // HTML 5
228        NodeList getElementsByClassName(in DOMString tagname);
229
230        readonly attribute DOMString compatMode;
231
232        // NodeSelector - Selector API
233        [RequiresAllArguments=Raise] Element querySelector(in DOMString selectors)
234            raises(DOMException);
235        [RequiresAllArguments=Raise] NodeList querySelectorAll(in DOMString selectors)
236            raises(DOMException);
237
238#if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API
239        readonly attribute boolean webkitIsFullScreen;
240        readonly attribute boolean webkitFullScreenKeyboardInputAllowed;
241        readonly attribute Element webkitCurrentFullScreenElement;
242        void webkitCancelFullScreen();
243#endif
244
245#if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C
246        // Event handler DOM attributes
247        attribute [DontEnum] EventListener onabort;
248        attribute [DontEnum] EventListener onblur;
249        attribute [DontEnum] EventListener onchange;
250        attribute [DontEnum] EventListener onclick;
251        attribute [DontEnum] EventListener oncontextmenu;
252        attribute [DontEnum] EventListener ondblclick;
253        attribute [DontEnum] EventListener ondrag;
254        attribute [DontEnum] EventListener ondragend;
255        attribute [DontEnum] EventListener ondragenter;
256        attribute [DontEnum] EventListener ondragleave;
257        attribute [DontEnum] EventListener ondragover;
258        attribute [DontEnum] EventListener ondragstart;
259        attribute [DontEnum] EventListener ondrop;
260        attribute [DontEnum] EventListener onerror;
261        attribute [DontEnum] EventListener onfocus;
262        attribute [DontEnum] EventListener oninput;
263        attribute [DontEnum] EventListener oninvalid;
264        attribute [DontEnum] EventListener onkeydown;
265        attribute [DontEnum] EventListener onkeypress;
266        attribute [DontEnum] EventListener onkeyup;
267        attribute [DontEnum] EventListener onload;
268        attribute [DontEnum] EventListener onmousedown;
269        attribute [DontEnum] EventListener onmousemove;
270        attribute [DontEnum] EventListener onmouseout;
271        attribute [DontEnum] EventListener onmouseover;
272        attribute [DontEnum] EventListener onmouseup;
273        attribute [DontEnum] EventListener onmousewheel;
274        attribute [DontEnum] EventListener onreadystatechange;
275        attribute [DontEnum] EventListener onscroll;
276        attribute [DontEnum] EventListener onselect;
277        attribute [DontEnum] EventListener onsubmit;
278
279        // attribute [DontEnum] EventListener oncanplay;
280        // attribute [DontEnum] EventListener oncanplaythrough;
281        // attribute [DontEnum] EventListener ondurationchange;
282        // attribute [DontEnum] EventListener onemptied;
283        // attribute [DontEnum] EventListener onended;
284        // attribute [DontEnum] EventListener onloadeddata;
285        // attribute [DontEnum] EventListener onloadedmetadata;
286        // attribute [DontEnum] EventListener onloadstart;
287        // attribute [DontEnum] EventListener onpause;
288        // attribute [DontEnum] EventListener onplay;
289        // attribute [DontEnum] EventListener onplaying;
290        // attribute [DontEnum] EventListener onprogress;
291        // attribute [DontEnum] EventListener onratechange;
292        // attribute [DontEnum] EventListener onseeked;
293        // attribute [DontEnum] EventListener onseeking;
294        // attribute [DontEnum] EventListener onshow;
295        // attribute [DontEnum] EventListener onstalled;
296        // attribute [DontEnum] EventListener onsuspend;
297        // attribute [DontEnum] EventListener ontimeupdate;
298        // attribute [DontEnum] EventListener onvolumechange;
299        // attribute [DontEnum] EventListener onwaiting;
300
301        // WebKit extensions
302        attribute [DontEnum] EventListener onbeforecut;
303        attribute [DontEnum] EventListener oncut;
304        attribute [DontEnum] EventListener onbeforecopy;
305        attribute [DontEnum] EventListener oncopy;
306        attribute [DontEnum] EventListener onbeforepaste;
307        attribute [DontEnum] EventListener onpaste;
308        attribute [DontEnum] EventListener onreset;
309        attribute [DontEnum] EventListener onsearch;
310        attribute [DontEnum] EventListener onselectstart;
311        attribute [DontEnum] EventListener onselectionchange;
312        attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchstart;
313        attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchmove;
314        attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchend;
315        attribute [DontEnum,Conditional=TOUCH_EVENTS,EnabledAtRuntime] EventListener ontouchcancel;
316        attribute [DontEnum, Conditional=FULLSCREEN_API] EventListener onwebkitfullscreenchange;
317#endif
318
319#if defined(ENABLE_TOUCH_EVENTS) && ENABLE_TOUCH_EVENTS
320        [ReturnsNew, EnabledAtRuntime] Touch createTouch(in DOMWindow window,
321                                                         in EventTarget target,
322                                                         in long identifier,
323                                                         in long pageX,
324                                                         in long pageY,
325                                                         in long ScreenX,
326                                                         in long screenY)
327            raises (DOMException);
328        [ReturnsNew, EnabledAtRuntime, Custom] TouchList createTouchList()
329            raises (DOMException);
330#endif
331
332#if defined(LANGUAGE_CPP) && LANGUAGE_CPP
333        // Extra WebCore methods exposed to allow compile-time casting in C++
334        boolean isHTMLDocument();
335#endif
336
337    };
338
339}
340