Open Bug 1984991 Opened 1 month ago Updated 1 month ago

[css-highlight-api] CSS custom highlights (and ::selection) are not invalidated on style changes

Categories

(Core :: CSS Parsing and Computation, defect)

Firefox 142
defect

Tracking

()

People

(Reporter: bartveneman, Unassigned, NeedInfo)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:142.0) Gecko/20100101 Firefox/142.0

Steps to reproduce:

  1. Create a text element
  2. Create a Range() or StaticRange() and a Highlight() within the text node to highlight text
  3. Apply a ::highlight(my-thing) color
  4. toggle a classname on the text element to change the color

CodePen repro: https://codepen.io/bartveneman/pen/KwdeyOp

Actual results:

Nothing happened

Expected results:

The highlight color should have been updated to blue when the toggle was enabled. This only happens when I resize the browser or select all the text and then unselecting it.

I believe our invalidation for these pseudo-elements is sketchy. We would end up in here and invalidate the element's style, but not trigger a repaint.

I think something like propagating an Option<RestyleDamage> from there, rather than an invalidate_self, and making that a repaint hint if changing ::selection / ::highlight would work here. It'd over-invalidate in some cases (if the color didn't actually change). One alternative would somehow keep around whether we have an active ::highlight and diff those styles around here...

Jan, mind setting a severity on this?

Status: UNCONFIRMED → NEW
Component: Layout → CSS Parsing and Computation
Ever confirmed: true
Flags: needinfo?(jjaschke)
Summary: css highlight color not updating on classname toggle → [css-highlight-api] CSS custom highlights (and ::selection) are not invalidated on style changes

We have a few failing WPT for this, for example custom-highlight-painting-invalidation-007.html.

I can take a look.

Severity: -- → S3
Flags: needinfo?(jjaschke)
Flags: needinfo?(jjaschke)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: