Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: a2a0526673356774cd14b30ee6ee7701deb51eb9
https://github.com/WebKit/WebKit/commit/a2a0526673356774cd14b30ee6ee7701deb51eb9
Author: Joanne Pan <[email protected]>
Date: 2026-07-06 (Mon, 06 Jul 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-computed-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-computed.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-in-keyframe-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-in-keyframe.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-nested-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-nested.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-serialize-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-serialize.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-unresolvable-argument-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-unresolvable-argument.html
M Source/WebCore/style/StyleSubstitutionResolver.cpp
M Source/WebCore/style/StyleSubstitutionResolver.h
Log Message:
-----------
[css-values-5 random-item()] computed-value resolution (parse <random-key>,
select item)
https://bugs.webkit.org/show_bug.cgi?id=317702
rdar://180457609
Reviewed by Tim Nguyen.
Follow-up to #67706 (parse-time argument grammar, now landed). This resolves
random-item() at computed-value time.
Following substituteAttrFunction, substituteRandomItemFunction:
1. Substitutes the argument grammar first (so var() in the key resolve),
2. Parses the first argument as a <random-key>,
3. Selects one item via the random base value (round(down, R * N, 1)),
4. Substitutes the chosen item.
Spec: https://drafts.csswg.org/css-values-5/#funcdef-random-item (grammar
verified
against the current ED).
The <random-key> subset here matches random()'s current support: auto |
<dashed-ident> | element-scoped
| fixed <number [0,1]>. The remaining <random-cache-key> keywords
(property-scoped |
property-index-scoped | <random-ua-ident>) are a separate follow-up, in sync
with random().
auto is keyed by a substitution-time index in a space separate from random()'s
parse-time
cssRandomFunctionCount, so an auto random-item() and an auto random() in the
same property value can
land on the same cache key and share a base value, and the index follows the
selected branch rather
than parse position. Unifying the two counters is the job of the shared
<random-key> helper follow-up
(rdar://180934069). A coexistence regression test is included.
Tests: imported/w3c/web-platform-tests/css/css-values/random-item-computed.html
imported/w3c/web-platform-tests/css/css-values/random-item-in-keyframe.html
imported/w3c/web-platform-tests/css/css-values/random-item-nested.html
imported/w3c/web-platform-tests/css/css-values/random-item-serialize.html
imported/w3c/web-platform-tests/css/css-values/random-item-unresolvable-argument.html
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-computed-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-computed.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-in-keyframe-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-in-keyframe.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-nested-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-nested.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-serialize-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-serialize.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-unresolvable-argument-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-unresolvable-argument.html:
Added.
* Source/WebCore/style/StyleSubstitutionResolver.cpp:
(WebCore::Style::SubstitutionResolver::substituteVariableFunction):
(WebCore::Style::SubstitutionResolver::substituteRandomItemFunction):
(WebCore::Style::SubstitutionResolver::randomItemBaseValue):
(WebCore::Style::SubstitutionResolver::substituteTokenRange):
(WebCore::Style::SubstitutionResolver::substitute):
* Source/WebCore/style/StyleSubstitutionResolver.h:
Canonical link: https://commits.webkit.org/316589@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications