Closed Bug 2059340 Opened 3 months ago Closed 1 month ago

caretPositionFromPoint returns offset 1 for blank space below the text in a textarea

Categories

(Core :: DOM: Core & HTML, defect)

Firefox 150
Desktop
Linux
defect

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox-esr140 --- unaffected
firefox-esr153 --- wontfix
firefox153 --- wontfix
firefox154 --- wontfix
firefox155 --- wontfix
firefox158 --- wontfix
firefox159 --- wontfix
firefox160 --- fixed

People

(Reporter: birtles, Assigned: emilio)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file, 1 external file)

Attached file Reduced test case —

Starting in Firefox 150, calling document.caretPositionFromPoint() at a point in the blank area below the text in a multi-line textarea returns the textarea with offset 1.

Firefox 149 returned the end of the textarea value instead. This is also where Firefox places the caret when the blank area is clicked.

The problem was originally reported on Arch Linux and is still reproducible in Firefox 155 on Linux. Works for me on Windows though.

STR

  1. Open the attached reduced testcase.
  2. Read the result printed below the textarea.

The testcase calls caretPositionFromPoint() at a point near the bottom middle of the textarea, well below its only line of text.

Actual result

offsetNode: TEXTAREA
offset: 1

Expected result

The offset should be 5, the end of the textarea value:

offsetNode: TEXTAREA
offset: 5

Regression information

Additional information

The regressing commit moved text-control editors from native anonymous content to UA shadow DOM. It also removed the nsContentUtils::GetAdjustedOffsetInTextControl() call from Document::CaretPositionFromPoint() and removed the helper itself.

That helper specifically corrected offsets when the point was to the right of the text or at the bottom of a textarea by returning the length of the
textarea's content. The new shadow-DOM path does not appear to have an equivalent correction.

See Also: → 882149

Set release status flags based on info from the regressing bug 2016280

:emilio, since you are the author of the regressor, bug 2016280, could you take a look? Also, could you set the severity field?

For more information, please visit BugBot documentation.

Sorry for the lag here!

Flags: needinfo?(emilio)

Hmm, lando seems a bit slow today: https://phabricator.services.mozilla.com/D332960

Assignee: nobody → emilio
Status: NEW → ASSIGNED
Severity: -- → S3
Pushed by ealvarez@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/8f48ec7c5318 https://hg.mozilla.org/integration/autoland/rev/91a77df60771 When CaretPositionFromPoint rewrites the node to be relative to the text, also rewrite the offset as needed. r=dom-core-reviewers,smaug
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/63619 for changes under testing/web-platform/tests

The patch landed in nightly and ESR is affected.

:emilio, please make an uplift decision for ESR:

  • For ESR, nominate the patch for the appropriate ESR uplift approval if the fix should be included in ESR, or set the ESR status flag(s) to wontfix if an uplift isn't needed. Each affected ESR release needs a decision.

See Requesting an Uplift for documentation on how to request an uplift.

For more information, please visit BugBot documentation.

Flags: needinfo?(emilio)

Upstream PR merged by moz-wptsync-bot

Probably can ride the trains.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: