Skip to content

[css-color-5] incorrect WPT tests for omitted alpha in relative color syntax #8708

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

Closed
romainmenke opened this issue Apr 12, 2023 · 5 comments

Comments

@romainmenke
Copy link
Member

https://drafts.csswg.org/css-color-5/#origin-color

Relative color syntax doesn’t change whether an argument is required or optional. If the alpha value is omitted, however, it defaults to taking from the origin color (rather than defaulting to 100%, as it does in the absolute syntax).

https://github.com/web-platform-tests/wpt/blob/master/css/css-color/parsing/color-computed-relative-color.html#L104

test_computed_value(`color`, `rgb(from rgb(20%, 40%, 60%, 80%) 0% 10 10)`, `rgb(0, 10, 10)`);
rgb(from rgb(20%, 40%, 60%, 80%) 0% 10 10)

The alpha channel is omitted, so alpha should be taken from the origin color.
The result should be : rgb(0, 10, 10, 0.8)

Maybe this is a fairly recent change to the specification?


I've updated the WPT tests to match the specification : web-platform-tests/wpt#39508

@romainmenke
Copy link
Member Author

(forgot to ping @svgeesus )

@svgeesus
Copy link
Contributor

Maybe this is a fairly recent change to the specification?

No, it was two years ago

@tabatkins committed on Feb 26, 2021

@svgeesus
Copy link
Contributor

Thanks for PR updating the WPT. Before approving, I need to check the right ranges are used, in the case where alpha is used as one of the color channels, particularly for rgb() which has a legacy-compatible 0,255 range on color channels. So in the case of 80% alpha, the value is 0.8 which is legal, but very dark on a 0,255 scale.

Using 0,1 alpha works better for color() of course which also uses a modern 0,1 scale.

Plus, mixing up the channels like this doesn't have much of a practical use case. I can't think when it might be useful in practice to have a red, green or blue value depend on the origin alpha. (And no it can't be used for premultiplication either because these are gamma-encoded color component values).

@romainmenke
Copy link
Member Author

romainmenke commented Apr 17, 2023

@svgeesus I think there is some confusion here.

This issue and the test changes are not related to using alpha as a value in other channels or doing any calculations with alpha.

So the ranges shouldn't be a factor.


The specification dictates that there is some form of "pass through" for alpha in particular. So this is always the alpha from origin color that is being used as the final alpha.

@romainmenke
Copy link
Member Author

The WPT tests were approved and merged, so I think we can close this @svgeesus ?

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

2 participants