[csswg-drafts] [css-pseudo-4] Ensuring selection foreground/background contrast (#6150)

chrishtr has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-pseudo-4] Ensuring selection foreground/background contrast ==
The [`::selection` pseudo-element](https://drafts.csswg.org/css-pseudo-4/#selectordef-selection) allows the developer to change the foreground and background of a selection.

What happens if there is not good enough contrast between the selected colors? Webkit and Chromium (*) currently have code that inverts the background, if the background and foreground color are exactly
the same. Gecko does not have this logic. [Here](https://codepen.io/webcompat/pen/GRroQJa) is an example page that differs.

Should we view this as a website bug, or an opportunity for the UA to intervene and ensure contrast? One argument for the latter could be that selection is primarily a UA feature, and therefore it's appropriate to intervene to override site bugs. But if we do so, any difference in heuristics between browsers could result in (probably accidentally) broken sites in some browsers.

Finally, the same question could be asked about the various other pseudo elements that are similar to selection.
 
(*) [Webkit code link](https://github.com/WebKit/WebKit/blob/8309593bc3f4715a365652c1a7ba9688efb4bb90/Source/WebCore/rendering/MarkedTextStyle.cpp#L87-L91)
 [Chromium code link](https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/paint/ng/ng_highlight_painter.cc;l=111)
[Gecko bug tracking an interop issue caused by this](https://bugzilla.mozilla.org/show_bug.cgi?id=1589539)

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6150 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 26 March 2021 17:27:43 UTC