Open frivoal opened 5 months ago
I think the alpha channel communicates something about author intent, and author intent should not be ignored. Something like this probably makes the most sense:
precompose the (semi-)transparent color against white or black depending on light vs dark mode, and use that as the actual color
In fact, we don't even need to say "against white or black depending on light vs dark mode", we have a system color for this: canvas
.
Just like in #9851, I think it's fine for the UA to use the color to create variations with more or less opacity, but the original color should be honored on at least part of the scrollbar.
The CSS Working Group just discussed [css-scrollbars] What do (semi) transparent colors mean for scrollbar-color
.
Here's a tentative summary of where we stand, based on the last call:
While not directly the topic of this issue, there was a proposal made that might help with it, at least in part: that if a thumb color is provided, it applies no only to the thumb, but also to any control other than the thumb that might appear on the track, such as scroll-up or scroll-down buttons.
(regardless of the rest, I'm in favor of adopting this part)
As for the main question of this issue, I think the options being considered are:
1a. specify that both thumb and track do respect transparency, without precomposition, (and so the track shows through the thumb and the background shows through the track); also special-case a fully transparent thumb and track to make the entire scrollbar invisible, even if it includes parts that are not otherwise colored (shading, texture, highlights, additional controls besides the thumb…)
1b. specify that both thumb and track do respect transparency, without precomposition; also that their alpha channel is also applied to the non-colored parts of the scrollbar. I think this is equivalent to saying that thumb and track are first colored ignoring the alpha channel, then the alpha channel of the thumb/track color is applied to the whole thumb/track, including both colored and non colored parts.
2a. Address scrollbar opacity through a separate scrollbar-opacity
property; the alpha channel in scrollbar-color
is ignored.
2b. Address scrollbar opacity through a separate scrollbar-opacity
property; the alpha channel in scrollbar-color
is precomposed (presumably over the named canvas
color, although we didn't spend much time discussing which color to precompose against).
We also discussed a "don't specify" option, but consider if off the table, because (at least) I would object to that: we cannot task authors with ensuring good contrast if they cannot know whether transparent
will mean invisible (non-precomposed), black (ignore alpha), white (precompose against white)…
Personally, I'm in favor of 2b.
While not directly the topic of this issue, there was a proposal made that might help with it, at least in part: that if a thumb color is provided, it applies no only to the thumb, but also to any control other than the thumb that might appear on the track, such as scroll-up or scroll-down buttons.
(regardless of the rest, I'm in favor of adopting this part)
Actually, I changed by mind on this. I think it is reasonable to allow the UAs to do that, but not to require that they do, as there exist scrollbar designs where the thumb is colored but the buttons are not.
I initially preferred 1b, as it seemed fairly intuitive for the author. But then, I think a common case would be having a translucent thumb color but still have the white highlights and dark shadows of the UA shading be at full opacity. So I think 2b is best.
The precompositing would just be of the alpha channel, so I don’t think the canvas color would enter into that operation, right? You’d just be multiplying the pixels of the color alpha channel with the value of scrollbar-opacity. Once you have the calculated opacity for each pixel, whatever was behind it in the z axis would be revealed to that degree for that pixel.
And presumably the thumb would be in front of the track in the z axis.
The CSS Working Group just discussed [css-scrollbars] What do (semi) transparent colors mean for scrollbar-color
, and agreed to the following:
RESOLVED: transparent colors in the thumb are transparent towards the track, and transparent colors in the track are transparent towards the background; transparency in those colors is not generalized to the entirety of the scrollbar
What should the use of fully or partly transparent colors mean for the
scrollbar-color
property ?Potential answers could be:
Because we put the responsibility of ensuring good contrast on the author, I think leaving it up to the UA is not appropirate.
This is related to, but possibly different from the similar question about accent colors discussed in https://github.com/w3c/csswg-drafts/issues/9852: the difference arises because in the accent-color's case, it is the browser's job to ensure good contrast somehow, while in the scrollbar's case, the author provides both colors and is responsible for the contrast. This could potentially result in different conclusions in either case.
As far as I can tell, both Chrome and Firefox currently do something of 4+5, though the way Firefox handles the transparency of the track is a little strange, as you get the same color as Chrome where the horizontal and vertical tracks intersect, but some darker/less transparent shade in each track separately.
http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=12309 Chrome:
Firefox:
(Note: these results are with classic / non-overlay scrollbars. See also https://github.com/w3c/csswg-drafts/issues/9855 for additional considerations in the case of overlay scrollbars)