Skip to content

[Custom Highlight API Extensions] Application of opacity #1432

Open

Description

Robert Flack (@flackr) wrote:

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?

Activity

  1. flackr commented on Oct 30, 2026

    @flackr

    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.

  2. kbabbitt commented on Nov 3, 2026

    @kbabbitt
    MemberAuthor

    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-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions