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>
// https://dom.spec.whatwg.org/#interface-abortcontroller
[Exposed=(Window,Worker)]
[Exposed=*]
interface AbortController {
constructor();

View file

@ -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);

View file

@ -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 {

View file

@ -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
};

View file

@ -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
{

View file

@ -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();
};

View file

@ -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 {

View file

@ -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;
};

View file

@ -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);
};

View file

@ -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;
};

View file

@ -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;
};

View file

@ -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);
};

View file

@ -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;

View file

@ -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();
};

View file

@ -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);
};

View file

@ -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);
};

View file

@ -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();
};

View file

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