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

[web-animations] when are keyframe values resolved? #8157

Open
graouts opened this issue Nov 30, 2022 · 2 comments
Open

[web-animations] when are keyframe values resolved? #8157

graouts opened this issue Nov 30, 2022 · 2 comments

Comments

@graouts
Copy link
Contributor

graouts commented Nov 30, 2022

This issue stems from web-platform-tests/wpt#37053 where I was asking about the intended behavior of a WPT test that essentially boils down to this little reduction:

const element = document.body.appendChild(document.createElement("div"));
element.style.fontSize = "40px";
element.animate({ "lineHeight": ["40px", "calc(40px - 2em)"] }, 1000);
element.currentTime = 500;

What is the value of line-height?

As of this writing, Chrome will compute the value as the 50% value between 40px and -40px (the unclamped output of calc(40px - 2em)) and resolve 0px.

Meanwhile, Firefox and Safari will resolve 20px, the 50% value between 40px and 0px (the clamped output of calc(40px - 2em)).

The difference here is that Safari (and I expect Firefox as well) will fully resolve the calc() value before using it as input to interpolating the animated value, whereas Chrome will not do so.

Of note, the CSS Values and Units spec has this to say in the Range Checking section for calc():

Parse-time range-checking of values is not performed within math functions, and therefore out-of-range values do not cause the declaration to become invalid. However, the value resulting from an expression must be clamped to the range allowed in the target context.

Should that mean that the calc() value here should be clamped for the allowed range, which the line-height definition clearly states should be non-negative?

I think it would be good for the Web Animations specification to at least have a note accounting for this.

Note that I raised #8158 which discussed a similar issue in the context of mix().

@graouts graouts changed the title [web-animations] when are keyframe values resolved [web-animations] when are keyframe values resolved? Nov 30, 2022
@andruud
Copy link
Member

andruud commented Dec 6, 2022

Should that mean that the calc() value here should be clamped for the allowed range, which the line-height definition clearly states should be non-negative?

Yes. Chrome is IMO wrong here. We are supposed to "compute" that value the same way "the" computed value is produced for line-height, per 5.3.2.

Regarding the more general question of "when keyframes are resolved" (from the title of this issue), this was mostly clarified in #5125 and the PR that resulted from that.

@graouts
Copy link
Contributor Author

graouts commented Dec 12, 2022

Filed web-platform-tests/wpt#37457 to update the relevant WPT tests to match the current spec state.

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