Commit 63d6cf2
layerX/layerY return incorrect values with CSS transforms
https://bugs.webkit.org/show_bug.cgi?id=306314
rdar://168968832
Reviewed by Lily Spiniolas and Abrar Rahman Protyasha.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
The layerX and layerY properties were computed by walking up the layer
tree and subtracting each layer's location(). This approach fails with
CSS transforms because layer locations are in local coordinate space
and don't account for transforms applied to parent layers.
It doesn't make sense not to include transforms when subtracting the
layer offset, because before this subtraction the mouse position value
already includes transforms (via absoluteLocation which applies the
documentToAbsoluteScaleFactor).
Fix by computing the layer's position in absolute coordinates using
localToAbsolute() with UseTransforms, matching Chromium's approach.
This ensures both the mouse position and layer position are in the
same coordinate system before computing their relative offset.
See: https://github.com/w3c/uievents/issues/398
* Source/WebCore/dom/MouseRelatedEvent.cpp:
(WebCore::MouseRelatedEvent::computeRelativePosition):
* LayoutTests/imported/w3c/web-platform-tests/uievents/mouse/layer-coords-transform-expected.txt: Progression
* LayoutTests/fast/events/mouse-relative-position-expected.txt:
* LayoutTests/fast/events/mouse-relative-position.html:
Canonical link: https://commits.webkit.org/306300@main1 parent 61e4fab commit 63d6cf2
File tree
4 files changed
+29
-11
lines changed- LayoutTests
- fast/events
- imported/w3c/web-platform-tests/uievents/mouse
- Source/WebCore/dom
4 files changed
+29
-11
lines changedLines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
| 100 | + | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
259 | 274 | | |
260 | 275 | | |
261 | 276 | | |
262 | 277 | | |
263 | 278 | | |
264 | | - | |
| 279 | + | |
265 | 280 | | |
266 | 281 | | |
267 | 282 | | |
| |||
0 commit comments