Re: [csswg-drafts] [css-color-4] Clarify that `none` is preserved in calculations (#10211)

> There is another scenario in which color space conversion happens.
> 
> `hsl`, `rgb`, `hwb` serialize as `color(srgb ...)` to aid in preserving wide gamut colors.
> 
> For example : `rgb(from rgb(250 120 120) calc(r + 20) g b)` if serialized as `rgb(270 120 120)` it would be clamped when roundtripping 

I have a faint memory that we changed this a while back and now `rgb()` doesn't clamp. @svgeesus ?

> To prevent that, it serialized as `color(srgb 1.05882 0.470588 0.470588)` instead

`rgb()` to `color(srgb)` should not drop any `none`s since all three components carry forwards. 
But this makes me wonder if the spec is even clear that `none` should be preserved during serialization!

> Chrome has implemented this and you can see how it erases `none` with for example `hsl` : [codepen.io/romainmenke/pen/VwNRBgg?editors=1111](https://codepen.io/romainmenke/pen/VwNRBgg?editors=1111)
> 
> I would have expected them to only do this conversion to `color(srgb ...)` when absolutely needed, but seems to happen quite eagerly.

I don’t quite understand what this demo is showing, but in general any conversion should not be done when not needed.

-- 
GitHub Notification of comment by LeaVerou
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10211#issuecomment-2080158204 using your GitHub account


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

Received on Friday, 26 April 2024 21:44:45 UTC