dom/webidl/Document.webidl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/webidl/Document.webidl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,365 @@
     1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 + *
     1.9 + * The origin of this IDL file is:
    1.10 + * http://dom.spec.whatwg.org/#interface-document
    1.11 + * http://www.whatwg.org/specs/web-apps/current-work/#the-document-object
    1.12 + * http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#api
    1.13 + * http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html#extensions-to-the-document-interface
    1.14 + * http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#sec-document-interface
    1.15 + * http://dev.w3.org/csswg/cssom/#extensions-to-the-document-interface
    1.16 + * http://dev.w3.org/csswg/cssom-view/#extensions-to-the-document-interface
    1.17 + *
    1.18 + * http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/core/nsIDOMDocument.idl
    1.19 + */
    1.20 +
    1.21 +interface WindowProxy;
    1.22 +interface nsISupports;
    1.23 +interface URI;
    1.24 +interface nsIDocShell;
    1.25 +
    1.26 +enum VisibilityState { "hidden", "visible" };
    1.27 +
    1.28 +/* http://dom.spec.whatwg.org/#interface-document */
    1.29 +[Constructor]
    1.30 +interface Document : Node {
    1.31 +  [Throws]
    1.32 +  readonly attribute DOMImplementation implementation;
    1.33 +  [Pure]
    1.34 +  readonly attribute DOMString URL;
    1.35 +  [Pure]
    1.36 +  readonly attribute DOMString documentURI;
    1.37 +  [Pure]
    1.38 +  readonly attribute DOMString compatMode;
    1.39 +  [Pure]
    1.40 +  readonly attribute DOMString characterSet;
    1.41 +  [Pure]
    1.42 +  readonly attribute DOMString contentType;
    1.43 +
    1.44 +  [Pure]
    1.45 +  readonly attribute DocumentType? doctype;
    1.46 +  [Pure]
    1.47 +  readonly attribute Element? documentElement;
    1.48 +  [Pure]
    1.49 +  HTMLCollection getElementsByTagName(DOMString localName);
    1.50 +  [Pure, Throws]
    1.51 +  HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
    1.52 +  [Pure]
    1.53 +  HTMLCollection getElementsByClassName(DOMString classNames);
    1.54 +  [Pure]
    1.55 +  Element? getElementById(DOMString elementId);
    1.56 +
    1.57 +  [NewObject, Throws]
    1.58 +  Element createElement(DOMString localName);
    1.59 +  [NewObject, Throws]
    1.60 +  Element createElementNS(DOMString? namespace, DOMString qualifiedName);
    1.61 +  [NewObject]
    1.62 +  DocumentFragment createDocumentFragment();
    1.63 +  [NewObject]
    1.64 +  Text createTextNode(DOMString data);
    1.65 +  [NewObject]
    1.66 +  Comment createComment(DOMString data);
    1.67 +  [NewObject, Throws]
    1.68 +  ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
    1.69 +
    1.70 +  [Throws]
    1.71 +  Node importNode(Node node, optional boolean deep = false);
    1.72 +  [Throws]
    1.73 +  Node adoptNode(Node node);
    1.74 +
    1.75 +  [NewObject, Throws]
    1.76 +  Event createEvent(DOMString interface);
    1.77 +
    1.78 +  [NewObject, Throws]
    1.79 +  Range createRange();
    1.80 +
    1.81 +  // NodeFilter.SHOW_ALL = 0xFFFFFFFF
    1.82 +  [NewObject, Throws]
    1.83 +  NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
    1.84 +  [NewObject, Throws]
    1.85 +  TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
    1.86 +
    1.87 +  // NEW
    1.88 +  // No support for prepend/append yet
    1.89 +  // void prepend((Node or DOMString)... nodes);
    1.90 +  // void append((Node or DOMString)... nodes);
    1.91 +
    1.92 +  // These are not in the spec, but leave them for now for backwards compat.
    1.93 +  // So sort of like Gecko extensions
    1.94 +  [NewObject, Throws]
    1.95 +  CDATASection createCDATASection(DOMString data);
    1.96 +  [NewObject, Throws]
    1.97 +  Attr createAttribute(DOMString name);
    1.98 +  [NewObject, Throws]
    1.99 +  Attr createAttributeNS(DOMString? namespace, DOMString name);
   1.100 +  [Pure]
   1.101 +  readonly attribute DOMString? inputEncoding;
   1.102 +};
   1.103 +
   1.104 +// http://www.whatwg.org/specs/web-apps/current-work/#the-document-object
   1.105 +partial interface Document {
   1.106 +  [PutForwards=href, Unforgeable] readonly attribute Location? location;
   1.107 +  //(HTML only)         attribute DOMString domain;
   1.108 +  readonly attribute DOMString referrer;
   1.109 +  //(HTML only)         attribute DOMString cookie;
   1.110 +  readonly attribute DOMString lastModified;
   1.111 +  readonly attribute DOMString readyState;
   1.112 +
   1.113 +  // DOM tree accessors
   1.114 +  //(Not proxy yet)getter object (DOMString name);
   1.115 +  [SetterThrows, Pure]
   1.116 +           attribute DOMString title;
   1.117 +  [Pure]
   1.118 +           attribute DOMString dir;
   1.119 +  //(HTML only)         attribute HTMLElement? body;
   1.120 +  //(HTML only)readonly attribute HTMLHeadElement? head;
   1.121 +  //(HTML only)readonly attribute HTMLCollection images;
   1.122 +  //(HTML only)readonly attribute HTMLCollection embeds;
   1.123 +  //(HTML only)readonly attribute HTMLCollection plugins;
   1.124 +  //(HTML only)readonly attribute HTMLCollection links;
   1.125 +  //(HTML only)readonly attribute HTMLCollection forms;
   1.126 +  //(HTML only)readonly attribute HTMLCollection scripts;
   1.127 +  //(HTML only)NodeList getElementsByName(DOMString elementName);
   1.128 +  //(HTML only)NodeList getItems(optional DOMString typeNames); // microdata
   1.129 +  //(Not implemented)readonly attribute DOMElementMap cssElementMap;
   1.130 +
   1.131 +  // dynamic markup insertion
   1.132 +  //(HTML only)Document open(optional DOMString type, optional DOMString replace);
   1.133 +  //(HTML only)WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace);
   1.134 +  //(HTML only)void close();
   1.135 +  //(HTML only)void write(DOMString... text);
   1.136 +  //(HTML only)void writeln(DOMString... text);
   1.137 +
   1.138 +  // user interaction
   1.139 +  [Pure]
   1.140 +  readonly attribute WindowProxy? defaultView;
   1.141 +  readonly attribute Element? activeElement;
   1.142 +  [Throws]
   1.143 +  boolean hasFocus();
   1.144 +  //(HTML only)         attribute DOMString designMode;
   1.145 +  //(HTML only)boolean execCommand(DOMString commandId);
   1.146 +  //(HTML only)boolean execCommand(DOMString commandId, boolean showUI);
   1.147 +  //(HTML only)boolean execCommand(DOMString commandId, boolean showUI, DOMString value);
   1.148 +  //(HTML only)boolean queryCommandEnabled(DOMString commandId);
   1.149 +  //(HTML only)boolean queryCommandIndeterm(DOMString commandId);
   1.150 +  //(HTML only)boolean queryCommandState(DOMString commandId);
   1.151 +  //(HTML only)boolean queryCommandSupported(DOMString commandId);
   1.152 +  //(HTML only)DOMString queryCommandValue(DOMString commandId);
   1.153 +  //(Not implemented)readonly attribute HTMLCollection commands;
   1.154 +
   1.155 +  // special event handler IDL attributes that only apply to Document objects
   1.156 +  [LenientThis] attribute EventHandler onreadystatechange;
   1.157 +
   1.158 +  // Gecko extensions?
   1.159 +                attribute EventHandler onwheel;
   1.160 +                attribute EventHandler oncopy;
   1.161 +                attribute EventHandler oncut;
   1.162 +                attribute EventHandler onpaste;
   1.163 +                attribute EventHandler onbeforescriptexecute;
   1.164 +                attribute EventHandler onafterscriptexecute;
   1.165 +  /**
   1.166 +   * True if this document is synthetic : stand alone image, video, audio file,
   1.167 +   * etc.
   1.168 +   */
   1.169 +  [Func="IsChromeOrXBL"] readonly attribute boolean mozSyntheticDocument;
   1.170 +  /**
   1.171 +   * Returns the script element whose script is currently being processed.
   1.172 +   *
   1.173 +   * @see <https://developer.mozilla.org/en/DOM/document.currentScript>
   1.174 +   */
   1.175 +  [Pure]
   1.176 +  readonly attribute Element? currentScript;
   1.177 +  /**
   1.178 +   * Release the current mouse capture if it is on an element within this
   1.179 +   * document.
   1.180 +   *
   1.181 +   * @see <https://developer.mozilla.org/en/DOM/document.releaseCapture>
   1.182 +   */
   1.183 +  void releaseCapture();
   1.184 +  /**
   1.185 +   * Use the given DOM element as the source image of target |-moz-element()|.
   1.186 +   *
   1.187 +   * This function introduces a new special ID (called "image element ID"),
   1.188 +   * which is only used by |-moz-element()|, and associates it with the given
   1.189 +   * DOM element.  Image elements ID's have the higher precedence than general
   1.190 +   * HTML id's, so if |document.mozSetImageElement(<id>, <element>)| is called,
   1.191 +   * |-moz-element(#<id>)| uses |<element>| as the source image even if there
   1.192 +   * is another element with id attribute = |<id>|.  To unregister an image
   1.193 +   * element ID |<id>|, call |document.mozSetImageElement(<id>, null)|.
   1.194 +   *
   1.195 +   * Example:
   1.196 +   * <script>
   1.197 +   *   canvas = document.createElement("canvas");
   1.198 +   *   canvas.setAttribute("width", 100);
   1.199 +   *   canvas.setAttribute("height", 100);
   1.200 +   *   // draw to canvas
   1.201 +   *   document.mozSetImageElement("canvasbg", canvas);
   1.202 +   * </script>
   1.203 +   * <div style="background-image: -moz-element(#canvasbg);"></div>
   1.204 +   *
   1.205 +   * @param aImageElementId an image element ID to associate with
   1.206 +   * |aImageElement|
   1.207 +   * @param aImageElement a DOM element to be used as the source image of
   1.208 +   * |-moz-element(#aImageElementId)|. If this is null, the function will
   1.209 +   * unregister the image element ID |aImageElementId|.
   1.210 +   *
   1.211 +   * @see <https://developer.mozilla.org/en/DOM/document.mozSetImageElement>
   1.212 +   */
   1.213 +  void mozSetImageElement(DOMString aImageElementId,
   1.214 +                          Element? aImageElement);
   1.215 +
   1.216 +  [ChromeOnly]
   1.217 +  readonly attribute URI? documentURIObject;
   1.218 +
   1.219 +};
   1.220 +
   1.221 +// http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#api
   1.222 +partial interface Document {
   1.223 +  // Note: Per spec the 'S' in these two is lowercase, but the "Moz"
   1.224 +  // versions hve it uppercase.
   1.225 +  readonly attribute boolean mozFullScreenEnabled;
   1.226 +  [Throws]
   1.227 +  readonly attribute Element? mozFullScreenElement;
   1.228 +
   1.229 +  //(Renamed?)void exitFullscreen();
   1.230 +
   1.231 +  // Gecko-specific fullscreen bits
   1.232 +  readonly attribute boolean mozFullScreen;
   1.233 +  void mozCancelFullScreen();
   1.234 +};
   1.235 +
   1.236 +// http://dvcs.w3.org/hg/pointerlock/raw-file/default/index.html#extensions-to-the-document-interface
   1.237 +partial interface Document {
   1.238 +    readonly attribute Element? mozPointerLockElement;
   1.239 +    void mozExitPointerLock ();
   1.240 +};
   1.241 +
   1.242 +//http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-document-register
   1.243 +partial interface Document {
   1.244 +    [Throws, Func="nsDocument::IsRegisterElementEnabled"]
   1.245 +    object registerElement(DOMString name, optional ElementRegistrationOptions options);
   1.246 +};
   1.247 +
   1.248 +//http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html#dfn-document-register
   1.249 +partial interface Document {
   1.250 +    [NewObject, Throws]
   1.251 +    Element createElement(DOMString localName, DOMString typeExtension);
   1.252 +    [NewObject, Throws]
   1.253 +    Element createElementNS(DOMString? namespace, DOMString qualifiedName, DOMString typeExtension);
   1.254 +};
   1.255 +
   1.256 +// http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PageVisibility/Overview.html#sec-document-interface
   1.257 +partial interface Document {
   1.258 +  readonly attribute boolean hidden;
   1.259 +  readonly attribute boolean mozHidden;
   1.260 +  readonly attribute VisibilityState visibilityState;
   1.261 +  readonly attribute VisibilityState mozVisibilityState;
   1.262 +};
   1.263 +
   1.264 +// http://dev.w3.org/csswg/cssom/#extensions-to-the-document-interface
   1.265 +partial interface Document {
   1.266 +    [Constant]
   1.267 +    readonly attribute StyleSheetList styleSheets;
   1.268 +    attribute DOMString? selectedStyleSheetSet;
   1.269 +    readonly attribute DOMString? lastStyleSheetSet;
   1.270 +    readonly attribute DOMString? preferredStyleSheetSet;
   1.271 +    [Constant]
   1.272 +    readonly attribute DOMStringList styleSheetSets;
   1.273 +    void enableStyleSheetsForSet (DOMString? name);
   1.274 +};
   1.275 +
   1.276 +// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-document-interface
   1.277 +partial interface Document {
   1.278 +    Element? elementFromPoint (float x, float y);
   1.279 +
   1.280 +    CaretPosition? caretPositionFromPoint (float x, float y);
   1.281 +};
   1.282 +
   1.283 +// http://dvcs.w3.org/hg/undomanager/raw-file/tip/undomanager.html
   1.284 +partial interface Document {
   1.285 +    [Pref="dom.undo_manager.enabled"]
   1.286 +    readonly attribute UndoManager? undoManager;
   1.287 +};
   1.288 +
   1.289 +// http://dev.w3.org/2006/webapi/selectors-api2/#interface-definitions
   1.290 +partial interface Document {
   1.291 +  [Throws, Pure]
   1.292 +  Element?  querySelector(DOMString selectors);
   1.293 +  [Throws, Pure]
   1.294 +  NodeList  querySelectorAll(DOMString selectors);
   1.295 +
   1.296 +  //(Not implemented)Element?  find(DOMString selectors, optional (Element or sequence<Node>)? refNodes);
   1.297 +  //(Not implemented)NodeList  findAll(DOMString selectors, optional (Element or sequence<Node>)? refNodes);
   1.298 +};
   1.299 +
   1.300 +//  Mozilla extensions of various sorts
   1.301 +partial interface Document {
   1.302 +  // nsIDOMDocumentXBL.  Wish we could make these [ChromeOnly], but
   1.303 +  // that would likely break bindings running with the page principal.
   1.304 +  [Func="IsChromeOrXBL"]
   1.305 +  NodeList? getAnonymousNodes(Element elt);
   1.306 +  [Func="IsChromeOrXBL"]
   1.307 +  Element? getAnonymousElementByAttribute(Element elt, DOMString attrName,
   1.308 +                                          DOMString attrValue);
   1.309 +  [Func="IsChromeOrXBL"]
   1.310 +  Element? getBindingParent(Node node);
   1.311 +  [Throws, Func="IsChromeOrXBL"]
   1.312 +  void loadBindingDocument(DOMString documentURL);
   1.313 +
   1.314 +  // nsIDOMDocumentTouch
   1.315 +  // XXXbz I can't find the sane spec for this stuff, so just cribbing
   1.316 +  // from our xpidl for now.
   1.317 +  [NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
   1.318 +  Touch createTouch(optional Window? view = null,
   1.319 +                    optional EventTarget? target = null,
   1.320 +                    optional long identifier = 0,
   1.321 +                    optional long pageX = 0,
   1.322 +                    optional long pageY = 0,
   1.323 +                    optional long screenX = 0,
   1.324 +                    optional long screenY = 0,
   1.325 +                    optional long clientX = 0,
   1.326 +                    optional long clientY = 0,
   1.327 +                    optional long radiusX = 0,
   1.328 +                    optional long radiusY = 0,
   1.329 +                    optional float rotationAngle = 0,
   1.330 +                    optional float force = 0);
   1.331 +  // XXXbz a hack to get around the fact that we don't support variadics as
   1.332 +  // distinguishing arguments yet.  Once this hack is removed. we can also
   1.333 +  // remove the corresponding overload on nsIDocument, since Touch... and
   1.334 +  // sequence<Touch> look the same in the C++.
   1.335 +  [NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
   1.336 +  TouchList createTouchList(Touch touch, Touch... touches);
   1.337 +  // XXXbz and another hack for the fact that we can't usefully have optional
   1.338 +  // distinguishing arguments but need a working zero-arg form of
   1.339 +  // createTouchList().
   1.340 +  [NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
   1.341 +  TouchList createTouchList();
   1.342 +  [NewObject, Func="nsGenericHTMLElement::TouchEventsEnabled"]
   1.343 +  TouchList createTouchList(sequence<Touch> touches);
   1.344 +
   1.345 +  [ChromeOnly]
   1.346 +  attribute boolean styleSheetChangeEventsEnabled;
   1.347 +
   1.348 +  [ChromeOnly, Throws]
   1.349 +  void obsoleteSheet(URI sheetURI);
   1.350 +  [ChromeOnly, Throws]
   1.351 +  void obsoleteSheet(DOMString sheetURI);
   1.352 +
   1.353 +  [ChromeOnly] readonly attribute nsIDocShell? docShell;
   1.354 +
   1.355 +  [ChromeOnly] readonly attribute DOMString contentLanguage;
   1.356 +};
   1.357 +
   1.358 +// Extension to give chrome JS the ability to determine when a document was
   1.359 +// created to satisfy an iframe with srcdoc attribute.
   1.360 +partial interface Document {
   1.361 +  [ChromeOnly] readonly attribute boolean isSrcdocDocument;
   1.362 +};
   1.363 +
   1.364 +Document implements XPathEvaluator;
   1.365 +Document implements GlobalEventHandlers;
   1.366 +Document implements TouchEventHandlers;
   1.367 +Document implements ParentNode;
   1.368 +Document implements OnErrorEventHandlerForNodes;

mercurial