Closed Bug 1872535 Opened 6 months ago Closed 5 months ago

CSS Highlights API bug when deleting and adding ranges

Categories

(Core :: DOM: Selection, defect)

defect

Tracking

()

VERIFIED FIXED
124 Branch
Tracking Status
firefox124 --- verified
firefox125 --- verified

People

(Reporter: kizmarh, Assigned: jjaschke)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

To reproduce (testing in 123.0a1 (2023-12-31) (64-bit)):

  1. Go to https://codepen.io/kizu/pen/WNmQrBW?editors=1010 (or open an attached .html)
  2. Click the button.
  3. Blur the button by clicking elsewhere.

What happened:

  • After step 2: the first word is fully highlighted, the second half of the second word is highlighted.
  • After step 3: the second word is not highlighted, the first word is fully highlighted.

What is expected:

  • There should be no visual changes: removing a range, then adding the same range should not have any impact. Safari and Chrome seem to work the same.
Component: CSS Parsing and Computation → DOM: Selection
Flags: needinfo?(jjaschke)

Hi Roman,

Thank you for your report. I’ll investigate!

Flags: needinfo?(jjaschke)
Flags: needinfo?(jjaschke)

Ranges inside of a Selection are expected to be sorted by their start point by the painting algorithms. Also, StaticRanges, which previously were not part of Selection, need to be considered for painting based on their IsValid() status.

This is now added by introducing a second array for invalid static ranges and an additional re-ordering method which needs to be called before paint that moves ranges in between.
A potential change in range endpoints can be determined by observing the Documents generation and by adding a flag that's set to true in Selection::NotifySelectionObservers().

Assignee: nobody → jjaschke
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: needinfo?(jjaschke)
Severity: -- → S3
Pushed by jjaschke@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/20e975d790c8
Deal with invalid `StaticRange`s and DOM mutations in `Selection`. r=smaug
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/44141 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 124 Branch
Upstream PR merged by moz-wptsync-bot
Regressions: 1878504
Flags: qe-verify+

Reproducible on a 2024-01-19 Nightly build on macOS 12.
Verified as fixed on Firefox 124.0b2 and Nightly 125.0a1 on macOS 12, Windows 10, Ubuntu 22.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: