Re: [csswg-drafts] CSS color serialization and <input type=color> with alpha/colorspace (#11008)

So we already do color space conversion to either sRGB or Display P3. So we are guaranteed to have a CSS color in either of those color spaces. And Display P3 is always serialized as `color(display-p3 ...)`. And sRGB is serialized as `#rrggbb` with the HTML-compatible directive set.

So the main question is what happens when the HTML-compatible directive is not set (i.e., when the `alpha` attribute is set). It seems nice to output `color(srgb ...)` there, but this is not guaranteed as the CSS color, while it is guaranteed to be sRGB, can still have many different representations.

I see two ways of getting there:

- Aside from converting the color space, also have some way to convert the representation within a color space. This seems awfully generic given the need though.
- Have some way to force `color(srgb ...)` output similar to how we can force `#rrggbb` output for sRGB colors.

My current prototype does a combination of these. WebKit's internal `Color` object has a way to force `color(...)` serialization, which I use in the sRGB + `alpha` attribute case.

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


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

Received on Thursday, 10 October 2024 07:05:14 UTC