Closed Bug 2087937 Opened 16 days ago Closed 5 days ago

[css-values] Property-scoped random() should use different UA prefix when substituted early

Categories

(Core :: CSS Parsing and Computation, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: sajidanwar, Assigned: sajidanwar)

References

(Blocks 1 open bug)

Details

Attachments

(2 external files)

Bug 2080511 added support for arbitrary substitution functions that parse their arguments at substitution time (which is at computed value time). This is called early substitution and it affects the prefix used by property-scoped / property-index-scoped random keys. For example:

  • width: if(style(--level < random(0, 10)): random(0px, 100px)) - The if's condition is substituted early, so function is equivalent to random(element-scoped ua-early-width-1, 0, 10). The branch value is substituted normally, so it is equivalent to random(element-scoped ua-width-1, 0px, 100px).
  • width: attr(data-width type(<length>)) with data-width="random(property-scoped, 0px, 100px)" - The attribute value is parsed as part of early substitution, so it is equivalent to random(ua-early-width, 0px, 100px).
  • animation-name: ident('animation-style-' random(1, 5, 1)) - The arguments are substituted and parsed early in order to construct the ident, so the random function is equivalent to random(element-scoped ua-early-animation-name-1, 1, 5, 1).

This requires adding a mode to the ParserContext to indicate early substitution.

Bug 2080511 added support for arbitrary substitution functions that parse their
arguments at substitution/computed-value time. This is called early substitution
and it affects the prefix used by property-scoped / property-index-scoped random
keys -- for example, when random() is used in attribute values of a typed attr(),
the conditions of if(), or the ident() function.

Generating the correct <random-ua-ident> for such random keys requires adding a
parsing mode to indicate early substitution, and introducing a separate counter for
early random() functions. This patch also propagates the correct property name
through the entire substitution process.

Assignee: nobody → sajidanwar94
Status: NEW → ASSIGNED
Blocks: 2090870
Status: ASSIGNED → RESOLVED
Closed: 7 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/65027 for changes under testing/web-platform/tests

Upstream PR merged by moz-wptsync-bot

Pushed by sajidanwar94@gmail.com: https://github.com/mozilla-firefox/firefox/commit/27ea5a44a55d https://hg.mozilla.org/integration/autoland/rev/399d663b21f9 Proper <random-ua-ident> for early substituted random() in substitution functions. r=firefox-style-system-reviewers,emilio

Backed out for causing wpt failures at custom-property-explicit-inherit-invalidation.html
Backout link
Push with failures
Failure log(s)

Flags: needinfo?(sajidanwar94)
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 162 Branch → ---

Failure for this patch is actually in random-computed.tentative.html, for example, this job. The root cause is that I have tests that try to test whether a <length> random value is using the expected ua-<PROPERTY>-<INDEX> identifier, by doing something like this (through arbitrary substitution functions):

margin: random(property-index-scoped, 1px, 300000px);
--registered-length: random(ua-margin-1, 1px, 300000px);

These should compute to the same value because the margin declaration should implicitly resolve to a ua-margin-1 random key.

The test failure occurs intermittently and is due to a serialization issue. Because margin is one of the properties that returns the used/resolved value from getComputedStyle, and Gecko represents layout values using fixed point app units, the value that the test sees may be slightly different from the --registered-length which is an f32. So for some large random values, the serialization can differ between the fixed and floating point values and can then fail the test.

So to fix, I'm changing this to use a 1px step so that the values are all representable and serialized the same.

Flags: needinfo?(sajidanwar94)
Pushed by sajidanwar94@gmail.com: https://github.com/mozilla-firefox/firefox/commit/424e490bbe64 https://hg.mozilla.org/integration/autoland/rev/c4c9ead74e0d Proper <random-ua-ident> for early substituted random() in substitution functions. r=firefox-style-system-reviewers,emilio
Status: REOPENED → RESOLVED
Closed: 7 days ago → 5 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/65151 for changes under testing/web-platform/tests

Upstream PR merged by moz-wptsync-bot

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: