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 [
     24     CustomToV8
     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     [CustomElementCallbacks=Enable, PerWorldBindings, ActivityLog=AccessForIsolatedWorlds, RaisesException] Element createElement([TreatNullAs=NullString,Default=Undefined] optional DOMString tagName);
     33     DocumentFragment   createDocumentFragment();
     34     [PerWorldBindings] Text createTextNode([Default=Undefined] optional DOMString data);
     35     Comment createComment([Default=Undefined] optional DOMString data);
     36     [RaisesException] CDATASection createCDATASection([Default=Undefined] optional DOMString data);
     37     [RaisesException] ProcessingInstruction createProcessingInstruction([Default=Undefined] optional DOMString target,
     38                                                                                  [Default=Undefined] optional DOMString data);
     39     [RaisesException] Attr createAttribute([Default=Undefined] optional DOMString name);
     40     [PerWorldBindings] NodeList           getElementsByTagName([Default=Undefined] optional DOMString tagname);
     41 
     42     // Introduced in DOM Level 2:
     43 
     44     [CustomElementCallbacks=Enable, PerWorldBindings, ActivityLog=AccessForIsolatedWorlds, RaisesException] Node importNode([Default=Undefined] optional Node importedNode,
     45                     optional boolean deep);
     46     [CustomElementCallbacks=Enable, PerWorldBindings, ActivityLog=AccessForIsolatedWorlds, RaisesException] Element createElementNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
     47                             [TreatNullAs=NullString,Default=Undefined] optional DOMString qualifiedName);
     48     [RaisesException] Attr createAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
     49                                                                           [TreatNullAs=NullString,Default=Undefined] optional DOMString qualifiedName);
     50      NodeList getElementsByTagNameNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI,
     51                                                    [Default=Undefined] optional DOMString localName);
     52     [PerWorldBindings] Element            getElementById([Default=Undefined] optional DOMString elementId);
     53 
     54     // DOM Level 3 Core
     55 
     56     [TreatReturnedNullStringAs=Null] readonly attribute DOMString inputEncoding;
     57 
     58     [TreatReturnedNullStringAs=Null] readonly attribute DOMString xmlEncoding;
     59              [TreatReturnedNullStringAs=Null, TreatNullAs=NullString, SetterRaisesException] attribute DOMString xmlVersion;
     60              [SetterRaisesException] attribute boolean xmlStandalone;
     61 
     62     [RaisesException, CustomElementCallbacks=Enable] Node               adoptNode([Default=Undefined] optional Node source);
     63 
     64     [TreatReturnedNullStringAs=Null] readonly attribute DOMString documentURI;
     65 
     66     // DOM Level 2 Events (DocumentEvents interface)
     67 
     68     [RaisesException] Event              createEvent([Default=Undefined] optional DOMString eventType);
     69 
     70     // DOM Level 2 Traversal and Range (DocumentRange interface)
     71 
     72     Range              createRange();
     73 
     74     // DOM Level 2 Traversal and Range (DocumentTraversal interface)
     75     // In DOM4, the fourth argument |expandEntityReferences| is removed.
     76     // Historically, this argument was never implemented and has been ignored.
     77     // We still receive the argument to keep compatibility, but don't do anything if it's specified.
     78     [RaisesException] NodeIterator createNodeIterator(Node root,
     79                                                       optional unsigned long whatToShow,
     80                                                       optional NodeFilter filter,
     81                                                       optional boolean expandEntityReferences);
     82     [RaisesException] TreeWalker createTreeWalker(Node root,
     83                                                   optional unsigned long whatToShow,
     84                                                   optional NodeFilter filter,
     85                                                   optional boolean expandEntityReferences);
     86 
     87     // DOM Level 2 Abstract Views (DocumentView interface)
     88 
     89     readonly attribute Window defaultView;
     90 
     91     // DOM Level 2 Style (DocumentStyle interface)
     92 
     93     readonly attribute StyleSheetList styleSheets;
     94 
     95     // DOM Level 2 Style (DocumentCSS interface)
     96 
     97      CSSStyleDeclaration getOverrideStyle([Default=Undefined] optional Element element,
     98                                                         [Default=Undefined] optional DOMString pseudoElement);
     99 
    100     // Common extensions
    101     [CustomElementCallbacks=Enable]
    102     boolean            execCommand([Default=Undefined] optional DOMString command,
    103                                    [Default=Undefined] optional boolean userInterface,
    104                                    [TreatNullAs=NullString, TreatUndefinedAs=NullString,Default=Undefined] optional DOMString value);
    105 
    106     boolean            queryCommandEnabled([Default=Undefined] optional DOMString command);
    107     boolean            queryCommandIndeterm([Default=Undefined] optional DOMString command);
    108     boolean            queryCommandState([Default=Undefined] optional DOMString command);
    109     boolean            queryCommandSupported([Default=Undefined] optional DOMString command);
    110     DOMString          queryCommandValue([Default=Undefined] optional DOMString command);
    111 
    112     // Moved down from HTMLDocument
    113 
    114              [TreatNullAs=NullString, CustomElementCallbacks=Enable] attribute DOMString title;
    115     readonly attribute DOMString referrer;
    116              [TreatNullAs=NullString, SetterRaisesException] attribute DOMString domain;
    117     readonly attribute DOMString URL;
    118 
    119              [TreatNullAs=NullString, GetterRaisesException, SetterRaisesException] attribute DOMString cookie;
    120 
    121              [SetterRaisesException, CustomElementCallbacks=Enable] attribute HTMLElement body;
    122 
    123     readonly attribute HTMLHeadElement head;
    124     readonly attribute HTMLCollection images;
    125     readonly attribute HTMLCollection applets;
    126     readonly attribute HTMLCollection links;
    127     readonly attribute HTMLCollection forms;
    128     readonly attribute HTMLCollection anchors;
    129     readonly attribute DOMString lastModified;
    130 
    131     [PerWorldBindings] NodeList getElementsByName([Default=Undefined] optional DOMString elementName);
    132 
    133     [Custom, Replaceable, PerWorldBindings, ActivityLog=AccessForIsolatedWorlds] readonly attribute Location location;
    134 
    135     // IE extensions
    136 
    137              [TreatReturnedNullStringAs=Undefined, TreatNullAs=NullString] attribute DOMString charset;
    138     [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     Range              caretRangeFromPoint([Default=Undefined] optional long x,
    144                                            [Default=Undefined] optional long y);
    145 
    146     // Mozilla extensions
    147     Selection          getSelection();
    148     [TreatReturnedNullStringAs=Null] readonly attribute DOMString characterSet;
    149 
    150     // WebKit extensions
    151 
    152     [TreatReturnedNullStringAs=Null] readonly attribute DOMString preferredStylesheetSet;
    153              [TreatReturnedNullStringAs=Null, TreatNullAs=NullString] attribute DOMString selectedStylesheetSet;
    154 
    155     CanvasRenderingContext getCSSCanvasContext(DOMString contextId, DOMString name, long width, long height);
    156 
    157     // HTML 5
    158     NodeList getElementsByClassName([Default=Undefined] optional DOMString tagname);
    159 
    160     readonly attribute DOMString compatMode;
    161 
    162     // NodeSelector - Selector API
    163     [RaisesException] Element querySelector(DOMString selectors);
    164     [RaisesException] NodeList querySelectorAll(DOMString selectors);
    165 
    166     void webkitExitPointerLock();
    167     readonly attribute Element webkitPointerLockElement;
    168 
    169     [EnabledAtRuntime=cssRegions] WebKitNamedFlowCollection webkitGetNamedFlows();
    170 
    171     [EnabledAtRuntime=fontLoadEvents] readonly attribute FontLoader fontloader;
    172 
    173     // Event handler DOM attributes
    174     [NotEnumerable] attribute EventHandler onabort;
    175     [NotEnumerable] attribute EventHandler onblur;
    176     [NotEnumerable] attribute EventHandler onchange;
    177     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onclick;
    178     [NotEnumerable] attribute EventHandler oncontextmenu;
    179     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondblclick;
    180     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondrag;
    181     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragend;
    182     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragenter;
    183     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragleave;
    184     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragover;
    185     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondragstart;
    186     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler ondrop;
    187     [NotEnumerable] attribute EventHandler onerror;
    188     [NotEnumerable] attribute EventHandler onfocus;
    189     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler oninput;
    190     [NotEnumerable] attribute EventHandler oninvalid;
    191     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onkeydown;
    192     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onkeypress;
    193     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onkeyup;
    194     [NotEnumerable] attribute EventHandler onload;
    195     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmousedown;
    196     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseenter;
    197     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseleave;
    198     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmousemove;
    199     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseout;
    200     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseover;
    201     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmouseup;
    202     [NotEnumerable, PerWorldBindings, ActivityLog=SetterForIsolatedWorlds] attribute EventHandler onmousewheel;
    203     [NotEnumerable] attribute EventHandler onreadystatechange;
    204     [NotEnumerable] attribute EventHandler onscroll;
    205     [NotEnumerable] attribute EventHandler onselect;
    206     [NotEnumerable] attribute EventHandler onsubmit;
    207 
    208     // attribute [NotEnumerable] EventHandler oncanplay;
    209     // attribute [NotEnumerable] EventHandler oncanplaythrough;
    210     // attribute [NotEnumerable] EventHandler ondurationchange;
    211     // attribute [NotEnumerable] EventHandler onemptied;
    212     // attribute [NotEnumerable] EventHandler onended;
    213     // attribute [NotEnumerable] EventHandler onloadeddata;
    214     // attribute [NotEnumerable] EventHandler onloadedmetadata;
    215     // attribute [NotEnumerable] EventHandler onloadstart;
    216     // attribute [NotEnumerable] EventHandler onpause;
    217     // attribute [NotEnumerable] EventHandler onplay;
    218     // attribute [NotEnumerable] EventHandler onplaying;
    219     // attribute [NotEnumerable] EventHandler onprogress;
    220     // attribute [NotEnumerable] EventHandler onratechange;
    221     // attribute [NotEnumerable] EventHandler onseeked;
    222     // attribute [NotEnumerable] EventHandler onseeking;
    223     // attribute [NotEnumerable] EventHandler onshow;
    224     // attribute [NotEnumerable] EventHandler onstalled;
    225     // attribute [NotEnumerable] EventHandler onsuspend;
    226     // attribute [NotEnumerable] EventHandler ontimeupdate;
    227     // attribute [NotEnumerable] EventHandler onvolumechange;
    228     // attribute [NotEnumerable] EventHandler onwaiting;
    229 
    230     // WebKit extensions
    231     [NotEnumerable] attribute EventHandler onbeforecut;
    232     [NotEnumerable] attribute EventHandler oncut;
    233     [NotEnumerable] attribute EventHandler onbeforecopy;
    234     [NotEnumerable] attribute EventHandler oncopy;
    235     [NotEnumerable] attribute EventHandler onbeforepaste;
    236     [NotEnumerable] attribute EventHandler onpaste;
    237     [NotEnumerable] attribute EventHandler onreset;
    238     [NotEnumerable] attribute EventHandler onsearch;
    239     [NotEnumerable] attribute EventHandler onselectstart;
    240     [NotEnumerable] attribute EventHandler onselectionchange;
    241     [NotEnumerable,EnabledAtRuntime=touch] attribute EventHandler ontouchstart;
    242     [NotEnumerable,EnabledAtRuntime=touch] attribute EventHandler ontouchmove;
    243     [NotEnumerable,EnabledAtRuntime=touch] attribute EventHandler ontouchend;
    244     [NotEnumerable,EnabledAtRuntime=touch] attribute EventHandler ontouchcancel;
    245     [NotEnumerable] attribute EventHandler onwebkitfullscreenchange;
    246     [NotEnumerable] attribute EventHandler onwebkitfullscreenerror;
    247     [NotEnumerable] attribute EventHandler onwebkitpointerlockchange;
    248     [NotEnumerable] attribute EventHandler onwebkitpointerlockerror;
    249     [NotEnumerable, EnabledAtRuntime=experimentalContentSecurityPolicyFeatures] attribute EventHandler onsecuritypolicyviolation;
    250 
    251     [EnabledAtRuntime=touch] Touch createTouch([Default=Undefined] optional Window window,
    252                                                [Default=Undefined] optional EventTarget target,
    253                                                [Default=Undefined] optional long identifier,
    254                                                [Default=Undefined] optional long pageX,
    255                                                [Default=Undefined] optional long pageY,
    256                                                [Default=Undefined] optional long screenX,
    257                                                [Default=Undefined] optional long screenY,
    258                                                [Default=Undefined] optional long webkitRadiusX,
    259                                                [Default=Undefined] optional long webkitRadiusY,
    260                                                [Default=Undefined] optional float webkitRotationAngle,
    261                                                [Default=Undefined] optional float webkitForce);
    262     [EnabledAtRuntime=touch, Custom, RaisesException] TouchList createTouchList();
    263 
    264     [DeprecateAs=PrefixedDocumentRegister, EnabledAtRuntime=customDOMElements, ImplementedAs=registerElement, CallWith=ScriptState, CustomElementCallbacks=Enable, RaisesException] CustomElementConstructor webkitRegister(DOMString name, optional Dictionary options);
    265     [EnabledAtRuntime=customDOMElements, ImplementedAs=registerElement, CallWith=ScriptState, CustomElementCallbacks=Enable, RaisesException] CustomElementConstructor register(DOMString name, optional Dictionary options);
    266     [CustomElementCallbacks=Enable, PerWorldBindings, ActivityLog=AccessForIsolatedWorlds, RaisesException] Element createElement(DOMString localName, [TreatNullAs=NullString] DOMString typeExtension);
    267     [CustomElementCallbacks=Enable, PerWorldBindings, ActivityLog=AccessForIsolatedWorlds, RaisesException] Element createElementNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString qualifiedName,
    268                             [TreatNullAs=NullString] DOMString typeExtension);
    269 
    270     // Page visibility API.
    271     readonly attribute DOMString webkitVisibilityState;
    272     readonly attribute boolean webkitHidden;
    273 
    274     // Security Policy API: http://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html#script-interfaces
    275     [EnabledAtRuntime=experimentalContentSecurityPolicyFeatures] readonly attribute SecurityPolicy securityPolicy;
    276 
    277     readonly attribute HTMLScriptElement currentScript;
    278 };
    279 
    280 Document implements ParentNode;
    281 
    282