caretPositionFromPoint does not take iframe transformation into account
Categories
(Core :: DOM: CSS Object Model, defect, P3)
Tracking
()
People
(Reporter: romain.petit.entreprise, Assigned: tlouw, Mentored)
References
(Regression)
Details
(Keywords: regression)
Attachments
(1 file)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36
Steps to reproduce:
1/ Create an iframe, apply a CSS transformation to it (X translation).
2/ Listen to pointerdown events into this iframe
3/ Execute document.caretPositionFromPoint into the iframe with events client X/Y as input.
=> Please see this jsfiddle, just click into the text and check output offsets (works only in Firefox)
https://jsfiddle.net/morille/4gpqtf7e/19/
Actual results:
The returned CaretPosition references the right node but the wrong offset.
By shifting the event coordinates by the amout of iframe translation, returned offset is correct.
Expected results:
The offset should match the offset of the character behind pointer.
Updated•5 years ago
|
Comment 1•5 years ago
|
||
Regression window:
https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=4e38ca9aaa48420fcb44df9e1a41e29ce53af267&tochange=f365bf91369c4f1327738cd4a4fb27ccdf05f274
Regressed by: f365bf91369c Kestrel — Bug 1025815 - caretPositionFromPoint needs to account for CSS transforms. r=bz
Kestrel,
Your patch seems to cause the regression. Can you look into this?
Updated•5 years ago
|
I used the same approach as nsDOMWindowUtils::selectAtPoint()
which is used for a selection test and it too fails when the iframe is transformed. nsLayoutUtils::GetEventCoordinatesRelativeTo()
can account for transforms but needs device coords, nsContentUtils::ToWidgetPoint()
is used to convert from client to device coords but does not account for the iframe transform so the device coords are wrong.
Comment 3•5 years ago
|
||
This is p3 as it stands I think.
I'm happy to help fix this (and Kestrel already provided some good hints), but probably won't have the cycles myself to do it.
Comment 4•5 years ago
|
||
Too late for a fix in 68. I'm marking this fix-optional for 69 so that we don't keep triaging it, since there is a priority assigned.
This issue still exists in 89. I'm looking forward to fix it.
Note that other browsers (Chrome and Safari) does not support caretPositionFromPoint, but caretRangeFromPoint which is an alternative on them does not have this issue.
Assignee | ||
Comment 6•2 years ago
|
||
Using nsLayoutUtils::TransformPoint instead of going through the widget takes the iframe's
transformations into account.
Updated•2 years ago
|
Pushed by tlouw@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/786c4d929af7 caretPositionFromPoint does not take iframe transformation into account r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/34874 for changes under testing/web-platform/tests
Comment 9•2 years ago
|
||
bugherder |
Upstream PR merged by moz-wptsync-bot
Updated•2 years ago
|
Description
•