Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 93db4c27e85ed5fdde2c83fb523405b759ac223c
https://github.com/WebKit/WebKit/commit/93db4c27e85ed5fdde2c83fb523405b759ac223c
Author: Joanne Pan <[email protected]>
Date: 2026-08-11 (Tue, 11 Aug 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-computed.tentative-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-serialize.tentative-expected.txt
M Source/WebCore/Headers.cmake
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/css/CSSRandomKeyParser.cpp
M Source/WebCore/css/CSSRandomKeyParser.h
M Source/WebCore/css/CSSValueKeywords.in
M Source/WebCore/css/calc/CSSCalcRandomCachingKey.h
A Source/WebCore/css/calc/CSSCalcRandomSharing.h
R Source/WebCore/css/calc/CSSCalcRandomSharingOptions.h
M Source/WebCore/css/calc/CSSCalcTree+Evaluation.cpp
M Source/WebCore/css/calc/CSSCalcTree+Evaluation.h
M Source/WebCore/css/calc/CSSCalcTree+Parser.cpp
M Source/WebCore/css/calc/CSSCalcTree+Serialization.cpp
M Source/WebCore/css/calc/CSSCalcTree+Simplification.cpp
M Source/WebCore/css/calc/CSSCalcTree.h
M Source/WebCore/style/StyleSubstitutionResolver.cpp
M Source/WebCore/style/calc/StyleCalculationTree+Conversion.cpp
Log Message:
-----------
Add random() property-scoped and property-index-scoped caching keywords
https://bugs.webkit.org/show_bug.cgi?id=314234
rdar://176395332
Reviewed by Tim Nguyen and Antti Koivisto.
Original patch by fantasai in PR #64877; reworked to match the <random-key>
grammar structure and address review feedback.
random() and random-item() gained the property-scoped and property-index-scoped
<random-cache-key> keywords, which were added to the spec alongside the
310532@main scoping inversion but never implemented. The <random-key> is modeled
to mirror the grammar: an optional <dashed-ident> name, element-scoped, and an
optional property-scoped or property-index-scoped descriptor, with auto as a
distinct top-level alternative. It resolves to a caching key so that random
functions sharing the same property (and, for property-index-scoped, the same
value index) share a base value. Per CSS Values 5 ยง 9.4.1 these keywords are
meant to simplify at parse time into a <random-ua-ident>; that form and its
serialization are a follow-up, so for now they serialize as the keyword rather
than the canonical ua-* form.
As a side effect of making auto a distinct top-level alternative, random(auto,
...)
is now element-scoped, matching an omitted <random-key>. It was previously
document-scoped, which was a bug.
This also fixes a pre-existing serialization bug: a <random-key> with
element-scoped but no <dashed-ident> serialized with a stray leading space, as
random( element-scoped, 0px, 100px). Two random-serialize.tentative expectations
flip from FAIL to PASS accordingly.
random-item() rejects an explicit property-scoped or property-index-scoped
inside a
custom property, because cssPropertyID() is CSSPropertyCustom for every custom
property and honoring the scope would collapse them onto one shared base value.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-computed.tentative-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-serialize.tentative-expected.txt:
* Source/WebCore/Headers.cmake:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSRandomKeyParser.cpp:
(WebCore::CSSPropertyParserHelpers::consumeUnresolvedRandomKey):
(WebCore::CSSPropertyParserHelpers::randomSharingAuto):
* Source/WebCore/css/CSSRandomKeyParser.h:
* Source/WebCore/css/CSSValueKeywords.in:
* Source/WebCore/css/calc/CSSCalcRandomCachingKey.h:
(WebCore::CSSCalc::RandomCachingKey::RandomCachingKey):
(WebCore::CSSCalc::RandomCachingKey::isHashTableDeletedValue const):
(WebCore::CSSCalc::RandomCachingKey::isHashTableEmptyValue const):
(WTF::CSSCalcRandomCachingKeyHash::hash):
(WebCore::CSSCalc::RandomCachingKey::convertToIdentifier): Deleted.
* Source/WebCore/css/calc/CSSCalcRandomSharing.h: Renamed from
Source/WebCore/css/calc/CSSCalcRandomSharingOptions.h.
* Source/WebCore/css/calc/CSSCalcTree+Evaluation.cpp:
(WebCore::CSSCalc::resolveRandomBaseValue):
* Source/WebCore/css/calc/CSSCalcTree+Evaluation.h:
* Source/WebCore/css/calc/CSSCalcTree+Parser.cpp:
(WebCore::CSSCalc::consumeRandom):
* Source/WebCore/css/calc/CSSCalcTree+Serialization.cpp:
(WebCore::CSSCalc::serializeMathFunctionArguments):
* Source/WebCore/css/calc/CSSCalcTree+Simplification.cpp:
(WebCore::CSSCalc::simplify):
* Source/WebCore/css/calc/CSSCalcTree.h:
* Source/WebCore/style/StyleSubstitutionResolver.cpp:
(WebCore::Style::randomKeyHasExplicitPropertyScope):
(WebCore::Style::SubstitutionResolver::randomItemBaseValue):
* Source/WebCore/style/calc/StyleCalculationTree+Conversion.cpp:
(WebCore::Style::Calculation::toStyle):
Canonical link: https://commits.webkit.org/318960@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications