LibWeb: Add PointerEvent.persistentDeviceId

Fixes at least 2 WPT subtests in /pointerevents.
This commit is contained in:
Jelle Raaijmakers 2024-10-18 10:52:06 +02:00 committed by Tim Flynn
commit effa21a69f
Notes: github-actions[bot] 2024-10-21 11:39:05 +00:00
3 changed files with 10 additions and 0 deletions

View file

@ -25,6 +25,7 @@ PointerEvent::PointerEvent(JS::Realm& realm, FlyString const& type, PointerEvent
, m_azimuth_angle(event_init.azimuth_angle.value_or(0)) , m_azimuth_angle(event_init.azimuth_angle.value_or(0))
, m_pointer_type(event_init.pointer_type) , m_pointer_type(event_init.pointer_type)
, m_is_primary(event_init.is_primary) , m_is_primary(event_init.is_primary)
, m_persistent_device_id(event_init.persistent_device_id)
{ {
} }

View file

@ -24,6 +24,7 @@ struct PointerEventInit : public MouseEventInit {
Optional<double> azimuth_angle; Optional<double> azimuth_angle;
String pointer_type; String pointer_type;
bool is_primary { false }; bool is_primary { false };
WebIDL::Long persistent_device_id { 0 };
}; };
// https://w3c.github.io/pointerevents/#pointerevent-interface // https://w3c.github.io/pointerevents/#pointerevent-interface
@ -49,6 +50,7 @@ public:
double azimuth_angle() const { return m_azimuth_angle; } double azimuth_angle() const { return m_azimuth_angle; }
String const& pointer_type() const { return m_pointer_type; } String const& pointer_type() const { return m_pointer_type; }
bool is_primary() const { return m_is_primary; } bool is_primary() const { return m_is_primary; }
WebIDL::Long persistent_device_id() const { return m_persistent_device_id; }
// https://w3c.github.io/pointerevents/#dom-pointerevent-pressure // 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. // For hardware and platforms that do not support pressure, the value MUST be 0.5 when in the active buttons state and 0 otherwise.
@ -119,6 +121,10 @@ private:
// Indicates if the pointer represents the primary pointer of this pointer type // Indicates if the pointer represents the primary pointer of this pointer type
// https://w3c.github.io/pointerevents/#dom-pointerevent-isprimary // https://w3c.github.io/pointerevents/#dom-pointerevent-isprimary
bool m_is_primary { false }; bool m_is_primary { false };
// A unique identifier for the pointing device.
// https://w3c.github.io/pointerevents/#dom-pointerevent-persistentdeviceid
WebIDL::Long m_persistent_device_id { 0 };
}; };
} }

View file

@ -1,5 +1,6 @@
#import <UIEvents/MouseEvent.idl> #import <UIEvents/MouseEvent.idl>
// https://w3c.github.io/pointerevents/#ref-for-dom-pointereventinit-1
dictionary PointerEventInit : MouseEventInit { dictionary PointerEventInit : MouseEventInit {
long pointerId = 0; long pointerId = 0;
double width = 1; double width = 1;
@ -13,6 +14,7 @@ dictionary PointerEventInit : MouseEventInit {
double azimuthAngle; double azimuthAngle;
DOMString pointerType = ""; DOMString pointerType = "";
boolean isPrimary = false; boolean isPrimary = false;
long persistentDeviceId = 0;
// FIXME: sequence<PointerEvent> coalescedEvents = []; // FIXME: sequence<PointerEvent> coalescedEvents = [];
// FIXME: sequence<PointerEvent> predictedEvents = []; // FIXME: sequence<PointerEvent> predictedEvents = [];
}; };
@ -33,6 +35,7 @@ interface PointerEvent : MouseEvent {
readonly attribute double azimuthAngle; readonly attribute double azimuthAngle;
readonly attribute DOMString pointerType; readonly attribute DOMString pointerType;
readonly attribute boolean isPrimary; readonly attribute boolean isPrimary;
readonly attribute long persistentDeviceId;
[FIXME, SecureContext] sequence<PointerEvent> getCoalescedEvents(); [FIXME, SecureContext] sequence<PointerEvent> getCoalescedEvents();
[FIXME] sequence<PointerEvent> getPredictedEvents(); [FIXME] sequence<PointerEvent> getPredictedEvents();
}; };