LibWeb: Update DOM IDL specs

I noticed some of these were running behind the upstream spec.
This commit is contained in:
Jelle Raaijmakers 2024-10-14 11:55:51 +02:00 committed by Tim Flynn
commit d5fd29adb7
Notes: github-actions[bot] 2024-10-14 16:00:25 +00:00
18 changed files with 33 additions and 52 deletions

View file

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

View file

@ -2,7 +2,7 @@
#import <DOM/EventHandler.idl> #import <DOM/EventHandler.idl>
// https://dom.spec.whatwg.org/#interface-AbortSignal // https://dom.spec.whatwg.org/#interface-AbortSignal
[Exposed=(Window,Worker), CustomVisit] [Exposed=*]
interface AbortSignal : EventTarget { interface AbortSignal : EventTarget {
[NewObject] static AbortSignal abort(optional any reason); [NewObject] static AbortSignal abort(optional any reason);
[Exposed=(Window,Worker), NewObject] static AbortSignal timeout([EnforceRange] unsigned long long milliseconds); [Exposed=(Window,Worker), NewObject] static AbortSignal timeout([EnforceRange] unsigned long long milliseconds);

View file

@ -1,13 +1,13 @@
#import <DOM/Event.idl> #import <DOM/Event.idl>
// https://dom.spec.whatwg.org/#interface-customevent // https://dom.spec.whatwg.org/#interface-customevent
[Exposed=(Window,Worker)] [Exposed=*]
interface CustomEvent : Event { interface CustomEvent : Event {
constructor(DOMString type, optional CustomEventInit eventInitDict = {}); constructor(DOMString type, optional CustomEventInit eventInitDict = {});
readonly attribute any detail; 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 { dictionary CustomEventInit : EventInit {

View file

@ -4,11 +4,9 @@
// https://dom.spec.whatwg.org/#domimplementation // https://dom.spec.whatwg.org/#domimplementation
[Exposed=Window] [Exposed=Window]
interface DOMImplementation { 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] XMLDocument createDocument([FlyString] DOMString? namespace, [LegacyNullToEmptyString] DOMString qualifiedName, optional DocumentType? doctype = null);
[NewObject] Document createHTMLDocument(optional DOMString title); [NewObject] Document createHTMLDocument(optional DOMString title);
[NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);
boolean hasFeature();
boolean hasFeature(); // useless; always returns true
}; };

View file

@ -145,12 +145,6 @@ void Event::init_event(String const& type, bool bubbles, bool cancelable)
initialize_event(type, bubbles, 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 // https://dom.spec.whatwg.org/#dom-event-composedpath
Vector<JS::Handle<EventTarget>> Event::composed_path() const Vector<JS::Handle<EventTarget>> Event::composed_path() const
{ {

View file

@ -9,6 +9,7 @@
#include <AK/FlyString.h> #include <AK/FlyString.h>
#include <LibWeb/Bindings/PlatformObject.h> #include <LibWeb/Bindings/PlatformObject.h>
#include <LibWeb/DOM/EventTarget.h> #include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/HighResolutionTime/DOMHighResTimeStamp.h>
namespace Web::DOM { namespace Web::DOM {
@ -54,7 +55,8 @@ public:
virtual ~Event() = default; 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; } FlyString const& type() const { return m_type; }
void set_type(FlyString const& type) { m_type = type; } void set_type(FlyString const& type) { m_type = type; }
@ -180,7 +182,7 @@ private:
Path m_path; Path m_path;
TouchTargetList m_touch_target_list; TouchTargetList m_touch_target_list;
double m_time_stamp { 0 }; HighResolutionTime::DOMHighResTimeStamp m_time_stamp { 0 };
void set_cancelled_flag(); void set_cancelled_flag();
}; };

View file

@ -1,9 +1,9 @@
#import <DOM/EventTarget.idl> #import <DOM/EventTarget.idl>
#import <HighResolutionTime/DOMHighResTimeStamp.idl>
// https://dom.spec.whatwg.org/#event // https://dom.spec.whatwg.org/#event
[Exposed=*] [Exposed=*]
interface Event { interface Event {
constructor(DOMString type, optional EventInit eventInitDict = {}); constructor(DOMString type, optional EventInit eventInitDict = {});
readonly attribute DOMString type; readonly attribute DOMString type;
@ -19,21 +19,20 @@ interface Event {
readonly attribute unsigned short eventPhase; readonly attribute unsigned short eventPhase;
undefined stopPropagation(); undefined stopPropagation();
attribute boolean cancelBubble; attribute boolean cancelBubble; // legacy alias of .stopPropagation()
undefined stopImmediatePropagation(); undefined stopImmediatePropagation();
readonly attribute boolean bubbles; readonly attribute boolean bubbles;
readonly attribute boolean cancelable; readonly attribute boolean cancelable;
attribute boolean returnValue; attribute boolean returnValue; // legacy
undefined preventDefault(); undefined preventDefault();
readonly attribute boolean defaultPrevented; readonly attribute boolean defaultPrevented;
readonly attribute boolean composed; readonly attribute boolean composed;
readonly attribute boolean isTrusted; [LegacyUnforgeable] readonly attribute boolean isTrusted;
readonly attribute double timeStamp; readonly attribute DOMHighResTimeStamp timeStamp;
undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false);
undefined initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false); // legacy
}; };
dictionary EventInit { dictionary EventInit {

View file

@ -3,16 +3,18 @@
// https://dom.spec.whatwg.org/#eventtarget // https://dom.spec.whatwg.org/#eventtarget
[Exposed=*] [Exposed=*]
interface EventTarget { interface EventTarget {
constructor(); constructor();
undefined addEventListener(DOMString type, EventListener? callback, optional (AddEventListenerOptions or boolean) options = {}); undefined addEventListener(DOMString type, EventListener? callback, optional (AddEventListenerOptions or boolean) options = {});
undefined removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options = {}); undefined removeEventListener(DOMString type, EventListener? callback, optional (EventListenerOptions or boolean) options = {});
[ImplementedAs=dispatch_event_binding] boolean dispatchEvent(Event event); [ImplementedAs=dispatch_event_binding] boolean dispatchEvent(Event event);
}; };
// FIXME: support callback interface
//callback interface EventListener {
// undefined handleEvent(Event event);
//};
dictionary EventListenerOptions { dictionary EventListenerOptions {
boolean capture = false; boolean capture = false;
}; };

View file

@ -3,9 +3,7 @@
// https://dom.spec.whatwg.org/#interface-htmlcollection // https://dom.spec.whatwg.org/#interface-htmlcollection
[Exposed=Window, LegacyUnenumerableNamedProperties] [Exposed=Window, LegacyUnenumerableNamedProperties]
interface HTMLCollection { interface HTMLCollection {
readonly attribute unsigned long length; readonly attribute unsigned long length;
getter Element? item(unsigned long index); getter Element? item(unsigned long index);
getter Element? namedItem(DOMString name); getter Element? namedItem(DOMString name);
}; };

View file

@ -4,19 +4,16 @@
// https://dom.spec.whatwg.org/#interface-mutationobserver // https://dom.spec.whatwg.org/#interface-mutationobserver
[Exposed=Window] [Exposed=Window]
interface MutationObserver { interface MutationObserver {
constructor(MutationCallback callback); constructor(MutationCallback callback);
undefined observe(Node target, optional MutationObserverInit options = {}); undefined observe(Node target, optional MutationObserverInit options = {});
undefined disconnect(); undefined disconnect();
sequence<MutationRecord> takeRecords(); sequence<MutationRecord> takeRecords();
}; };
callback MutationCallback = undefined (sequence<MutationRecord> mutations, MutationObserver observer); callback MutationCallback = undefined (sequence<MutationRecord> mutations, MutationObserver observer);
dictionary MutationObserverInit { dictionary MutationObserverInit {
boolean childList = false; boolean childList = false;
boolean attributes; boolean attributes;
boolean characterData; boolean characterData;
@ -24,5 +21,4 @@ dictionary MutationObserverInit {
boolean attributeOldValue; boolean attributeOldValue;
boolean characterDataOldValue; boolean characterDataOldValue;
sequence<DOMString> attributeFilter; sequence<DOMString> attributeFilter;
}; };

View file

@ -4,7 +4,6 @@
// https://dom.spec.whatwg.org/#interface-mutationrecord // https://dom.spec.whatwg.org/#interface-mutationrecord
[Exposed=Window] [Exposed=Window]
interface MutationRecord { interface MutationRecord {
readonly attribute DOMString type; readonly attribute DOMString type;
[SameObject] readonly attribute Node target; [SameObject] readonly attribute Node target;
[SameObject] readonly attribute NodeList addedNodes; [SameObject] readonly attribute NodeList addedNodes;
@ -14,5 +13,4 @@ interface MutationRecord {
readonly attribute DOMString? attributeName; readonly attribute DOMString? attributeName;
readonly attribute DOMString? attributeNamespace; readonly attribute DOMString? attributeNamespace;
readonly attribute DOMString? oldValue; readonly attribute DOMString? oldValue;
}; };

View file

@ -11,7 +11,6 @@ interface NamedNodeMap {
[CEReactions] Attr? setNamedItem(Attr attr); [CEReactions] Attr? setNamedItem(Attr attr);
[CEReactions] Attr? setNamedItemNS(Attr attr); [CEReactions] Attr? setNamedItemNS(Attr attr);
[CEReactions] Attr removeNamedItem([FlyString] DOMString qualifiedName); [CEReactions] Attr removeNamedItem([FlyString] DOMString qualifiedName);
[CEReactions] Attr removeNamedItemNS([FlyString] DOMString? namespace, [FlyString] DOMString localName); [CEReactions] Attr removeNamedItemNS([FlyString] DOMString? namespace, [FlyString] DOMString localName);
}; };

View file

@ -43,7 +43,7 @@ interface Node : EventTarget {
[ImplementedAs=clone_node_binding, CEReactions] Node cloneNode(optional boolean deep = false); [ImplementedAs=clone_node_binding, CEReactions] Node cloneNode(optional boolean deep = false);
boolean isEqualNode(Node? otherNode); 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_DISCONNECTED = 0x01;
const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02; const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;

View file

@ -4,7 +4,6 @@
// https://dom.spec.whatwg.org/#interface-nodeiterator // https://dom.spec.whatwg.org/#interface-nodeiterator
[Exposed=Window] [Exposed=Window]
interface NodeIterator { interface NodeIterator {
[SameObject] readonly attribute Node root; [SameObject] readonly attribute Node root;
readonly attribute Node referenceNode; readonly attribute Node referenceNode;
readonly attribute boolean pointerBeforeReferenceNode; readonly attribute boolean pointerBeforeReferenceNode;
@ -15,5 +14,4 @@ interface NodeIterator {
Node? previousNode(); Node? previousNode();
undefined detach(); undefined detach();
}; };

View file

@ -5,7 +5,6 @@
// https://dom.spec.whatwg.org/#interface-range // https://dom.spec.whatwg.org/#interface-range
[Exposed=Window] [Exposed=Window]
interface Range : AbstractRange { interface Range : AbstractRange {
constructor(); constructor();
readonly attribute Node commonAncestorContainer; readonly attribute Node commonAncestorContainer;
@ -32,7 +31,7 @@ interface Range : AbstractRange {
[CEReactions] undefined insertNode(Node node); [CEReactions] undefined insertNode(Node node);
[CEReactions] undefined surroundContents(Node newParent); [CEReactions] undefined surroundContents(Node newParent);
Range cloneRange(); [NewObject] Range cloneRange();
undefined detach(); undefined detach();
boolean isPointInRange(Node node, unsigned long offset); boolean isPointInRange(Node node, unsigned long offset);
@ -40,13 +39,13 @@ interface Range : AbstractRange {
boolean intersectsNode(Node node); boolean intersectsNode(Node node);
// https://drafts.csswg.org/cssom-view/#extensions-to-the-range-interface
DOMRectList getClientRects(); DOMRectList getClientRects();
DOMRect getBoundingClientRect(); [NewObject] DOMRect getBoundingClientRect();
stringifier; stringifier;
// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment
// FIXME: [CEReactions, NewObject] DocumentFragment createContextualFragment((TrustedHTML or DOMString) string); // FIXME: [CEReactions, NewObject] DocumentFragment createContextualFragment((TrustedHTML or DOMString) string);
[CEReactions, NewObject] DocumentFragment createContextualFragment(DOMString string); [CEReactions, NewObject] DocumentFragment createContextualFragment(DOMString string);
}; };

View file

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

View file

@ -4,7 +4,6 @@
// https://dom.spec.whatwg.org/#interface-treewalker // https://dom.spec.whatwg.org/#interface-treewalker
[Exposed=Window] [Exposed=Window]
interface TreeWalker { interface TreeWalker {
[SameObject] readonly attribute Node root; [SameObject] readonly attribute Node root;
readonly attribute unsigned long whatToShow; readonly attribute unsigned long whatToShow;
readonly attribute NodeFilter? filter; readonly attribute NodeFilter? filter;
@ -17,5 +16,4 @@ interface TreeWalker {
Node? nextSibling(); Node? nextSibling();
Node? previousNode(); Node? previousNode();
Node? nextNode(); Node? nextNode();
}; };

View file

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