-
Notifications
You must be signed in to change notification settings - Fork 715
CSS color serialization and <input type=color> with alpha/colorspace #11008
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
Comments
I think this likely could be defined in terms of non-modifying relative color calculation. That is,
with colorspace
which would compute to a This would work just as well with the value
This is fully defined and already in engines, so should be straight forward to implement as well. |
That's great! Any idea @svgeesus how to do the appropriate wording? |
I'm thinking about it. It does need to be explicit in the spec, not just deducible to experts.
Sure but we need to have language so that which of these two you get is clear, and can be interoperable. |
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 So the main question is what happens when the HTML-compatible directive is not set (i.e., when the I see two ways of getting there:
My current prototype does a combination of these. WebKit's internal |
While that's true in this case, there's a proposal for a JS Color API and as part of that we might (I've definitely wanted this before) want to choose the serialisation. For example hex with alpha has wider browser and tooling support so you might want to output the colour in that serialisation. |
You probably already know this and just simplified for brevity, but since you are prototyping an implementation I felt the need to point out that non-unity alpha is only one of the cases that means
Which means that extended-range sRGB will not use the hex serialization, either. For example |
True, but we only support " |
(I think adding "srgb" would be good. In general, now that we srgb is not clamped to [0,1], it's a pretty good default interchange value). Would be good to clarify what behavior is desired for some edge case input values: Should
Should NaN / infinity be serialized.
Should currentColor be supported? And if so, what value should it serialize as?
|
I agree that these cases should be explicitly covered, but also don't see a typical color picker generating them. |
Right, the color picker is unlikely to ever generate them, but I believe the user can explicitly set the value as a string using the value attribute. |
Yeah, I think those should be covered by how we invoke "parse a CSS <color>" without passing in context. So (" |
I think I will address this problem in the HTML PR for now by adding language to the effect of
which will at least make it unambiguous what we need. I believe the questions Sam raised are already addressed by the combination of whatwg/html#10456 and CSS Color, albeit not always in a straightforward manner:
I will leave this issue open to potentially allow for that (and other) wording to be improved if the CSS WG decides to add more primitives here. |
Agreed about missing values (which includes NaN). |
Per whatwg/html#9940 (comment) the |
Oh right, the initial value. |
I see that the PR is merged. @annevk Is there more to do here? Or can this be closed? |
I think that comment outlines the reasons for keeping this open, but if the CSS WG doesn't think further clarification is needed in its drafts then this can be closed. Seems worth carefully checking again though since it's not entirely clear to Sam that will go for others too. |
Perhaps a new subsection "Color in 2D Canvas" under the existing 3. Applying Color in CSS to explicitly state the consequences of no context, and also to point out that Would another new section about <input type=color"> also be useful? |
For whatwg/html#10456 we allow
<input type=color>
's internal color to be set as follows:value
attribute).This color is then color space converted depending on the
colorspace
attribute and serialized for API purposes and form submission. We only support the 'srgb' and 'display-p3' color spaces for now.When
colorspace
is set to "limited-srgb
" (default value) and thealpha
attribute is not set we specifically instruct CSS color serialization to use the hexadecimal syntax for compatibility.Otherwise we follow CSS color serialization directly.
However, what is not clear currently is what kind of normalization color space conversion applies. E.g., if the input is
lab(51.2345% -13.6271 16.2401)
, is the output going to becolor(srgb 0.41587 0.503670 0.36664)
? How is that defined? What if the input is#11223344
?Ideally from a web developer perspective I think it would always use
color(srgb ...)
orcolor(display-p3 ...)
unless we needed compatibility with the existing input as described above. But now I'm wondering if that is actually what we ended up requiring or if there are some other loose ends to tighten up.cc @svgeesus @lukewarlow @weinig
The text was updated successfully, but these errors were encountered: