Skip to content
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

[css-color-4] Computed/used value of color doesn't specify how to serialize. #1891

Closed
AmeliaBR opened this issue Oct 18, 2017 · 6 comments
Closed

Comments

@AmeliaBR
Copy link
Contributor

The section "Resolving Color values" in CSS Colors 4 makes it explicit that computed & used values for color should use rgb or rgba notation.

But it doesn't say whether to use the (0-255) format or percentages. Quick test suggest that integer format is preferred by browsers.

On high-color-depth monitors, converting all colors to integers could mean a loss of data, if the numbers were always rounded off to a nearest integer. But since the latest specs allow decimals in the 0-255 syntax, maybe the rounding could be left as implementation-dependent?

@AmeliaBR AmeliaBR added the css-color-4 Current Work label Oct 18, 2017
@svgeesus
Copy link
Contributor

svgeesus commented Nov 7, 2017

Agree this should be specified.

Integer format is historically more popular, but it also assumes an 8 bit per component model. The introduction of wide gamut displays means that higher bit depths are becoming more common. Canvas is also shifting to allow more bits per component.

Thus, CSS Color 4 is tending to prefer a bit-depth agnostic 0 to 1 (or for rgb, 0% to 100%) I would prefer to see the % notation.

The introduction of wider RGB spaces, ICC colors, Lab, LCH also means that computed and used values, and serialized values, need to be specified there too.

@tabatkins
Copy link
Member

The rgb() numeric args are numbers now, not ints, so they can handle any bit depth with no problem. Since impls have historically serialized with the number syntax, we should probably preserve that in the serialization rules.

@tabatkins tabatkins changed the title [css-color-4] Computed/used value of color doesn't specify which rgb() syntax to use. [css-color-4] Computed/used value of color doesn't specify how to serialize. Nov 1, 2019
@svgeesus
Copy link
Contributor

svgeesus commented Nov 2, 2019

Agreed. Lets clarify in the spec that the rgb(percentage form, with optional alpha) is the serialization. At least, as long as the working colorspace has it's initial value of sRGB.

@AmeliaBR
Copy link
Contributor Author

AmeliaBR commented Nov 3, 2019

rgb() with percentages would be a breaking change from existing implementations.

I agree with Tab, it is better to standardize on rgb with arbitrary precision numbers, since this simplifies to integers if the input is rgb integers or hex codes (maintaining compat), while still allowing for higher precision value or values beyond the sRGB gamut if the specified value uses a different format.

@svgeesus
Copy link
Contributor

The change from ints to numbers in rgb() could easily be missed, so I think this needs an example in the spec.

It also directly contradicts CSSOM, which is now fine as we resolved today to remove the serailization of RGB from CSSOM and consolidate it all into CSS Color 4; so that text can now have the precision test built in.

rgb(146.064 107.457 131.223)
is now valid, and equal to
rgb(57.28% 42.14% 51.46%)

Given the conflict with what CSSOM used to say, this needs tests too.

@svgeesus
Copy link
Contributor

Examples have now been added to the spec, serialising for all the sRGB-based ones to `rgb( )' with suppression of trailing zeroes, and of trailing decimal if all the fractional part is zero, and suppression of fully opaque alpha, and no commas. Not sure about the commas though for compat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants