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-5] Consider always requiring a colorspace argument to color-mix() #6051

Closed
weinig opened this issue Feb 27, 2021 · 8 comments
Closed
Labels
css-color-5 Color modification

Comments

@weinig
Copy link
Contributor

weinig commented Feb 27, 2021

In the current CSS Color 5 draft's color-mix() function, https://drafts.csswg.org/css-color-5/#color-mix, the colorspace is argument is optional, and leaving it out defaults to "lch".

I would like to suggest we remove the default value and always require a colorspace to specified. In general, I think requiring explicit color spaces is beneficial to avoid circumstances like we have now with implicit sRGB, where the best choice is no longer what we think it is. If in the past, we had required all colors / transformations of colors to be tagged, it would be much easier to change things today, as finding all the uses of sRGB in a codebase would be just searching for that explicit usage.

It's always possible to add a default later, if it becomes a burden, but it is much harder to remove one, so I think being conservative for now is the right tradeoff to make.

@smfr smfr added the css-color-5 Color modification label Mar 1, 2021
@LeaVerou
Copy link
Member

LeaVerou commented Mar 1, 2021

I'm ok with requiring a default for now, with the explicit intent of removing it later.

@emilio
Copy link
Collaborator

emilio commented Mar 1, 2021

Yeah, requiring a color space also avoids deciding what the right default should be. I'd note that colors-4 says that:

The exception is that if all the s to be interpolated are sRGB values, and they are all expressed in a legacy syntax such as hex colors, named colors, rgb(), hsl() or hwb() (and the equivalent alpha-including forms) then they are interpolated in gamma-encoded sRGB space.

It's not clear which of the two defaults wins here, and personally I think it'd be a bit weird if color-mix(a, b) behaved differently than regular animations and transitions.

@LeaVerou
Copy link
Member

LeaVerou commented Mar 1, 2021

@emilio That is the crappy legacy behavior which is there for no other reason besides web compat (and should probably use a "may"). There is no other reason other than web compat to interpolate or composit anything in gamma-encoded sRGB so we should not repeat that mistake in anything new that we produce.

@emilio
Copy link
Collaborator

emilio commented Mar 2, 2021

I agree, but thus I think being explicit at least for now is better :)

@LeaVerou
Copy link
Member

LeaVerou commented Mar 2, 2021

@una @svgeesus @argyleink do you agree? If so I could make that change along with the others.

@argyleink
Copy link
Contributor

looks good to me 🙂

@svgeesus
Copy link
Contributor

svgeesus commented Mar 2, 2021

@emilio wrote:

It's not clear which of the two defaults wins here, and personally I think it'd be a bit weird if color-mix(a, b) behaved differently than regular animations and transitions.

I addressed that in #6059

@svgeesus
Copy link
Contributor

svgeesus commented Mar 2, 2021

@una @svgeesus @argyleink do you agree?

I agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-color-5 Color modification
Projects
None yet
Development

No branches or pull requests

6 participants