Intent to Ship: Stop modifying author-defined selection colors

189 views
Skip to first unread message

Stephen Chenney

unread,
May 8, 2024, 7:41:40 PMMay 8
to blink-dev

Contact emails

sche...@chromium.org

Explainer

None

Specification

https://www.w3.org/TR/css-pseudo-4/#highlight-selectors

Summary

Chromium currently checks all selection highlight colors against the text color and inverts the highlight color if it matches the text. Hence, author-defined ::selection CSS properties may be modified by the browser despite explicit author intent. For example, a CSS rule "::selection { color: cyan; background: cyan; }" the background is inverted and red color is used. In https://github.com/w3c/csswg-drafts/issues/6150 the CSS Working Group resolved to disallow the chromium behavior. We propose to implement this spec change and bring chromium into compatibility with other browsers.

Blink component

Blink>CSS

TAG review

None

TAG review status

Not applicable

Risks



Interoperability and Compatibility

Low risk. Gecko and WebKit both respect author colors from ::selection already. The change makes chromium compatible. It is highly unlikely that authors are depending on chromium behavior given it is hard to predict and the number of people who have looked at the workarounds. Note the workarounds (adding some transparency) will not be broken by the change.



Gecko: Shipped

WebKit: Shipped

Web developershttps://stackoverflow.com/questions/14970891/css-selection-color-behaving-strangely-on-chrome

Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

None



Debuggability

Improved because the rendered result now matches the colors specified by authors and reported in DevTools.



Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, ChromeOS, Android, and Android WebView)?

Yes

Is this feature fully tested by web-platform-tests?

Yes

Flag name on chrome://flags

None

Finch feature name

SelectionRespectsColors

Non-finch justification

The change has been behind Experimental Web Platform Features for 4 months, with no issues reported.



Requires code in //chrome?

False

Tracking bug

https://issues.chromium.org/issues/40771258

Estimated milestones

Shipping on desktop127
Shipping on Android127


Anticipated spec changes

Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).

None

Link to entry on the Chrome Platform Status

https://chromestatus.com/feature/5657973985640448?gate=6583848377253888

Yoav Weiss (@Shopify)

unread,
May 15, 2024, 11:55:34 AMMay 15
to blink-dev, Stephen Chenney
LGTM1

Alex Russell

unread,
May 15, 2024, 12:08:21 PMMay 15
to blink-dev, Yoav Weiss, Stephen Chenney
LGTM2

Chris Harrelson

unread,
May 15, 2024, 12:12:30 PMMay 15
to Alex Russell, blink-dev, Yoav Weiss, Stephen Chenney
LGTM3

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/c7dccb61-b1f7-4a88-b512-389beff7fa58n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages