1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
|
/*
* Copyright (C) 2006, 2007, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007 Samuel Weinig <sam@webkit.org>
*
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* 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.
*/
// https://html.spec.whatwg.org/C/#the-document-object
enum DocumentReadyState { "loading", "interactive", "complete" };
// https://w3c.github.io/page-visibility/#visibilitystate-enum
enum VisibilityState { "hidden", "visible" };
typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement;
// https://dom.spec.whatwg.org/#interface-document
// https://html.spec.whatwg.org/C/#documents
[
Exposed=Window
] interface Document : Node {
[CallWith=Document] constructor();
[SameObject] readonly attribute DOMImplementation implementation;
[ImplementedAs=urlForBinding] readonly attribute USVString URL;
// FIXME: documentURI should not be nullable.
[ImplementedAs=urlForBinding] readonly attribute USVString? documentURI;
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;
[Affects=Nothing] HTMLCollection getElementsByTagName(DOMString localName);
[Affects=Nothing] HTMLCollection getElementsByTagNameNS(DOMString? namespaceURI, DOMString localName);
[Affects=Nothing] HTMLCollection getElementsByClassName(DOMString classNames);
[NewObject, PerWorldBindings, RaisesException, ImplementedAs=CreateElementForBinding] Element createElement(DOMString localName);
[NewObject, 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, CEReactions, RaisesException] Node importNode(Node node, optional boolean deep = false);
// TODO(https://crbug.com/399124619): Merge all importnode variants, once Scoped Custom Element Registries
// are shipped unflagged
[NewObject, CEReactions, RaisesException, RuntimeEnabled=ScopedCustomElementRegistry] Node importNode(Node node, ImportNodeOptions options);
[RaisesException, CEReactions] 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);
// 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;
// HTML
// https://html.spec.whatwg.org/C/#the-document-object
// https://github.com/whatwg/html/pull/9538
[CallWith=ExecutionContext,RaisesException,MeasureAs=ParseHTMLUnsafe] static Document parseHTMLUnsafe(HTMLString html);
// https://wicg.github.io/sanitizer-api/#sanitizer-api
// TODO(356601280): Merge the two setHTMLUnsafe variants into one, once the
// different RuntimeEnabled flags are both perma-enabled.
[RuntimeEnabled=SanitizerAPI,RaisesException,CallWith=ExecutionContext,MeasureAs=ParseHTMLUnsafe,CEReactions] static Document parseHTMLUnsafe(HTMLString html, SetHTMLUnsafeOptions options);
[RuntimeEnabled=SanitizerAPI,RaisesException,CallWith=ExecutionContext,MeasureAs=ParseHTMLSafe,CEReactions] static Document parseHTML(DOMString html, optional SetHTMLOptions options = {});
// resource metadata management
[PutForwards=href, LegacyUnforgeable] readonly attribute Location? location;
[RaisesException=Setter] attribute USVString domain;
readonly attribute USVString 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 local_window_proxy.cc.
// getter object (DOMString name);
[CEReactions] attribute DOMString title;
[CEReactions] attribute DOMString dir;
[CEReactions, RaisesException=Setter, 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;
[Affects=Nothing, PerWorldBindings] NodeList getElementsByName(DOMString elementName);
[ImplementedAs=currentScriptForBinding] readonly attribute HTMLOrSVGScriptElement? currentScript;
// dynamic markup insertion
[CallWith=Isolate, CEReactions, RaisesException, MeasureAs=DocumentOpenTwoArgs] Document open(optional DOMString type = "text/html", optional DOMString replace = "");
[CallWith=Isolate, RaisesException, MeasureAs=DocumentOpenThreeArgs] Window open(USVString url, DOMString name, DOMString features);
[CEReactions, RaisesException] void close();
[CallWith=Isolate, CEReactions, RaisesException] void write(DOMString... text);
[CallWith=Isolate, CEReactions, RaisesException] void writeln(DOMString... text);
// TrustedTypes variants of the above.
[CallWith=Isolate, CEReactions, RaisesException] void write(TrustedHTML text);
[CallWith=Isolate, CEReactions, RaisesException] void writeln(TrustedHTML text);
// TODO(330516530): Merge all write/writeln variants, once TrustedTypesHTML
// is perma-enabled.
[CallWith=Isolate, CEReactions, RaisesException, RuntimeEnabled=TrustedTypesHTML] undefined write(TrustedHTML text1, (TrustedHTML or DOMString)... text);
[CallWith=Isolate, CEReactions, RaisesException, RuntimeEnabled=TrustedTypesHTML] undefined writeln(TrustedHTML text1, (TrustedHTML or DOMString)... text);
// user interaction
readonly attribute Window? defaultView;
[Affects=Nothing] boolean hasFocus();
[CEReactions, MeasureAs=DocumentDesignMode] attribute DOMString designMode;
// Only the execCommand("insertHTML",..) sub-command needs to be Trusted
// Types checked. Other sub-commands will string-ify its input. This, we
// pass in a type union instead of using a [StringContext=] annotation.
[CEReactions, RaisesException] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional (DOMString or TrustedHTML) 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);
[LegacyLenientThis] attribute EventHandler onreadystatechange;
// HTML obsolete features
// https://html.spec.whatwg.org/C/#Document-partial
[Measure] readonly attribute HTMLCollection anchors;
[Measure] readonly attribute HTMLCollection applets;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString fgColor;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString linkColor;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString vlinkColor;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString alinkColor;
[CEReactions] attribute [LegacyNullToEmptyString] DOMString bgColor;
[MeasureAs=DocumentClear] void clear();
[MeasureAs=DocumentCaptureEvents] void captureEvents();
[MeasureAs=DocumentReleaseEvents] void releaseEvents();
[SameObject, MeasureAs=DocumentAll] readonly attribute HTMLAllCollection all;
readonly attribute Element? scrollingElement;
// Pointer Lock
// https://w3c.github.io/pointerlock/#extensions-to-the-document-interface
attribute EventHandler onpointerlockchange;
attribute EventHandler onpointerlockerror;
[MeasureAs=DocumentExitPointerLock] void exitPointerLock();
// Custom Elements
// https://w3c.github.io/webcomponents/spec/custom/#extensions-to-document-interface-to-register
// https://w3c.github.io/webcomponents/spec/custom/#extensions-to-document-interface-to-instantiate
[PerWorldBindings, RaisesException, ImplementedAs=CreateElementForBinding] Element createElement(DOMString localName, (DOMString or ElementCreationOptions) options);
[RaisesException] Element createElementNS(DOMString? namespaceURI, DOMString qualifiedName, (DOMString or ElementCreationOptions) options);
// Page Visibility
// https://w3c.github.io/page-visibility/#extensions-to-the-document-interface
readonly attribute boolean hidden;
readonly attribute VisibilityState visibilityState;
readonly attribute boolean wasDiscarded;
// https://wicg.github.io/nav-speculation/prerendering.html#dom-document-prerendering
[Measure] readonly attribute boolean prerendering;
// Non-exposed API, used to evaluate and test soft navigation heuristics
[RuntimeEnabled=SoftNavigationHeuristics] readonly attribute unsigned long softNavigations;
// Non-standard APIs
[MeasureAs=DocumentCaretRangeFromPoint] Range caretRangeFromPoint(optional long x = 0, optional long y = 0);
// https://www.w3.org/TR/cssom-view/#dom-document-caretpositionfrompoint
[NewObject, MeasureAs=CaretPositionFromPoint, RuntimeEnabled=CaretPositionFromPoint] CaretPosition? caretPositionFromPoint(float x, float y, optional CaretPositionFromPointOptions options = {});
// Text fragment directive API
// https://wicg.github.io/scroll-to-text-fragment/#feature-detectability
[SameObject, Measure, RuntimeEnabled=TextFragmentIdentifiers] readonly attribute FragmentDirective fragmentDirective;
// https://w3c.github.io/webappsec-feature-policy/#the-policy-object
readonly attribute FeaturePolicy featurePolicy;
// 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 https://crbug.com/43394 will resolve this.
[MeasureAs=PrefixedPageVisibility, ImplementedAs=visibilityStateAsString] readonly attribute DOMString webkitVisibilityState;
[MeasureAs=PrefixedPageVisibility, ImplementedAs=hidden] readonly attribute boolean webkitHidden;
// Private Token API (https://github.com/wicg/trust-token-api)
[CallWith=ScriptState, Measure, RaisesException, NewObject, SecureContext, RuntimeEnabled=PrivateStateTokens] Promise<boolean> hasPrivateToken(USVString issuer);
[CallWith=ScriptState, Measure, RaisesException, NewObject, SecureContext, RuntimeEnabled=PrivateStateTokens] Promise<boolean> hasRedemptionRecord(USVString issuer);
// ARIA Notify API
// https://github.com/WICG/aom/blob/gh-pages/notification-api.md
[RuntimeEnabled=AriaNotify,MeasureAs=AriaNotify] void ariaNotify(DOMString announcement, optional AriaNotificationOptions options = {});
// The (experimental) DOM Parts API.
[RuntimeEnabled=DOMPartsAPI] DocumentPartRoot getPartRoot();
// Event handler attributes
attribute EventHandler onbeforecopy;
attribute EventHandler onbeforecut;
attribute EventHandler onbeforepaste;
attribute EventHandler onfreeze;
[Measure] attribute EventHandler onprerenderingchange;
attribute EventHandler onresume;
attribute EventHandler onsearch;
attribute EventHandler onvisibilitychange;
// Proposed setter for focus navigation starting point
// https://github.com/whatwg/html/issues/5326
[RuntimeEnabled=SetSequentialFocusStartingPoint, ImplementedAs=SetSequentialFocusNavigationStartingPoint] void setSequentialFocusStartingPoint(Element element);
};
Document includes GlobalEventHandlers;
Document includes DocumentAndElementEventHandlers;
Document includes ParentNode;
Document includes NonElementParentNode;
Document includes DocumentOrShadowRoot;
Document includes FontFaceSource;
|