Commit Graph

2 Commits

Author SHA1 Message Date
Andreas Kling
12af95cfa2 LibWeb: Floor coordinates for untrusted MouseEvent and PointerEvent
Per the PointerEvents spec and Chromium's behavior, untrusted (JS-
constructed) MouseEvent coordinates should be floored to integers.

PointerEvent overrides this behavior: for non-click types (pointerdown,
pointermove, etc.), fractional coordinates are preserved. For click,
auxclick, and contextmenu events, coordinates are floored via the
MouseEvent base class.

Trusted events (created by the user agent) always preserve fractional
coordinate values.
2026-03-08 18:09:10 +01:00
Andreas Kling
2a547ec687 LibWeb: Initialize pageX/pageY and offsetX/offsetY in event constructors
When constructing MouseEvent, PointerEvent, DragEvent, or WheelEvent
from JavaScript, pageX/pageY and offsetX/offsetY were left at 0
instead of being initialized from clientX/clientY.

Per the CSSOM View spec, pageX should be clientX + scrollX (which is 0
for a newly constructed event with no associated window), and offsetX
should be clientX minus the target's bounding rect origin (which is 0
for an event with no target). So both should default to clientX.
2026-03-08 18:09:10 +01:00