Skip to content

[css-images-4] Saturate invalid cross-fade values #5333

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

Open
0xekez opened this issue Jul 17, 2020 · 4 comments
Open

[css-images-4] Saturate invalid cross-fade values #5333

0xekez opened this issue Jul 17, 2020 · 4 comments

Comments

@0xekez
Copy link

0xekez commented Jul 17, 2020

Per the cross-fade spec:

The percentage represents how much of each image is retained when it is blended with the other images. The percentage must be between 0% and 100% inclusive; any other value is invalid (emphasis mine).

It would be nice to clarify what to do with an invalid value.

Currently both Safari and Chrome handle invalid values by saturating them between 0 and 100 percent. For example, using their older, implemented syntax:

-webkit-cross-fade(
url('https://mdn.mozillademos.org/files/8543/br.png'),
url('https://mdn.mozillademos.org/files/8545/tr.png'),
-50%)

has a computed value of

-webkit-cross-fade(
url('https://mdn.mozillademos.org/files/8543/br.png'),
url('https://mdn.mozillademos.org/files/8545/tr.png'),
0)

We should consider standardizing this behavior or specifying something else if that doesn't seem reasonable.

@tabatkins
Copy link
Member

"Invalid" has a well-defined meaning in CSS; a property with an invalid value is ignored. Chrome/Safari are buggy here. (This function predates the WK/Chrome fork, so they're both buggy due to the shared initial implementation.)

@0xekez
Copy link
Author

0xekez commented Jul 17, 2020

Interesting. Thanks for the information. I actually didn't know that they shared an implementation. Is that to say that the standard would require that a cross-fade with an invalid percentage is completely ignored or that it does something like below?

cross-fade(blue 110%, red)
/* is equivalent to */
cross-fade(blue, red)

@tabatkins
Copy link
Member

Completely ignored; it makes the property invalid, so the property gets dropped at parse-time. (Or, in some cases, becomes "invalid at computed-value time" and set to the initial or inherited value.)

@emilio
Copy link
Collaborator

emilio commented Jul 20, 2020

Hmm, percentages in filter functions are clamped to a hundred rather than rejected at parse time...

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