blob: 48f660038cd743f36388cde74bcced8a01a83721 [file] [log] [blame]
* Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007 Samuel Weinig <>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* Library General Public License for more details.
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
[Custom] callback CustomElementConstructor = Element ();
enum DocumentReadyState { "loading", "interactive", "complete" };
enum VisibilityState { "hidden", "visible", "prerender"};
enum AddressSpace { "local", "private", "public" };
typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement;
] interface Document : Node {
[SameObject] readonly attribute DOMImplementation implementation;
[ImplementedAs=urlForBinding] readonly attribute DOMString URL;
// FIXME: documentURI should not be nullable.
[ImplementedAs=urlForBinding] readonly attribute DOMString? documentURI;
[MeasureAs=DocumentOrigin] readonly attribute DOMString origin;
[RuntimeEnabled=Suborigins] readonly attribute DOMString suborigin;
readonly attribute DOMString compatMode;
readonly attribute DOMString characterSet;
[ImplementedAs=characterSet] readonly attribute DOMString charset; // legacy alias of .characterSet
[ImplementedAs=characterSet] readonly attribute DOMString inputEncoding; // legacy alias of .characterSet
readonly attribute DOMString contentType;
readonly attribute DocumentType? doctype;
readonly attribute Element? documentElement;
HTMLCollection getElementsByTagName(DOMString localName);
HTMLCollection getElementsByTagNameNS(DOMString? namespaceURI, DOMString localName);
HTMLCollection getElementsByClassName(DOMString classNames);
[NewObject, DoNotTestNewObject, CustomElementCallbacks, PerWorldBindings, RaisesException] Element createElement(DOMString localName);
[NewObject, DoNotTestNewObject, CustomElementCallbacks, RaisesException] Element createElementNS(DOMString? namespaceURI, DOMString qualifiedName);
[NewObject] DocumentFragment createDocumentFragment();
[NewObject] Text createTextNode(DOMString data);
[NewObject, RaisesException] CDATASection createCDATASection(DOMString data);
[NewObject] Comment createComment(DOMString data);
[NewObject, RaisesException] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data);
[NewObject, DoNotTestNewObject, CEReactions, CustomElementCallbacks, RaisesException] Node importNode(Node node, optional boolean deep = false);
[RaisesException, CEReactions, CustomElementCallbacks] Node adoptNode(Node node);
[NewObject, RaisesException, MeasureAs=DocumentCreateAttribute] Attr createAttribute(DOMString localName);
[NewObject, RaisesException, MeasureAs=DocumentCreateAttributeNS] Attr createAttributeNS(DOMString? namespaceURI, DOMString qualifiedName);
[NewObject, RaisesException, CallWith=ScriptState] Event createEvent(DOMString eventType);
[NewObject] Range createRange();
// NodeFilter.SHOW_ALL = 0xFFFFFFFF
[NewObject] NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
[NewObject] TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null);
// NonDocumentRootScroller (
[RaisesException=Setter, RuntimeEnabled=SetRootScroller, Measure] attribute Element? rootScroller;
// FIXME: xmlEncoding/xmlVersion/xmlStandalone have been removed from the spec.
[MeasureAs=DocumentXMLEncoding] readonly attribute DOMString? xmlEncoding;
[RaisesException=Setter, MeasureAs=DocumentXMLVersion] attribute DOMString? xmlVersion;
[RaisesException=Setter, MeasureAs=DocumentXMLStandalone] attribute boolean xmlStandalone;
// resource metadata management
[PutForwards=href, Unforgeable] readonly attribute Location? location;
[RaisesException=Setter] attribute DOMString domain;
readonly attribute DOMString referrer;
[RaisesException, RuntimeCallStatsCounter=DocumentCookie] attribute DOMString cookie;
readonly attribute DOMString lastModified;
readonly attribute DocumentReadyState readyState;
// DOM tree accessors
// Named getter is implemented without IDL code generation for better
// performance. See LocalWindowProxy.cpp.
// getter object (DOMString name);
[CEReactions, CustomElementCallbacks] attribute DOMString title;
[CEReactions, CustomElementCallbacks] attribute DOMString dir;
[CEReactions, RaisesException=Setter, CustomElementCallbacks, PerWorldBindings] attribute HTMLElement? body;
readonly attribute HTMLHeadElement? head;
[SameObject, Measure] readonly attribute HTMLCollection images;
[SameObject, Measure] readonly attribute HTMLCollection embeds;
[SameObject, ImplementedAs=embeds, Measure] readonly attribute HTMLCollection plugins;
[SameObject, Measure] readonly attribute HTMLCollection links;
[SameObject, Measure] readonly attribute HTMLCollection forms;
[SameObject, Measure] readonly attribute HTMLCollection scripts;
[PerWorldBindings] NodeList getElementsByName(DOMString elementName);
[ImplementedAs=currentScriptForBinding] readonly attribute HTMLOrSVGScriptElement? currentScript;
// dynamic markup insertion
// FIXME: There are two open() methods in the spec.
[Custom, CEReactions, CustomElementCallbacks, RaisesException, MeasureAs=DocumentOpen] void open();
[CEReactions, RaisesException] void close();
[CallWith=EnteredWindow, CEReactions, CustomElementCallbacks, RaisesException] void write(DOMString... text);
[CallWith=EnteredWindow, CEReactions, CustomElementCallbacks, RaisesException] void writeln(DOMString... text);
// TrustedTypes variants of the above.
// TODO(mkwst): Write a spec for this.
[RuntimeEnabled=TrustedDOMTypes, CallWith=EnteredWindow, CEReactions, CustomElementCallbacks, RaisesException] void write(TrustedHTML text);
[RuntimeEnabled=TrustedDOMTypes, CallWith=EnteredWindow, CEReactions, CustomElementCallbacks, RaisesException] void writeln(TrustedHTML text);
// user interaction
readonly attribute Window? defaultView;
boolean hasFocus();
[CEReactions, CustomElementCallbacks, MeasureAs=DocumentDesignMode] attribute DOMString designMode;
[CEReactions, CustomElementCallbacks, RaisesException] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = "");
[RaisesException] boolean queryCommandEnabled(DOMString commandId);
[RaisesException] boolean queryCommandIndeterm(DOMString commandId);
[RaisesException] boolean queryCommandState(DOMString commandId);
[RaisesException] boolean queryCommandSupported(DOMString commandId);
[RaisesException] DOMString queryCommandValue(DOMString commandId);
[LenientThis] attribute EventHandler onreadystatechange;
// HTML obsolete features
// FIXME: *Color are on HTMLDocument.
[Measure] readonly attribute HTMLCollection anchors;
[Measure] readonly attribute HTMLCollection applets;
// FIXME: clear(), captureEvents(), releaseEvents() and all are on HTMLDocument.
// CSS Object Model (CSSOM)
attribute DOMString? selectedStylesheetSet;
readonly attribute DOMString? preferredStylesheetSet;
readonly attribute Element? scrollingElement;
// Pointer Lock
attribute EventHandler onpointerlockchange;
attribute EventHandler onpointerlockerror;
[MeasureAs=DocumentExitPointerLock] void exitPointerLock();
// Touch Events
[OriginTrialEnabled=TouchEventFeatureDetection, Measure, LegacyInterfaceTypeChecking, Custom=CallPrologue]
Touch createTouch(Window view,
EventTarget target,
long identifier,
double pageX,
double pageY,
double screenX,
double screenY,
optional unrestricted double radiusX = 0,
optional unrestricted double radiusY = 0,
optional unrestricted float rotationAngle = 0,
optional unrestricted float force = 0);
[OriginTrialEnabled=TouchEventFeatureDetection] TouchList createTouchList(Touch... touches);
// Custom Elements
// FIXME: The registerElement return type should be Function.
[CallWith=ScriptState, CustomElementCallbacks, RaisesException, MeasureAs=DocumentRegisterElement] CustomElementConstructor registerElement(DOMString type, optional ElementRegistrationOptions options);
// FIXME: The typeExtension arguments should not be nullable.
[CustomElementCallbacks, PerWorldBindings, RaisesException] Element createElement(DOMString localName, (DOMString or Dictionary)? options);
[CustomElementCallbacks, RaisesException] Element createElementNS(DOMString? namespaceURI, DOMString qualifiedName, (DOMString or Dictionary)? options);
// Page Visibility
readonly attribute boolean hidden;
readonly attribute VisibilityState visibilityState;
// CORS and RFC1918
[RuntimeEnabled=CorsRFC1918, ImplementedAs=addressSpaceForBindings] readonly attribute AddressSpace addressSpace;
// Non-standard APIs
[MeasureAs=DocumentCaretRangeFromPoint] Range caretRangeFromPoint([Default=Undefined] optional long x, [Default=Undefined] optional long y);
// Deprecated prefixed page visibility API.
// TODO(davidben): This is a property so attaching a deprecation warning results in false positives when outputting
// document in the console. It's possible will resolve this.
[MeasureAs=PrefixedPageVisibility, ImplementedAs=visibilityState] readonly attribute DOMString webkitVisibilityState;
[MeasureAs=PrefixedPageVisibility, ImplementedAs=hidden] readonly attribute boolean webkitHidden;
// Event handler attributes
attribute EventHandler onbeforecopy;
attribute EventHandler onbeforecut;
attribute EventHandler onbeforepaste;
attribute EventHandler oncopy;
attribute EventHandler oncut;
attribute EventHandler onpaste;
attribute EventHandler onsearch;
[RuntimeEnabled=ExperimentalContentSecurityPolicyFeatures] attribute EventHandler onsecuritypolicyviolation;
attribute EventHandler onselectionchange;
attribute EventHandler onselectstart;
attribute EventHandler onvisibilitychange;
Document implements GlobalEventHandlers;
Document implements ParentNode;
Document implements NonElementParentNode;
Document implements DocumentOrShadowRoot;
Document implements FontFaceSource;