From ba26802d6974cda8ffa239af1ff89cbc8ad08cae Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 29 Jul 2022 09:34:27 +0200 Subject: [PATCH] wasmjob: added webidl --- demo/wasienv/dom/job_web.pas | 112 +- demo/wasienv/dom/job_web.webidl | 7433 +++++++++++++++++++++++++++++++ 2 files changed, 7538 insertions(+), 7 deletions(-) create mode 100644 demo/wasienv/dom/job_web.webidl diff --git a/demo/wasienv/dom/job_web.pas b/demo/wasienv/dom/job_web.pas index 0276f87..d0ff15c 100644 --- a/demo/wasienv/dom/job_web.pas +++ b/demo/wasienv/dom/job_web.pas @@ -599,10 +599,12 @@ Type TJSShareData --------------------------------------------------------------------} + TJSFileDynArray = IJSArray; // array of TJSFile TJSShareDataRec = record title: UnicodeString; text: UnicodeString; url: UnicodeString; + files: TJSFileDynArray; end; { -------------------------------------------------------------------- @@ -2561,7 +2563,7 @@ Type TJSRangeDynArray = IJSArray; // array of TJSRange IJSSelection = interface(IJSObject) - ['{522D4098-FC2A-35AF-A806-57B88516481A}'] + ['{A4886FB0-977D-3F5E-AEF5-E54883662A9A}'] function _GetanchorNode: IJSNode; function _GetanchorOffset: LongWord; function _GetfocusNode: IJSNode; @@ -2592,6 +2594,7 @@ Type procedure deleteFromDocument; function containsNode(aNode: IJSNode; allowPartialContainment: Boolean): Boolean; overload; function containsNode(aNode: IJSNode): Boolean; overload; + function toString: UnicodeString; procedure modify(const alter: UnicodeString; const aDirection: UnicodeString; const aGranularity: UnicodeString); function toStringWithFormat(const aFormatType: UnicodeString; aFlags: LongWord; aWrapColumn: Integer): UnicodeString; procedure addSelectionListener(aNewListener: IJSnsISelectionListener); @@ -2645,6 +2648,7 @@ Type procedure deleteFromDocument; function containsNode(aNode: IJSNode; allowPartialContainment: Boolean): Boolean; overload; function containsNode(aNode: IJSNode): Boolean; overload; + function toString: UnicodeString; procedure modify(const alter: UnicodeString; const aDirection: UnicodeString; const aGranularity: UnicodeString); function toStringWithFormat(const aFormatType: UnicodeString; aFlags: LongWord; aWrapColumn: Integer): UnicodeString; procedure addSelectionListener(aNewListener: IJSnsISelectionListener); @@ -4469,12 +4473,15 @@ Type --------------------------------------------------------------------} IJSNode = interface(IJSEventTarget) - ['{14C2BA88-3B6E-38A7-B7BB-309263ADD6A5}'] + ['{D147ACB2-D5F2-3E4B-B173-FE9078740E75}'] function _GetnodeType: Word; function _GetnodeName: UnicodeString; function _GetbaseURI: UnicodeString; function _GetisConnected: Boolean; + function _GetownerDocument: IJSDocument; function _GetparentNode: IJSNode; + function _GetparentElement: IJSElement; + function _GetchildNodes: IJSNodeList; function _GetfirstChild: IJSNode; function _GetlastChild: IJSNode; function _GetpreviousSibling: IJSNode; @@ -4504,7 +4511,10 @@ Type property nodeName: UnicodeString read _GetnodeName; property baseURI: UnicodeString read _GetbaseURI; property isConnected: Boolean read _GetisConnected; + property ownerDocument: IJSDocument read _GetownerDocument; property parentNode: IJSNode read _GetparentNode; + property parentElement: IJSElement read _GetparentElement; + property childNodes: IJSNodeList read _GetchildNodes; property firstChild: IJSNode read _GetfirstChild; property lastChild: IJSNode read _GetlastChild; property previousSibling: IJSNode read _GetpreviousSibling; @@ -4519,7 +4529,10 @@ Type function _GetnodeName: UnicodeString; function _GetbaseURI: UnicodeString; function _GetisConnected: Boolean; + function _GetownerDocument: IJSDocument; function _GetparentNode: IJSNode; + function _GetparentElement: IJSElement; + function _GetchildNodes: IJSNodeList; function _GetfirstChild: IJSNode; function _GetlastChild: IJSNode; function _GetpreviousSibling: IJSNode; @@ -4571,7 +4584,10 @@ Type property nodeName: UnicodeString read _GetnodeName; property baseURI: UnicodeString read _GetbaseURI; property isConnected: Boolean read _GetisConnected; + property ownerDocument: IJSDocument read _GetownerDocument; property parentNode: IJSNode read _GetparentNode; + property parentElement: IJSElement read _GetparentElement; + property childNodes: IJSNodeList read _GetchildNodes; property firstChild: IJSNode read _GetfirstChild; property lastChild: IJSNode read _GetlastChild; property previousSibling: IJSNode read _GetpreviousSibling; @@ -5955,7 +5971,7 @@ Type --------------------------------------------------------------------} IJSDocument = interface(IJSNode) - ['{A1B6B3EF-9623-307D-B3D8-CB586BF44C96}'] + ['{83571DA0-6FFE-34FA-83C8-C58C8170FB3C}'] function _Getimplementation_: IJSDOMImplementation; function _GetURL: UnicodeString; function _GetdocumentURI: UnicodeString; @@ -6076,6 +6092,7 @@ Type function importNode(aNode: IJSNode): IJSNode; overload; function adoptNode(aNode: IJSNode): IJSNode; function createEvent(const aInterface_: UnicodeString): IJSEvent; + function createRange: IJSRange; function createCDATASection(const aData: UnicodeString): IJSCDATASection; function createAttribute(const aName: UnicodeString): IJSAttr; function createAttributeNS(const aNamespace: UnicodeString; const aName: UnicodeString): IJSAttr; @@ -6450,6 +6467,7 @@ Type function importNode(aNode: IJSNode): IJSNode; overload; function adoptNode(aNode: IJSNode): IJSNode; function createEvent(const aInterface_: UnicodeString): IJSEvent; + function createRange: IJSRange; function createCDATASection(const aData: UnicodeString): IJSCDATASection; function createAttribute(const aName: UnicodeString): IJSAttr; function createAttributeNS(const aNamespace: UnicodeString; const aName: UnicodeString): IJSAttr; @@ -6742,7 +6760,7 @@ Type --------------------------------------------------------------------} IJSElement = interface(IJSNode) - ['{509EC8E5-B2F0-3FDB-8B1E-ED96E018A43D}'] + ['{72733125-1779-3283-A7CC-978597375199}'] function _GetnamespaceURI: UnicodeString; function _Getprefix: UnicodeString; function _GetlocalName: UnicodeString; @@ -6771,6 +6789,8 @@ Type function _GetscrollLeftMax: Integer; function _GetinnerHTML: UnicodeString; function _GetouterHTML: UnicodeString; + function _GetshadowRoot: IJSShadowRoot; + function _GetopenOrClosedShadowRoot: IJSShadowRoot; function _Getslot: UnicodeString; function _GethasVisibleScrollbars: Boolean; function _GetclientHeightDouble: Double; @@ -6823,6 +6843,9 @@ Type function removeAttributeNode(aOldAttr: IJSAttr): IJSAttr; function getAttributeNodeNS(const aNamespaceURI: UnicodeString; const aLocalName: UnicodeString): IJSAttr; function setAttributeNodeNS(aNewAttr: IJSAttr): IJSAttr; + function getTransformToAncestor(ancestor: IJSElement): IJSDOMMatrixReadOnly; + function getTransformToParent: IJSDOMMatrixReadOnly; + function getTransformToViewport: IJSDOMMatrixReadOnly; function getClientRects: IJSDOMRectList; function getBoundingClientRect: IJSDOMRect; procedure scrollIntoView(arg: Boolean); overload; @@ -6841,6 +6864,7 @@ Type procedure insertAdjacentHTML(const aPosition: UnicodeString; const aText: UnicodeString); function querySelector(const aSelectors: UTF8String): IJSElement; function querySelectorAll(const aSelectors: UTF8String): IJSNodeList; + function attachShadow(const aShadowRootInitDict: TJSShadowRootInit): IJSShadowRoot; procedure requestPointerLock; function hasGridFragments: Boolean; function getElementsWithGrid: TJSElementDynArray; @@ -6891,6 +6915,8 @@ Type property scrollLeftMax: Integer read _GetscrollLeftMax; property innerHTML: UnicodeString read _GetinnerHTML write _SetinnerHTML; property outerHTML: UnicodeString read _GetouterHTML write _SetouterHTML; + property shadowRoot: IJSShadowRoot read _GetshadowRoot; + property openOrClosedShadowRoot: IJSShadowRoot read _GetopenOrClosedShadowRoot; property slot: UnicodeString read _Getslot write _Setslot; // property onfullscreenchange: TEventHandler read _Getonfullscreenchange write _Setonfullscreenchange; // property onfullscreenerror: TEventHandler read _Getonfullscreenerror write _Setonfullscreenerror; @@ -6936,6 +6962,8 @@ Type function _GetscrollLeftMax: Integer; function _GetinnerHTML: UnicodeString; function _GetouterHTML: UnicodeString; + function _GetshadowRoot: IJSShadowRoot; + function _GetopenOrClosedShadowRoot: IJSShadowRoot; function _Getslot: UnicodeString; function _GethasVisibleScrollbars: Boolean; function _GetclientHeightDouble: Double; @@ -6989,6 +7017,9 @@ Type function removeAttributeNode(aOldAttr: IJSAttr): IJSAttr; function getAttributeNodeNS(const aNamespaceURI: UnicodeString; const aLocalName: UnicodeString): IJSAttr; function setAttributeNodeNS(aNewAttr: IJSAttr): IJSAttr; + function getTransformToAncestor(ancestor: IJSElement): IJSDOMMatrixReadOnly; + function getTransformToParent: IJSDOMMatrixReadOnly; + function getTransformToViewport: IJSDOMMatrixReadOnly; function getClientRects: IJSDOMRectList; function getBoundingClientRect: IJSDOMRect; procedure scrollIntoView(arg: Boolean); overload; @@ -7007,6 +7038,7 @@ Type procedure insertAdjacentHTML(const aPosition: UnicodeString; const aText: UnicodeString); function querySelector(const aSelectors: UTF8String): IJSElement; function querySelectorAll(const aSelectors: UTF8String): IJSNodeList; + function attachShadow(const aShadowRootInitDict: TJSShadowRootInit): IJSShadowRoot; procedure requestPointerLock; function hasGridFragments: Boolean; function getElementsWithGrid: TJSElementDynArray; @@ -7058,6 +7090,8 @@ Type property scrollLeftMax: Integer read _GetscrollLeftMax; property innerHTML: UnicodeString read _GetinnerHTML write _SetinnerHTML; property outerHTML: UnicodeString read _GetouterHTML write _SetouterHTML; + property shadowRoot: IJSShadowRoot read _GetshadowRoot; + property openOrClosedShadowRoot: IJSShadowRoot read _GetopenOrClosedShadowRoot; property slot: UnicodeString read _Getslot write _Setslot; // property onfullscreenchange: TEventHandler read _Getonfullscreenchange write _Setonfullscreenchange; // property onfullscreenerror: TEventHandler read _Getonfullscreenerror write _Setonfullscreenerror; @@ -9854,7 +9888,11 @@ var column: LongWord; error: TJOB_JSValue; begin - event:=H.GetValue; source:=H.GetString; lineno:=H.GetMaxInt; column:=H.GetMaxInt; error:=H.GetValue; + event:=H.GetValue; + source:=H.GetString; + lineno:=H.GetMaxInt; + column:=H.GetMaxInt; + error:=H.GetValue; Result:=H.AllocJSValue(TOnErrorEventHandlerNonNull(aMethod)(event,source,lineno,column,error)); end; @@ -9889,7 +9927,8 @@ var oldDocument: IJSDocument; newDocment: IJSDocument; begin - oldDocument:=H.GetObject(TJSDocument) as IJSDocument; newDocment:=H.GetObject(TJSDocument) as IJSDocument; + oldDocument:=H.GetObject(TJSDocument) as IJSDocument; + newDocment:=H.GetObject(TJSDocument) as IJSDocument; TLifecycleAdoptedCallback(aMethod)(oldDocument,newDocment); Result:=H.AllocUndefined; end; @@ -9901,7 +9940,10 @@ var newValue: UnicodeString; namespaceURI: UnicodeString; begin - attrName:=H.GetString; oldValue:=H.GetString; newValue:=H.GetString; namespaceURI:=H.GetString; + attrName:=H.GetString; + oldValue:=H.GetString; + newValue:=H.GetString; + namespaceURI:=H.GetString; TLifecycleAttributeChangedCallback(aMethod)(attrName,oldValue,newValue,namespaceURI); Result:=H.AllocUndefined; end; @@ -11622,6 +11664,11 @@ begin Result:=InvokeJSBooleanResult('containsNode',[aNode]); end; +function TJSSelection.toString: UnicodeString; +begin + Result:=InvokeJSUnicodeStringResult('toString',[]); +end; + procedure TJSSelection.modify(const alter: UnicodeString; const aDirection: UnicodeString; const aGranularity: UnicodeString); begin InvokeJSNoResult('modify',[alter,aDirection,aGranularity]); @@ -13622,11 +13669,26 @@ begin Result:=ReadJSPropertyBoolean('isConnected'); end; +function TJSNode._GetownerDocument: IJSDocument; +begin + Result:=ReadJSPropertyObject('ownerDocument',TJSDocument) as IJSDocument; +end; + function TJSNode._GetparentNode: IJSNode; begin Result:=ReadJSPropertyObject('parentNode',TJSNode) as IJSNode; end; +function TJSNode._GetparentElement: IJSElement; +begin + Result:=ReadJSPropertyObject('parentElement',TJSElement) as IJSElement; +end; + +function TJSNode._GetchildNodes: IJSNodeList; +begin + Result:=ReadJSPropertyObject('childNodes',TJSNodeList) as IJSNodeList; +end; + function TJSNode._GetfirstChild: IJSNode; begin Result:=ReadJSPropertyObject('firstChild',TJSNode) as IJSNode; @@ -16087,6 +16149,11 @@ begin Result:=InvokeJSObjectResult('createEvent',[aInterface_],TJSEvent) as IJSEvent; end; +function TJSDocument.createRange: IJSRange; +begin + Result:=InvokeJSObjectResult('createRange',[],TJSRange) as IJSRange; +end; + function TJSDocument.createCDATASection(const aData: UnicodeString): IJSCDATASection; begin Result:=InvokeJSObjectResult('createCDATASection',[aData],TJSCDATASection) as IJSCDATASection; @@ -16574,6 +16641,16 @@ begin Result:=ReadJSPropertyUnicodeString('outerHTML'); end; +function TJSElement._GetshadowRoot: IJSShadowRoot; +begin + Result:=ReadJSPropertyObject('shadowRoot',TJSShadowRoot) as IJSShadowRoot; +end; + +function TJSElement._GetopenOrClosedShadowRoot: IJSShadowRoot; +begin + Result:=ReadJSPropertyObject('openOrClosedShadowRoot',TJSShadowRoot) as IJSShadowRoot; +end; + function TJSElement._Getslot: UnicodeString; begin Result:=ReadJSPropertyUnicodeString('slot'); @@ -16834,6 +16911,21 @@ begin Result:=InvokeJSObjectResult('setAttributeNodeNS',[aNewAttr],TJSAttr) as IJSAttr; end; +function TJSElement.getTransformToAncestor(ancestor: IJSElement): IJSDOMMatrixReadOnly; +begin + Result:=InvokeJSObjectResult('getTransformToAncestor',[ancestor],TJSDOMMatrixReadOnly) as IJSDOMMatrixReadOnly; +end; + +function TJSElement.getTransformToParent: IJSDOMMatrixReadOnly; +begin + Result:=InvokeJSObjectResult('getTransformToParent',[],TJSDOMMatrixReadOnly) as IJSDOMMatrixReadOnly; +end; + +function TJSElement.getTransformToViewport: IJSDOMMatrixReadOnly; +begin + Result:=InvokeJSObjectResult('getTransformToViewport',[],TJSDOMMatrixReadOnly) as IJSDOMMatrixReadOnly; +end; + function TJSElement.getClientRects: IJSDOMRectList; begin Result:=InvokeJSObjectResult('getClientRects',[],TJSDOMRectList) as IJSDOMRectList; @@ -16924,6 +17016,11 @@ begin Result:=InvokeJSObjectResult('querySelectorAll',[aSelectors],TJSNodeList) as IJSNodeList; end; +function TJSElement.attachShadow(const aShadowRootInitDict: TJSShadowRootInit): IJSShadowRoot; +begin + Result:=InvokeJSObjectResult('attachShadow',[aShadowRootInitDict],TJSShadowRoot) as IJSShadowRoot; +end; + procedure TJSElement.requestPointerLock; begin InvokeJSNoResult('requestPointerLock',[]); @@ -20503,3 +20600,4 @@ finalization JSDocument.Free; JSWindow.Free; end. + diff --git a/demo/wasienv/dom/job_web.webidl b/demo/wasienv/dom/job_web.webidl new file mode 100644 index 0000000..cea3c2a --- /dev/null +++ b/demo/wasienv/dom/job_web.webidl @@ -0,0 +1,7433 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/2012/WD-dom-20120105/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + + +dictionary EventListenerOptions { + boolean capture = false; + /* Setting to true make the listener be added to the system group. */ + [Func="ThreadSafeIsChromeOrUAWidget"] + boolean mozSystemGroup = false; +}; + +dictionary AddEventListenerOptions : EventListenerOptions { + boolean passive; + boolean once = false; +// Mattias: AbortSignal signal; + [ChromeOnly] + boolean wantUntrusted; +}; + +[Exposed=(Window,Worker,WorkerDebugger,AudioWorklet)] +interface EventTarget { + [Throws] + constructor(); + + /* Passing null for wantsUntrusted means "default behavior", which + differs in content and chrome. In content that default boolean + value is true, while in chrome the default boolean value is + false. */ + [Throws] + void addEventListener(DOMString type, + EventListener? listener, + optional (AddEventListenerOptions or boolean) options = {}, + optional boolean? wantsUntrusted = null); + [Throws] + void removeEventListener(DOMString type, + EventListener? listener, + optional (EventListenerOptions or boolean) options = {}); + [Throws, NeedsCallerType] + boolean dispatchEvent(Event event); +}; + +// Mozilla extensions for use by JS-implemented event targets to +// implement on* properties. +partial interface EventTarget { + // The use of [TreatNonCallableAsNull] here is a bit of a hack: it just makes + // the codegen check whether the type involved is either + // [TreatNonCallableAsNull] or [TreatNonObjectAsNull] and if it is handle it + // accordingly. In particular, it will NOT actually treat a non-null + // non-callable object as null here. + [ChromeOnly, Throws] + void setEventHandler(DOMString type, + [TreatNonCallableAsNull] EventHandler handler); + +// Mattias: [ChromeOnly] +// EventHandler getEventHandler(DOMString type); +}; + +// Mozilla extension to make firing events on event targets from +// chrome easier. This returns the window which can be used to create +// events to fire at this EventTarget, or null if there isn't one. +partial interface EventTarget { +// Mattias: [ChromeOnly, Exposed=Window, BinaryName="ownerGlobalForBindings"] +// readonly attribute WindowProxy? ownerGlobal; +}; +interface Node : EventTarget { + const unsigned short ELEMENT_NODE = 1; + const unsigned short ATTRIBUTE_NODE = 2; + const unsigned short TEXT_NODE = 3; + const unsigned short CDATA_SECTION_NODE = 4; + const unsigned short ENTITY_REFERENCE_NODE = 5; // legacy + const unsigned short ENTITY_NODE = 6; // legacy + const unsigned short PROCESSING_INSTRUCTION_NODE = 7; + const unsigned short COMMENT_NODE = 8; + const unsigned short DOCUMENT_NODE = 9; + const unsigned short DOCUMENT_TYPE_NODE = 10; + const unsigned short DOCUMENT_FRAGMENT_NODE = 11; + const unsigned short NOTATION_NODE = 12; // legacy + readonly attribute unsigned short nodeType; + readonly attribute DOMString nodeName; + + readonly attribute USVString baseURI; + + readonly attribute boolean isConnected; + readonly attribute Document? ownerDocument; + Node getRootNode(optional GetRootNodeOptions options = {}); + readonly attribute Node? parentNode; + readonly attribute Element? parentElement; + boolean hasChildNodes(); + [SameObject] readonly attribute NodeList childNodes; + readonly attribute Node? firstChild; + readonly attribute Node? lastChild; + readonly attribute Node? previousSibling; + readonly attribute Node? nextSibling; + + [CEReactions] attribute DOMString? nodeValue; + [CEReactions] attribute DOMString? textContent; + [CEReactions] undefined normalize(); + + [CEReactions, NewObject] Node cloneNode(optional boolean deep = false); + boolean isEqualNode(Node? otherNode); + boolean isSameNode(Node? otherNode); // legacy alias of === + + const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; + const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; + const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04; + const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08; + const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10; + const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; + unsigned short compareDocumentPosition(Node other); + boolean contains(Node? other); + + DOMString? lookupPrefix(DOMString? namespace); + DOMString? lookupNamespaceURI(DOMString? prefix); + boolean isDefaultNamespace(DOMString? namespace); + + [CEReactions] Node insertBefore(Node node, Node? child); + [CEReactions] Node appendChild(Node node); + [CEReactions] Node replaceChild(Node node, Node child); + [CEReactions] Node removeChild(Node child); +}; + +dictionary GetRootNodeOptions { + boolean composed = false; +}; + +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.w3.org/TR/2012/WD-dom-20120105/ + * + * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C + * liability, trademark and document use rules apply. + */ + +[Exposed=Window] +// Mattias: +//callback interface EventListener { +// void handleEvent(Event event); +//}; +callback EventListener = boolean (Event event); + +interface Event { +// Mattias: constructor(DOMString type, optional EventInit eventInitDict = {}); + + readonly attribute DOMString type; + readonly attribute EventTarget? target; + readonly attribute EventTarget? srcElement; // legacy + readonly attribute EventTarget? currentTarget; + sequence composedPath(); + + const unsigned short NONE = 0; + const unsigned short CAPTURING_PHASE = 1; + const unsigned short AT_TARGET = 2; + const unsigned short BUBBLING_PHASE = 3; + readonly attribute unsigned short eventPhase; + + undefined stopPropagation(); + attribute boolean cancelBubble; // legacy alias of .stopPropagation() + undefined stopImmediatePropagation(); + + readonly attribute boolean bubbles; + readonly attribute boolean cancelable; + attribute boolean returnValue; // legacy + undefined preventDefault(); + readonly attribute boolean defaultPrevented; + readonly attribute boolean composed; + +// Mattias: [LegacyUnforgeable] readonly attribute boolean isTrusted; +// readonly attribute DOMHighResTimeStamp timeStamp; + + undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // legacy +}; + + +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * The origin of this IDL file is + * http://www.whatwg.org/specs/web-apps/current-work/#eventhandler + * + * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and + * Opera Software ASA. You are granted a license to use, reproduce + * and create derivative works of this document. + */ +[LegacyTreatNonObjectAsNull] +callback EventHandlerNonNull = any (Event event); +typedef EventHandlerNonNull? EventHandler; + +[LegacyTreatNonObjectAsNull] +callback OnBeforeUnloadEventHandlerNonNull = DOMString? (Event event); +typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnloadEventHandler; + +[LegacyTreatNonObjectAsNull] +callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long column, optional any error); +typedef OnErrorEventHandlerNonNull? OnErrorEventHandler; + +interface mixin GlobalEventHandlers { + attribute EventHandler onabort; + attribute EventHandler onblur; +// We think the spec is wrong here. See OnErrorEventHandlerForNodes/Window +// below. +// attribute OnErrorEventHandler onerror; + attribute EventHandler onfocus; + //(Not implemented)attribute EventHandler oncancel; + attribute EventHandler onauxclick; + [Pref="dom.input_events.beforeinput.enabled"] + attribute EventHandler onbeforeinput; + attribute EventHandler oncanplay; + attribute EventHandler oncanplaythrough; + attribute EventHandler onchange; + attribute EventHandler onclick; + attribute EventHandler onclose; + attribute EventHandler oncontextmenu; + attribute EventHandler oncuechange; + attribute EventHandler ondblclick; + attribute EventHandler ondrag; + attribute EventHandler ondragend; + attribute EventHandler ondragenter; + [Func="Event::IsDragExitEnabled"] + attribute EventHandler ondragexit; + attribute EventHandler ondragleave; + attribute EventHandler ondragover; + attribute EventHandler ondragstart; + attribute EventHandler ondrop; + attribute EventHandler ondurationchange; + attribute EventHandler onemptied; + attribute EventHandler onended; + attribute EventHandler onformdata; + attribute EventHandler oninput; + attribute EventHandler oninvalid; + attribute EventHandler onkeydown; + attribute EventHandler onkeypress; + attribute EventHandler onkeyup; + attribute EventHandler onload; + attribute EventHandler onloadeddata; + attribute EventHandler onloadedmetadata; + attribute EventHandler onloadend; + attribute EventHandler onloadstart; + attribute EventHandler onmousedown; + [LegacyLenientThis] attribute EventHandler onmouseenter; + [LegacyLenientThis] attribute EventHandler onmouseleave; + attribute EventHandler onmousemove; + attribute EventHandler onmouseout; + attribute EventHandler onmouseover; + attribute EventHandler onmouseup; + attribute EventHandler onwheel; + attribute EventHandler onpause; + attribute EventHandler onplay; + attribute EventHandler onplaying; + attribute EventHandler onprogress; + attribute EventHandler onratechange; + attribute EventHandler onreset; + attribute EventHandler onresize; + attribute EventHandler onscroll; + attribute EventHandler onsecuritypolicyviolation; + attribute EventHandler onseeked; + attribute EventHandler onseeking; + attribute EventHandler onselect; + attribute EventHandler onslotchange; + //(Not implemented)attribute EventHandler onsort; + attribute EventHandler onstalled; + attribute EventHandler onsubmit; + attribute EventHandler onsuspend; + attribute EventHandler ontimeupdate; + attribute EventHandler onvolumechange; + attribute EventHandler onwaiting; + + attribute EventHandler onselectstart; + attribute EventHandler onselectionchange; + + attribute EventHandler ontoggle; + + // Pointer events handlers + attribute EventHandler onpointercancel; + attribute EventHandler onpointerdown; + attribute EventHandler onpointerup; + attribute EventHandler onpointermove; + attribute EventHandler onpointerout; + attribute EventHandler onpointerover; + attribute EventHandler onpointerenter; + attribute EventHandler onpointerleave; + attribute EventHandler ongotpointercapture; + attribute EventHandler onlostpointercapture; + + // Mozilla-specific handlers. Unprefixed handlers live in + // Document rather than here. + [Deprecated="MozfullscreenchangeDeprecatedPrefix"] + attribute EventHandler onmozfullscreenchange; + [Deprecated="MozfullscreenerrorDeprecatedPrefix"] + attribute EventHandler onmozfullscreenerror; + + // CSS-Animation and CSS-Transition handlers. + attribute EventHandler onanimationcancel; + attribute EventHandler onanimationend; + attribute EventHandler onanimationiteration; + attribute EventHandler onanimationstart; + attribute EventHandler ontransitioncancel; + attribute EventHandler ontransitionend; + attribute EventHandler ontransitionrun; + attribute EventHandler ontransitionstart; + + // CSS-Animation and CSS-Transition legacy handlers. + // This handler isn't standard. + [BinaryName="onwebkitAnimationEnd"] + attribute EventHandler onwebkitanimationend; + [BinaryName="onwebkitAnimationIteration"] + attribute EventHandler onwebkitanimationiteration; + [BinaryName="onwebkitAnimationStart"] + attribute EventHandler onwebkitanimationstart; + [BinaryName="onwebkitTransitionEnd"] + attribute EventHandler onwebkittransitionend; +}; + +interface mixin WindowEventHandlers { + attribute EventHandler onafterprint; + attribute EventHandler onbeforeprint; + attribute OnBeforeUnloadEventHandler onbeforeunload; + attribute EventHandler onhashchange; + attribute EventHandler onlanguagechange; + attribute EventHandler onmessage; + attribute EventHandler onmessageerror; + attribute EventHandler onoffline; + attribute EventHandler ononline; + attribute EventHandler onpagehide; + attribute EventHandler onpageshow; + attribute EventHandler onpopstate; + attribute EventHandler onrejectionhandled; + attribute EventHandler onstorage; + attribute EventHandler onunhandledrejection; + attribute EventHandler onunload; +}; + +// https://w3c.github.io/gamepad/#extensions-to-the-windoweventhandlers-interface-mixin +partial interface mixin WindowEventHandlers { + attribute EventHandler ongamepadconnected; + attribute EventHandler ongamepaddisconnected; +}; + +interface mixin DocumentAndElementEventHandlers { + attribute EventHandler oncopy; + attribute EventHandler oncut; + attribute EventHandler onpaste; +}; + +// The spec has |attribute OnErrorEventHandler onerror;| on +// GlobalEventHandlers, and calls the handler differently depending on +// whether an ErrorEvent was fired. We don't do that, and until we do we'll +// need to distinguish between onerror on Window or on nodes. + +interface mixin OnErrorEventHandlerForNodes { + attribute EventHandler onerror; +}; + +interface mixin OnErrorEventHandlerForWindow { + attribute OnErrorEventHandler onerror; +}; +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * https://dom.spec.whatwg.org/#interface-document + * https://html.spec.whatwg.org/multipage/dom.html#the-document-object + * https://html.spec.whatwg.org/multipage/obsolete.html#other-elements%2C-attributes-and-apis + * https://fullscreen.spec.whatwg.org/#api + * https://w3c.github.io/pointerlock/#extensions-to-the-document-interface + * https://w3c.github.io/pointerlock/#extensions-to-the-documentorshadowroot-mixin + * https://w3c.github.io/page-visibility/#extensions-to-the-document-interface + * https://drafts.csswg.org/cssom/#extensions-to-the-document-interface + * https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface + * https://wicg.github.io/feature-policy/#policy + */ + +interface ContentSecurityPolicy; +interface Principal; +interface WindowProxy; +interface nsISupports; +interface URI; +interface nsIDocShell; +interface nsILoadGroup; +interface nsIReferrerInfo; +interface nsICookieJarSettings; +interface nsIPermissionDelegateHandler; +interface XULCommandDispatcher; + +enum VisibilityState { "hidden", "visible" }; + +/* https://dom.spec.whatwg.org/#dictdef-elementcreationoptions */ +dictionary ElementCreationOptions { + DOMString is; + + [ChromeOnly] + DOMString pseudo; +}; + +/* https://dom.spec.whatwg.org/#interface-document */ +[Exposed=Window] +interface Document : Node { + [Throws] + constructor(); + + [Throws] + readonly attribute DOMImplementation implementation; + [Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType] + readonly attribute DOMString URL; + [Pure, Throws, BinaryName="documentURIFromJS", NeedsCallerType] + readonly attribute DOMString documentURI; + [Pure] + readonly attribute DOMString compatMode; + [Pure] + readonly attribute DOMString characterSet; + [Pure,BinaryName="characterSet"] + readonly attribute DOMString charset; // legacy alias of .characterSet + [Pure,BinaryName="characterSet"] + readonly attribute DOMString inputEncoding; // legacy alias of .characterSet + [Pure] + readonly attribute DOMString contentType; + + [Pure] + readonly attribute DocumentType? doctype; + [Pure] + readonly attribute Element? documentElement; + [Pure] + HTMLCollection getElementsByTagName(DOMString localName); + [Pure, Throws] + HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); + [Pure] + HTMLCollection getElementsByClassName(DOMString classNames); + [Pure] + Element? getElementById(DOMString elementId); + + // These DOM methods cannot be accessed by UA Widget scripts + // because the DOM element reflectors will be in the content scope, + // instead of the desired UA Widget scope. + [CEReactions, NewObject, Throws, Func="IsNotUAWidget"] + Element createElement(DOMString localName, optional (ElementCreationOptions or DOMString) options = {}); + [CEReactions, NewObject, Throws, Func="IsNotUAWidget"] + Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional (ElementCreationOptions or DOMString) options = {}); + [NewObject] + DocumentFragment createDocumentFragment(); + [NewObject, Func="IsNotUAWidget"] + Text createTextNode(DOMString data); + [NewObject, Func="IsNotUAWidget"] + Comment createComment(DOMString data); +// Mattias: [NewObject, Throws] +// ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data); + + [CEReactions, Throws, Func="IsNotUAWidget"] + Node importNode(Node node, optional boolean deep = false); + [CEReactions, Throws, Func="IsNotUAWidget"] + Node adoptNode(Node node); + + [NewObject, Throws, NeedsCallerType] + Event createEvent(DOMString interface); + + [NewObject, Throws] + Range createRange(); + + // NodeFilter.SHOW_ALL = 0xFFFFFFFF +// Mattias: [NewObject, Throws] +// NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); +// Mattias: [NewObject, Throws] +// TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow = 0xFFFFFFFF, optional NodeFilter? filter = null); + + // NEW + // No support for prepend/append yet + // void prepend((Node or DOMString)... nodes); + // void append((Node or DOMString)... nodes); + + // These are not in the spec, but leave them for now for backwards compat. + // So sort of like Gecko extensions + [NewObject, Throws] + CDATASection createCDATASection(DOMString data); + [NewObject, Throws] + Attr createAttribute(DOMString name); + [NewObject, Throws] + Attr createAttributeNS(DOMString? namespace, DOMString name); +}; + +// https://html.spec.whatwg.org/multipage/dom.html#the-document-object +partial interface Document { + [PutForwards=href, LegacyUnforgeable] readonly attribute Location? location; + [SetterThrows] attribute DOMString domain; + readonly attribute DOMString referrer; + [Throws] attribute DOMString cookie; + readonly attribute DOMString lastModified; + readonly attribute DOMString readyState; + + // DOM tree accessors + //(Not proxy yet)getter object (DOMString name); + [CEReactions, SetterThrows, Pure] + attribute DOMString title; + [CEReactions, Pure] + attribute DOMString dir; + [CEReactions, Pure, SetterThrows] + attribute HTMLElement? body; + [Pure] + readonly attribute HTMLHeadElement? head; + [SameObject] readonly attribute HTMLCollection images; + [SameObject] readonly attribute HTMLCollection embeds; + [SameObject] readonly attribute HTMLCollection plugins; + [SameObject] readonly attribute HTMLCollection links; + [SameObject] readonly attribute HTMLCollection forms; + [SameObject] readonly attribute HTMLCollection scripts; + [Pure] + NodeList getElementsByName(DOMString elementName); + //(Not implemented)readonly attribute DOMElementMap cssElementMap; + + // dynamic markup insertion + [CEReactions, Throws] + Document open(optional DOMString unused1, optional DOMString unused2); // both arguments are ignored + [CEReactions, Throws] + WindowProxy? open(USVString url, DOMString name, DOMString features); + [CEReactions, Throws] + void close(); + [CEReactions, Throws] + void write(DOMString... text); + [CEReactions, Throws] + void writeln(DOMString... text); + + // user interaction + [Pure] + readonly attribute WindowProxy? defaultView; + [Throws] + boolean hasFocus(); + [CEReactions, SetterThrows, SetterNeedsSubjectPrincipal] + attribute DOMString designMode; + [CEReactions, Throws, NeedsSubjectPrincipal] + boolean execCommand(DOMString commandId, optional boolean showUI = false, + optional DOMString value = ""); + [Throws, NeedsSubjectPrincipal] + boolean queryCommandEnabled(DOMString commandId); + [Throws] + boolean queryCommandIndeterm(DOMString commandId); + [Throws] + boolean queryCommandState(DOMString commandId); + [Throws, NeedsCallerType] + boolean queryCommandSupported(DOMString commandId); + [Throws] + DOMString queryCommandValue(DOMString commandId); + //(Not implemented)readonly attribute HTMLCollection commands; + + // special event handler IDL attributes that only apply to Document objects + [LegacyLenientThis] attribute EventHandler onreadystatechange; + + // Gecko extensions? + attribute EventHandler onbeforescriptexecute; + attribute EventHandler onafterscriptexecute; + + /** + * True if this document is synthetic : stand alone image, video, audio file, + * etc. + */ + [Func="IsChromeOrUAWidget"] readonly attribute boolean mozSyntheticDocument; + /** + * Returns the script element whose script is currently being processed. + * + * @see + */ + [Pure] + readonly attribute Element? currentScript; + /** + * Release the current mouse capture if it is on an element within this + * document. + * + * @see + */ + [Deprecated=DocumentReleaseCapture, Pref="dom.mouse_capture.enabled"] + void releaseCapture(); + /** + * Use the given DOM element as the source image of target |-moz-element()|. + * + * This function introduces a new special ID (called "image element ID"), + * which is only used by |-moz-element()|, and associates it with the given + * DOM element. Image elements ID's have the higher precedence than general + * HTML id's, so if |document.mozSetImageElement(, )| is called, + * |-moz-element(#)| uses || as the source image even if there + * is another element with id attribute = ||. To unregister an image + * element ID ||, call |document.mozSetImageElement(, null)|. + * + * Example: + * + *
+ * + * @param aImageElementId an image element ID to associate with + * |aImageElement| + * @param aImageElement a DOM element to be used as the source image of + * |-moz-element(#aImageElementId)|. If this is null, the function will + * unregister the image element ID |aImageElementId|. + * + * @see + */ + [UseCounter] + void mozSetImageElement(DOMString aImageElementId, + Element? aImageElement); + + [ChromeOnly] + readonly attribute URI? documentURIObject; + + /** + * Current referrer policy - one of the referrer policy value from + * ReferrerPolicy.webidl. + */ + [ChromeOnly] + readonly attribute ReferrerPolicy referrerPolicy; + + /** + * Current referrer info, which holds all referrer related information + * including referrer policy and raw referrer of document. + */ + [ChromeOnly] + readonly attribute nsIReferrerInfo referrerInfo; + +}; + +// https://html.spec.whatwg.org/multipage/obsolete.html#other-elements%2C-attributes-and-apis +partial interface Document { + [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; + + [SameObject] readonly attribute HTMLCollection anchors; + [SameObject] readonly attribute HTMLCollection applets; + + void clear(); + // @deprecated These are old Netscape 4 methods. Do not use, + // the implementation is no-op. + // XXXbz do we actually need these anymore? + void captureEvents(); + void releaseEvents(); + + [SameObject] readonly attribute HTMLAllCollection all; +}; + +// https://fullscreen.spec.whatwg.org/#api +partial interface Document { + // Note: Per spec the 'S' in these two is lowercase, but the "Moz" + // versions have it uppercase. + [LegacyLenientSetter, Unscopable] + readonly attribute boolean fullscreen; + [BinaryName="fullscreen"] + readonly attribute boolean mozFullScreen; + [LegacyLenientSetter, NeedsCallerType] + readonly attribute boolean fullscreenEnabled; + [BinaryName="fullscreenEnabled", NeedsCallerType] + readonly attribute boolean mozFullScreenEnabled; + +// Mattias: [NewObject] +// Promise exitFullscreen(); +// Mattias: [NewObject, BinaryName="exitFullscreen"] +// Promise mozCancelFullScreen(); + + // Events handlers + attribute EventHandler onfullscreenchange; + attribute EventHandler onfullscreenerror; +}; + +// https://w3c.github.io/pointerlock/#extensions-to-the-document-interface +// https://w3c.github.io/pointerlock/#extensions-to-the-documentorshadowroot-mixin +partial interface Document { + void exitPointerLock(); + + // Event handlers + attribute EventHandler onpointerlockchange; + attribute EventHandler onpointerlockerror; +}; + +// Mozilla-internal document extensions specific to error pages. +partial interface Document { +// Mattias: [Func="Document::CallerIsTrustedAboutCertError", NewObject] +// Promise addCertException(boolean isTemporary); + + [Func="Document::CallerIsTrustedAboutHttpsOnlyError"] + void reloadWithHttpsOnlyException(); + +// Mattias: [Func="Document::CallerIsTrustedAboutCertError", Throws] +// FailedCertSecurityInfo getFailedCertSecurityInfo(); + +// Mattias: [Func="Document::CallerIsTrustedAboutNetError", Throws] +// NetErrorInfo getNetErrorInfo(); + + [Func="Document::CallerIsTrustedAboutNetError"] + attribute boolean allowDeprecatedTls; +}; + +// https://w3c.github.io/page-visibility/#extensions-to-the-document-interface +partial interface Document { + readonly attribute boolean hidden; + readonly attribute VisibilityState visibilityState; + attribute EventHandler onvisibilitychange; +}; + +// https://drafts.csswg.org/cssom/#extensions-to-the-document-interface +partial interface Document { + attribute DOMString? selectedStyleSheetSet; + readonly attribute DOMString? lastStyleSheetSet; + readonly attribute DOMString? preferredStyleSheetSet; + [Constant] + readonly attribute DOMStringList styleSheetSets; + void enableStyleSheetsForSet (DOMString? name); +}; + +// https://drafts.csswg.org/cssom-view/#extensions-to-the-document-interface +partial interface Document { + CaretPosition? caretPositionFromPoint (float x, float y); + + readonly attribute Element? scrollingElement; +}; + +// http://dev.w3.org/2006/webapi/selectors-api2/#interface-definitions +partial interface Document { + [Throws, Pure] + Element? querySelector(UTF8String selectors); + [Throws, Pure] + NodeList querySelectorAll(UTF8String selectors); + + //(Not implemented)Element? find(DOMString selectors, optional (Element or sequence)? refNodes); + //(Not implemented)NodeList findAll(DOMString selectors, optional (Element or sequence)? refNodes); +}; + +// https://drafts.csswg.org/web-animations/#extensions-to-the-document-interface +partial interface Document { +// Mattias: [Func="Document::AreWebAnimationsTimelinesEnabled"] +// readonly attribute DocumentTimeline timeline; +}; + +// https://svgwg.org/svg2-draft/struct.html#InterfaceDocumentExtensions +partial interface Document { + [BinaryName="SVGRootElement"] + readonly attribute SVGSVGElement? rootElement; +}; + +// Mozilla extensions of various sorts +partial interface Document { + // Creates a new XUL element regardless of the document's default type. + [ChromeOnly, CEReactions, NewObject, Throws] + Element createXULElement(DOMString localName, optional (ElementCreationOptions or DOMString) options = {}); + // Wether the document was loaded using a nsXULPrototypeDocument. + [ChromeOnly] + readonly attribute boolean loadedFromPrototype; + + // The principal to use for the storage area of this document + [ChromeOnly] + readonly attribute Principal effectiveStoragePrincipal; + + // You should probably not be using this principal getter since it performs + // no checks to ensure that the partitioned principal should really be used + // here. It is only designed to be used in very specific circumstances, such + // as when inheriting the document/storage principal. + [ChromeOnly] + readonly attribute Principal partitionedPrincipal; + + // The cookieJarSettings of this document + [ChromeOnly] + readonly attribute nsICookieJarSettings cookieJarSettings; + + // Touch bits + // XXXbz I can't find the sane spec for this stuff, so just cribbing + // from our xpidl for now. +// Mattiastodo: [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"] + //Touch createTouch(optional Window? view = null, + // optional EventTarget? target = null, + // optional long identifier = 0, + // optional long pageX = 0, + // optional long pageY = 0, + // optional long screenX = 0, + // optional long screenY = 0, + // optional long clientX = 0, + // optional long clientY = 0, + // optional long radiusX = 0, + // optional long radiusY = 0, + // optional float rotationAngle = 0, + // optional float force = 0); + // XXXbz a hack to get around the fact that we don't support variadics as + // distinguishing arguments yet. Once this hack is removed. we can also + // remove the corresponding overload on Document, since Touch... and + // sequence look the same in the C++. +// Mattias: [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"] +// TouchList createTouchList(Touch touch, Touch... touches); + // XXXbz and another hack for the fact that we can't usefully have optional + // distinguishing arguments but need a working zero-arg form of + // createTouchList(). +// Mattias: [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"] +// TouchList createTouchList(); +// Mattias: [NewObject, Func="nsGenericHTMLElement::LegacyTouchAPIEnabled"] +// TouchList createTouchList(sequence touches); + + [ChromeOnly] + attribute boolean styleSheetChangeEventsEnabled; + + [ChromeOnly] + attribute boolean shadowRootAttachedEventEnabled; + + [ChromeOnly] readonly attribute DOMString contentLanguage; + + [ChromeOnly] readonly attribute nsILoadGroup? documentLoadGroup; + + // Blocks the initial document parser until the given promise is settled. +// Mattias: [ChromeOnly, NewObject] +// Promise blockParsing(Promise promise, +// optional BlockParsingOptions options = {}); + + [Func="nsContentUtils::IsPDFJS", BinaryName="blockUnblockOnloadForPDFJS"] + void blockUnblockOnload(boolean block); + + // like documentURI, except that for error pages, it returns the URI we were + // trying to load when we hit an error, rather than the error page's own URI. + [ChromeOnly] readonly attribute URI? mozDocumentURIIfNotForErrorPages; + + // A promise that is resolved when we have both fired DOMContentLoaded and + // are ready to start layout. + // This is used for the "document_idle" webextension script injection point. + [ChromeOnly, Throws] + readonly attribute Promise documentReadyForIdle; + + // Lazily created command dispatcher, returns null if the document is not + // chrome privileged. + [ChromeOnly] + readonly attribute XULCommandDispatcher? commandDispatcher; + + [ChromeOnly] + attribute boolean devToolsWatchingDOMMutations; + + /** + * Returns all the shadow roots connected to the document, in no particular + * order, and without regard to open/closed-ness. Also returns UA widgets + * (like