Skip to content

Commit

Permalink
LibWeb: Add PointerEvent.getCoalescedEvents() and .getPredictedEvents()
Browse files Browse the repository at this point in the history
Fixes at least 4 WPT subtests in /pointerevents.
  • Loading branch information
gmta committed Oct 18, 2024
1 parent ecd0090 commit 8f2f744
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Userland/Libraries/LibWeb/UIEvents/PointerEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ PointerEvent::PointerEvent(JS::Realm& realm, FlyString const& type, PointerEvent
, m_pointer_type(event_init.pointer_type)
, m_is_primary(event_init.is_primary)
, m_persistent_device_id(event_init.persistent_device_id)
, m_coalesced_events(event_init.coalesced_events)
, m_predicted_events(event_init.predicted_events)
{
}

Expand Down
10 changes: 10 additions & 0 deletions Userland/Libraries/LibWeb/UIEvents/PointerEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct PointerEventInit : public MouseEventInit {
String pointer_type;
bool is_primary { false };
WebIDL::Long persistent_device_id { 0 };
AK::Vector<JS::Handle<PointerEvent>> coalesced_events;
AK::Vector<JS::Handle<PointerEvent>> predicted_events;
};

// https://w3c.github.io/pointerevents/#pointerevent-interface
Expand All @@ -51,6 +53,8 @@ class PointerEvent : public MouseEvent {
String const& pointer_type() const { return m_pointer_type; }
bool is_primary() const { return m_is_primary; }
WebIDL::Long persistent_device_id() const { return m_persistent_device_id; }
AK::Vector<JS::Handle<PointerEvent>> get_coalesced_events() const { return m_coalesced_events; };
AK::Vector<JS::Handle<PointerEvent>> get_predicted_events() const { return m_predicted_events; };

// https://w3c.github.io/pointerevents/#dom-pointerevent-pressure
// For hardware and platforms that do not support pressure, the value MUST be 0.5 when in the active buttons state and 0 otherwise.
Expand Down Expand Up @@ -125,6 +129,12 @@ class PointerEvent : public MouseEvent {
// A unique identifier for the pointing device.
// https://w3c.github.io/pointerevents/#dom-pointerevent-persistentdeviceid
WebIDL::Long m_persistent_device_id { 0 };

// https://w3c.github.io/pointerevents/#dom-pointerevent-getcoalescedevents
AK::Vector<JS::Handle<PointerEvent>> m_coalesced_events;

// https://w3c.github.io/pointerevents/#dom-pointerevent-getpredictedevents
AK::Vector<JS::Handle<PointerEvent>> m_predicted_events;
};

}
Expand Down
8 changes: 4 additions & 4 deletions Userland/Libraries/LibWeb/UIEvents/PointerEvent.idl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ dictionary PointerEventInit : MouseEventInit {
DOMString pointerType = "";
boolean isPrimary = false;
long persistentDeviceId = 0;
// FIXME: sequence<PointerEvent> coalescedEvents = [];
// FIXME: sequence<PointerEvent> predictedEvents = [];
sequence<PointerEvent> coalescedEvents = [];
sequence<PointerEvent> predictedEvents = [];
};

// https://w3c.github.io/pointerevents/#pointerevent-interface
Expand All @@ -36,6 +36,6 @@ interface PointerEvent : MouseEvent {
readonly attribute DOMString pointerType;
readonly attribute boolean isPrimary;
readonly attribute long persistentDeviceId;
[FIXME, SecureContext] sequence<PointerEvent> getCoalescedEvents();
[FIXME] sequence<PointerEvent> getPredictedEvents();
[SecureContext] sequence<PointerEvent> getCoalescedEvents();
sequence<PointerEvent> getPredictedEvents();
};

0 comments on commit 8f2f744

Please sign in to comment.