Re: [csswg-drafts] [css-values-5] Maybe min, max and step should not be part of the random-caching-key (#11742)

The CSS Working Group just discussed `[css-values-5] Maybe min, max and step should not be part of the random-caching-key`.

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Proposal at https://github.com/w3c/csswg-drafts/issues/11742#issuecomment-2707697957<br>
&lt;emilio> TabAtkins: defining randomness in CSS because the execution model is not strictly temporal<br>
&lt;emilio> ... can't hold on to existing values<br>
&lt;emilio> ... don't want to calculate a random value on every recalc<br>
&lt;emilio> ... you need to have some stability<br>
&lt;emilio> ... the old draft did this via a caching key approach<br>
&lt;emilio> ... so if the key is the same between two instances of a random() function then the values need to be the same<br>
&lt;emilio> ... this caching key has changed tho<br>
&lt;emilio> ... author could provide a custom-ident, but also min/max/step values were pulled in<br>
&lt;emilio> ... any other random function would probably have a different step and thus generate a different random value<br>
&lt;emilio> ... this worked reasonably well but did mean that values could be accidentally linked together<br>
&lt;emilio> ... so random width/height you would get a random square<br>
&lt;emilio> ... rather than a random value<br>
&lt;fantasai> s/value/rectangle<br>
&lt;emilio> ... fantasai proposed something else, which is on the spec right now. Caching key is (property, index among random values in that property)<br>
&lt;emilio> ... so if you use `width: ...;` the key is (width, 0)<br>
&lt;emilio> fantasai: you don't want a global random<br>
&lt;emilio> ... caching key also includes the element identity<br>
&lt;emilio> ... all of that gets computed to a random value which they inherits so that we don't recalc it for inheritable properties<br>
&lt;emilio> TabAtkins: so on a single element if you use the same values on different properties you're guaranteed to get distinct values<br>
&lt;emilio> ... you can override it if you want, so you could still pass the same ident to width/height<br>
&lt;emilio> ... some good examples of this are in the spec<br>
&lt;emilio> ... don't know what people might need for this but I propose we accept the new draft based on elika's proposal for the different key<br>
&lt;emilio> q+<br>
&lt;emilio> ... one further question about bikeshedding the keyword name<br>
&lt;weinig> q+<br>
&lt;astearns> ack emilio<br>
&lt;fantasai> emilio: Is this declaration index thing local to each element you compute?<br>
&lt;fantasai> TabAtkins: There's a 2nd thing you can provide, which is a keyword indicating whether this value should be shared by all elements with this style, or be element-specific.<br>
&lt;fantasai> TabAtkins: Then it either includes the element identity in the caching key or not<br>
&lt;weinig> q-<br>
&lt;fantasai> emilio: Say you have 2 selectors with random() and you have an element that matches one, and another that matches both of them<br>
&lt;fantasai> emilio: so in one the index ...<br>
&lt;fantasai> TabAtkins: index is just the number of random() instances in that declaration.<br>
&lt;fantasai> TabAtkins: so for 'width' always index of zero<br>
&lt;fantasai> emilio: So if they're in different elements, they would be shared?<br>
&lt;fantasai> TabAtkins: if not adding extra "match-across-elements" keyword, then they all include element ident<br>
&lt;fantasai> TabAtkins: This is new, because CSS generally doesn't care where a value came from<br>
&lt;fantasai> TabAtkins: whether spell out in comma-separated selector list, or in a style attr, these are all the same<br>
&lt;fantasai> TabAtkins: I want to maintain that equivalence as much as possible<br>
&lt;fantasai> TabAtkins: so only including information from declaration it lives in. Nothing from style rule or selector.<br>
&lt;fantasai> emilio: So maybe some things that you would expect to work don't?<br>
&lt;fantasai> emilio: e.g. 10 elements, each with style blah: random()<br>
&lt;fantasai> emilio: ok, sounds good<br>
&lt;fantasai> TabAtkins: To be clear, having it vary by element is the default. You have to specify keyword to make it shared across elements.<br>
&lt;fantasai> TabAtkins: so common case would be what you expect there<br>
&lt;fantasai> emilio: seems reasonable<br>
&lt;fantasai> emilio: Shorthands maybe funny?<br>
&lt;fantasai> TabAtkins: it uses the declared property, e.g. in 'margin' you'd use 'margin' as part of the key, not the longhand names<br>
&lt;fantasai> TabAtkins: if you write 'margin: random(...)' you get equal margins on all four sides<br>
&lt;fantasai> TabAtkins: there's a bit of text in the draft about how this works for custom properties, it's a bit weird (unfortunately)<br>
&lt;fantasai> TabAtkins: unregistered vs registered properties, since the latter compute and the former don't before substitution<br>
&lt;fantasai> emilio: Might be confusing, but as long as we clarify impact of registration should be ok<br>
&lt;fantasai> astearns: over time<br>
&lt;astearns> ack fantasai<br>
&lt;emilio> fantasai: what we're trying to do is by default you get max randomness (varies by element, property, declaration index), but doesn't by where you declare it<br>
&lt;emilio> ... within an element you can make it shared by using the custom property<br>
&lt;emilio> ... can share across elements with the keyword tbd<br>
&lt;emilio> ... I think it's the right direction<br>
&lt;emilio> astearns: a bit concerned about oriol's comments<br>
&lt;fantasai> astearns: Concerned about Oriol not being convinced yet.<br>
&lt;emilio> TabAtkins: I feel strongly about this model<br>
&lt;emilio> fantasai: we should give oriol a chance to comment on here<br>
&lt;emilio> astearns: let's defer this to next week<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11742#issuecomment-2737419031 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 19 March 2025 17:04:51 UTC