-
Notifications
You must be signed in to change notification settings - Fork 746
Closed
Labels
Closed Accepted by CSSWG ResolutionCommenter SatisfiedCommenter has indicated satisfaction with the resolution / edits.Commenter has indicated satisfaction with the resolution / edits.css-color-4Current WorkCurrent Work
Description
Originally posted by @annevk in whatwg/html#8917 (comment)
From HTML's perspective we have these requirements:
- 2D canvas: stores a CSS color and when that color happens to use 8-bit per component it needs to be serialized as
#...
(when opaque) orrgba(...)
(when not opaque). I think it would make sense if we could set a boolean named parameter called "HTMLCompatible" or some such when serializing to enable that. <input type=color>
: stores a CSS color, but when serializing that color a) needs to be converted to a color space according to thecolorspace
attribute b) when that is Limited sRGB that color b1) needs to be rounded to 8-bits per component and b2) use "HTMLCompatible" just like 2D canvas
I think for <input type=color>
:
- HTML should probably do the color space conversion upon the CSS color.
- HTML should probably do the rounding as well, although I could also see this being an additional named parameter, but I don't see much utility in that unless there's multiple callers needing it.
So here is what this would mean for the CSS Color specification for maximum clarity:
- It needs to define a "serialize a CSS color" operation that takes a CSS color and outputs a string (doh).
- It needs to define a "HTMLCompatible" named parameter for that operation that influences the serialization when the passed CSS color is a) in the 'srgb' color space and b) uses 8-bits per component. In particular for colors meeting those requirements it will use https://html.spec.whatwg.org/multipage/canvas.html#serialisation-of-a-color (which it defines itself so that definition can be removed from HTML).
Does that make sense? Once that's in place I can update the <input type=color>
PR and perhaps also create a separate PR to ensure 2D canvas is properly defined.
Metadata
Metadata
Assignees
Labels
Closed Accepted by CSSWG ResolutionCommenter SatisfiedCommenter has indicated satisfaction with the resolution / edits.Commenter has indicated satisfaction with the resolution / edits.css-color-4Current WorkCurrent Work