瀏覽代碼

LibWeb: Update DOM IDL specs

I noticed some of these were running behind the upstream spec.
Jelle Raaijmakers 9 月之前
父節點
當前提交
d5fd29adb7

+ 1 - 1
Userland/Libraries/LibWeb/DOM/AbortController.idl

@@ -1,7 +1,7 @@
 #import <DOM/AbortSignal.idl>
 
 // https://dom.spec.whatwg.org/#interface-abortcontroller
-[Exposed=(Window,Worker)]
+[Exposed=*]
 interface AbortController {
     constructor();
 

+ 1 - 1
Userland/Libraries/LibWeb/DOM/AbortSignal.idl

@@ -2,7 +2,7 @@
 #import <DOM/EventHandler.idl>
 
 // 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);

+ 2 - 2
Userland/Libraries/LibWeb/DOM/CustomEvent.idl

@@ -1,13 +1,13 @@
 #import <DOM/Event.idl>
 
 // 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 {

+ 2 - 4
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
 };

+ 0 - 6
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<JS::Handle<EventTarget>> Event::composed_path() const
 {

+ 4 - 2
Userland/Libraries/LibWeb/DOM/Event.h

@@ -9,6 +9,7 @@
 #include <AK/FlyString.h>
 #include <LibWeb/Bindings/PlatformObject.h>
 #include <LibWeb/DOM/EventTarget.h>
+#include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h>
 
 namespace Web::DOM {
 
@@ -54,7 +55,8 @@ public:
 
     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 @@ private:
     Path m_path;
     TouchTargetList m_touch_target_list;
 
-    double m_time_stamp { 0 };
+    HighResolutionTime::DOMHighResTimeStamp m_time_stamp { 0 };
 
     void set_cancelled_flag();
 };

+ 6 - 7
Userland/Libraries/LibWeb/DOM/Event.idl

@@ -1,9 +1,9 @@
 #import <DOM/EventTarget.idl>
+#import <HighResolutionTime/DOMHighResTimeStamp.idl>
 
 // 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 {

+ 5 - 3
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;
 };

+ 0 - 2
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);
-
 };

+ 0 - 4
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<MutationRecord> takeRecords();
-
 };
 
 callback MutationCallback = undefined (sequence<MutationRecord> mutations, MutationObserver observer);
 
 dictionary MutationObserverInit {
-
     boolean childList = false;
     boolean attributes;
     boolean characterData;
@@ -24,5 +21,4 @@ dictionary MutationObserverInit {
     boolean attributeOldValue;
     boolean characterDataOldValue;
     sequence<DOMString> attributeFilter;
-
 };

+ 0 - 2
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;
-
 };

+ 0 - 1
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);
 };

+ 1 - 1
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;

+ 0 - 2
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();
-
 };

+ 3 - 4
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);
-
 };

+ 7 - 6
Userland/Libraries/LibWeb/DOM/StaticRange.idl

@@ -1,15 +1,16 @@
 #import <DOM/Node.idl>
 #import <DOM/AbstractRange.idl>
 
-// https://dom.spec.whatwg.org/#staticrange
-[Exposed=Window]
-interface StaticRange : AbstractRange {
-    constructor(StaticRangeInit init);
-};
-
+// https://dom.spec.whatwg.org/#dictdef-staticrangeinit
 dictionary StaticRangeInit {
     required Node startContainer;
     required unsigned long startOffset;
     required Node endContainer;
     required unsigned long endOffset;
 };
+
+// https://dom.spec.whatwg.org/#staticrange
+[Exposed=Window]
+interface StaticRange : AbstractRange {
+    constructor(StaticRangeInit init);
+};

+ 0 - 2
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();
-
 };

+ 1 - 2
Userland/Libraries/LibWeb/DOM/XMLDocument.idl

@@ -2,5 +2,4 @@
 
 // https://dom.spec.whatwg.org/#xmldocument
 [Exposed=Window]
-interface XMLDocument : Document {
-};
+interface XMLDocument : Document {};