1/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2/* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. 5 * 6 * https://dom.spec.whatwg.org/#interface-document 7 * https://html.spec.whatwg.org/multipage/dom.html#the-document-object 8 * https://html.spec.whatwg.org/multipage/obsolete.html#other-elements%2C-attributes-and-apis 9 * https://fullscreen.spec.whatwg.org/#api 10 * https://w3c.github.io/pointerlock/#extensions-to-the-document-interface 11 * https://w3c.github.io/pointerlock/#extensions-to-the-documentorshadowroot-mixin 12 * https://w3c.github.io/page-visibility/#extensions-to-the-document-interface 13 * https://drafts.csswg.org/cssom/#extensions-to-the-document-interface 14 * https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface 15 */ 16 17/*TODO 18interface WindowProxy; 19interface nsISupports; 20interface URI; 21interface nsIDocShell; 22interface nsILoadGroup; 23*/ 24 25enum VisibilityState { "hidden", "visible" }; 26 27/* https://dom.spec.whatwg.org/#dictdef-elementcreationoptions */ 28dictionary ElementCreationOptions { 29 DOMString is; 30 31 [ChromeOnly] 32 DOMString pseudo; 33}; 34 35/* https://dom.spec.whatwg.org/#interface-document */ 36[Constructor] 37interface Document : Node { 38 [Throws] 39 readonly attribute DOMImplementation implementation; 40 [Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType] 41 readonly attribute DOMString URL; 42 [Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType] 43 readonly attribute DOMString documentURI; 44 [Pure] 45 readonly attribute DOMString compatMode; 46 [Pure] 47 readonly attribute DOMString characterSet; 48 [Pure,BinaryName="characterSet"] 49 readonly attribute DOMString charset; // legacy alias of .characterSet 50 [Pure,BinaryName="characterSet"] 51 readonly attribute DOMString inputEncoding; // legacy alias of .characterSet 52 [Pure] 53 readonly attribute DOMString contentType; 54 55 [Pure] 56 readonly attribute DocumentType? doctype; 57 [Pure] 58 readonly attribute Element? documentElement; 59 60 [Pure] 61 HTMLCollection getElementsByTagName(DOMString localName); 62 [Pure, Throws] 63 HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); 64 [Pure] 65 HTMLCollection getElementsByClassName(DOMString classNames); 66 [Pure] 67 Element? getElementById(DOMString elementId); 68 69 [CEReactions, NewObject, Throws] 70 Element createElement(DOMString localName, optional (ElementCreationOptions or DOMString) options); 71 [CEReactions, NewObject, Throws] 72 Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional (ElementCreationOptions or DOMString) options); 73 [NewObject] 74 DocumentFragment createDocumentFragment(); 75 [NewObject] 76 Text createTextNode(DOMString data); 77 [NewObject] 78 Comment createComment(DOMString data); 79 [NewObject, Throws] 80 ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data); 81 82 [CEReactions, Throws] 83 Node importNode(Node node, optional boolean deep = false); 84 [CEReactions, Throws] 85 Node adoptNode(Node node); 86 87 [NewObject, Throws, NeedsCallerType] 88 Event createEvent(DOMString interface); 89 90 [NewObject, Throws] 91 Range createRange(); 92 93 // NodeFilter.SHOW_ALL = 0xFFFFFFFF 94 [NewObject, Throws] 95 NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); 96 [NewObject, Throws] 97 TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); 98 99 // NEW 100 // No support for prepend/append yet 101 // void prepend((Node or DOMString)... nodes); 102 // void append((Node or DOMString)... nodes); 103 104 // These are not in the spec, but leave them for now for backwards compat. 105 // So sort of like Gecko extensions 106 [NewObject, Throws] 107 CDATASection createCDATASection(DOMString data); 108 [NewObject, Throws] 109 Attr createAttribute(DOMString name); 110 [NewObject, Throws] 111 Attr createAttributeNS(DOMString? namespace, DOMString name); 112}; 113 114// https://html.spec.whatwg.org/multipage/dom.html#the-document-object 115partial interface Document { 116 [PutForwards=href, Unforgeable] readonly attribute Location? location; 117 //(HTML only) attribute DOMString domain; 118 readonly attribute DOMString referrer; 119 //(HTML only) attribute DOMString cookie; 120 readonly attribute DOMString lastModified; 121 readonly attribute DOMString readyState; 122 123 // DOM tree accessors 124 //(Not proxy yet)getter object (DOMString name); 125 [CEReactions, SetterThrows, Pure] 126 attribute DOMString title; 127 [CEReactions, Pure] 128 attribute DOMString dir; 129 [CEReactions, Pure, SetterThrows] 130 attribute HTMLElement? body; 131 [Pure] 132 readonly attribute HTMLHeadElement? head; 133 [SameObject] readonly attribute HTMLCollection images; 134 [SameObject] readonly attribute HTMLCollection embeds; 135 [SameObject] readonly attribute HTMLCollection plugins; 136 [SameObject] readonly attribute HTMLCollection links; 137 [SameObject] readonly attribute HTMLCollection forms; 138 [SameObject] readonly attribute HTMLCollection scripts; 139 [Pure] 140 NodeList getElementsByName(DOMString elementName); 141 142 //(Not implemented)readonly attribute DOMElementMap cssElementMap; 143 144 // dynamic markup insertion 145 //(HTML only)Document open(optional DOMString type, optional DOMString replace); 146 //(HTML only)WindowProxy open(DOMString url, DOMString name, DOMString features, optional boolean replace); 147 //(HTML only)void close(); 148 //(HTML only)void write(DOMString... text); 149 //(HTML only)void writeln(DOMString... text); 150 151 // user interaction 152 [Pure] 153 readonly attribute WindowProxy? defaultView; 154 [Throws] 155 boolean hasFocus(); 156 //(HTML only) attribute DOMString designMode; 157 //(HTML only)boolean execCommand(DOMString commandId); 158 //(HTML only)boolean execCommand(DOMString commandId, boolean showUI); 159 //(HTML only)boolean execCommand(DOMString commandId, boolean showUI, DOMString value); 160 //(HTML only)boolean queryCommandEnabled(DOMString commandId); 161 //(HTML only)boolean queryCommandIndeterm(DOMString commandId); 162 //(HTML only)boolean queryCommandState(DOMString commandId); 163 //(HTML only)boolean queryCommandSupported(DOMString commandId); 164 //(HTML only)DOMString queryCommandValue(DOMString commandId); 165 //(Not implemented)readonly attribute HTMLCollection commands; 166 167 // special event handler IDL attributes that only apply to Document objects 168 [LenientThis] attribute EventHandler onreadystatechange; 169 170 // Gecko extensions? 171 attribute EventHandler onbeforescriptexecute; 172 attribute EventHandler onafterscriptexecute; 173 174 [Pref="dom.select_events.enabled"] 175 attribute EventHandler onselectionchange; 176 177 /** 178 * Returns the script element whose script is currently being processed. 179 * 180 * @see <https://developer.mozilla.org/en/DOM/document.currentScript> 181 */ 182 [Pure] 183 readonly attribute Element? currentScript; 184 /** 185 * Release the current mouse capture if it is on an element within this 186 * document. 187 * 188 * @see <https://developer.mozilla.org/en/DOM/document.releaseCapture> 189 */ 190 void releaseCapture(); 191 192 [ChromeOnly] 193 readonly attribute URI? documentURIObject; 194 195 /** 196 * Current referrer policy - one of the REFERRER_POLICY_* constants 197 * from nsIHttpChannel. 198 */ 199 [ChromeOnly] 200 readonly attribute unsigned long referrerPolicy; 201 202}; 203 204// https://html.spec.whatwg.org/multipage/obsolete.html#other-elements%2C-attributes-and-apis 205partial interface Document { 206 //(HTML only)[CEReactions] attribute [TreatNullAs=EmptyString] DOMString fgColor; 207 //(HTML only)[CEReactions] attribute [TreatNullAs=EmptyString] DOMString linkColor; 208 //(HTML only)[CEReactions] attribute [TreatNullAs=EmptyString] DOMString vlinkColor; 209 //(HTML only)[CEReactions] attribute [TreatNullAs=EmptyString] DOMString alinkColor; 210 //(HTML only)[CEReactions] attribute [TreatNullAs=EmptyString] DOMString bgColor; 211 212 [SameObject] readonly attribute HTMLCollection anchors; 213 [SameObject] readonly attribute HTMLCollection applets; 214 215 //(HTML only)void clear(); 216 //(HTML only)void captureEvents(); 217 //(HTML only)void releaseEvents(); 218 219 //(HTML only)[SameObject] readonly attribute HTMLAllCollection all; 220}; 221 222// https://fullscreen.spec.whatwg.org/#api 223partial interface Document { 224 // Note: Per spec the 'S' in these two is lowercase, but the "Moz" 225 // versions have it uppercase. 226 [LenientSetter, Unscopable, Func="nsDocument::IsUnprefixedFullscreenEnabled"] 227 readonly attribute boolean fullscreen; 228 [LenientSetter, Func="nsDocument::IsUnprefixedFullscreenEnabled", NeedsCallerType] 229 readonly attribute boolean fullscreenEnabled; 230 231 [Func="nsDocument::IsUnprefixedFullscreenEnabled"] 232 void exitFullscreen(); 233 234 // Events handlers 235 [Func="nsDocument::IsUnprefixedFullscreenEnabled"] 236 attribute EventHandler onfullscreenchange; 237 [Func="nsDocument::IsUnprefixedFullscreenEnabled"] 238 attribute EventHandler onfullscreenerror; 239}; 240 241// https://w3c.github.io/pointerlock/#extensions-to-the-document-interface 242// https://w3c.github.io/pointerlock/#extensions-to-the-documentorshadowroot-mixin 243partial interface Document { 244 void exitPointerLock(); 245 246 // Event handlers 247 attribute EventHandler onpointerlockchange; 248 attribute EventHandler onpointerlockerror; 249}; 250 251// https://w3c.github.io/page-visibility/#extensions-to-the-document-interface 252partial interface Document { 253 readonly attribute boolean hidden; 254 readonly attribute VisibilityState visibilityState; 255 attribute EventHandler onvisibilitychange; 256}; 257 258// https://drafts.csswg.org/cssom/#extensions-to-the-document-interface 259partial interface Document { 260 attribute DOMString? selectedStyleSheetSet; 261 readonly attribute DOMString? lastStyleSheetSet; 262 readonly attribute DOMString? preferredStyleSheetSet; 263 [Constant] 264 readonly attribute DOMStringList styleSheetSets; 265 void enableStyleSheetsForSet (DOMString? name); 266}; 267 268// https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface 269partial interface Document { 270 CaretPosition? caretPositionFromPoint (float x, float y); 271 272 readonly attribute Element? scrollingElement; 273}; 274 275// http://dev.w3.org/2006/webapi/selectors-api2/#interface-definitions 276partial interface Document { 277 [Throws, Pure] 278 Element? querySelector(DOMString selectors); 279 [Throws, Pure] 280 NodeList querySelectorAll(DOMString selectors); 281 282 //(Not implemented)Element? find(DOMString selectors, optional (Element or sequence<Node>)? refNodes); 283 //(Not implemented)NodeList findAll(DOMString selectors, optional (Element or sequence<Node>)? refNodes); 284}; 285 286// https://drafts.csswg.org/web-animations/#extensions-to-the-document-interface 287partial interface Document { 288 [Func="nsDocument::IsWebAnimationsEnabled"] 289 readonly attribute DocumentTimeline timeline; 290 [Func="nsDocument::IsWebAnimationsEnabled"] 291 sequence<Animation> getAnimations(); 292}; 293 294// https://svgwg.org/svg2-draft/struct.html#InterfaceDocumentExtensions 295partial interface Document { 296 [BinaryName="SVGRootElement"] 297 readonly attribute SVGSVGElement? rootElement; 298}; 299 300dictionary BlockParsingOptions { 301 /** 302 * If true, blocks script-created parsers (created via document.open()) in 303 * addition to network-created parsers. 304 */ 305 boolean blockScriptCreated = true; 306}; 307 308// Extension to give chrome JS the ability to determine when a document was 309// created to satisfy an iframe with srcdoc attribute. 310partial interface Document { 311 [ChromeOnly] readonly attribute boolean isSrcdocDocument; 312}; 313 314 315// Extension to give chrome JS the ability to get the underlying 316// sandbox flag attribute 317partial interface Document { 318 [ChromeOnly] readonly attribute DOMString? sandboxFlagsAsString; 319}; 320 321 322/** 323 * Chrome document anonymous content management. 324 * This is a Chrome-only API that allows inserting fixed positioned anonymous 325 * content on top of the current page displayed in the document. 326 * The supplied content is cloned and inserted into the document's CanvasFrame. 327 * Note that this only works for HTML documents. 328 */ 329partial interface Document { 330 /** 331 * Deep-clones the provided element and inserts it into the CanvasFrame. 332 * Returns an AnonymousContent instance that can be used to manipulate the 333 * inserted element. 334 */ 335 [ChromeOnly, NewObject, Throws] 336 AnonymousContent insertAnonymousContent(Element aElement); 337 338 /** 339 * Removes the element inserted into the CanvasFrame given an AnonymousContent 340 * instance. 341 */ 342 [ChromeOnly, Throws] 343 void removeAnonymousContent(AnonymousContent aContent); 344}; 345 346// http://w3c.github.io/selection-api/#extensions-to-document-interface 347partial interface Document { 348 [Throws] 349 Selection? getSelection(); 350}; 351 352// Extension to give chrome JS the ability to determine whether 353// the user has interacted with the document or not. 354partial interface Document { 355 [ChromeOnly] readonly attribute boolean userHasInteracted; 356}; 357 358// Extension to give chrome JS the ability to simulate activate the docuement 359// by user gesture. 360partial interface Document { 361 [ChromeOnly] 362 void notifyUserGestureActivation(); 363}; 364 365// For more information on Flash classification, see 366// toolkit/components/url-classifier/flash-block-lists.rst 367enum FlashClassification { 368 "unclassified", // Denotes a classification that has not yet been computed. 369 // Allows for lazy classification. 370 "unknown", // Site is not on the whitelist or blacklist 371 "allowed", // Site is on the Flash whitelist 372 "denied" // Site is on the Flash blacklist 373}; 374partial interface Document { 375 [ChromeOnly] 376 readonly attribute FlashClassification documentFlashClassification; 377}; 378 379Document includes XPathEvaluator; 380Document includes GlobalEventHandlers; 381Document includes DocumentAndElementEventHandlers; 382Document includes TouchEventHandlers; 383Document includes ParentNode; 384Document includes OnErrorEventHandlerForNodes; 385Document includes GeometryUtils; 386Document includes FontFaceSource; 387Document includes DocumentOrShadowRoot; 388