-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cssom-1][css-color-4] Move serialization of <color>
and <alpha-value>
#9798
Comments
Yes, I see that there is still an inlline issue wondering what to do about case folding while #7870 (comment) (and subsequent discussion) says that ASCII-lowercase folding is done, as does https://drafts.csswg.org/css-color-4/#serializing-color-values which was then adopted by CSSWG resolution. So that inline issue should be deleted. |
I agree that the algorithm for serializing internal 8-bit alpha values needs to be moved over to CSS Color 4, which currently does not cover that case. |
@emilio what is your preference, should I:
|
@emilio CSS Color 4 has now been updated to add the 8-bit unsigned alpha serialization logic from cssom-1 in a28b013 I also added a couple of worked examples. Would you like a PR on cssom-1 to remove it from there, or should I just do it? |
0.499 × 255 = 127.245 so if rounded and stored as uint8_t it will be 127 |
Either way works for me. |
(Thanks for taking care of this, I had missed the previous ping) |
50 * 2.55 = 127.5 but it is 127.499999... because of floating point precision. Rounded up, 127.5 is 128, which is not equal to 127, so the next branch of the algorithm applies. To be honest, I cannot say I understand all the intricacies of this algorithm and the relation with unsigned 8-bit representation, but |
@emilio @tabatkins do you know why there is a cssom-specific "rounding up" specified, rather than "round to +infinity" like everywhere else in CSS? Which would give 127 in the example @cdoublev mentioned? Also do we know the history of this 8bit alpha algorithm, is it baked into Web compat at this point? |
Yeah, or I was trying to match implemented behavior in some browser. |
I came across this in Chrome:
|
This is about color channels, not the alpha channel, whose related code appears a few lines below, which is matching the specified algorithm, and which has been introduced the first time in this commit. While digging, I stumbled upon this commit message:
I still do not understand the rounding with 3 decimal places, but maybe things could be simplified now. |
According to #7870 (comment), how to serialize
<color>
should be removed from CSSOM and how to serialize<alpha-value>
should be moved to CSS Color 4.If I am not mistaken, the algorithm for
<alpha-value>
is required when stored internally as an 8-bit integer, which seems to be the case for most browsers (if not all), and helps explaining why0.499
may be serialized to0.498
, for example.The text was updated successfully, but these errors were encountered: