Skip to content

[css-pseudo] Highlight pseudos and forced-color-adjust #7264

Closed
@dandclark

Description

@dandclark

I'd like to try to clarify how forced-color-adjust should apply to highlight pseudos.

In crbug.com/1309835, @andruud raised the question of how forced-color-adjust:preserve-parent-color should interact with the special definition of currentColor used with highlight inheritance. Normally preserve-parent-color has currentColor compute to the used value of the parent's color, but with highlights it's not so clear what this value should resolve to. Making it dependent on which highlight overlays are active could be problematic as that info may not be readily available until paint-time.

A simple way to resolve any strangeness could be to just treat forced-color-adjust:preserve-parent-color as forced-color-adjust:none for highlights. The motivating use case for preserve-parent-color involving SVG icons doesn't seem to be applicable to highlight pseudos as far as I can tell.

Considering things more broadly, does it make sense to allow forced-color-adjust in highlight pseudos at all? It is not one of the properties listed at https://drafts.csswg.org/css-pseudo-4/#highlight-styling, but Chrome allows it to be used with ::selection and the other highlight pseudos when --enable-blink-features=HighlightInheritance is enabled. Example here. (When HighlightInheritance is not enabled, Chrome looks like it always ignores forced colors for ::selection pseudos, which seems clearly wrong).

Perhaps highlights should always just use the forced-colors state of the originating element. Does it actually make sense to allow authors to opt out of forced colors for highlights but not the element containing the underlying text? Or vice versa?

cc @alisonmaher @delan @mrego

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