You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Custom Highlight API Extensions] Application of opacity #1432
I really don't think you should do opacity as a stacking context. It's odd that you arbitrarily pick one to win, and compositing it as a layer has non-trivial rendering costs. I could imagine that the highlight opacity applies as a multiplier on the opacity instead which would naturally combine opacities of multiple overlapping highlights. Have you investigated whether it is reasonable to apply the opacity to the painted style of the highights and text individually rather than creating a layer?
In particular, each highlight affecting opacity would add an alpha to all painting for each run of text it affects, while still allowing the highlights, text, and other effects to be independently painted.
I talk about compositing a lot in the explainer because I'm focused on the animation use case, but in practice I think it's going to be up to the user agent to make smart decisions about when to actually create layers. It's certainly possible to create animations that would demand lots of composition, but authors are already doing this with spans, and I'd imagine any animation we could construct with highlights would be no worse than an equivalent animation constructed with spans - is there something I'm not thinking of?
Re: applying the opacity to the painted style of the highlights and text individually - I think what you're talking about is one of the alternatives I listed, which basically leaves the painting as it is but applies opacity kind of like stroke-opacity in SVG where it modifies the individual components in the highlight rule. I protoyped that, but it had behaviors that I found counterintuitive, which are described in the explainer. Let me know if I'm misunderstanding though.
Activity
flackr commentedon Oct 30, 2026
In particular, each highlight affecting opacity would add an alpha to all painting for each run of text it affects, while still allowing the highlights, text, and other effects to be independently painted.
kbabbitt commentedon Nov 3, 2026
Thanks, couple of thoughts on this:
I talk about compositing a lot in the explainer because I'm focused on the animation use case, but in practice I think it's going to be up to the user agent to make smart decisions about when to actually create layers. It's certainly possible to create animations that would demand lots of composition, but authors are already doing this with spans, and I'd imagine any animation we could construct with highlights would be no worse than an equivalent animation constructed with spans - is there something I'm not thinking of?
Re: applying the opacity to the painted style of the highlights and text individually - I think what you're talking about is one of the alternatives I listed, which basically leaves the painting as it is but applies opacity kind of like
stroke-opacityin SVG where it modifies the individual components in the highlight rule. I protoyped that, but it had behaviors that I found counterintuitive, which are described in the explainer. Let me know if I'm misunderstanding though.