Skip to content

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

Closed

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

Activity

  1. delan commented on May 10, 2022

    @delan
    Contributor
  2. css-meeting-bot commented on May 18, 2022

    @css-meeting-bot
    Member

    The CSS Working Group just discussed [css-pseudo] Highlight pseudos and forced-color-adjust, and agreed to the following:

    • RESOLVED: forced-color-adjust doesn't do anything on highlight pseudos, and highlight pseudos take their forced color state from the originating element
    The full IRC log of that discussion <dbaron> Topic: [css-pseudo] Highlight pseudos and forced-color-adjust
    <emilio> (I guess that's what chrishtr just said)
    <dbaron> github: https://github.com//issues/7264
    <dbaron> dandclark: question about how forced-color-adjust:preserve-parent-color should work with highlight inheritance
    <dbaron> dandclark: this interaction is potentially problematic.
    <fantasai> emilio, yeah, and it's obnoxious when I try to load a page and it gives me a blank forever even though I know the text is loaded
    <dbaron> dandclark: Prereq: consider wether forced-color-adjust should be allowed in highlight pseudos.
    <dbaron> dandclark: List of properties. Currently not allowed there.
    <Rossen_> q?
    <dbaron> s/Prereq/Prerequisite/
    <dbaron> s/List/The spec gives a list/
    <dbaron> s/wether/whether/
    <dbaron> fantasai: I think the idea of having it not apply and just applying the forced-color-adjust effect of the originating element makes sense to me.
    <dbaron> fantasai: I think that was mentioned in the post as a way to deal with this.
    <dbaron> dandclark: I think that's a good outcome... seems simplest.
    <dbaron> dandclark: For all other color based properties the highlights are sort of an independent cascade. But I think it makes sense here. Seems odd that the originating element would take forced colors and the highlights not.
    <dbaron> dandclark: If the originating element has forced-color-adjust:preserve-parent-color, what does that mean for highlight pseudos that are active over that originating element?
    <dbaron> fantasai: Effect is that the color property is able to inherit from the parent the actual color of the parent... and that doesn't really impact the highlight pseudos ... which doesn't matter for highlight pseudos where the currentcolor keyword comes from the previous layer. So the keyword wouldn't have an effect.
    <dbaron> dandclark: so then try to resolve that forced-color-adjust doesn't do anything on highlight pseudos, and that highlight pseudos take forced color state of originating element
    <dbaron> Rossen: Proposed resolution: forced-color-adjust doesn't do anything on highlight pseudos, and highlight pseudos take their forced color state from the originating element
    <dbaron> RESOLVED: forced-color-adjust doesn't do anything on highlight pseudos, and highlight pseudos take their forced color state from the originating element

    See official minutes

  3. dandclark commented on May 18, 2022

    @dandclark
    ContributorAuthor

    @fantasai Could you help me understand what these tags mean?
    I'm guessing that Needs Edits means that a spec change is needed to reflect the meeting resolution, but I'm not sure about Closed Accepted by CSSWG Resolution.

    Sorry if these are documented somewhere; I looked but couldn't find anything.

  4. 4 remaining items

  5. fantasai commented on Dec 29, 2022

    @fantasai
    Collaborator

    @dandclark The Needs Edits label, as you guessed, means that the spec needs edits to reflect the resolution; Closed Accepted by CSSWG Resolution means that the issue was resolved by a CSSWG decision. There's other Closed labels that reflect whether it was accepted or rejected, and what type of acceptance... these are currently only documented in https://github.com/w3c/csswg-drafts/blob/main/bin/issuegen.pl#L104 and I mainly use it as a forcing function to think about what kind of decision or review might be needed.

    The resolution is now edit in as 05e463d ; please let me know if that reflects your understanding of the resolution of this issue! Thanks!

  6. dandclark commented on Jan 5, 2023

    @dandclark
    ContributorAuthor

    Thanks for clarifying! 05e463d looks right to me, so I'll go ahead and fully Close this.

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