From 1d4f075780a52a9db38c6ebf314dd5b25e5efefa Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Mon, 14 Oct 2024 11:55:51 +0200 Subject: [PATCH] LibWeb: Update DOM IDL specs I noticed some of these were running behind the upstream spec. --- Userland/Libraries/LibWeb/DOM/AbortController.idl | 2 +- Userland/Libraries/LibWeb/DOM/AbortSignal.idl | 2 +- Userland/Libraries/LibWeb/DOM/CustomEvent.idl | 4 ++-- Userland/Libraries/LibWeb/DOM/DOMImplementation.idl | 6 ++---- Userland/Libraries/LibWeb/DOM/Event.cpp | 6 ------ Userland/Libraries/LibWeb/DOM/Event.h | 6 ++++-- Userland/Libraries/LibWeb/DOM/Event.idl | 13 ++++++------- Userland/Libraries/LibWeb/DOM/EventTarget.idl | 8 +++++--- Userland/Libraries/LibWeb/DOM/HTMLCollection.idl | 2 -- Userland/Libraries/LibWeb/DOM/MutationObserver.idl | 4 ---- Userland/Libraries/LibWeb/DOM/MutationRecord.idl | 2 -- Userland/Libraries/LibWeb/DOM/NamedNodeMap.idl | 1 - Userland/Libraries/LibWeb/DOM/Node.idl | 2 +- Userland/Libraries/LibWeb/DOM/NodeIterator.idl | 2 -- Userland/Libraries/LibWeb/DOM/Range.idl | 7 +++---- Userland/Libraries/LibWeb/DOM/StaticRange.idl | 10 +++++----- Userland/Libraries/LibWeb/DOM/TreeWalker.idl | 2 -- Userland/Libraries/LibWeb/DOM/XMLDocument.idl | 3 +-- 18 files changed, 31 insertions(+), 51 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/AbortController.idl b/Userland/Libraries/LibWeb/DOM/AbortController.idl index 657d29b127563..37e9009397128 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortController.idl +++ b/Userland/Libraries/LibWeb/DOM/AbortController.idl @@ -1,7 +1,7 @@ #import // https://dom.spec.whatwg.org/#interface-abortcontroller -[Exposed=(Window,Worker)] +[Exposed=*] interface AbortController { constructor(); diff --git a/Userland/Libraries/LibWeb/DOM/AbortSignal.idl b/Userland/Libraries/LibWeb/DOM/AbortSignal.idl index 92e54d16c09ca..724477444206b 100644 --- a/Userland/Libraries/LibWeb/DOM/AbortSignal.idl +++ b/Userland/Libraries/LibWeb/DOM/AbortSignal.idl @@ -2,7 +2,7 @@ #import // https://dom.spec.whatwg.org/#interface-AbortSignal -[Exposed=(Window,Worker), CustomVisit] +[Exposed=*] interface AbortSignal : EventTarget { [NewObject] static AbortSignal abort(optional any reason); [Exposed=(Window,Worker), NewObject] static AbortSignal timeout([EnforceRange] unsigned long long milliseconds); diff --git a/Userland/Libraries/LibWeb/DOM/CustomEvent.idl b/Userland/Libraries/LibWeb/DOM/CustomEvent.idl index 9c373bb132c9b..fbc2a61ecbfae 100644 --- a/Userland/Libraries/LibWeb/DOM/CustomEvent.idl +++ b/Userland/Libraries/LibWeb/DOM/CustomEvent.idl @@ -1,13 +1,13 @@ #import // https://dom.spec.whatwg.org/#interface-customevent -[Exposed=(Window,Worker)] +[Exposed=*] 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); + undefined initCustomEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any detail = null); // legacy }; dictionary CustomEventInit : EventInit { diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.idl b/Userland/Libraries/LibWeb/DOM/DOMImplementation.idl index 0d7dd1d9be17e..28fe6392402ee 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.idl +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.idl @@ -4,11 +4,9 @@ // https://dom.spec.whatwg.org/#domimplementation [Exposed=Window] interface DOMImplementation { - + [NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId); [NewObject] XMLDocument createDocument([FlyString] DOMString? namespace, [LegacyNullToEmptyString] DOMString qualifiedName, optional DocumentType? doctype = null); [NewObject] Document createHTMLDocument(optional DOMString title); - [NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId); - - boolean hasFeature(); + boolean hasFeature(); // useless; always returns true }; diff --git a/Userland/Libraries/LibWeb/DOM/Event.cpp b/Userland/Libraries/LibWeb/DOM/Event.cpp index a36bbadea2368..3707a411cf732 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.cpp +++ b/Userland/Libraries/LibWeb/DOM/Event.cpp @@ -145,12 +145,6 @@ void Event::init_event(String const& type, bool bubbles, bool cancelable) initialize_event(type, bubbles, cancelable); } -// https://dom.spec.whatwg.org/#dom-event-timestamp -double Event::time_stamp() const -{ - return m_time_stamp; -} - // https://dom.spec.whatwg.org/#dom-event-composedpath Vector> Event::composed_path() const { diff --git a/Userland/Libraries/LibWeb/DOM/Event.h b/Userland/Libraries/LibWeb/DOM/Event.h index ad9c1bcc6358a..0e57dbaa67463 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.h +++ b/Userland/Libraries/LibWeb/DOM/Event.h @@ -9,6 +9,7 @@ #include #include #include +#include namespace Web::DOM { @@ -54,7 +55,8 @@ class Event : public Bindings::PlatformObject { virtual ~Event() = default; - double time_stamp() const; + // https://dom.spec.whatwg.org/#dom-event-timestamp + HighResolutionTime::DOMHighResTimeStamp time_stamp() const { return m_time_stamp; } FlyString const& type() const { return m_type; } void set_type(FlyString const& type) { m_type = type; } @@ -180,7 +182,7 @@ class Event : public Bindings::PlatformObject { Path m_path; TouchTargetList m_touch_target_list; - double m_time_stamp { 0 }; + HighResolutionTime::DOMHighResTimeStamp m_time_stamp { 0 }; void set_cancelled_flag(); }; diff --git a/Userland/Libraries/LibWeb/DOM/Event.idl b/Userland/Libraries/LibWeb/DOM/Event.idl index 4bccbf4edf701..b081fcb918ca2 100644 --- a/Userland/Libraries/LibWeb/DOM/Event.idl +++ b/Userland/Libraries/LibWeb/DOM/Event.idl @@ -1,9 +1,9 @@ #import +#import // https://dom.spec.whatwg.org/#event [Exposed=*] interface Event { - constructor(DOMString type, optional EventInit eventInitDict = {}); readonly attribute DOMString type; @@ -19,21 +19,20 @@ interface Event { readonly attribute unsigned short eventPhase; undefined stopPropagation(); - attribute boolean cancelBubble; + attribute boolean cancelBubble; // legacy alias of .stopPropagation() undefined stopImmediatePropagation(); readonly attribute boolean bubbles; readonly attribute boolean cancelable; - attribute boolean returnValue; + attribute boolean returnValue; // legacy undefined preventDefault(); readonly attribute boolean defaultPrevented; readonly attribute boolean composed; - readonly attribute boolean isTrusted; - readonly attribute double timeStamp; - - undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); + [LegacyUnforgeable] readonly attribute boolean isTrusted; + readonly attribute DOMHighResTimeStamp timeStamp; + undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // legacy }; dictionary EventInit { diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.idl b/Userland/Libraries/LibWeb/DOM/EventTarget.idl index 4ac642b65fee9..d30fc3847c733 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.idl +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.idl @@ -3,16 +3,18 @@ // https://dom.spec.whatwg.org/#eventtarget [Exposed=*] 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 = {}); - [ImplementedAs=dispatch_event_binding] boolean dispatchEvent(Event event); - }; +// FIXME: support callback interface +//callback interface EventListener { +// undefined handleEvent(Event event); +//}; + dictionary EventListenerOptions { boolean capture = false; }; diff --git a/Userland/Libraries/LibWeb/DOM/HTMLCollection.idl b/Userland/Libraries/LibWeb/DOM/HTMLCollection.idl index dff67c2b4df86..cf09b0de3d386 100644 --- a/Userland/Libraries/LibWeb/DOM/HTMLCollection.idl +++ b/Userland/Libraries/LibWeb/DOM/HTMLCollection.idl @@ -3,9 +3,7 @@ // https://dom.spec.whatwg.org/#interface-htmlcollection [Exposed=Window, LegacyUnenumerableNamedProperties] interface HTMLCollection { - readonly attribute unsigned long length; getter Element? item(unsigned long index); getter Element? namedItem(DOMString name); - }; diff --git a/Userland/Libraries/LibWeb/DOM/MutationObserver.idl b/Userland/Libraries/LibWeb/DOM/MutationObserver.idl index 7c24ce41ef7d4..7776b4ee6410b 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationObserver.idl +++ b/Userland/Libraries/LibWeb/DOM/MutationObserver.idl @@ -4,19 +4,16 @@ // https://dom.spec.whatwg.org/#interface-mutationobserver [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; @@ -24,5 +21,4 @@ dictionary MutationObserverInit { boolean attributeOldValue; boolean characterDataOldValue; sequence attributeFilter; - }; diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.idl b/Userland/Libraries/LibWeb/DOM/MutationRecord.idl index db8a4790cb403..3462e5bd1e135 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationRecord.idl +++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.idl @@ -4,7 +4,6 @@ // https://dom.spec.whatwg.org/#interface-mutationrecord [Exposed=Window] interface MutationRecord { - readonly attribute DOMString type; [SameObject] readonly attribute Node target; [SameObject] readonly attribute NodeList addedNodes; @@ -14,5 +13,4 @@ interface MutationRecord { readonly attribute DOMString? attributeName; readonly attribute DOMString? attributeNamespace; readonly attribute DOMString? oldValue; - }; diff --git a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.idl b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.idl index 6a8b6d03f5bb2..51f185d81a3bf 100644 --- a/Userland/Libraries/LibWeb/DOM/NamedNodeMap.idl +++ b/Userland/Libraries/LibWeb/DOM/NamedNodeMap.idl @@ -11,7 +11,6 @@ interface NamedNodeMap { [CEReactions] Attr? setNamedItem(Attr attr); [CEReactions] Attr? setNamedItemNS(Attr attr); - [CEReactions] Attr removeNamedItem([FlyString] DOMString qualifiedName); [CEReactions] Attr removeNamedItemNS([FlyString] DOMString? namespace, [FlyString] DOMString localName); }; diff --git a/Userland/Libraries/LibWeb/DOM/Node.idl b/Userland/Libraries/LibWeb/DOM/Node.idl index 8bc4c00bdfa8b..fc7a2365f5736 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.idl +++ b/Userland/Libraries/LibWeb/DOM/Node.idl @@ -43,7 +43,7 @@ interface Node : EventTarget { [ImplementedAs=clone_node_binding, CEReactions] Node cloneNode(optional boolean deep = false); boolean isEqualNode(Node? otherNode); - boolean isSameNode(Node? otherNode); + boolean isSameNode(Node? otherNode); // legacy alias of === const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01; const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; diff --git a/Userland/Libraries/LibWeb/DOM/NodeIterator.idl b/Userland/Libraries/LibWeb/DOM/NodeIterator.idl index 576b2e625d22f..0530e45e69ea4 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeIterator.idl +++ b/Userland/Libraries/LibWeb/DOM/NodeIterator.idl @@ -4,7 +4,6 @@ // https://dom.spec.whatwg.org/#interface-nodeiterator [Exposed=Window] interface NodeIterator { - [SameObject] readonly attribute Node root; readonly attribute Node referenceNode; readonly attribute boolean pointerBeforeReferenceNode; @@ -15,5 +14,4 @@ interface NodeIterator { Node? previousNode(); undefined detach(); - }; diff --git a/Userland/Libraries/LibWeb/DOM/Range.idl b/Userland/Libraries/LibWeb/DOM/Range.idl index 29c4336a0e9ad..6a003332dd592 100644 --- a/Userland/Libraries/LibWeb/DOM/Range.idl +++ b/Userland/Libraries/LibWeb/DOM/Range.idl @@ -5,7 +5,6 @@ // https://dom.spec.whatwg.org/#interface-range [Exposed=Window] interface Range : AbstractRange { - constructor(); readonly attribute Node commonAncestorContainer; @@ -32,7 +31,7 @@ interface Range : AbstractRange { [CEReactions] undefined insertNode(Node node); [CEReactions] undefined surroundContents(Node newParent); - Range cloneRange(); + [NewObject] Range cloneRange(); undefined detach(); boolean isPointInRange(Node node, unsigned long offset); @@ -40,13 +39,13 @@ interface Range : AbstractRange { boolean intersectsNode(Node node); + // https://drafts.csswg.org/cssom-view/#extensions-to-the-range-interface DOMRectList getClientRects(); - DOMRect getBoundingClientRect(); + [NewObject] DOMRect getBoundingClientRect(); stringifier; // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment // FIXME: [CEReactions, NewObject] DocumentFragment createContextualFragment((TrustedHTML or DOMString) string); [CEReactions, NewObject] DocumentFragment createContextualFragment(DOMString string); - }; diff --git a/Userland/Libraries/LibWeb/DOM/StaticRange.idl b/Userland/Libraries/LibWeb/DOM/StaticRange.idl index 9e9a3567bc889..5180c885faa4c 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticRange.idl +++ b/Userland/Libraries/LibWeb/DOM/StaticRange.idl @@ -2,14 +2,14 @@ #import // https://dom.spec.whatwg.org/#staticrange -[Exposed=Window] -interface StaticRange : AbstractRange { - constructor(StaticRangeInit init); -}; - dictionary StaticRangeInit { required Node startContainer; required unsigned long startOffset; required Node endContainer; required unsigned long endOffset; }; + +[Exposed=Window] +interface StaticRange : AbstractRange { + constructor(StaticRangeInit init); +}; diff --git a/Userland/Libraries/LibWeb/DOM/TreeWalker.idl b/Userland/Libraries/LibWeb/DOM/TreeWalker.idl index 876ad210beee1..54ad34a2f1559 100644 --- a/Userland/Libraries/LibWeb/DOM/TreeWalker.idl +++ b/Userland/Libraries/LibWeb/DOM/TreeWalker.idl @@ -4,7 +4,6 @@ // https://dom.spec.whatwg.org/#interface-treewalker [Exposed=Window] interface TreeWalker { - [SameObject] readonly attribute Node root; readonly attribute unsigned long whatToShow; readonly attribute NodeFilter? filter; @@ -17,5 +16,4 @@ interface TreeWalker { Node? nextSibling(); Node? previousNode(); Node? nextNode(); - }; diff --git a/Userland/Libraries/LibWeb/DOM/XMLDocument.idl b/Userland/Libraries/LibWeb/DOM/XMLDocument.idl index d415bccd12418..63cf4fbbf04e9 100644 --- a/Userland/Libraries/LibWeb/DOM/XMLDocument.idl +++ b/Userland/Libraries/LibWeb/DOM/XMLDocument.idl @@ -2,5 +2,4 @@ // https://dom.spec.whatwg.org/#xmldocument [Exposed=Window] -interface XMLDocument : Document { -}; +interface XMLDocument : Document {};