Home | History | Annotate | Download | only in dom
      1 /*
      2  * Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved.
      3  * Copyright (C) 2006, 2007 Samuel Weinig <sam (at) 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 callback CustomElementConstructor = Element ();
     22 
     23 typedef (CanvasRenderingContext2D or WebGLRenderingContext) RenderingContext;
     24 
     25 [
     26     SpecialWrapFor=HTMLDocument|XMLDocument
     27 ] interface 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     [CustomElementCallbacks, PerWorldBindings, LogActivity, RaisesException] Element createElement(DOMString tagName);
     35     DocumentFragment createDocumentFragment();
     36     Text createTextNode(DOMString data);
     37     Comment createComment(DOMString data);
     38     [RaisesException, MeasureAs=DocumentCreateCDATASection] CDATASection createCDATASection([Default=Undefined] optional DOMString data); // Removed from DOM4.
     39     [RaisesException] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
     40     [RaisesException, MeasureAs=DocumentCreateAttribute] Attr createAttribute([Default=Undefined] optional DOMString name); // Removed from DOM4.
     41     HTMLCollection getElementsByTagName(DOMString localName);
     42 
     43     // Introduced in DOM Level 2:
     44 
     45     [CustomElementCallbacks, LogActivity, RaisesException] Node importNode(Node node, optional boolean deep);
     46     [CustomElementCallbacks, LogActivity, RaisesException] Element createElementNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString qualifiedName);
     47     [RaisesException, DeprecateAs=DocumentCreateAttributeNS] Attr createAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
     48                                                                                   [TreatNullAs=NullString,Default=Undefined] optional DOMString qualifiedName); // Removed from DOM4.
     49     HTMLCollection getElementsByTagNameNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString localName);
     50     [PerWorldBindings] Element getElementById(DOMString elementId);
     51 
     52     // DOM Level 3 Core
     53 
     54     [TreatReturnedNullStringAs=Null, MeasureAs=DocumentInputEncoding] readonly attribute DOMString inputEncoding; // Removed from DOM4.
     55 
     56     [TreatReturnedNullStringAs=Null, MeasureAs=DocumentXMLEncoding] readonly attribute DOMString xmlEncoding; // Removed from DOM4.
     57     [TreatReturnedNullStringAs=Null, TreatNullAs=NullString, RaisesException=Setter, MeasureAs=DocumentXMLVersion] attribute DOMString xmlVersion; // Removed from DOM4.
     58     [RaisesException=Setter, MeasureAs=DocumentXMLStandalone] attribute boolean xmlStandalone; // Removed from DOM4.
     59 
     60     [RaisesException, CustomElementCallbacks] Node adoptNode(Node node);
     61 
     62     [TreatReturnedNullStringAs=Null, ImplementedAs=url] readonly attribute DOMString documentURI;
     63 
     64     // DOM Level 2 Events (DocumentEvents interface)
     65 
     66     [RaisesException] Event createEvent(DOMString eventType);
     67 
     68     // DOM Level 2 Traversal and Range (DocumentRange interface)
     69 
     70     Range createRange();
     71 
     72     // DOM Level 2 Traversal and Range (DocumentTraversal interface)
     73 
     74     [RaisesException] NodeIterator createNodeIterator(Node root,
     75                                                       optional unsigned long whatToShow,
     76                                                       optional NodeFilter filter);
     77     [RaisesException] TreeWalker createTreeWalker(Node root,
     78                                                   optional unsigned long whatToShow,
     79                                                   optional NodeFilter filter);
     80 
     81     // DOM Level 2 Abstract Views (DocumentView interface)
     82 
     83     [ImplementedAs=executingWindow] readonly attribute Window defaultView;
     84 
     85     // DOM Level 2 Style (DocumentStyle interface)
     86 
     87     readonly attribute StyleSheetList styleSheets;
     88 
     89     // DOM Level 2 Style (DocumentCSS interface)
     90 
     91      CSSStyleDeclaration getOverrideStyle([Default=Undefined] optional Element element,
     92                                                         [Default=Undefined] optional DOMString pseudoElement);
     93 
     94     // DOM 4
     95     readonly attribute DOMString contentType;
     96 
     97     // Common extensions
     98     [CustomElementCallbacks]
     99     boolean            execCommand([Default=Undefined] optional DOMString command,
    100                                    [Default=Undefined] optional boolean userInterface,
    101                                    [TreatNullAs=NullString, TreatUndefinedAs=NullString,Default=Undefined] optional DOMString value);
    102 
    103     boolean            queryCommandEnabled([Default=Undefined] optional DOMString command);
    104     boolean            queryCommandIndeterm([Default=Undefined] optional DOMString command);
    105     boolean            queryCommandState([Default=Undefined] optional DOMString command);
    106     boolean            queryCommandSupported([Default=Undefined] optional DOMString command);
    107     DOMString          queryCommandValue([Default=Undefined] optional DOMString command);
    108 
    109     // Moved down from HTMLDocument
    110              [TreatNullAs=NullString, CustomElementCallbacks] attribute DOMString dir;
    111              [TreatNullAs=NullString, CustomElementCallbacks] attribute DOMString designMode;
    112              [TreatNullAs=NullString, CustomElementCallbacks] attribute DOMString title;
    113     readonly attribute DOMString referrer;
    114              [TreatNullAs=NullString, RaisesException=Setter] attribute DOMString domain;
    115     readonly attribute DOMString URL;
    116 
    117              [TreatNullAs=NullString, RaisesException] attribute DOMString cookie;
    118 
    119              [RaisesException=Setter, CustomElementCallbacks, PerWorldBindings] attribute HTMLElement body;
    120 
    121     readonly attribute HTMLHeadElement head;
    122     readonly attribute HTMLCollection images;
    123     readonly attribute HTMLCollection applets;
    124     readonly attribute HTMLCollection embeds;
    125     [ImplementedAs=embeds] readonly attribute HTMLCollection plugins;
    126     readonly attribute HTMLCollection links;
    127     readonly attribute HTMLCollection forms;
    128     readonly attribute HTMLCollection scripts;
    129     readonly attribute HTMLCollection anchors;
    130     readonly attribute DOMString lastModified;
    131 
    132     [PerWorldBindings] NodeList getElementsByName([Default=Undefined] optional DOMString elementName);
    133 
    134     [LogActivity, PutForwards=href] readonly attribute Location location;
    135 
    136     // IE extensions
    137     [MeasureAs=DocumentCharset, TreatReturnedNullStringAs=Undefined, TreatNullAs=NullString] attribute DOMString charset;
    138     [MeasureAs=DocumentDefaultCharset, TreatReturnedNullStringAs=Undefined] readonly attribute DOMString defaultCharset;
    139     [TreatReturnedNullStringAs=Undefined] readonly attribute DOMString readyState;
    140 
    141     Element            elementFromPoint([Default=Undefined] optional long x,
    142                                         [Default=Undefined] optional long y);
    143     [MeasureAs=DocumentCaretRangeFromPoint]
    144     Range              caretRangeFromPoint([Default=Undefined] optional long x,
    145                                            [Default=Undefined] optional long y);
    146 
    147     // Mozilla extensions
    148     Selection          getSelection();
    149     [TreatReturnedNullStringAs=Null] readonly attribute DOMString characterSet;
    150 
    151     // WebKit extensions
    152 
    153     [TreatReturnedNullStringAs=Null] readonly attribute DOMString preferredStylesheetSet;
    154     [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString selectedStylesheetSet;
    155 
    156     [MeasureAs=DocumentGetCSSCanvasContext] RenderingContext getCSSCanvasContext(DOMString contextId, DOMString name, long width, long height);
    157 
    158     // HTML 5
    159     HTMLCollection getElementsByClassName(DOMString classNames);
    160     readonly attribute Element activeElement;
    161     boolean hasFocus();
    162 
    163     readonly attribute DOMString compatMode;
    164 
    165     [MeasureAs=DocumentExitPointerLock] void exitPointerLock();
    166     [MeasureAs=DocumentPointerLockElement] readonly attribute Element pointerLockElement;
    167     [MeasureAs=PrefixedDocumentExitPointerLock, ImplementedAs=exitPointerLock] void webkitExitPointerLock();
    168     [MeasureAs=PrefixedDocumentPointerLockElement, ImplementedAs=pointerLockElement] readonly attribute Element webkitPointerLockElement;
    169 
    170     // Event handler attributes
    171     attribute EventHandler onbeforecopy;
    172     attribute EventHandler onbeforecut;
    173     attribute EventHandler onbeforepaste;
    174     attribute EventHandler oncopy;
    175     attribute EventHandler oncut;
    176     attribute EventHandler onpaste;
    177     attribute EventHandler onpointerlockchange;
    178     attribute EventHandler onpointerlockerror;
    179     attribute EventHandler onreadystatechange;
    180     attribute EventHandler onsearch;
    181     [RuntimeEnabled=ExperimentalContentSecurityPolicyFeatures] attribute EventHandler onsecuritypolicyviolation;
    182     attribute EventHandler onselectionchange;
    183     attribute EventHandler onselectstart;
    184     [RuntimeEnabled=Touch] attribute EventHandler ontouchcancel;
    185     [RuntimeEnabled=Touch] attribute EventHandler ontouchend;
    186     [RuntimeEnabled=Touch] attribute EventHandler ontouchmove;
    187     [RuntimeEnabled=Touch] attribute EventHandler ontouchstart;
    188     attribute EventHandler onwebkitfullscreenchange;
    189     attribute EventHandler onwebkitfullscreenerror;
    190     attribute EventHandler onwebkitpointerlockchange;
    191     attribute EventHandler onwebkitpointerlockerror;
    192     [LogActivity=SetterOnly] attribute EventHandler onwheel;
    193 
    194     [RuntimeEnabled=Touch] Touch createTouch([Default=Undefined] optional Window window,
    195                                                [Default=Undefined] optional EventTarget target,
    196                                                [Default=Undefined] optional long identifier,
    197                                                [Default=Undefined] optional double pageX,
    198                                                [Default=Undefined] optional double pageY,
    199                                                [Default=Undefined] optional double screenX,
    200                                                [Default=Undefined] optional double screenY,
    201                                                [Default=Undefined] optional double webkitRadiusX,
    202                                                [Default=Undefined] optional double webkitRadiusY,
    203                                                [Default=Undefined] optional float webkitRotationAngle,
    204                                                [Default=Undefined] optional float webkitForce);
    205     [RuntimeEnabled=Touch] TouchList createTouchList(Touch... touches);
    206 
    207     [CallWith=ScriptState, CustomElementCallbacks, RaisesException, MeasureAs=DocumentRegisterElement] CustomElementConstructor registerElement(DOMString name, optional Dictionary options);
    208     [CustomElementCallbacks, PerWorldBindings, LogActivity, RaisesException] Element createElement(DOMString localName, [TreatNullAs=NullString] DOMString typeExtension);
    209     [CustomElementCallbacks, LogActivity, RaisesException] Element createElementNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString qualifiedName,
    210                             [TreatNullAs=NullString] DOMString typeExtension);
    211 
    212     // Page visibility API.
    213     readonly attribute DOMString visibilityState;
    214     readonly attribute boolean hidden;
    215 
    216     // Deprecated prefixed page visibility API.
    217     // TODO(davidben): This is a property so attaching a deprecation warning results in false positives when outputting
    218     // document in the console. It's possible http://crbug.com/43394 will resolve this.
    219     [MeasureAs=PrefixedPageVisibility, ImplementedAs=visibilityState] readonly attribute DOMString webkitVisibilityState;
    220     [MeasureAs=PrefixedPageVisibility, ImplementedAs=hidden] readonly attribute boolean webkitHidden;
    221 
    222     readonly attribute HTMLScriptElement currentScript;
    223 };
    224 
    225 Document implements GlobalEventHandlers;
    226 Document implements ParentNode;
    227