Skip to content

Commit

Permalink
LibWeb: Update DOM IDL specs
Browse files Browse the repository at this point in the history
I noticed some of these were running behind the upstream spec.
  • Loading branch information
gmta committed Oct 14, 2024
1 parent 8003d63 commit 1d4f075
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/DOM/AbortController.idl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import <DOM/AbortSignal.idl>

// https://dom.spec.whatwg.org/#interface-abortcontroller
[Exposed=(Window,Worker)]
[Exposed=*]
interface AbortController {
constructor();

Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/DOM/AbortSignal.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Userland/Libraries/LibWeb/DOM/CustomEvent.idl
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions Userland/Libraries/LibWeb/DOM/DOMImplementation.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
6 changes: 0 additions & 6 deletions Userland/Libraries/LibWeb/DOM/Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 4 additions & 2 deletions Userland/Libraries/LibWeb/DOM/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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();
};
Expand Down
13 changes: 6 additions & 7 deletions Userland/Libraries/LibWeb/DOM/Event.idl
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down
8 changes: 5 additions & 3 deletions Userland/Libraries/LibWeb/DOM/EventTarget.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
2 changes: 0 additions & 2 deletions Userland/Libraries/LibWeb/DOM/HTMLCollection.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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);

};
4 changes: 0 additions & 4 deletions Userland/Libraries/LibWeb/DOM/MutationObserver.idl
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,21 @@
// 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;
boolean subtree = false;
boolean attributeOldValue;
boolean characterDataOldValue;
sequence<DOMString> attributeFilter;

};
2 changes: 0 additions & 2 deletions Userland/Libraries/LibWeb/DOM/MutationRecord.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,5 +13,4 @@ interface MutationRecord {
readonly attribute DOMString? attributeName;
readonly attribute DOMString? attributeNamespace;
readonly attribute DOMString? oldValue;

};
1 change: 0 additions & 1 deletion Userland/Libraries/LibWeb/DOM/NamedNodeMap.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/DOM/Node.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions Userland/Libraries/LibWeb/DOM/NodeIterator.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,5 +14,4 @@ interface NodeIterator {
Node? previousNode();

undefined detach();

};
7 changes: 3 additions & 4 deletions Userland/Libraries/LibWeb/DOM/Range.idl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// https://dom.spec.whatwg.org/#interface-range
[Exposed=Window]
interface Range : AbstractRange {

constructor();

readonly attribute Node commonAncestorContainer;
Expand All @@ -32,21 +31,21 @@ 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);
short comparePoint(Node node, unsigned long offset);

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

};
10 changes: 5 additions & 5 deletions Userland/Libraries/LibWeb/DOM/StaticRange.idl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#import <DOM/AbstractRange.idl>

// 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);
};
2 changes: 0 additions & 2 deletions Userland/Libraries/LibWeb/DOM/TreeWalker.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,5 +16,4 @@ interface TreeWalker {
Node? nextSibling();
Node? previousNode();
Node? nextNode();

};
3 changes: 1 addition & 2 deletions Userland/Libraries/LibWeb/DOM/XMLDocument.idl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

// https://dom.spec.whatwg.org/#xmldocument
[Exposed=Window]
interface XMLDocument : Document {
};
interface XMLDocument : Document {};

0 comments on commit 1d4f075

Please sign in to comment.