Skip to content

[css-values-5] Should random() function caching key work over used values? #11747

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
nt1m opened this issue Feb 19, 2025 · 4 comments
Open

Comments

@nt1m
Copy link
Member

nt1m commented Feb 19, 2025

Right now, it works over used values as specified by https://drafts.csswg.org/css-values-5/#random-caching , but that leads to weird behavior where resizing a window will cause new random values to be computed when viewport units are used: https://bugs.webkit.org/show_bug.cgi?id=287918

cc @tabatkins @weinig @smfr

@nt1m nt1m changed the title [css-values-5] Should random() function caching key work over computed values? [css-values-5] Should random() function caching key work over used values? Feb 19, 2025
@Loirooriol
Copy link
Contributor

<length> is absolutized to canonical units at computed-value time, so basing caching on computed values would have the same problem. And basing it on specified values seems weird?

@nt1m
Copy link
Member Author

nt1m commented Feb 19, 2025

#11742 would be one solution to this.

@tabatkins
Copy link
Member

Putting #11742 to the side for now, I don't have a real opinion on how this is resolved. The caching key is just constructed from the arguments to make it more likely that it's page-unique by default.

I don't think we really have a defined notion of "equality" for specified values. In theory we could make it based on token streams or source text, if we really wanted it to be stable?

@tabatkins
Copy link
Member

tabatkins commented Mar 8, 2025

Checked in a bunch of edits for review and WG approval as part of #11742 which also address this. The function no longer depends on its arguments at all except for the random-caching key; instead we synthesize some aspects of the caching key from the function's environment (the element, the property, this function's index among other random functions in the property value) if necessary.

So, assuming we approve the #11742 edits, this issue will be closed as well.

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

4 participants