Skip to content

[css-paint-api] Support for using paint() in element overlays #982

Closed
@jimkyndemeyer

Description

@jimkyndemeyer

In https://drafts.css-houdini.org/css-paint-api/#intro there is mention of using paint() as filters, although that is not yet supported.

If I understand the current spec, paint is limited to being used on background-image and border-image. I'd like to propose an additional "layer" of painting, namely the types of overlays that browser-based devtools show, e.g. how the box model appears in Chrome devtools:

overlay

A few key points:

  • The painted overlays need to be the last layer of paint such that the same effect as the devtools can achieved using alpha blending
  • Registering painting in the overlay needs to be non-destructive, that is it can't override existing css properties such as background image or border image as this will change the appearance of the element being highlighted using an overlay paint. Open question: Potentially a new CSS property is needed?
  • Multiple overlay paints should be allowed, e.g. registered using unique ids -- again to be non-destructive if multiple overlays need to be shown at once. Open question: how to register paint by multiple ids?

A few example use cases:

  • In a browser based visual design tool or devtools, easily overlay a highlight on top of hovered/selected elements
  • In browser extensions, easily highlight elements without having to modify the DOM

Adding this would remove a whole class of problems with doing overlays, e.g. calculating their position effectively, keeping them in sync with layout changes, and not having to insert additional DOM elements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions