Closed Bug 1546612 Opened 5 years ago Closed 2 years ago

caretPositionFromPoint does not take iframe transformation into account

Categories

(Core :: DOM: CSS Object Model, defect, P3)

66 Branch
defect

Tracking

()

RESOLVED FIXED
104 Branch
Tracking Status
firefox-esr60 --- unaffected
firefox-esr91 --- wontfix
firefox-esr102 --- wontfix
firefox66 --- wontfix
firefox67 --- wontfix
firefox68 --- wontfix
firefox69 --- wontfix
firefox102 --- wontfix
firefox103 --- wontfix
firefox104 --- fixed

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.

Status: UNCONFIRMED → NEW
Component: Untriaged → DOM: Core & HTML
Ever confirmed: true
Keywords: regression
Product: Firefox → Core

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?

Has Regression Range: --- → yes
Has STR: --- → yes
Flags: needinfo?(ke5trel)
Regressed by: 1025815
Component: DOM: Core & HTML → DOM: CSS Object Model

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.

Flags: needinfo?(ke5trel)

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.

Mentor: emilio
Priority: -- → P3
See Also: → 1548560

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.

Using nsLayoutUtils::TransformPoint instead of going through the widget takes the iframe's
transformations into account.

Assignee: nobody → tlouw
Status: NEW → ASSIGNED
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
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: