diff --git a/Example/README.md b/Example/README.md index 88a3238..6fde644 100644 --- a/Example/README.md +++ b/Example/README.md @@ -19,8 +19,9 @@ swiftenv automatically selects the specified version when entering the directory ## Usage -1. Build `webidl2swift` or run it using `swift run`. -2. Generate the WebAPI module by running `webidl2swift -i WebIDL-files -o WebAPI`. -3. Build the website using the Makefile by running `make && make build`. -4. Start a local webserver, e.g. by running `python3 -m http.server`. +1. Generate the latest `dom.webidl` by running `npm install; npm run generate-dom` +2. Build `webidl2swift` or run it using `swift run`. +3. Generate the WebAPI module by running `webidl2swift -i WebIDL-files -o WebAPI`. +4. Build the website using the Makefile by running `make && make build`. +5. Start a local webserver, e.g. by running `python3 -m http.server`. diff --git a/Example/WebIDL-files/dom.webidl b/Example/WebIDL-files/dom.webidl index 0e37763..63ec972 100644 --- a/Example/WebIDL-files/dom.webidl +++ b/Example/WebIDL-files/dom.webidl @@ -4,7 +4,7 @@ interface Event { readonly attribute DOMString type; readonly attribute EventTarget? target; - readonly attribute EventTarget? srcElement; // historical + readonly attribute EventTarget? srcElement; // legacy readonly attribute EventTarget? currentTarget; sequence composedPath(); @@ -15,20 +15,598 @@ interface Event { readonly attribute unsigned short eventPhase; undefined stopPropagation(); - attribute boolean cancelBubble; // historical alias of .stopPropagation + attribute boolean cancelBubble; // legacy alias of .stopPropagation() undefined stopImmediatePropagation(); readonly attribute boolean bubbles; readonly attribute boolean cancelable; - attribute boolean returnValue; // historical + attribute boolean returnValue; // legacy undefined preventDefault(); readonly attribute boolean defaultPrevented; readonly attribute boolean composed; - [Unforgeable] readonly attribute boolean isTrusted; + [LegacyUnforgeable] readonly attribute boolean isTrusted; readonly attribute DOMHighResTimeStamp timeStamp; - undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // historical + undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // legacy +}; + +dictionary EventInit { + boolean bubbles = false; + boolean cancelable = false; + boolean composed = false; +}; +partial interface Window { + [Replaceable] readonly attribute (Event or undefined) event; // legacy +}; +[Exposed=(Window,Worker)] +interface CustomEvent : Event { + constructor(DOMString type, optional CustomEventInit eventInitDict = {}); + + readonly attribute any detail; + + undefined initCustomEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any detail = null); // legacy +}; + +dictionary CustomEventInit : EventInit { + any detail = null; +}; +[Exposed=(Window,Worker,AudioWorklet)] +interface EventTarget { + constructor(); + + undefined addEventListener(DOMString type, EventListener? callback, optional (AddEventListenerOptions or boolean) options = {}); + undefined removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options = {}); + boolean dispatchEvent(Event event); +}; + +callback interface EventListener { + undefined handleEvent(Event event); +}; + +dictionary EventListenerOptions { + boolean capture = false; +}; + +dictionary AddEventListenerOptions : EventListenerOptions { + boolean passive = false; + boolean once = false; + AbortSignal signal; +}; +[Exposed=(Window,Worker)] +interface AbortController { + constructor(); + + [SameObject] readonly attribute AbortSignal signal; + + undefined abort(); +}; +[Exposed=(Window,Worker)] +interface AbortSignal : EventTarget { + readonly attribute boolean aborted; + + attribute EventHandler onabort; +};interface mixin NonElementParentNode { + Element? getElementById(DOMString elementId); +}; +Document includes NonElementParentNode; +DocumentFragment includes NonElementParentNode; +interface mixin DocumentOrShadowRoot { +}; +Document includes DocumentOrShadowRoot; +ShadowRoot includes DocumentOrShadowRoot; +interface mixin ParentNode { + [SameObject] readonly attribute HTMLCollection children; + readonly attribute Element? firstElementChild; + readonly attribute Element? lastElementChild; + readonly attribute unsigned long childElementCount; + + [CEReactions, Unscopable] undefined prepend((Node or DOMString)... nodes); + [CEReactions, Unscopable] undefined append((Node or DOMString)... nodes); + [CEReactions, Unscopable] undefined replaceChildren((Node or DOMString)... nodes); + + Element? querySelector(DOMString selectors); + [NewObject] NodeList querySelectorAll(DOMString selectors); +}; +Document includes ParentNode; +DocumentFragment includes ParentNode; +Element includes ParentNode; +interface mixin NonDocumentTypeChildNode { + readonly attribute Element? previousElementSibling; + readonly attribute Element? nextElementSibling; +}; +Element includes NonDocumentTypeChildNode; +CharacterData includes NonDocumentTypeChildNode; +interface mixin ChildNode { + [CEReactions, Unscopable] undefined before((Node or DOMString)... nodes); + [CEReactions, Unscopable] undefined after((Node or DOMString)... nodes); + [CEReactions, Unscopable] undefined replaceWith((Node or DOMString)... nodes); + [CEReactions, Unscopable] undefined remove(); +}; +DocumentType includes ChildNode; +Element includes ChildNode; +CharacterData includes ChildNode; +interface mixin Slottable { + readonly attribute HTMLSlotElement? assignedSlot; +}; +Element includes Slottable; +Text includes Slottable; +[Exposed=Window] +interface NodeList { + getter Node? item(unsigned long index); + readonly attribute unsigned long length; + iterable; +}; +[Exposed=Window, LegacyUnenumerableNamedProperties] +interface HTMLCollection { + readonly attribute unsigned long length; + getter Element? item(unsigned long index); + getter Element? namedItem(DOMString name); +}; +[Exposed=Window] +interface MutationObserver { + constructor(MutationCallback callback); + + undefined observe(Node target, optional MutationObserverInit options = {}); + undefined disconnect(); + sequence takeRecords(); +}; + +callback MutationCallback = undefined (sequence mutations, MutationObserver observer); + +dictionary MutationObserverInit { + boolean childList = false; + boolean attributes; + boolean characterData; + boolean subtree = false; + boolean attributeOldValue; + boolean characterDataOldValue; + sequence attributeFilter; +}; +[Exposed=Window] +interface MutationRecord { + readonly attribute DOMString type; + [SameObject] readonly attribute Node target; + [SameObject] readonly attribute NodeList addedNodes; + [SameObject] readonly attribute NodeList removedNodes; + readonly attribute Node? previousSibling; + readonly attribute Node? nextSibling; + readonly attribute DOMString? attributeName; + readonly attribute DOMString? attributeNamespace; + readonly attribute DOMString? oldValue; +}; +[Exposed=Window] +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; +}; +[Exposed=Window] +interface Document : Node { + constructor(); + + [SameObject] readonly attribute DOMImplementation implementation; + readonly attribute USVString URL; + readonly attribute USVString documentURI; + readonly attribute DOMString compatMode; + readonly attribute DOMString characterSet; + readonly attribute DOMString charset; // legacy alias of .characterSet + readonly attribute DOMString inputEncoding; // legacy alias of .characterSet + readonly attribute DOMString contentType; + + readonly attribute DocumentType? doctype; + readonly attribute Element? documentElement; + HTMLCollection getElementsByTagName(DOMString qualifiedName); + HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); + HTMLCollection getElementsByClassName(DOMString classNames); + + [CEReactions, NewObject] Element createElement(DOMString localName, optional (DOMString or ElementCreationOptions) options = {}); + [CEReactions, NewObject] Element createElementNS(DOMString? namespace, DOMString qualifiedName, optional (DOMString or ElementCreationOptions) options = {}); + [NewObject] DocumentFragment createDocumentFragment(); + [NewObject] Text createTextNode(DOMString data); + [NewObject] CDATASection createCDATASection(DOMString data); + [NewObject] Comment createComment(DOMString data); + [NewObject] ProcessingInstruction createProcessingInstruction(DOMString target, DOMString data); + + [CEReactions, NewObject] Node importNode(Node node, optional boolean deep = false); + [CEReactions] Node adoptNode(Node node); + + [NewObject] Attr createAttribute(DOMString localName); + [NewObject] Attr createAttributeNS(DOMString? namespace, DOMString qualifiedName); + + [NewObject] Event createEvent(DOMString interface); // legacy + + [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); +}; + +[Exposed=Window] +interface XMLDocument : Document {}; + +dictionary ElementCreationOptions { + DOMString is; +}; +[Exposed=Window] +interface DOMImplementation { + [NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId); + [NewObject] XMLDocument createDocument(DOMString? namespace, [LegacyNullToEmptyString] DOMString qualifiedName, optional DocumentType? doctype = null); + [NewObject] Document createHTMLDocument(optional DOMString title); + + boolean hasFeature(); // useless; always returns true +}; +[Exposed=Window] +interface DocumentType : Node { + readonly attribute DOMString name; + readonly attribute DOMString publicId; + readonly attribute DOMString systemId; +}; +[Exposed=Window] +interface DocumentFragment : Node { + constructor(); +}; +[Exposed=Window] +interface ShadowRoot : DocumentFragment { + readonly attribute ShadowRootMode mode; + readonly attribute Element host; + attribute EventHandler onslotchange; +}; + +enum ShadowRootMode { "open", "closed" }; +[Exposed=Window] +interface Element : Node { + readonly attribute DOMString? namespaceURI; + readonly attribute DOMString? prefix; + readonly attribute DOMString localName; + readonly attribute DOMString tagName; + + [CEReactions] attribute DOMString id; + [CEReactions] attribute DOMString className; + [SameObject, PutForwards=value] readonly attribute DOMTokenList classList; + [CEReactions, Unscopable] attribute DOMString slot; + + boolean hasAttributes(); + [SameObject] readonly attribute NamedNodeMap attributes; + sequence getAttributeNames(); + DOMString? getAttribute(DOMString qualifiedName); + DOMString? getAttributeNS(DOMString? namespace, DOMString localName); + [CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value); + [CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value); + [CEReactions] undefined removeAttribute(DOMString qualifiedName); + [CEReactions] undefined removeAttributeNS(DOMString? namespace, DOMString localName); + [CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force); + boolean hasAttribute(DOMString qualifiedName); + boolean hasAttributeNS(DOMString? namespace, DOMString localName); + + Attr? getAttributeNode(DOMString qualifiedName); + Attr? getAttributeNodeNS(DOMString? namespace, DOMString localName); + [CEReactions] Attr? setAttributeNode(Attr attr); + [CEReactions] Attr? setAttributeNodeNS(Attr attr); + [CEReactions] Attr removeAttributeNode(Attr attr); + + ShadowRoot attachShadow(ShadowRootInit init); + readonly attribute ShadowRoot? shadowRoot; + + Element? closest(DOMString selectors); + boolean matches(DOMString selectors); + boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches + + HTMLCollection getElementsByTagName(DOMString qualifiedName); + HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); + HTMLCollection getElementsByClassName(DOMString classNames); + + [CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy + undefined insertAdjacentText(DOMString where, DOMString data); // legacy +}; + +dictionary ShadowRootInit { + required ShadowRootMode mode; + boolean delegatesFocus = false; +}; +[Exposed=Window, + LegacyUnenumerableNamedProperties] +interface NamedNodeMap { + readonly attribute unsigned long length; + getter Attr? item(unsigned long index); + getter Attr? getNamedItem(DOMString qualifiedName); + Attr? getNamedItemNS(DOMString? namespace, DOMString localName); + [CEReactions] Attr? setNamedItem(Attr attr); + [CEReactions] Attr? setNamedItemNS(Attr attr); + [CEReactions] Attr removeNamedItem(DOMString qualifiedName); + [CEReactions] Attr removeNamedItemNS(DOMString? namespace, DOMString localName); +}; +[Exposed=Window] +interface Attr : Node { + readonly attribute DOMString? namespaceURI; + readonly attribute DOMString? prefix; + readonly attribute DOMString localName; + readonly attribute DOMString name; + [CEReactions] attribute DOMString value; + + readonly attribute Element? ownerElement; + + readonly attribute boolean specified; // useless; always returns true +};[Exposed=Window] +interface CharacterData : Node { + attribute [LegacyNullToEmptyString] DOMString data; + readonly attribute unsigned long length; + DOMString substringData(unsigned long offset, unsigned long count); + undefined appendData(DOMString data); + undefined insertData(unsigned long offset, DOMString data); + undefined deleteData(unsigned long offset, unsigned long count); + undefined replaceData(unsigned long offset, unsigned long count, DOMString data); +}; +[Exposed=Window] +interface Text : CharacterData { + constructor(optional DOMString data = ""); + + [NewObject] Text splitText(unsigned long offset); + readonly attribute DOMString wholeText; +}; +[Exposed=Window] +interface CDATASection : Text { +};[Exposed=Window] +interface ProcessingInstruction : CharacterData { + readonly attribute DOMString target; +};[Exposed=Window] +interface Comment : CharacterData { + constructor(optional DOMString data = ""); +}; +[Exposed=Window] +interface AbstractRange { + readonly attribute Node startContainer; + readonly attribute unsigned long startOffset; + readonly attribute Node endContainer; + readonly attribute unsigned long endOffset; + readonly attribute boolean collapsed; +}; +dictionary StaticRangeInit { + required Node startContainer; + required unsigned long startOffset; + required Node endContainer; + required unsigned long endOffset; +}; + +[Exposed=Window] +interface StaticRange : AbstractRange { + constructor(StaticRangeInit init); +}; +[Exposed=Window] +interface Range : AbstractRange { + constructor(); + + readonly attribute Node commonAncestorContainer; + + undefined setStart(Node node, unsigned long offset); + undefined setEnd(Node node, unsigned long offset); + undefined setStartBefore(Node node); + undefined setStartAfter(Node node); + undefined setEndBefore(Node node); + undefined setEndAfter(Node node); + undefined collapse(optional boolean toStart = false); + undefined selectNode(Node node); + undefined selectNodeContents(Node node); + + const unsigned short START_TO_START = 0; + const unsigned short START_TO_END = 1; + const unsigned short END_TO_END = 2; + const unsigned short END_TO_START = 3; + short compareBoundaryPoints(unsigned short how, Range sourceRange); + + [CEReactions] undefined deleteContents(); + [CEReactions, NewObject] DocumentFragment extractContents(); + [CEReactions, NewObject] DocumentFragment cloneContents(); + [CEReactions] undefined insertNode(Node node); + [CEReactions] undefined surroundContents(Node newParent); + + [NewObject] Range cloneRange(); + undefined detach(); + + boolean isPointInRange(Node node, unsigned long offset); + short comparePoint(Node node, unsigned long offset); + + boolean intersectsNode(Node node); + + stringifier; +}; +[Exposed=Window] +interface NodeIterator { + [SameObject] readonly attribute Node root; + readonly attribute Node referenceNode; + readonly attribute boolean pointerBeforeReferenceNode; + readonly attribute unsigned long whatToShow; + readonly attribute NodeFilter? filter; + + Node? nextNode(); + Node? previousNode(); + + undefined detach(); +}; +[Exposed=Window] +interface TreeWalker { + [SameObject] readonly attribute Node root; + readonly attribute unsigned long whatToShow; + readonly attribute NodeFilter? filter; + attribute Node currentNode; + + Node? parentNode(); + Node? firstChild(); + Node? lastChild(); + Node? previousSibling(); + Node? nextSibling(); + Node? previousNode(); + Node? nextNode(); +};[Exposed=Window] +callback interface NodeFilter { + // Constants for acceptNode() + const unsigned short FILTER_ACCEPT = 1; + const unsigned short FILTER_REJECT = 2; + const unsigned short FILTER_SKIP = 3; + + // Constants for whatToShow + const unsigned long SHOW_ALL = 0xFFFFFFFF; + const unsigned long SHOW_ELEMENT = 0x1; + const unsigned long SHOW_ATTRIBUTE = 0x2; + const unsigned long SHOW_TEXT = 0x4; + const unsigned long SHOW_CDATA_SECTION = 0x8; + const unsigned long SHOW_ENTITY_REFERENCE = 0x10; // legacy + const unsigned long SHOW_ENTITY = 0x20; // legacy + const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x40; + const unsigned long SHOW_COMMENT = 0x80; + const unsigned long SHOW_DOCUMENT = 0x100; + const unsigned long SHOW_DOCUMENT_TYPE = 0x200; + const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x400; + const unsigned long SHOW_NOTATION = 0x800; // legacy + + unsigned short acceptNode(Node node); +}; +[Exposed=Window] +interface DOMTokenList { + readonly attribute unsigned long length; + getter DOMString? item(unsigned long index); + boolean contains(DOMString token); + [CEReactions] undefined add(DOMString... tokens); + [CEReactions] undefined remove(DOMString... tokens); + [CEReactions] boolean toggle(DOMString token, optional boolean force); + [CEReactions] boolean replace(DOMString token, DOMString newToken); + boolean supports(DOMString token); + [CEReactions] stringifier attribute DOMString value; + iterable; +}; +[Exposed=Window] +interface XPathResult { + const unsigned short ANY_TYPE = 0; + const unsigned short NUMBER_TYPE = 1; + const unsigned short STRING_TYPE = 2; + const unsigned short BOOLEAN_TYPE = 3; + const unsigned short UNORDERED_NODE_ITERATOR_TYPE = 4; + const unsigned short ORDERED_NODE_ITERATOR_TYPE = 5; + const unsigned short UNORDERED_NODE_SNAPSHOT_TYPE = 6; + const unsigned short ORDERED_NODE_SNAPSHOT_TYPE = 7; + const unsigned short ANY_UNORDERED_NODE_TYPE = 8; + const unsigned short FIRST_ORDERED_NODE_TYPE = 9; + + readonly attribute unsigned short resultType; + readonly attribute unrestricted double numberValue; + readonly attribute DOMString stringValue; + readonly attribute boolean booleanValue; + readonly attribute Node? singleNodeValue; + readonly attribute boolean invalidIteratorState; + readonly attribute unsigned long snapshotLength; + + Node? iterateNext(); + Node? snapshotItem(unsigned long index); +}; +[Exposed=Window] +interface XPathExpression { + // XPathResult.ANY_TYPE = 0 + XPathResult evaluate(Node contextNode, optional unsigned short type = 0, optional XPathResult? result = null); +}; +callback interface XPathNSResolver { + DOMString? lookupNamespaceURI(DOMString? prefix); +}; + +interface mixin XPathEvaluatorBase { + [NewObject] XPathExpression createExpression(DOMString expression, optional XPathNSResolver? resolver = null); + XPathNSResolver createNSResolver(Node nodeResolver); + // XPathResult.ANY_TYPE = 0 + XPathResult evaluate(DOMString expression, Node contextNode, optional XPathNSResolver? resolver = null, optional unsigned short type = 0, optional XPathResult? result = null); +}; +Document includes XPathEvaluatorBase; +[Exposed=Window] +interface XPathEvaluator { + constructor(); +}; + +XPathEvaluator includes XPathEvaluatorBase; +[Exposed=(Window,Worker,AudioWorklet)] +interface Event { + 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; + + [LegacyUnforgeable] readonly attribute boolean isTrusted; + readonly attribute DOMHighResTimeStamp timeStamp; + + undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // legacy }; dictionary EventInit { @@ -38,7 +616,7 @@ dictionary EventInit { }; partial interface Window { - [Replaceable] readonly attribute any event; // historical + [Replaceable] readonly attribute (Event or undefined) event; // legacy }; [Exposed=(Window,Worker)] @@ -47,7 +625,7 @@ interface CustomEvent : Event { readonly attribute any detail; - undefined initCustomEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any detail = null); // historical + undefined initCustomEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any detail = null); // legacy }; dictionary CustomEventInit : EventInit { @@ -74,6 +652,7 @@ dictionary EventListenerOptions { dictionary AddEventListenerOptions : EventListenerOptions { boolean passive = false; boolean once = false; + AbortSignal signal; }; [Exposed=(Window,Worker)] @@ -110,6 +689,7 @@ interface mixin ParentNode { [CEReactions, Unscopable] undefined prepend((Node or DOMString)... nodes); [CEReactions, Unscopable] undefined append((Node or DOMString)... nodes); + [CEReactions, Unscopable] undefined replaceChildren((Node or DOMString)... nodes); Element? querySelector(DOMString selectors); [NewObject] NodeList querySelectorAll(DOMString selectors); @@ -135,11 +715,11 @@ DocumentType includes ChildNode; Element includes ChildNode; CharacterData includes ChildNode; -interface mixin Slotable { +interface mixin Slottable { readonly attribute HTMLSlotElement? assignedSlot; }; -Element includes Slotable; -Text includes Slotable; +Element includes Slottable; +Text includes Slottable; [Exposed=Window] interface NodeList { @@ -195,14 +775,14 @@ interface Node : EventTarget { 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; // historical - const unsigned short ENTITY_NODE = 6; // historical + 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; // historical + const unsigned short NOTATION_NODE = 12; // legacy readonly attribute unsigned short nodeType; readonly attribute DOMString nodeName; @@ -226,7 +806,7 @@ interface Node : EventTarget { [CEReactions, NewObject] Node cloneNode(optional boolean deep = false); boolean isEqualNode(Node? otherNode); - boolean isSameNode(Node? otherNode); // historical alias of === + boolean isSameNode(Node? otherNode); // legacy alias of === const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; @@ -260,8 +840,8 @@ interface Document : Node { readonly attribute USVString documentURI; readonly attribute DOMString compatMode; readonly attribute DOMString characterSet; - readonly attribute DOMString charset; // historical alias of .characterSet - readonly attribute DOMString inputEncoding; // historical alias of .characterSet + readonly attribute DOMString charset; // legacy alias of .characterSet + readonly attribute DOMString inputEncoding; // legacy alias of .characterSet readonly attribute DOMString contentType; readonly attribute DocumentType? doctype; @@ -284,7 +864,7 @@ interface Document : Node { [NewObject] Attr createAttribute(DOMString localName); [NewObject] Attr createAttributeNS(DOMString? namespace, DOMString qualifiedName); - [NewObject] Event createEvent(DOMString interface); // historical + [NewObject] Event createEvent(DOMString interface); // legacy [NewObject] Range createRange(); @@ -303,7 +883,7 @@ dictionary ElementCreationOptions { [Exposed=Window] interface DOMImplementation { [NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId); - [NewObject] XMLDocument createDocument(DOMString? namespace, [TreatNullAs=EmptyString] DOMString qualifiedName, optional DocumentType? doctype = null); + [NewObject] XMLDocument createDocument(DOMString? namespace, [LegacyNullToEmptyString] DOMString qualifiedName, optional DocumentType? doctype = null); [NewObject] Document createHTMLDocument(optional DOMString title); boolean hasFeature(); // useless; always returns true @@ -366,14 +946,14 @@ interface Element : Node { Element? closest(DOMString selectors); boolean matches(DOMString selectors); - boolean webkitMatchesSelector(DOMString selectors); // historical alias of .matches + boolean webkitMatchesSelector(DOMString selectors); // legacy alias of .matches HTMLCollection getElementsByTagName(DOMString qualifiedName); HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName); HTMLCollection getElementsByClassName(DOMString classNames); - [CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // historical - undefined insertAdjacentText(DOMString where, DOMString data); // historical + [CEReactions] Element? insertAdjacentElement(DOMString where, Element element); // legacy + undefined insertAdjacentText(DOMString where, DOMString data); // legacy }; dictionary ShadowRootInit { @@ -408,7 +988,7 @@ interface Attr : Node { }; [Exposed=Window] interface CharacterData : Node { - attribute [TreatNullAs=EmptyString] DOMString data; + attribute [LegacyNullToEmptyString] DOMString data; readonly attribute unsigned long length; DOMString substringData(unsigned long offset, unsigned long count); undefined appendData(DOMString data); @@ -539,14 +1119,14 @@ callback interface NodeFilter { const unsigned long SHOW_ATTRIBUTE = 0x2; const unsigned long SHOW_TEXT = 0x4; const unsigned long SHOW_CDATA_SECTION = 0x8; - const unsigned long SHOW_ENTITY_REFERENCE = 0x10; // historical - const unsigned long SHOW_ENTITY = 0x20; // historical + const unsigned long SHOW_ENTITY_REFERENCE = 0x10; // legacy + const unsigned long SHOW_ENTITY = 0x20; // legacy const unsigned long SHOW_PROCESSING_INSTRUCTION = 0x40; const unsigned long SHOW_COMMENT = 0x80; const unsigned long SHOW_DOCUMENT = 0x100; const unsigned long SHOW_DOCUMENT_TYPE = 0x200; const unsigned long SHOW_DOCUMENT_FRAGMENT = 0x400; - const unsigned long SHOW_NOTATION = 0x800; // historical + const unsigned long SHOW_NOTATION = 0x800; // legacy unsigned short acceptNode(Node node); }; @@ -614,3 +1194,4 @@ interface XPathEvaluator { }; XPathEvaluator includes XPathEvaluatorBase; + diff --git a/Example/WebIDL-files/html.webidl b/Example/WebIDL-files/html.webidl new file mode 100644 index 0000000..c3ef295 --- /dev/null +++ b/Example/WebIDL-files/html.webidl @@ -0,0 +1,2316 @@ +[Exposed=Window] +interface Example { + // this is an IDL definition +};[Exposed=Window, + LegacyUnenumerableNamedProperties] +interface HTMLAllCollection { + readonly attribute unsigned long length; + getter Element (unsigned long index); + getter (HTMLCollection or Element)? namedItem(DOMString name); + (HTMLCollection or Element)? item(optional DOMString nameOrIndex); + + // Note: HTMLAllCollection objects have a custom [[Call]] internal method and an [[IsHTMLDDA]] internal slot. +};[Exposed=Window] +interface HTMLFormControlsCollection : HTMLCollection { + // inherits length and item() + getter (RadioNodeList or Element)? namedItem(DOMString name); // shadows inherited namedItem() +}; + +[Exposed=Window] +interface RadioNodeList : NodeList { + attribute DOMString value; +};[Exposed=Window] +interface HTMLOptionsCollection : HTMLCollection { + // inherits item(), namedItem() + [CEReactions] attribute unsigned long length; // shadows inherited length + [CEReactions] setter undefined (unsigned long index, HTMLOptionElement? option); + [CEReactions] undefined add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null); + [CEReactions] undefined remove(long index); + attribute long selectedIndex; +};[Exposed=(Window,Worker)] +interface DOMStringList { + readonly attribute unsigned long length; + getter DOMString? item(unsigned long index); + boolean contains(DOMString string); +};enum DocumentReadyState { "loading", "interactive", "complete" }; +typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement; + +[LegacyOverrideBuiltIns] +partial interface Document { + // resource metadata management + [PutForwards=href, LegacyUnforgeable] readonly attribute Location? location; + attribute USVString domain; + readonly attribute USVString referrer; + attribute USVString cookie; + readonly attribute DOMString lastModified; + readonly attribute DocumentReadyState readyState; + + // DOM tree accessors + getter object (DOMString name); + [CEReactions] attribute DOMString title; + [CEReactions] attribute DOMString dir; + [CEReactions] attribute HTMLElement? body; + 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; + NodeList getElementsByName(DOMString elementName); + readonly attribute HTMLOrSVGScriptElement? currentScript; // classic scripts in a document tree only + + // dynamic markup insertion + [CEReactions] Document open(optional DOMString unused1, optional DOMString unused2); // both arguments are ignored + WindowProxy? open(USVString url, DOMString name, DOMString features); + [CEReactions] undefined close(); + [CEReactions] undefined write(DOMString... text); + [CEReactions] undefined writeln(DOMString... text); + + // user interaction + readonly attribute WindowProxy? defaultView; + boolean hasFocus(); + [CEReactions] attribute DOMString designMode; + [CEReactions] boolean execCommand(DOMString commandId, optional boolean showUI = false, optional DOMString value = ""); + boolean queryCommandEnabled(DOMString commandId); + boolean queryCommandIndeterm(DOMString commandId); + boolean queryCommandState(DOMString commandId); + boolean queryCommandSupported(DOMString commandId); + DOMString queryCommandValue(DOMString commandId); + + // special event handler IDL attributes that only apply to Document objects + [LegacyLenientThis] attribute EventHandler onreadystatechange; + + // also has obsolete members +}; +Document includes GlobalEventHandlers; +Document includes DocumentAndElementEventHandlers;partial interface mixin DocumentOrShadowRoot { + readonly attribute Element? activeElement; +};[Exposed=Window] +interface HTMLElement : Element { + [HTMLConstructor] constructor(); + + // metadata attributes + [CEReactions] attribute DOMString title; + [CEReactions] attribute DOMString lang; + [CEReactions] attribute boolean translate; + [CEReactions] attribute DOMString dir; + + // user interaction + [CEReactions] attribute boolean hidden; + undefined click(); + [CEReactions] attribute DOMString accessKey; + readonly attribute DOMString accessKeyLabel; + [CEReactions] attribute boolean draggable; + [CEReactions] attribute boolean spellcheck; + [CEReactions] attribute DOMString autocapitalize; + + [CEReactions] attribute [LegacyNullToEmptyString] DOMString innerText; + + ElementInternals attachInternals(); +}; + +HTMLElement includes GlobalEventHandlers; +HTMLElement includes DocumentAndElementEventHandlers; +HTMLElement includes ElementContentEditable; +HTMLElement includes HTMLOrSVGElement; + +[Exposed=Window] +interface HTMLUnknownElement : HTMLElement { + // Note: intentionally no [HTMLConstructor] +};interface mixin HTMLOrSVGElement { + [SameObject] readonly attribute DOMStringMap dataset; + attribute DOMString nonce; // intentionally no [CEReactions] + + [CEReactions] attribute boolean autofocus; + [CEReactions] attribute long tabIndex; + undefined focus(optional FocusOptions options = {}); + undefined blur(); +};[Exposed=Window, + LegacyOverrideBuiltIns] +interface DOMStringMap { + getter DOMString (DOMString name); + [CEReactions] setter undefined (DOMString name, DOMString value); + [CEReactions] deleter undefined (DOMString name); +};[Exposed=Window] +interface HTMLHtmlElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLHeadElement : HTMLElement { + [HTMLConstructor] constructor(); +};[Exposed=Window] +interface HTMLTitleElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString text; +};[Exposed=Window] +interface HTMLBaseElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute USVString href; + [CEReactions] attribute DOMString target; +};[Exposed=Window] +interface HTMLLinkElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute USVString href; + [CEReactions] attribute DOMString? crossOrigin; + [CEReactions] attribute DOMString rel; + [CEReactions] attribute DOMString as; // (default "") + [SameObject, PutForwards=value] readonly attribute DOMTokenList relList; + [CEReactions] attribute DOMString media; + [CEReactions] attribute DOMString integrity; + [CEReactions] attribute DOMString hreflang; + [CEReactions] attribute DOMString type; + [SameObject, PutForwards=value] readonly attribute DOMTokenList sizes; + [CEReactions] attribute USVString imageSrcset; + [CEReactions] attribute DOMString imageSizes; + [CEReactions] attribute DOMString referrerPolicy; + [CEReactions] attribute boolean disabled; + + // also has obsolete members +}; +HTMLLinkElement includes LinkStyle;[Exposed=Window] +interface HTMLMetaElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString name; + [CEReactions] attribute DOMString httpEquiv; + [CEReactions] attribute DOMString content; + + // also has obsolete members +};[Exposed=Window] +interface HTMLStyleElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString media; + + // also has obsolete members +}; +HTMLStyleElement includes LinkStyle;[Exposed=Window] +interface HTMLBodyElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +}; + +HTMLBodyElement includes WindowEventHandlers;[Exposed=Window] +interface HTMLHeadingElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLParagraphElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLHRElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLPreElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLQuoteElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute USVString cite; +};[Exposed=Window] +interface HTMLOListElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute boolean reversed; + [CEReactions] attribute long start; + [CEReactions] attribute DOMString type; + + // also has obsolete members +};[Exposed=Window] +interface HTMLUListElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLMenuElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLLIElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute long value; + + // also has obsolete members +};[Exposed=Window] +interface HTMLDListElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLDivElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLAnchorElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString target; + [CEReactions] attribute DOMString download; + [CEReactions] attribute USVString ping; + [CEReactions] attribute DOMString rel; + [SameObject, PutForwards=value] readonly attribute DOMTokenList relList; + [CEReactions] attribute DOMString hreflang; + [CEReactions] attribute DOMString type; + + [CEReactions] attribute DOMString text; + + [CEReactions] attribute DOMString referrerPolicy; + + // also has obsolete members +}; +HTMLAnchorElement includes HTMLHyperlinkElementUtils;[Exposed=Window] +interface HTMLDataElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString value; +};[Exposed=Window] +interface HTMLTimeElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString dateTime; +};[Exposed=Window] +interface HTMLSpanElement : HTMLElement { + [HTMLConstructor] constructor(); +};[Exposed=Window] +interface HTMLBRElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +};interface mixin HTMLHyperlinkElementUtils { + [CEReactions] stringifier attribute USVString href; + readonly attribute USVString origin; + [CEReactions] attribute USVString protocol; + [CEReactions] attribute USVString username; + [CEReactions] attribute USVString password; + [CEReactions] attribute USVString host; + [CEReactions] attribute USVString hostname; + [CEReactions] attribute USVString port; + [CEReactions] attribute USVString pathname; + [CEReactions] attribute USVString search; + [CEReactions] attribute USVString hash; +};[Exposed=Window] +interface HTMLModElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute USVString cite; + [CEReactions] attribute DOMString dateTime; +};[Exposed=Window] +interface HTMLPictureElement : HTMLElement { + [HTMLConstructor] constructor(); +};[Exposed=Window] +interface HTMLSourceElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute USVString src; + [CEReactions] attribute DOMString type; + [CEReactions] attribute USVString srcset; + [CEReactions] attribute DOMString sizes; + [CEReactions] attribute DOMString media; +};[Exposed=Window, + LegacyFactoryFunction=Image(optional unsigned long width, optional unsigned long height)] +interface HTMLImageElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString alt; + [CEReactions] attribute USVString src; + [CEReactions] attribute USVString srcset; + [CEReactions] attribute DOMString sizes; + [CEReactions] attribute DOMString? crossOrigin; + [CEReactions] attribute DOMString useMap; + [CEReactions] attribute boolean isMap; + [CEReactions] attribute unsigned long width; + [CEReactions] attribute unsigned long height; + readonly attribute unsigned long naturalWidth; + readonly attribute unsigned long naturalHeight; + readonly attribute boolean complete; + readonly attribute USVString currentSrc; + [CEReactions] attribute DOMString referrerPolicy; + [CEReactions] attribute DOMString decoding; + [CEReactions] attribute DOMString loading; + + Promise decode(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLIFrameElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute USVString src; + [CEReactions] attribute DOMString srcdoc; + [CEReactions] attribute DOMString name; + [SameObject, PutForwards=value] readonly attribute DOMTokenList sandbox; + [CEReactions] attribute DOMString allow; + [CEReactions] attribute boolean allowFullscreen; + [CEReactions] attribute DOMString width; + [CEReactions] attribute DOMString height; + [CEReactions] attribute DOMString referrerPolicy; + [CEReactions] attribute DOMString loading; + readonly attribute Document? contentDocument; + readonly attribute WindowProxy? contentWindow; + Document? getSVGDocument(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLEmbedElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute USVString src; + [CEReactions] attribute DOMString type; + [CEReactions] attribute DOMString width; + [CEReactions] attribute DOMString height; + Document? getSVGDocument(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLObjectElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute USVString data; + [CEReactions] attribute DOMString type; + [CEReactions] attribute DOMString name; + [CEReactions] attribute DOMString useMap; + readonly attribute HTMLFormElement? form; + [CEReactions] attribute DOMString width; + [CEReactions] attribute DOMString height; + readonly attribute Document? contentDocument; + readonly attribute WindowProxy? contentWindow; + Document? getSVGDocument(); + + readonly attribute boolean willValidate; + readonly attribute ValidityState validity; + readonly attribute DOMString validationMessage; + boolean checkValidity(); + boolean reportValidity(); + undefined setCustomValidity(DOMString error); + + // also has obsolete members +};[Exposed=Window] +interface HTMLParamElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString name; + [CEReactions] attribute DOMString value; + + // also has obsolete members +};[Exposed=Window] +interface HTMLVideoElement : HTMLMediaElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute unsigned long width; + [CEReactions] attribute unsigned long height; + readonly attribute unsigned long videoWidth; + readonly attribute unsigned long videoHeight; + [CEReactions] attribute USVString poster; + [CEReactions] attribute boolean playsInline; +};[Exposed=Window, + LegacyFactoryFunction=Audio(optional DOMString src)] +interface HTMLAudioElement : HTMLMediaElement { + [HTMLConstructor] constructor(); +};[Exposed=Window] +interface HTMLTrackElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString kind; + [CEReactions] attribute USVString src; + [CEReactions] attribute DOMString srclang; + [CEReactions] attribute DOMString label; + [CEReactions] attribute boolean default; + + const unsigned short NONE = 0; + const unsigned short LOADING = 1; + const unsigned short LOADED = 2; + const unsigned short ERROR = 3; + readonly attribute unsigned short readyState; + + readonly attribute TextTrack track; +};enum CanPlayTypeResult { "" /* empty string */, "maybe", "probably" }; +typedef (MediaStream or MediaSource or Blob) MediaProvider; + +[Exposed=Window] +interface HTMLMediaElement : HTMLElement { + + // error state + readonly attribute MediaError? error; + + // network state + [CEReactions] attribute USVString src; + attribute MediaProvider? srcObject; + readonly attribute USVString currentSrc; + [CEReactions] attribute DOMString? crossOrigin; + const unsigned short NETWORK_EMPTY = 0; + const unsigned short NETWORK_IDLE = 1; + const unsigned short NETWORK_LOADING = 2; + const unsigned short NETWORK_NO_SOURCE = 3; + readonly attribute unsigned short networkState; + [CEReactions] attribute DOMString preload; + readonly attribute TimeRanges buffered; + undefined load(); + CanPlayTypeResult canPlayType(DOMString type); + + // ready state + const unsigned short HAVE_NOTHING = 0; + const unsigned short HAVE_METADATA = 1; + const unsigned short HAVE_CURRENT_DATA = 2; + const unsigned short HAVE_FUTURE_DATA = 3; + const unsigned short HAVE_ENOUGH_DATA = 4; + readonly attribute unsigned short readyState; + readonly attribute boolean seeking; + + // playback state + attribute double currentTime; + undefined fastSeek(double time); + readonly attribute unrestricted double duration; + object getStartDate(); + readonly attribute boolean paused; + attribute double defaultPlaybackRate; + attribute double playbackRate; + attribute boolean preservesPitch; + readonly attribute TimeRanges played; + readonly attribute TimeRanges seekable; + readonly attribute boolean ended; + [CEReactions] attribute boolean autoplay; + [CEReactions] attribute boolean loop; + Promise play(); + undefined pause(); + + // controls + [CEReactions] attribute boolean controls; + attribute double volume; + attribute boolean muted; + [CEReactions] attribute boolean defaultMuted; + + // tracks + [SameObject] readonly attribute AudioTrackList audioTracks; + [SameObject] readonly attribute VideoTrackList videoTracks; + [SameObject] readonly attribute TextTrackList textTracks; + TextTrack addTextTrack(TextTrackKind kind, optional DOMString label = "", optional DOMString language = ""); +};[Exposed=Window] +interface MediaError { + const unsigned short MEDIA_ERR_ABORTED = 1; + const unsigned short MEDIA_ERR_NETWORK = 2; + const unsigned short MEDIA_ERR_DECODE = 3; + const unsigned short MEDIA_ERR_SRC_NOT_SUPPORTED = 4; + + readonly attribute unsigned short code; + readonly attribute DOMString message; +};[Exposed=Window] +interface AudioTrackList : EventTarget { + readonly attribute unsigned long length; + getter AudioTrack (unsigned long index); + AudioTrack? getTrackById(DOMString id); + + attribute EventHandler onchange; + attribute EventHandler onaddtrack; + attribute EventHandler onremovetrack; +}; + +[Exposed=Window] +interface AudioTrack { + readonly attribute DOMString id; + readonly attribute DOMString kind; + readonly attribute DOMString label; + readonly attribute DOMString language; + attribute boolean enabled; +}; + +[Exposed=Window] +interface VideoTrackList : EventTarget { + readonly attribute unsigned long length; + getter VideoTrack (unsigned long index); + VideoTrack? getTrackById(DOMString id); + readonly attribute long selectedIndex; + + attribute EventHandler onchange; + attribute EventHandler onaddtrack; + attribute EventHandler onremovetrack; +}; + +[Exposed=Window] +interface VideoTrack { + readonly attribute DOMString id; + readonly attribute DOMString kind; + readonly attribute DOMString label; + readonly attribute DOMString language; + attribute boolean selected; +};[Exposed=Window] +interface TextTrackList : EventTarget { + readonly attribute unsigned long length; + getter TextTrack (unsigned long index); + TextTrack? getTrackById(DOMString id); + + attribute EventHandler onchange; + attribute EventHandler onaddtrack; + attribute EventHandler onremovetrack; +};enum TextTrackMode { "disabled", "hidden", "showing" }; +enum TextTrackKind { "subtitles", "captions", "descriptions", "chapters", "metadata" }; + +[Exposed=Window] +interface TextTrack : EventTarget { + readonly attribute TextTrackKind kind; + readonly attribute DOMString label; + readonly attribute DOMString language; + + readonly attribute DOMString id; + readonly attribute DOMString inBandMetadataTrackDispatchType; + + attribute TextTrackMode mode; + + readonly attribute TextTrackCueList? cues; + readonly attribute TextTrackCueList? activeCues; + + undefined addCue(TextTrackCue cue); + undefined removeCue(TextTrackCue cue); + + attribute EventHandler oncuechange; +};[Exposed=Window] +interface TextTrackCueList { + readonly attribute unsigned long length; + getter TextTrackCue (unsigned long index); + TextTrackCue? getCueById(DOMString id); +};[Exposed=Window] +interface TextTrackCue : EventTarget { + readonly attribute TextTrack? track; + + attribute DOMString id; + attribute double startTime; + attribute double endTime; + attribute boolean pauseOnExit; + + attribute EventHandler onenter; + attribute EventHandler onexit; +};[Exposed=Window] +interface TimeRanges { + readonly attribute unsigned long length; + double start(unsigned long index); + double end(unsigned long index); +};[Exposed=Window] +interface TrackEvent : Event { + constructor(DOMString type, optional TrackEventInit eventInitDict = {}); + + readonly attribute (VideoTrack or AudioTrack or TextTrack)? track; +}; + +dictionary TrackEventInit : EventInit { + (VideoTrack or AudioTrack or TextTrack)? track = null; +};[Exposed=Window] +interface HTMLMapElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString name; + [SameObject] readonly attribute HTMLCollection areas; +};[Exposed=Window] +interface HTMLAreaElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString alt; + [CEReactions] attribute DOMString coords; + [CEReactions] attribute DOMString shape; + [CEReactions] attribute DOMString target; + [CEReactions] attribute DOMString download; + [CEReactions] attribute USVString ping; + [CEReactions] attribute DOMString rel; + [SameObject, PutForwards=value] readonly attribute DOMTokenList relList; + [CEReactions] attribute DOMString referrerPolicy; + + // also has obsolete members +}; +HTMLAreaElement includes HTMLHyperlinkElementUtils;[Exposed=Window] +interface HTMLTableElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute HTMLTableCaptionElement? caption; + HTMLTableCaptionElement createCaption(); + [CEReactions] undefined deleteCaption(); + + [CEReactions] attribute HTMLTableSectionElement? tHead; + HTMLTableSectionElement createTHead(); + [CEReactions] undefined deleteTHead(); + + [CEReactions] attribute HTMLTableSectionElement? tFoot; + HTMLTableSectionElement createTFoot(); + [CEReactions] undefined deleteTFoot(); + + [SameObject] readonly attribute HTMLCollection tBodies; + HTMLTableSectionElement createTBody(); + + [SameObject] readonly attribute HTMLCollection rows; + HTMLTableRowElement insertRow(optional long index = -1); + [CEReactions] undefined deleteRow(long index); + + // also has obsolete members +};[Exposed=Window] +interface HTMLTableCaptionElement : HTMLElement { + [HTMLConstructor] constructor(); + + // also has obsolete members +};[Exposed=Window] +interface HTMLTableColElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute unsigned long span; + + // also has obsolete members +};[Exposed=Window] +interface HTMLTableSectionElement : HTMLElement { + [HTMLConstructor] constructor(); + + [SameObject] readonly attribute HTMLCollection rows; + HTMLTableRowElement insertRow(optional long index = -1); + [CEReactions] undefined deleteRow(long index); + + // also has obsolete members +};[Exposed=Window] +interface HTMLTableRowElement : HTMLElement { + [HTMLConstructor] constructor(); + + readonly attribute long rowIndex; + readonly attribute long sectionRowIndex; + [SameObject] readonly attribute HTMLCollection cells; + HTMLTableCellElement insertCell(optional long index = -1); + [CEReactions] undefined deleteCell(long index); + + // also has obsolete members +};[Exposed=Window] +interface HTMLTableCellElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute unsigned long colSpan; + [CEReactions] attribute unsigned long rowSpan; + [CEReactions] attribute DOMString headers; + readonly attribute long cellIndex; + + [CEReactions] attribute DOMString scope; // only conforming for th elements + [CEReactions] attribute DOMString abbr; // only conforming for th elements + + // also has obsolete members +};[Exposed=Window, + LegacyOverrideBuiltIns, + LegacyUnenumerableNamedProperties] +interface HTMLFormElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString acceptCharset; + [CEReactions] attribute USVString action; + [CEReactions] attribute DOMString autocomplete; + [CEReactions] attribute DOMString enctype; + [CEReactions] attribute DOMString encoding; + [CEReactions] attribute DOMString method; + [CEReactions] attribute DOMString name; + [CEReactions] attribute boolean noValidate; + [CEReactions] attribute DOMString target; + [CEReactions] attribute DOMString rel; + [SameObject, PutForwards=value] readonly attribute DOMTokenList relList; + + [SameObject] readonly attribute HTMLFormControlsCollection elements; + readonly attribute unsigned long length; + getter Element (unsigned long index); + getter (RadioNodeList or Element) (DOMString name); + + undefined submit(); + undefined requestSubmit(optional HTMLElement? submitter = null); + [CEReactions] undefined reset(); + boolean checkValidity(); + boolean reportValidity(); +};[Exposed=Window] +interface HTMLLabelElement : HTMLElement { + [HTMLConstructor] constructor(); + + readonly attribute HTMLFormElement? form; + [CEReactions] attribute DOMString htmlFor; + readonly attribute HTMLElement? control; +};[Exposed=Window] +interface HTMLInputElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString accept; + [CEReactions] attribute DOMString alt; + [CEReactions] attribute DOMString autocomplete; + [CEReactions] attribute boolean defaultChecked; + attribute boolean checked; + [CEReactions] attribute DOMString dirName; + [CEReactions] attribute boolean disabled; + readonly attribute HTMLFormElement? form; + attribute FileList? files; + [CEReactions] attribute USVString formAction; + [CEReactions] attribute DOMString formEnctype; + [CEReactions] attribute DOMString formMethod; + [CEReactions] attribute boolean formNoValidate; + [CEReactions] attribute DOMString formTarget; + [CEReactions] attribute unsigned long height; + attribute boolean indeterminate; + readonly attribute HTMLElement? list; + [CEReactions] attribute DOMString max; + [CEReactions] attribute long maxLength; + [CEReactions] attribute DOMString min; + [CEReactions] attribute long minLength; + [CEReactions] attribute boolean multiple; + [CEReactions] attribute DOMString name; + [CEReactions] attribute DOMString pattern; + [CEReactions] attribute DOMString placeholder; + [CEReactions] attribute boolean readOnly; + [CEReactions] attribute boolean required; + [CEReactions] attribute unsigned long size; + [CEReactions] attribute USVString src; + [CEReactions] attribute DOMString step; + [CEReactions] attribute DOMString type; + [CEReactions] attribute DOMString defaultValue; + [CEReactions] attribute [LegacyNullToEmptyString] DOMString value; + attribute object? valueAsDate; + attribute unrestricted double valueAsNumber; + [CEReactions] attribute unsigned long width; + + undefined stepUp(optional long n = 1); + undefined stepDown(optional long n = 1); + + readonly attribute boolean willValidate; + readonly attribute ValidityState validity; + readonly attribute DOMString validationMessage; + boolean checkValidity(); + boolean reportValidity(); + undefined setCustomValidity(DOMString error); + + readonly attribute NodeList? labels; + + undefined select(); + attribute unsigned long? selectionStart; + attribute unsigned long? selectionEnd; + attribute DOMString? selectionDirection; + undefined setRangeText(DOMString replacement); + undefined setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode = "preserve"); + undefined setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction); + + // also has obsolete members +};[Exposed=Window] +interface HTMLButtonElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute boolean disabled; + readonly attribute HTMLFormElement? form; + [CEReactions] attribute USVString formAction; + [CEReactions] attribute DOMString formEnctype; + [CEReactions] attribute DOMString formMethod; + [CEReactions] attribute boolean formNoValidate; + [CEReactions] attribute DOMString formTarget; + [CEReactions] attribute DOMString name; + [CEReactions] attribute DOMString type; + [CEReactions] attribute DOMString value; + + readonly attribute boolean willValidate; + readonly attribute ValidityState validity; + readonly attribute DOMString validationMessage; + boolean checkValidity(); + boolean reportValidity(); + undefined setCustomValidity(DOMString error); + + readonly attribute NodeList labels; +};[Exposed=Window] +interface HTMLSelectElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString autocomplete; + [CEReactions] attribute boolean disabled; + readonly attribute HTMLFormElement? form; + [CEReactions] attribute boolean multiple; + [CEReactions] attribute DOMString name; + [CEReactions] attribute boolean required; + [CEReactions] attribute unsigned long size; + + readonly attribute DOMString type; + + [SameObject] readonly attribute HTMLOptionsCollection options; + [CEReactions] attribute unsigned long length; + getter Element? item(unsigned long index); + HTMLOptionElement? namedItem(DOMString name); + [CEReactions] undefined add((HTMLOptionElement or HTMLOptGroupElement) element, optional (HTMLElement or long)? before = null); + [CEReactions] undefined remove(); // ChildNode overload + [CEReactions] undefined remove(long index); + [CEReactions] setter undefined (unsigned long index, HTMLOptionElement? option); + + [SameObject] readonly attribute HTMLCollection selectedOptions; + attribute long selectedIndex; + attribute DOMString value; + + readonly attribute boolean willValidate; + readonly attribute ValidityState validity; + readonly attribute DOMString validationMessage; + boolean checkValidity(); + boolean reportValidity(); + undefined setCustomValidity(DOMString error); + + readonly attribute NodeList labels; +};[Exposed=Window] +interface HTMLDataListElement : HTMLElement { + [HTMLConstructor] constructor(); + + [SameObject] readonly attribute HTMLCollection options; +};[Exposed=Window] +interface HTMLOptGroupElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute boolean disabled; + [CEReactions] attribute DOMString label; +};[Exposed=Window, + LegacyFactoryFunction=Option(optional DOMString text = "", optional DOMString value, optional boolean defaultSelected = false, optional boolean selected = false)] +interface HTMLOptionElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute boolean disabled; + readonly attribute HTMLFormElement? form; + [CEReactions] attribute DOMString label; + [CEReactions] attribute boolean defaultSelected; + attribute boolean selected; + [CEReactions] attribute DOMString value; + + [CEReactions] attribute DOMString text; + readonly attribute long index; +};[Exposed=Window] +interface HTMLTextAreaElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString autocomplete; + [CEReactions] attribute unsigned long cols; + [CEReactions] attribute DOMString dirName; + [CEReactions] attribute boolean disabled; + readonly attribute HTMLFormElement? form; + [CEReactions] attribute long maxLength; + [CEReactions] attribute long minLength; + [CEReactions] attribute DOMString name; + [CEReactions] attribute DOMString placeholder; + [CEReactions] attribute boolean readOnly; + [CEReactions] attribute boolean required; + [CEReactions] attribute unsigned long rows; + [CEReactions] attribute DOMString wrap; + + readonly attribute DOMString type; + [CEReactions] attribute DOMString defaultValue; + attribute [LegacyNullToEmptyString] DOMString value; + readonly attribute unsigned long textLength; + + readonly attribute boolean willValidate; + readonly attribute ValidityState validity; + readonly attribute DOMString validationMessage; + boolean checkValidity(); + boolean reportValidity(); + undefined setCustomValidity(DOMString error); + + readonly attribute NodeList labels; + + undefined select(); + attribute unsigned long selectionStart; + attribute unsigned long selectionEnd; + attribute DOMString selectionDirection; + undefined setRangeText(DOMString replacement); + undefined setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode = "preserve"); + undefined setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction); +};[Exposed=Window] +interface HTMLOutputElement : HTMLElement { + [HTMLConstructor] constructor(); + + [SameObject, PutForwards=value] readonly attribute DOMTokenList htmlFor; + readonly attribute HTMLFormElement? form; + [CEReactions] attribute DOMString name; + + readonly attribute DOMString type; + [CEReactions] attribute DOMString defaultValue; + [CEReactions] attribute DOMString value; + + readonly attribute boolean willValidate; + readonly attribute ValidityState validity; + readonly attribute DOMString validationMessage; + boolean checkValidity(); + boolean reportValidity(); + undefined setCustomValidity(DOMString error); + + readonly attribute NodeList labels; +};[Exposed=Window] +interface HTMLProgressElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute double value; + [CEReactions] attribute double max; + readonly attribute double position; + readonly attribute NodeList labels; +};[Exposed=Window] +interface HTMLMeterElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute double value; + [CEReactions] attribute double min; + [CEReactions] attribute double max; + [CEReactions] attribute double low; + [CEReactions] attribute double high; + [CEReactions] attribute double optimum; + readonly attribute NodeList labels; +};[Exposed=Window] +interface HTMLFieldSetElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute boolean disabled; + readonly attribute HTMLFormElement? form; + [CEReactions] attribute DOMString name; + + readonly attribute DOMString type; + + [SameObject] readonly attribute HTMLCollection elements; + + readonly attribute boolean willValidate; + [SameObject] readonly attribute ValidityState validity; + readonly attribute DOMString validationMessage; + boolean checkValidity(); + boolean reportValidity(); + undefined setCustomValidity(DOMString error); +};[Exposed=Window] +interface HTMLLegendElement : HTMLElement { + [HTMLConstructor] constructor(); + + readonly attribute HTMLFormElement? form; + + // also has obsolete members +};enum SelectionMode { + "select", + "start", + "end", + "preserve" // default +};[Exposed=Window] +interface ValidityState { + readonly attribute boolean valueMissing; + readonly attribute boolean typeMismatch; + readonly attribute boolean patternMismatch; + readonly attribute boolean tooLong; + readonly attribute boolean tooShort; + readonly attribute boolean rangeUnderflow; + readonly attribute boolean rangeOverflow; + readonly attribute boolean stepMismatch; + readonly attribute boolean badInput; + readonly attribute boolean customError; + readonly attribute boolean valid; +};[Exposed=Window] +interface SubmitEvent : Event { + constructor(DOMString type, optional SubmitEventInit eventInitDict = {}); + + readonly attribute HTMLElement? submitter; +}; + +dictionary SubmitEventInit : EventInit { + HTMLElement? submitter = null; +};[Exposed=Window] +interface FormDataEvent : Event { + constructor(DOMString type, FormDataEventInit eventInitDict); + + readonly attribute FormData formData; +}; + +dictionary FormDataEventInit : EventInit { + required FormData formData; +};[Exposed=Window] +interface HTMLDetailsElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute boolean open; +};[Exposed=Window] +interface HTMLDialogElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute boolean open; + attribute DOMString returnValue; + [CEReactions] undefined show(); + [CEReactions] undefined showModal(); + [CEReactions] undefined close(optional DOMString returnValue); +};[Exposed=Window] +interface HTMLScriptElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute USVString src; + [CEReactions] attribute DOMString type; + [CEReactions] attribute boolean noModule; + [CEReactions] attribute boolean async; + [CEReactions] attribute boolean defer; + [CEReactions] attribute DOMString? crossOrigin; + [CEReactions] attribute DOMString text; + [CEReactions] attribute DOMString integrity; + [CEReactions] attribute DOMString referrerPolicy; + + // also has obsolete members +};[Exposed=Window] +interface HTMLTemplateElement : HTMLElement { + [HTMLConstructor] constructor(); + + readonly attribute DocumentFragment content; +};[Exposed=Window] +interface HTMLSlotElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString name; + sequence assignedNodes(optional AssignedNodesOptions options = {}); + sequence assignedElements(optional AssignedNodesOptions options = {}); +}; + +dictionary AssignedNodesOptions { + boolean flatten = false; +};typedef (CanvasRenderingContext2D or ImageBitmapRenderingContext or WebGLRenderingContext or WebGL2RenderingContext) RenderingContext; + +[Exposed=Window] +interface HTMLCanvasElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute unsigned long width; + [CEReactions] attribute unsigned long height; + + RenderingContext? getContext(DOMString contextId, optional any options = null); + + USVString toDataURL(optional DOMString type = "image/png", optional any quality); + undefined toBlob(BlobCallback _callback, optional DOMString type = "image/png", optional any quality); + OffscreenCanvas transferControlToOffscreen(); +}; + +callback BlobCallback = undefined (Blob? blob);typedef (HTMLImageElement or + SVGImageElement) HTMLOrSVGImageElement; + +typedef (HTMLOrSVGImageElement or + HTMLVideoElement or + HTMLCanvasElement or + ImageBitmap or + OffscreenCanvas) CanvasImageSource; + +enum CanvasFillRule { "nonzero", "evenodd" }; + +dictionary CanvasRenderingContext2DSettings { + boolean alpha = true; + boolean desynchronized = false; +}; + +enum ImageSmoothingQuality { "low", "medium", "high" }; + +[Exposed=Window] +interface CanvasRenderingContext2D { + // back-reference to the canvas + readonly attribute HTMLCanvasElement canvas; + + CanvasRenderingContext2DSettings getContextAttributes(); +}; +CanvasRenderingContext2D includes CanvasState; +CanvasRenderingContext2D includes CanvasTransform; +CanvasRenderingContext2D includes CanvasCompositing; +CanvasRenderingContext2D includes CanvasImageSmoothing; +CanvasRenderingContext2D includes CanvasFillStrokeStyles; +CanvasRenderingContext2D includes CanvasShadowStyles; +CanvasRenderingContext2D includes CanvasFilters; +CanvasRenderingContext2D includes CanvasRect; +CanvasRenderingContext2D includes CanvasDrawPath; +CanvasRenderingContext2D includes CanvasUserInterface; +CanvasRenderingContext2D includes CanvasText; +CanvasRenderingContext2D includes CanvasDrawImage; +CanvasRenderingContext2D includes CanvasImageData; +CanvasRenderingContext2D includes CanvasPathDrawingStyles; +CanvasRenderingContext2D includes CanvasTextDrawingStyles; +CanvasRenderingContext2D includes CanvasPath; + +interface mixin CanvasState { + // state + undefined save(); // push state on state stack + undefined restore(); // pop state stack and restore state +}; + +interface mixin CanvasTransform { + // transformations (default transform is the identity matrix) + undefined scale(unrestricted double x, unrestricted double y); + undefined rotate(unrestricted double angle); + undefined translate(unrestricted double x, unrestricted double y); + undefined transform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f); + + [NewObject] DOMMatrix getTransform(); + undefined setTransform(unrestricted double a, unrestricted double b, unrestricted double c, unrestricted double d, unrestricted double e, unrestricted double f); + undefined setTransform(optional DOMMatrix2DInit transform = {}); + undefined resetTransform(); + +}; + +interface mixin CanvasCompositing { + // compositing + attribute unrestricted double globalAlpha; // (default 1.0) + attribute DOMString globalCompositeOperation; // (default source-over) +}; + +interface mixin CanvasImageSmoothing { + // image smoothing + attribute boolean imageSmoothingEnabled; // (default true) + attribute ImageSmoothingQuality imageSmoothingQuality; // (default low) + +}; + +interface mixin CanvasFillStrokeStyles { + // colors and styles (see also the CanvasPathDrawingStyles and CanvasTextDrawingStyles interfaces) + attribute (DOMString or CanvasGradient or CanvasPattern) strokeStyle; // (default black) + attribute (DOMString or CanvasGradient or CanvasPattern) fillStyle; // (default black) + CanvasGradient createLinearGradient(double x0, double y0, double x1, double y1); + CanvasGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1); + CanvasPattern? createPattern(CanvasImageSource image, [LegacyNullToEmptyString] DOMString repetition); + +}; + +interface mixin CanvasShadowStyles { + // shadows + attribute unrestricted double shadowOffsetX; // (default 0) + attribute unrestricted double shadowOffsetY; // (default 0) + attribute unrestricted double shadowBlur; // (default 0) + attribute DOMString shadowColor; // (default transparent black) +}; + +interface mixin CanvasFilters { + // filters + attribute DOMString filter; // (default "none") +}; + +interface mixin CanvasRect { + // rects + undefined clearRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); + undefined fillRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); + undefined strokeRect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); +}; + +interface mixin CanvasDrawPath { + // path API (see also CanvasPath) + undefined beginPath(); + undefined fill(optional CanvasFillRule fillRule = "nonzero"); + undefined fill(Path2D path, optional CanvasFillRule fillRule = "nonzero"); + undefined stroke(); + undefined stroke(Path2D path); + undefined clip(optional CanvasFillRule fillRule = "nonzero"); + undefined clip(Path2D path, optional CanvasFillRule fillRule = "nonzero"); + boolean isPointInPath(unrestricted double x, unrestricted double y, optional CanvasFillRule fillRule = "nonzero"); + boolean isPointInPath(Path2D path, unrestricted double x, unrestricted double y, optional CanvasFillRule fillRule = "nonzero"); + boolean isPointInStroke(unrestricted double x, unrestricted double y); + boolean isPointInStroke(Path2D path, unrestricted double x, unrestricted double y); +}; + +interface mixin CanvasUserInterface { + undefined drawFocusIfNeeded(Element element); + undefined drawFocusIfNeeded(Path2D path, Element element); + undefined scrollPathIntoView(); + undefined scrollPathIntoView(Path2D path); +}; + +interface mixin CanvasText { + // text (see also the CanvasPathDrawingStyles and CanvasTextDrawingStyles interfaces) + undefined fillText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth); + undefined strokeText(DOMString text, unrestricted double x, unrestricted double y, optional unrestricted double maxWidth); + TextMetrics measureText(DOMString text); +}; + +interface mixin CanvasDrawImage { + // drawing images + undefined drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy); + undefined drawImage(CanvasImageSource image, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh); + undefined drawImage(CanvasImageSource image, unrestricted double sx, unrestricted double sy, unrestricted double sw, unrestricted double sh, unrestricted double dx, unrestricted double dy, unrestricted double dw, unrestricted double dh); +}; + +interface mixin CanvasImageData { + // pixel manipulation + ImageData createImageData(long sw, long sh); + ImageData createImageData(ImageData imagedata); + ImageData getImageData(long sx, long sy, long sw, long sh); + undefined putImageData(ImageData imagedata, long dx, long dy); + undefined putImageData(ImageData imagedata, long dx, long dy, long dirtyX, long dirtyY, long dirtyWidth, long dirtyHeight); +}; + +enum CanvasLineCap { "butt", "round", "square" }; +enum CanvasLineJoin { "round", "bevel", "miter" }; +enum CanvasTextAlign { "start", "end", "left", "right", "center" }; +enum CanvasTextBaseline { "top", "hanging", "middle", "alphabetic", "ideographic", "bottom" }; +enum CanvasDirection { "ltr", "rtl", "inherit" }; + +interface mixin CanvasPathDrawingStyles { + // line caps/joins + attribute unrestricted double lineWidth; // (default 1) + attribute CanvasLineCap lineCap; // (default "butt") + attribute CanvasLineJoin lineJoin; // (default "miter") + attribute unrestricted double miterLimit; // (default 10) + + // dashed lines + undefined setLineDash(sequence segments); // default empty + sequence getLineDash(); + attribute unrestricted double lineDashOffset; +}; + +interface mixin CanvasTextDrawingStyles { + // text + attribute DOMString font; // (default 10px sans-serif) + attribute CanvasTextAlign textAlign; // (default: "start") + attribute CanvasTextBaseline textBaseline; // (default: "alphabetic") + attribute CanvasDirection direction; // (default: "inherit") +}; + +interface mixin CanvasPath { + // shared path API methods + undefined closePath(); + undefined moveTo(unrestricted double x, unrestricted double y); + undefined lineTo(unrestricted double x, unrestricted double y); + undefined quadraticCurveTo(unrestricted double cpx, unrestricted double cpy, unrestricted double x, unrestricted double y); + undefined bezierCurveTo(unrestricted double cp1x, unrestricted double cp1y, unrestricted double cp2x, unrestricted double cp2y, unrestricted double x, unrestricted double y); + undefined arcTo(unrestricted double x1, unrestricted double y1, unrestricted double x2, unrestricted double y2, unrestricted double radius); + undefined rect(unrestricted double x, unrestricted double y, unrestricted double w, unrestricted double h); + undefined arc(unrestricted double x, unrestricted double y, unrestricted double radius, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false); + undefined ellipse(unrestricted double x, unrestricted double y, unrestricted double radiusX, unrestricted double radiusY, unrestricted double rotation, unrestricted double startAngle, unrestricted double endAngle, optional boolean anticlockwise = false); +}; + +[Exposed=(Window,Worker)] +interface CanvasGradient { + // opaque object + undefined addColorStop(double offset, DOMString color); +}; + +[Exposed=(Window,Worker)] +interface CanvasPattern { + // opaque object + undefined setTransform(optional DOMMatrix2DInit transform = {}); +}; + +[Exposed=(Window,Worker)] +interface TextMetrics { + // x-direction + readonly attribute double width; // advance width + readonly attribute double actualBoundingBoxLeft; + readonly attribute double actualBoundingBoxRight; + + // y-direction + readonly attribute double fontBoundingBoxAscent; + readonly attribute double fontBoundingBoxDescent; + readonly attribute double actualBoundingBoxAscent; + readonly attribute double actualBoundingBoxDescent; + readonly attribute double emHeightAscent; + readonly attribute double emHeightDescent; + readonly attribute double hangingBaseline; + readonly attribute double alphabeticBaseline; + readonly attribute double ideographicBaseline; +}; + +[Exposed=(Window,Worker), + Serializable] +interface ImageData { + constructor(unsigned long sw, unsigned long sh); + constructor(Uint8ClampedArray data, unsigned long sw, optional unsigned long sh); + + readonly attribute unsigned long width; + readonly attribute unsigned long height; + readonly attribute Uint8ClampedArray data; +}; + +[Exposed=(Window,Worker)] +interface Path2D { + constructor(optional (Path2D or DOMString) path); + + undefined addPath(Path2D path, optional DOMMatrix2DInit transform = {}); +}; +Path2D includes CanvasPath;[Exposed=(Window,Worker)] +interface ImageBitmapRenderingContext { + readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas; + undefined transferFromImageBitmap(ImageBitmap? bitmap); +}; + +dictionary ImageBitmapRenderingContextSettings { + boolean alpha = true; +};typedef (OffscreenCanvasRenderingContext2D or ImageBitmapRenderingContext or WebGLRenderingContext or WebGL2RenderingContext) OffscreenRenderingContext; + +dictionary ImageEncodeOptions { + DOMString type = "image/png"; + unrestricted double quality; +}; + +enum OffscreenRenderingContextId { "2d", "bitmaprenderer", "webgl", "webgl2" }; + +[Exposed=(Window,Worker), Transferable] +interface OffscreenCanvas : EventTarget { + constructor([EnforceRange] unsigned long long width, [EnforceRange] unsigned long long height); + + attribute [EnforceRange] unsigned long long width; + attribute [EnforceRange] unsigned long long height; + + OffscreenRenderingContext? getContext(OffscreenRenderingContextId contextId, optional any options = null); + ImageBitmap transferToImageBitmap(); + Promise convertToBlob(optional ImageEncodeOptions options = {}); +};[Exposed=(Window,Worker)] +interface OffscreenCanvasRenderingContext2D { + undefined commit(); + readonly attribute OffscreenCanvas canvas; +}; + +OffscreenCanvasRenderingContext2D includes CanvasState; +OffscreenCanvasRenderingContext2D includes CanvasTransform; +OffscreenCanvasRenderingContext2D includes CanvasCompositing; +OffscreenCanvasRenderingContext2D includes CanvasImageSmoothing; +OffscreenCanvasRenderingContext2D includes CanvasFillStrokeStyles; +OffscreenCanvasRenderingContext2D includes CanvasShadowStyles; +OffscreenCanvasRenderingContext2D includes CanvasFilters; +OffscreenCanvasRenderingContext2D includes CanvasRect; +OffscreenCanvasRenderingContext2D includes CanvasDrawPath; +OffscreenCanvasRenderingContext2D includes CanvasText; +OffscreenCanvasRenderingContext2D includes CanvasDrawImage; +OffscreenCanvasRenderingContext2D includes CanvasImageData; +OffscreenCanvasRenderingContext2D includes CanvasPathDrawingStyles; +OffscreenCanvasRenderingContext2D includes CanvasTextDrawingStyles; +OffscreenCanvasRenderingContext2D includes CanvasPath;[Exposed=Window] +interface CustomElementRegistry { + [CEReactions] undefined define(DOMString name, CustomElementConstructor constructor, optional ElementDefinitionOptions options = {}); + (CustomElementConstructor or undefined) get(DOMString name); + Promise whenDefined(DOMString name); + [CEReactions] undefined upgrade(Node root); +}; + +callback CustomElementConstructor = HTMLElement (); + +dictionary ElementDefinitionOptions { + DOMString extends; +};[Exposed=Window] +interface ElementInternals { + // Shadow root access + readonly attribute ShadowRoot? shadowRoot; + + // Form-associated custom elements + undefined setFormValue((File or USVString or FormData)? value, + optional (File or USVString or FormData)? state); + + readonly attribute HTMLFormElement? form; + + undefined setValidity(optional ValidityStateFlags flags = {}, + optional DOMString message, + optional HTMLElement anchor); + readonly attribute boolean willValidate; + readonly attribute ValidityState validity; + readonly attribute DOMString validationMessage; + boolean checkValidity(); + boolean reportValidity(); + + readonly attribute NodeList labels; +}; + +// Accessibility semantics +ElementInternals includes ARIAMixin; + +dictionary ValidityStateFlags { + boolean valueMissing = false; + boolean typeMismatch = false; + boolean patternMismatch = false; + boolean tooLong = false; + boolean tooShort = false; + boolean rangeUnderflow = false; + boolean rangeOverflow = false; + boolean stepMismatch = false; + boolean badInput = false; + boolean customError = false; +};dictionary FocusOptions { + boolean preventScroll = false; +};interface mixin ElementContentEditable { + [CEReactions] attribute DOMString contentEditable; + [CEReactions] attribute DOMString enterKeyHint; + readonly attribute boolean isContentEditable; + [CEReactions] attribute DOMString inputMode; +};[Exposed=Window] +interface DataTransfer { + constructor(); + + attribute DOMString dropEffect; + attribute DOMString effectAllowed; + + [SameObject] readonly attribute DataTransferItemList items; + + undefined setDragImage(Element image, long x, long y); + + /* old interface */ + readonly attribute FrozenArray types; + DOMString getData(DOMString format); + undefined setData(DOMString format, DOMString data); + undefined clearData(optional DOMString format); + [SameObject] readonly attribute FileList files; +};[Exposed=Window] +interface DataTransferItemList { + readonly attribute unsigned long length; + getter DataTransferItem (unsigned long index); + DataTransferItem? add(DOMString data, DOMString type); + DataTransferItem? add(File data); + undefined remove(unsigned long index); + undefined clear(); +};[Exposed=Window] +interface DataTransferItem { + readonly attribute DOMString kind; + readonly attribute DOMString type; + undefined getAsString(FunctionStringCallback? _callback); + File? getAsFile(); +}; + +callback FunctionStringCallback = undefined (DOMString data);[Exposed=Window] +interface DragEvent : MouseEvent { + constructor(DOMString type, optional DragEventInit eventInitDict = {}); + + readonly attribute DataTransfer? dataTransfer; +}; + +dictionary DragEventInit : MouseEventInit { + DataTransfer? dataTransfer = null; +};[Global=Window, + Exposed=Window, + LegacyUnenumerableNamedProperties] +interface Window : EventTarget { + // the current browsing context + [LegacyUnforgeable] readonly attribute WindowProxy window; + [Replaceable] readonly attribute WindowProxy self; + [LegacyUnforgeable] readonly attribute Document document; + attribute DOMString name; + [PutForwards=href, LegacyUnforgeable] readonly attribute Location location; + readonly attribute History history; + readonly attribute CustomElementRegistry customElements; + [Replaceable] readonly attribute BarProp locationbar; + [Replaceable] readonly attribute BarProp menubar; + [Replaceable] readonly attribute BarProp personalbar; + [Replaceable] readonly attribute BarProp scrollbars; + [Replaceable] readonly attribute BarProp statusbar; + [Replaceable] readonly attribute BarProp toolbar; + attribute DOMString status; + undefined close(); + readonly attribute boolean closed; + undefined stop(); + undefined focus(); + undefined blur(); + + // other browsing contexts + [Replaceable] readonly attribute WindowProxy frames; + [Replaceable] readonly attribute unsigned long length; + [LegacyUnforgeable] readonly attribute WindowProxy? top; + attribute any opener; + [Replaceable] readonly attribute WindowProxy? parent; + readonly attribute Element? frameElement; + WindowProxy? open(optional USVString url = "", optional DOMString target = "_blank", optional [LegacyNullToEmptyString] DOMString features = ""); + getter object (DOMString name); + // Since this is the global object, the IDL named getter adds a NamedPropertiesObject exotic + // object on the prototype chain. Indeed, this does not make the global object an exotic object. + // Indexed access is taken care of by the WindowProxy exotic object. + + // the user agent + readonly attribute Navigator navigator; + readonly attribute boolean originAgentCluster; + + // user prompts + undefined alert(); + undefined alert(DOMString message); + boolean confirm(optional DOMString message = ""); + DOMString? prompt(optional DOMString message = "", optional DOMString default = ""); + undefined print(); + + undefined postMessage(any message, USVString targetOrigin, optional sequence transfer = []); + undefined postMessage(any message, optional WindowPostMessageOptions options = {}); + + // also has obsolete members +}; +Window includes GlobalEventHandlers; +Window includes WindowEventHandlers; + +dictionary WindowPostMessageOptions : PostMessageOptions { + USVString targetOrigin = "/"; +};[Exposed=Window] +interface BarProp { + readonly attribute boolean visible; +};enum ScrollRestoration { "auto", "manual" }; + +[Exposed=Window] +interface History { + readonly attribute unsigned long length; + attribute ScrollRestoration scrollRestoration; + readonly attribute any state; + undefined go(optional long delta = 0); + undefined back(); + undefined forward(); + undefined pushState(any data, DOMString title, optional USVString? url = null); + undefined replaceState(any data, DOMString title, optional USVString? url = null); +};[Exposed=Window] +interface Location { // but see also additional creation steps and overridden internal methods + [LegacyUnforgeable] stringifier attribute USVString href; + [LegacyUnforgeable] readonly attribute USVString origin; + [LegacyUnforgeable] attribute USVString protocol; + [LegacyUnforgeable] attribute USVString host; + [LegacyUnforgeable] attribute USVString hostname; + [LegacyUnforgeable] attribute USVString port; + [LegacyUnforgeable] attribute USVString pathname; + [LegacyUnforgeable] attribute USVString search; + [LegacyUnforgeable] attribute USVString hash; + + [LegacyUnforgeable] undefined assign(USVString url); + [LegacyUnforgeable] undefined replace(USVString url); + [LegacyUnforgeable] undefined reload(); + + [LegacyUnforgeable, SameObject] readonly attribute DOMStringList ancestorOrigins; +};[Exposed=Window] +interface PopStateEvent : Event { + constructor(DOMString type, optional PopStateEventInit eventInitDict = {}); + + readonly attribute any state; +}; + +dictionary PopStateEventInit : EventInit { + any state = null; +};[Exposed=Window] +interface HashChangeEvent : Event { + constructor(DOMString type, optional HashChangeEventInit eventInitDict = {}); + + readonly attribute USVString oldURL; + readonly attribute USVString newURL; +}; + +dictionary HashChangeEventInit : EventInit { + USVString oldURL = ""; + USVString newURL = ""; +};[Exposed=Window] +interface PageTransitionEvent : Event { + constructor(DOMString type, optional PageTransitionEventInit eventInitDict = {}); + + readonly attribute boolean persisted; +}; + +dictionary PageTransitionEventInit : EventInit { + boolean persisted = false; +};[Exposed=Window] +interface BeforeUnloadEvent : Event { + attribute DOMString returnValue; +};[Exposed=(Window,Worker)] +interface ErrorEvent : Event { + constructor(DOMString type, optional ErrorEventInit eventInitDict = {}); + + readonly attribute DOMString message; + readonly attribute USVString filename; + readonly attribute unsigned long lineno; + readonly attribute unsigned long colno; + readonly attribute any error; +}; + +dictionary ErrorEventInit : EventInit { + DOMString message = ""; + USVString filename = ""; + unsigned long lineno = 0; + unsigned long colno = 0; + any error = null; +};[Exposed=(Window,Worker)] +interface PromiseRejectionEvent : Event { + constructor(DOMString type, PromiseRejectionEventInit eventInitDict); + + readonly attribute Promise promise; + readonly attribute any reason; +}; + +dictionary PromiseRejectionEventInit : EventInit { + required Promise promise; + any reason; +};[LegacyTreatNonObjectAsNull] +callback EventHandlerNonNull = any (Event event); +typedef EventHandlerNonNull? EventHandler;[LegacyTreatNonObjectAsNull] +callback OnErrorEventHandlerNonNull = any ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long colno, optional any error); +typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;[LegacyTreatNonObjectAsNull] +callback OnBeforeUnloadEventHandlerNonNull = DOMString? (Event event); +typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnloadEventHandler;interface mixin GlobalEventHandlers { + attribute EventHandler onabort; + attribute EventHandler onauxclick; + attribute EventHandler onblur; + attribute EventHandler oncancel; + 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; + attribute EventHandler ondragleave; + attribute EventHandler ondragover; + attribute EventHandler ondragstart; + attribute EventHandler ondrop; + attribute EventHandler ondurationchange; + attribute EventHandler onemptied; + attribute EventHandler onended; + attribute OnErrorEventHandler onerror; + attribute EventHandler onfocus; + 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 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 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; + attribute EventHandler onstalled; + attribute EventHandler onsubmit; + attribute EventHandler onsuspend; + attribute EventHandler ontimeupdate; + attribute EventHandler ontoggle; + attribute EventHandler onvolumechange; + attribute EventHandler onwaiting; + attribute EventHandler onwebkitanimationend; + attribute EventHandler onwebkitanimationiteration; + attribute EventHandler onwebkitanimationstart; + attribute EventHandler onwebkittransitionend; + attribute EventHandler onwheel; +}; + +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; +}; + +interface mixin DocumentAndElementEventHandlers { + attribute EventHandler oncopy; + attribute EventHandler oncut; + attribute EventHandler onpaste; +};typedef (DOMString or Function) TimerHandler; + +interface mixin WindowOrWorkerGlobalScope { + [Replaceable] readonly attribute USVString origin; + readonly attribute boolean isSecureContext; + readonly attribute boolean crossOriginIsolated; + + // base64 utility methods + DOMString btoa(DOMString data); + ByteString atob(DOMString data); + + // timers + long setTimeout(TimerHandler handler, optional long timeout = 0, any... arguments); + undefined clearTimeout(optional long handle = 0); + long setInterval(TimerHandler handler, optional long timeout = 0, any... arguments); + undefined clearInterval(optional long handle = 0); + + // microtask queuing + undefined queueMicrotask(VoidFunction callback); + + // ImageBitmap + Promise createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options = {}); + Promise createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options = {}); +}; +Window includes WindowOrWorkerGlobalScope; +WorkerGlobalScope includes WindowOrWorkerGlobalScope;[Exposed=Window] +interface DOMParser { + constructor(); + + [NewObject] Document parseFromString(DOMString string, DOMParserSupportedType type); +}; + +enum DOMParserSupportedType { + "text/html", + "text/xml", + "application/xml", + "application/xhtml+xml", + "image/svg+xml" +};[Exposed=Window] +interface Navigator { + // objects implementing this interface also implement the interfaces given below +}; +Navigator includes NavigatorID; +Navigator includes NavigatorLanguage; +Navigator includes NavigatorOnLine; +Navigator includes NavigatorContentUtils; +Navigator includes NavigatorCookies; +Navigator includes NavigatorPlugins; +Navigator includes NavigatorConcurrentHardware;interface mixin NavigatorID { + readonly attribute DOMString appCodeName; // constant "Mozilla" + readonly attribute DOMString appName; // constant "Netscape" + readonly attribute DOMString appVersion; + readonly attribute DOMString platform; + readonly attribute DOMString product; // constant "Gecko" + [Exposed=Window] readonly attribute DOMString productSub; + readonly attribute DOMString userAgent; + [Exposed=Window] readonly attribute DOMString vendor; + [Exposed=Window] readonly attribute DOMString vendorSub; // constant "" +};partial interface mixin NavigatorID { + [Exposed=Window] boolean taintEnabled(); // constant false + [Exposed=Window] readonly attribute DOMString oscpu; +};interface mixin NavigatorLanguage { + readonly attribute DOMString language; + readonly attribute FrozenArray languages; +};interface mixin NavigatorOnLine { + readonly attribute boolean onLine; +};interface mixin NavigatorContentUtils { + [SecureContext] undefined registerProtocolHandler(DOMString scheme, USVString url); + [SecureContext] undefined unregisterProtocolHandler(DOMString scheme, USVString url); +};interface mixin NavigatorCookies { + readonly attribute boolean cookieEnabled; +};interface mixin NavigatorPlugins { + [SameObject] readonly attribute PluginArray plugins; + [SameObject] readonly attribute MimeTypeArray mimeTypes; + boolean javaEnabled(); +}; + +[Exposed=Window, + LegacyUnenumerableNamedProperties] +interface PluginArray { + undefined refresh(optional boolean reload = false); + readonly attribute unsigned long length; + getter Plugin? item(unsigned long index); + getter Plugin? namedItem(DOMString name); +}; + +[Exposed=Window, + LegacyUnenumerableNamedProperties] +interface MimeTypeArray { + readonly attribute unsigned long length; + getter MimeType? item(unsigned long index); + getter MimeType? namedItem(DOMString name); +}; + +[Exposed=Window, + LegacyUnenumerableNamedProperties] +interface Plugin { + readonly attribute DOMString name; + readonly attribute DOMString description; + readonly attribute DOMString filename; + readonly attribute unsigned long length; + getter MimeType? item(unsigned long index); + getter MimeType? namedItem(DOMString name); +}; + +[Exposed=Window] +interface MimeType { + readonly attribute DOMString type; + readonly attribute DOMString description; + readonly attribute DOMString suffixes; // comma-separated + readonly attribute Plugin enabledPlugin; +};[Exposed=(Window,Worker), Serializable, Transferable] +interface ImageBitmap { + readonly attribute unsigned long width; + readonly attribute unsigned long height; + undefined close(); +}; + +typedef (CanvasImageSource or + Blob or + ImageData) ImageBitmapSource; + +enum ImageOrientation { "none", "flipY" }; +enum PremultiplyAlpha { "none", "premultiply", "default" }; +enum ColorSpaceConversion { "none", "default" }; +enum ResizeQuality { "pixelated", "low", "medium", "high" }; + +dictionary ImageBitmapOptions { + ImageOrientation imageOrientation = "none"; + PremultiplyAlpha premultiplyAlpha = "default"; + ColorSpaceConversion colorSpaceConversion = "default"; + [EnforceRange] unsigned long resizeWidth; + [EnforceRange] unsigned long resizeHeight; + ResizeQuality resizeQuality = "low"; +};callback FrameRequestCallback = undefined (DOMHighResTimeStamp time); + +interface mixin AnimationFrameProvider { + unsigned long requestAnimationFrame(FrameRequestCallback callback); + undefined cancelAnimationFrame(unsigned long handle); +}; +Window includes AnimationFrameProvider; +DedicatedWorkerGlobalScope includes AnimationFrameProvider;[Exposed=(Window,Worker,AudioWorklet)] +interface MessageEvent : Event { + constructor(DOMString type, optional MessageEventInit eventInitDict = {}); + + readonly attribute any data; + readonly attribute USVString origin; + readonly attribute DOMString lastEventId; + readonly attribute MessageEventSource? source; + readonly attribute FrozenArray ports; + + undefined initMessageEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any data = null, optional USVString origin = "", optional DOMString lastEventId = "", optional MessageEventSource? source = null, optional sequence ports = []); +}; + +dictionary MessageEventInit : EventInit { + any data = null; + USVString origin = ""; + DOMString lastEventId = ""; + MessageEventSource? source = null; + sequence ports = []; +}; + +typedef (WindowProxy or MessagePort or ServiceWorker) MessageEventSource;[Exposed=(Window,Worker)] +interface EventSource : EventTarget { + constructor(USVString url, optional EventSourceInit eventSourceInitDict = {}); + + readonly attribute USVString url; + readonly attribute boolean withCredentials; + + // ready state + const unsigned short CONNECTING = 0; + const unsigned short OPEN = 1; + const unsigned short CLOSED = 2; + readonly attribute unsigned short readyState; + + // networking + attribute EventHandler onopen; + attribute EventHandler onmessage; + attribute EventHandler onerror; + undefined close(); +}; + +dictionary EventSourceInit { + boolean withCredentials = false; +};enum BinaryType { "blob", "arraybuffer" }; +[Exposed=(Window,Worker)] +interface WebSocket : EventTarget { + constructor(USVString url, optional (DOMString or sequence) protocols = []); + + readonly attribute USVString url; + + // ready state + const unsigned short CONNECTING = 0; + const unsigned short OPEN = 1; + const unsigned short CLOSING = 2; + const unsigned short CLOSED = 3; + readonly attribute unsigned short readyState; + readonly attribute unsigned long long bufferedAmount; + + // networking + attribute EventHandler onopen; + attribute EventHandler onerror; + attribute EventHandler onclose; + readonly attribute DOMString extensions; + readonly attribute DOMString protocol; + undefined close(optional [Clamp] unsigned short code, optional USVString reason); + + // messaging + attribute EventHandler onmessage; + attribute BinaryType binaryType; + undefined send(USVString data); + undefined send(Blob data); + undefined send(ArrayBuffer data); + undefined send(ArrayBufferView data); +};[Exposed=(Window,Worker)] +interface CloseEvent : Event { + constructor(DOMString type, optional CloseEventInit eventInitDict = {}); + + readonly attribute boolean wasClean; + readonly attribute unsigned short code; + readonly attribute USVString reason; +}; + +dictionary CloseEventInit : EventInit { + boolean wasClean = false; + unsigned short code = 0; + USVString reason = ""; +};[Exposed=(Window,Worker)] +interface MessageChannel { + constructor(); + + readonly attribute MessagePort port1; + readonly attribute MessagePort port2; +};[Exposed=(Window,Worker,AudioWorklet), Transferable] +interface MessagePort : EventTarget { + undefined postMessage(any message, sequence transfer); + undefined postMessage(any message, optional PostMessageOptions options = {}); + undefined start(); + undefined close(); + + // event handlers + attribute EventHandler onmessage; + attribute EventHandler onmessageerror; +}; + +dictionary PostMessageOptions { + sequence transfer = []; +};[Exposed=(Window,Worker)] +interface BroadcastChannel : EventTarget { + constructor(DOMString name); + + readonly attribute DOMString name; + undefined postMessage(any message); + undefined close(); + attribute EventHandler onmessage; + attribute EventHandler onmessageerror; +};[Exposed=Worker] +interface WorkerGlobalScope : EventTarget { + readonly attribute WorkerGlobalScope self; + readonly attribute WorkerLocation location; + readonly attribute WorkerNavigator navigator; + undefined importScripts(USVString... urls); + + attribute OnErrorEventHandler onerror; + attribute EventHandler onlanguagechange; + attribute EventHandler onoffline; + attribute EventHandler ononline; + attribute EventHandler onrejectionhandled; + attribute EventHandler onunhandledrejection; +};[Global=(Worker,DedicatedWorker),Exposed=DedicatedWorker] +interface DedicatedWorkerGlobalScope : WorkerGlobalScope { + [Replaceable] readonly attribute DOMString name; + + undefined postMessage(any message, sequence transfer); + undefined postMessage(any message, optional PostMessageOptions options = {}); + + undefined close(); + + attribute EventHandler onmessage; + attribute EventHandler onmessageerror; +};[Global=(Worker,SharedWorker),Exposed=SharedWorker] +interface SharedWorkerGlobalScope : WorkerGlobalScope { + [Replaceable] readonly attribute DOMString name; + + undefined close(); + + attribute EventHandler onconnect; +};interface mixin AbstractWorker { + attribute EventHandler onerror; +};[Exposed=(Window,DedicatedWorker,SharedWorker)] +interface Worker : EventTarget { + constructor(USVString scriptURL, optional WorkerOptions options = {}); + + undefined terminate(); + + undefined postMessage(any message, sequence transfer); + undefined postMessage(any message, optional PostMessageOptions options = {}); + attribute EventHandler onmessage; + attribute EventHandler onmessageerror; +}; + +dictionary WorkerOptions { + WorkerType type = "classic"; + RequestCredentials credentials = "same-origin"; // credentials is only used if type is "module" + DOMString name = ""; +}; + +enum WorkerType { "classic", "module" }; + +Worker includes AbstractWorker;[Exposed=Window] +interface SharedWorker : EventTarget { + constructor(USVString scriptURL, optional (DOMString or WorkerOptions) options = {}); + + readonly attribute MessagePort port; +}; +SharedWorker includes AbstractWorker;interface mixin NavigatorConcurrentHardware { + readonly attribute unsigned long long hardwareConcurrency; +};[Exposed=Worker] +interface WorkerNavigator {}; +WorkerNavigator includes NavigatorID; +WorkerNavigator includes NavigatorLanguage; +WorkerNavigator includes NavigatorOnLine; +WorkerNavigator includes NavigatorConcurrentHardware;[Exposed=Worker] +interface WorkerLocation { + stringifier readonly attribute USVString href; + readonly attribute USVString origin; + readonly attribute USVString protocol; + readonly attribute USVString host; + readonly attribute USVString hostname; + readonly attribute USVString port; + readonly attribute USVString pathname; + readonly attribute USVString search; + readonly attribute USVString hash; +};partial interface Window { + [SameObject, SecureContext] readonly attribute Worklet fakeWorklet1; + [SameObject, SecureContext] readonly attribute Worklet fakeWorklet2; +};[Global=(Worklet,FakeWorklet), + Exposed=FakeWorklet, + SecureContext] +interface FakeWorkletGlobalScope { + undefined registerFake(DOMString type, Function classConstructor); +};[Exposed=Worklet, SecureContext] +interface WorkletGlobalScope {};[Exposed=Window, SecureContext] +interface Worklet { + [NewObject] Promise addModule(USVString moduleURL, optional WorkletOptions options = {}); +}; + +dictionary WorkletOptions { + RequestCredentials credentials = "same-origin"; +};[Exposed=Window] +interface Storage { + readonly attribute unsigned long length; + DOMString? key(unsigned long index); + getter DOMString? getItem(DOMString key); + setter undefined setItem(DOMString key, DOMString value); + deleter undefined removeItem(DOMString key); + undefined clear(); +};interface mixin WindowSessionStorage { + readonly attribute Storage sessionStorage; +}; +Window includes WindowSessionStorage;interface mixin WindowLocalStorage { + readonly attribute Storage localStorage; +}; +Window includes WindowLocalStorage;[Exposed=Window] +interface StorageEvent : Event { + constructor(DOMString type, optional StorageEventInit eventInitDict = {}); + + readonly attribute DOMString? key; + readonly attribute DOMString? oldValue; + readonly attribute DOMString? newValue; + readonly attribute USVString url; + readonly attribute Storage? storageArea; + + undefined initStorageEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional DOMString? key = null, optional DOMString? oldValue = null, optional DOMString? newValue = null, optional USVString url = "", optional Storage? storageArea = null); +}; + +dictionary StorageEventInit : EventInit { + DOMString? key = null; + DOMString? oldValue = null; + DOMString? newValue = null; + USVString url = ""; + Storage? storageArea = null; +};[Exposed=Window] +interface HTMLMarqueeElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString behavior; + [CEReactions] attribute DOMString bgColor; + [CEReactions] attribute DOMString direction; + [CEReactions] attribute DOMString height; + [CEReactions] attribute unsigned long hspace; + [CEReactions] attribute long loop; + [CEReactions] attribute unsigned long scrollAmount; + [CEReactions] attribute unsigned long scrollDelay; + [CEReactions] attribute boolean trueSpeed; + [CEReactions] attribute unsigned long vspace; + [CEReactions] attribute DOMString width; + + attribute EventHandler onbounce; + attribute EventHandler onfinish; + attribute EventHandler onstart; + + undefined start(); + undefined stop(); +};[Exposed=Window] +interface HTMLFrameSetElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString cols; + [CEReactions] attribute DOMString rows; +}; +HTMLFrameSetElement includes WindowEventHandlers;[Exposed=Window] +interface HTMLFrameElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute DOMString name; + [CEReactions] attribute DOMString scrolling; + [CEReactions] attribute USVString src; + [CEReactions] attribute DOMString frameBorder; + [CEReactions] attribute USVString longDesc; + [CEReactions] attribute boolean noResize; + readonly attribute Document? contentDocument; + readonly attribute WindowProxy? contentWindow; + + [CEReactions] attribute [LegacyNullToEmptyString] DOMString marginHeight; + [CEReactions] attribute [LegacyNullToEmptyString] DOMString marginWidth; +};partial interface HTMLAnchorElement { + [CEReactions] attribute DOMString coords; + [CEReactions] attribute DOMString charset; + [CEReactions] attribute DOMString name; + [CEReactions] attribute DOMString rev; + [CEReactions] attribute DOMString shape; +};partial interface HTMLAreaElement { + [CEReactions] attribute boolean noHref; +};partial interface HTMLBodyElement { + [CEReactions] attribute [LegacyNullToEmptyString] DOMString text; + [CEReactions] attribute [LegacyNullToEmptyString] DOMString link; + [CEReactions] attribute [LegacyNullToEmptyString] DOMString vLink; + [CEReactions] attribute [LegacyNullToEmptyString] DOMString aLink; + [CEReactions] attribute [LegacyNullToEmptyString] DOMString bgColor; + [CEReactions] attribute DOMString background; +};partial interface HTMLBRElement { + [CEReactions] attribute DOMString clear; +};partial interface HTMLTableCaptionElement { + [CEReactions] attribute DOMString align; +};partial interface HTMLTableColElement { + [CEReactions] attribute DOMString align; + [CEReactions] attribute DOMString ch; + [CEReactions] attribute DOMString chOff; + [CEReactions] attribute DOMString vAlign; + [CEReactions] attribute DOMString width; +};[Exposed=Window] +interface HTMLDirectoryElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute boolean compact; +};partial interface HTMLDivElement { + [CEReactions] attribute DOMString align; +};partial interface HTMLDListElement { + [CEReactions] attribute boolean compact; +};partial interface HTMLEmbedElement { + [CEReactions] attribute DOMString align; + [CEReactions] attribute DOMString name; +};[Exposed=Window] +interface HTMLFontElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute [LegacyNullToEmptyString] DOMString color; + [CEReactions] attribute DOMString face; + [CEReactions] attribute DOMString size; +};partial interface HTMLHeadingElement { + [CEReactions] attribute DOMString align; +};partial interface HTMLHRElement { + [CEReactions] attribute DOMString align; + [CEReactions] attribute DOMString color; + [CEReactions] attribute boolean noShade; + [CEReactions] attribute DOMString size; + [CEReactions] attribute DOMString width; +};partial interface HTMLHtmlElement { + [CEReactions] attribute DOMString version; +};partial interface HTMLIFrameElement { + [CEReactions] attribute DOMString align; + [CEReactions] attribute DOMString scrolling; + [CEReactions] attribute DOMString frameBorder; + [CEReactions] attribute USVString longDesc; + + [CEReactions] attribute [LegacyNullToEmptyString] DOMString marginHeight; + [CEReactions] attribute [LegacyNullToEmptyString] DOMString marginWidth; +};partial interface HTMLImageElement { + [CEReactions] attribute DOMString name; + [CEReactions] attribute USVString lowsrc; + [CEReactions] attribute DOMString align; + [CEReactions] attribute unsigned long hspace; + [CEReactions] attribute unsigned long vspace; + [CEReactions] attribute USVString longDesc; + + [CEReactions] attribute [LegacyNullToEmptyString] DOMString border; +};partial interface HTMLInputElement { + [CEReactions] attribute DOMString align; + [CEReactions] attribute DOMString useMap; +};partial interface HTMLLegendElement { + [CEReactions] attribute DOMString align; +};partial interface HTMLLIElement { + [CEReactions] attribute DOMString type; +};partial interface HTMLLinkElement { + [CEReactions] attribute DOMString charset; + [CEReactions] attribute DOMString rev; + [CEReactions] attribute DOMString target; +};partial interface HTMLMenuElement { + [CEReactions] attribute boolean compact; +};partial interface HTMLMetaElement { + [CEReactions] attribute DOMString scheme; +};partial interface HTMLObjectElement { + [CEReactions] attribute DOMString align; + [CEReactions] attribute DOMString archive; + [CEReactions] attribute DOMString code; + [CEReactions] attribute boolean declare; + [CEReactions] attribute unsigned long hspace; + [CEReactions] attribute DOMString standby; + [CEReactions] attribute unsigned long vspace; + [CEReactions] attribute DOMString codeBase; + [CEReactions] attribute DOMString codeType; + + [CEReactions] attribute [LegacyNullToEmptyString] DOMString border; +};partial interface HTMLOListElement { + [CEReactions] attribute boolean compact; +};partial interface HTMLParagraphElement { + [CEReactions] attribute DOMString align; +};partial interface HTMLParamElement { + [CEReactions] attribute DOMString type; + [CEReactions] attribute DOMString valueType; +};partial interface HTMLPreElement { + [CEReactions] attribute long width; +};partial interface HTMLStyleElement { + [CEReactions] attribute DOMString type; +};partial interface HTMLScriptElement { + [CEReactions] attribute DOMString charset; + [CEReactions] attribute DOMString event; + [CEReactions] attribute DOMString htmlFor; +};partial interface HTMLTableElement { + [CEReactions] attribute DOMString align; + [CEReactions] attribute DOMString border; + [CEReactions] attribute DOMString frame; + [CEReactions] attribute DOMString rules; + [CEReactions] attribute DOMString summary; + [CEReactions] attribute DOMString width; + + [CEReactions] attribute [LegacyNullToEmptyString] DOMString bgColor; + [CEReactions] attribute [LegacyNullToEmptyString] DOMString cellPadding; + [CEReactions] attribute [LegacyNullToEmptyString] DOMString cellSpacing; +};partial interface HTMLTableSectionElement { + [CEReactions] attribute DOMString align; + [CEReactions] attribute DOMString ch; + [CEReactions] attribute DOMString chOff; + [CEReactions] attribute DOMString vAlign; +};partial interface HTMLTableCellElement { + [CEReactions] attribute DOMString align; + [CEReactions] attribute DOMString axis; + [CEReactions] attribute DOMString height; + [CEReactions] attribute DOMString width; + + [CEReactions] attribute DOMString ch; + [CEReactions] attribute DOMString chOff; + [CEReactions] attribute boolean noWrap; + [CEReactions] attribute DOMString vAlign; + + [CEReactions] attribute [LegacyNullToEmptyString] DOMString bgColor; +};partial interface HTMLTableRowElement { + [CEReactions] attribute DOMString align; + [CEReactions] attribute DOMString ch; + [CEReactions] attribute DOMString chOff; + [CEReactions] attribute DOMString vAlign; + + [CEReactions] attribute [LegacyNullToEmptyString] DOMString bgColor; +};partial interface HTMLUListElement { + [CEReactions] attribute boolean compact; + [CEReactions] attribute DOMString type; +};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; + + undefined clear(); + undefined captureEvents(); + undefined releaseEvents(); + + [SameObject] readonly attribute HTMLAllCollection all; +};partial interface Window { + undefined captureEvents(); + undefined releaseEvents(); + + [Replaceable, SameObject] readonly attribute External external; +};[Exposed=Window] +interface External { + undefined AddSearchProvider(); + undefined IsSearchProviderInstalled(); +}; \ No newline at end of file diff --git a/Example/get-webidl.js b/Example/get-webidl.js new file mode 100644 index 0000000..711f3cc --- /dev/null +++ b/Example/get-webidl.js @@ -0,0 +1,13 @@ +const cheerio = require('cheerio') +const fetch = require('node-fetch') +const fs = require('fs') + +fetch(`https://${process.argv[2]}.spec.whatwg.org`) + .then(res => res.text()) + .then(html => cheerio.load(html)) + .then($ => $('.idl.def, pre code.idl').text()) + .then(idl => { + fs.writeFileSync(`WebIDL-files/${process.argv[2]}.webidl`, idl) + console.log(`Wrote ${idl.split('\n').length.toLocaleString()} lines!`) + }) + .catch(err => console.error("Failed!", err)) diff --git a/Example/package-lock.json b/Example/package-lock.json index 971d92b..8a85c3f 100644 --- a/Example/package-lock.json +++ b/Example/package-lock.json @@ -599,6 +599,12 @@ "multicast-dns-service-types": "^1.1.0" } }, + "boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", + "dev": true + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -842,6 +848,34 @@ } } }, + "cheerio": { + "version": "1.0.0-rc.5", + "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.5.tgz", + "integrity": "sha512-yoqps/VCaZgN4pfXtenwHROTp8NG6/Hlt4Jpz2FEP0ZJQ+ZUkVDd0hAPDNKhj3nakpfPt/CNs57yEtxD1bXQiw==", + "dev": true, + "requires": { + "cheerio-select-tmp": "^0.1.0", + "dom-serializer": "~1.2.0", + "domhandler": "^4.0.0", + "entities": "~2.1.0", + "htmlparser2": "^6.0.0", + "parse5": "^6.0.0", + "parse5-htmlparser2-tree-adapter": "^6.0.0" + } + }, + "cheerio-select-tmp": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/cheerio-select-tmp/-/cheerio-select-tmp-0.1.1.tgz", + "integrity": "sha512-YYs5JvbpU19VYJyj+F7oYrIE2BOll1/hRU7rEy/5+v9BzkSo3bK81iAeeQEMI92vRIxz677m72UmJUiVwwgjfQ==", + "dev": true, + "requires": { + "css-select": "^3.1.2", + "css-what": "^4.0.0", + "domelementtype": "^2.1.0", + "domhandler": "^4.0.0", + "domutils": "^2.4.4" + } + }, "chokidar": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.4.0.tgz", @@ -1238,6 +1272,25 @@ "randomfill": "^1.0.3" } }, + "css-select": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-3.1.2.tgz", + "integrity": "sha512-qmss1EihSuBNWNNhHjxzxSfJoFBM/lERB/Q4EnsJQQC62R2evJDW481091oAdOr9uh46/0n4nrg0It5cAnj1RA==", + "dev": true, + "requires": { + "boolbase": "^1.0.0", + "css-what": "^4.0.0", + "domhandler": "^4.0.0", + "domutils": "^2.4.3", + "nth-check": "^2.0.0" + } + }, + "css-what": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-4.0.0.tgz", + "integrity": "sha512-teijzG7kwYfNVsUh2H/YN62xW3KK9YhXEgSlbxMlcyjPNvdKJqFx5lrwlJgoFP1ZHlB89iGDlo/JyshKeRhv5A==", + "dev": true + }, "cyclist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-1.0.1.tgz", @@ -1432,12 +1485,49 @@ "buffer-indexof": "^1.0.0" } }, + "dom-serializer": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.2.0.tgz", + "integrity": "sha512-n6kZFH/KlCrqs/1GHMOd5i2fd/beQHuehKdWvNNffbGHTr/almdhuVvTVFb3V7fglz+nC50fFusu3lY33h12pA==", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "entities": "^2.0.0" + } + }, "domain-browser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", "dev": true }, + "domelementtype": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.1.0.tgz", + "integrity": "sha512-LsTgx/L5VpD+Q8lmsXSHW2WpA+eBlZ9HPf3erD1IoPF00/3JKHZ3BknUVA2QGDNu69ZNmyFmCWBSO45XjYKC5w==", + "dev": true + }, + "domhandler": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.0.0.tgz", + "integrity": "sha512-KPTbnGQ1JeEMQyO1iYXoagsI6so/C96HZiFyByU3T6iAzpXn8EGEvct6unm1ZGoed8ByO2oirxgwxBmqKF9haA==", + "dev": true, + "requires": { + "domelementtype": "^2.1.0" + } + }, + "domutils": { + "version": "2.4.4", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.4.4.tgz", + "integrity": "sha512-jBC0vOsECI4OMdD0GC9mGn7NXPLb+Qt6KW1YDQzeQYRUFKmNG8lh7mO5HiELfr+lLQE7loDVI4QcAxV80HS+RA==", + "dev": true, + "requires": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0" + } + }, "duplexify": { "version": "3.7.1", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", @@ -1590,6 +1680,12 @@ } } }, + "entities": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", + "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==", + "dev": true + }, "errno": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", @@ -2476,6 +2572,18 @@ "integrity": "sha512-rhE/4Z3hIhzHAUKbW8jVcCyuT5oJCXXqhN/6mXXVCpzTmvJnoH2HL/bt3EZ6p55jbFJBeAe1ZNpL5BugLujxNA==", "dev": true }, + "htmlparser2": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.0.0.tgz", + "integrity": "sha512-numTQtDZMoh78zJpaNdJ9MXb2cv5G3jwUoe3dMQODubZvLoGvTE/Ofp6sHvH8OGKcN/8A47pGLi/k58xHP/Tfw==", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "domutils": "^2.4.4", + "entities": "^2.0.0" + } + }, "http-deceiver": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", @@ -3316,6 +3424,12 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, + "node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", + "dev": true + }, "node-forge": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.9.0.tgz", @@ -3425,6 +3539,15 @@ "path-key": "^2.0.0" } }, + "nth-check": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.0.0.tgz", + "integrity": "sha512-i4sc/Kj8htBrAiH1viZ0TgU8Y5XqCaV/FziYK6TBczxmeKm3AEFWqqF3195yKudrarqy7Zu80Ra5dobFjn9X/Q==", + "dev": true, + "requires": { + "boolbase": "^1.0.0" + } + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -3703,6 +3826,21 @@ "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", "dev": true }, + "parse5": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", + "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", + "dev": true + }, + "parse5-htmlparser2-tree-adapter": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz", + "integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==", + "dev": true, + "requires": { + "parse5": "^6.0.1" + } + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", diff --git a/Example/package.json b/Example/package.json index 26ded69..84b9bf8 100644 --- a/Example/package.json +++ b/Example/package.json @@ -9,11 +9,14 @@ "javascript-kit-swift": "file:./HelloWorld/.build/checkouts/JavaScriptKit/Runtime" }, "devDependencies": { + "cheerio": "1.0.0-rc.5", + "node-fetch": "^2.6.1", "webpack": "^4.42.0", "webpack-cli": "^3.3.11", "webpack-dev-server": "^3.10.3" }, "scripts": { + "generate-webidl": "node get-webidl.js dom; node get-webidl.js html", "build": "webpack", "start": "webpack-dev-server" }, diff --git a/Package.resolved b/Package.resolved index 60c83d4..729a005 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,15 +1,6 @@ { "object": { "pins": [ - { - "package": "swift-argument-parser", - "repositoryURL": "https://github.com/apple/swift-argument-parser", - "state": { - "branch": null, - "revision": "223d62adc52d51669ae2ee19bdb8b7d9fd6fcd9c", - "version": "0.0.6" - } - }, { "package": "swift-format", "repositoryURL": "https://github.com/apple/swift-format.git", diff --git a/Sources/WebIDL/IntermediateRepresentation/IRGenerator.swift b/Sources/WebIDL/IntermediateRepresentation/IRGenerator.swift index 5778f4c..4147aa4 100644 --- a/Sources/WebIDL/IntermediateRepresentation/IRGenerator.swift +++ b/Sources/WebIDL/IntermediateRepresentation/IRGenerator.swift @@ -284,8 +284,6 @@ public class IRGenerator { case .any: return ir.registerBasicType(withTypeName: "JSValue") - case .undefined: - return ir.registerBasicType(withTypeName: "Void") case .promiseType(let promise): let returnType = handleType(promise.returnType) @@ -417,6 +415,8 @@ public class IRGenerator { return ir.registerBasicType(withTypeName: "Int8") case .octet: return ir.registerBasicType(withTypeName: "UInt8") + case .undefined: + return ir.registerBasicType(withTypeName: "Void") } } diff --git a/Sources/WebIDL/Parser/Models.swift b/Sources/WebIDL/Parser/Models.swift index d65edbc..fc65b7e 100644 --- a/Sources/WebIDL/Parser/Models.swift +++ b/Sources/WebIDL/Parser/Models.swift @@ -285,7 +285,6 @@ public indirect enum SingleType: Equatable { case distinguishableType(DistinguishableType) case any - case undefined case promiseType(Promise) } @@ -358,6 +357,7 @@ public enum StringType: String, Equatable, Hashable { public enum PrimitiveType: Equatable { case UnsignedIntegerType(UnsignedIntegerType) case UnrestrictedFloatType(UnrestrictedFloatType) + case undefined case boolean case byte case octet diff --git a/Sources/WebIDL/Parser/Parser.swift b/Sources/WebIDL/Parser/Parser.swift index b0e007b..e1d2d25 100644 --- a/Sources/WebIDL/Parser/Parser.swift +++ b/Sources/WebIDL/Parser/Parser.swift @@ -1635,7 +1635,6 @@ public class Parser { SingleType :: DistinguishableType any - undefined void [removed from most recent spec] PromiseType */ @@ -1649,10 +1648,6 @@ public class Parser { tokens.removeFirst() return .any - case .terminal(.undefined), .terminal(.void): - tokens.removeFirst() - return .undefined - case let token where firstSet(for: .PromiseType).contains(token): let promise = try parsePromiseType() return .promiseType(promise) @@ -1809,6 +1804,8 @@ public class Parser { PrimitiveType :: UnsignedIntegerType UnrestrictedFloatType + undefined + void [deprecated] boolean byte octet @@ -1821,6 +1818,10 @@ public class Parser { case let token where firstSet(for: .UnrestrictedFloatType).contains(token): return .UnrestrictedFloatType(try parseUnrestrictedFloatType()) + case .terminal(.undefined), .terminal(.void): + tokens.removeFirst() + return .undefined + case .terminal(.boolean): tokens.removeFirst() return .boolean @@ -2445,7 +2446,7 @@ func firstSet(for symbol: NonTerminal) -> Set { case .SingleType: return union( firstSet(for: .DistinguishableType), - [.terminal(.any), .terminal(.undefined), .terminal(.void)], + [.terminal(.any)], firstSet(for: .PromiseType) ) @@ -2474,6 +2475,8 @@ func firstSet(for symbol: NonTerminal) -> Set { case .PrimitiveType: let terminals: Set = [ + .terminal(.void), + .terminal(.undefined), .terminal(.boolean), .terminal(.byte), .terminal(.octet), diff --git a/Tests/webidl2swiftTests/ParserTests.swift b/Tests/webidl2swiftTests/ParserTests.swift index 4c02bc8..b57c916 100644 --- a/Tests/webidl2swiftTests/ParserTests.swift +++ b/Tests/webidl2swiftTests/ParserTests.swift @@ -171,7 +171,7 @@ final class ParserTests: XCTestCase { XCTAssertEqual(definitions as! [CallbackInterface], [ CallbackInterface(identifer: "A", extendedAttributeList: [], callbackInterfaceMembers: [ - .regularOperation(.init(returnType: .single(.undefined), operationName: .identifier("handle"), argumentList: [.init(rest: .nonOptional(.single(.any), true, .identifier("data")), extendedAttributeList: [])]), []) + .regularOperation(.init(returnType: .single(.distinguishableType(.primitive(.undefined, false))), operationName: .identifier("handle"), argumentList: [.init(rest: .nonOptional(.single(.any), true, .identifier("data")), extendedAttributeList: [])]), []) ]) ]) } @@ -185,7 +185,7 @@ final class ParserTests: XCTestCase { let definitions = try parser.parse() XCTAssertEqual(definitions as! [Callback], [ - Callback(identifier: "CallbackHandler", extendedAttributeList: [], returnType: .single(.undefined), argumentList: []) + Callback(identifier: "CallbackHandler", extendedAttributeList: [], returnType: .single(.distinguishableType(.primitive(.undefined, false))), argumentList: []) ]) } }