Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 306d64a3ebf767b8467315d6b7eefa7383445c36
      
https://github.com/WebKit/WebKit/commit/306d64a3ebf767b8467315d6b7eefa7383445c36
  Author: Joanne Pan <[email protected]>
  Date:   2026-07-15 (Wed, 15 Jul 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-computed-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-computed.html
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    A Source/WebCore/css/CSSRandomKeyParser.cpp
    A Source/WebCore/css/CSSRandomKeyParser.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/style/StyleSubstitutionResolver.cpp

  Log Message:
  -----------
  [css-values-5 random-item()] Share <random-key> parsing between random() and 
random-item()
https://bugs.webkit.org/show_bug.cgi?id=319297
rdar://182133406

Reviewed by Elika Etemad.

random() and random-item() each had their own copy of the <random-key> parsing
(the auto / <dashed-ident> / element-scoped / fixed <number> sharing key). Per
review discussion on PR #68097, factor that logic into a single shared consumer
so the two stay in sync.

Add CSSPropertyParserHelpers::consumeUnresolvedRandomKey(), which parses
<random-key> and returns a CSSCalc::Random::Sharing. A makeAuto callback 
supplies
the RandomSharingOptions::Auto key, so each caller keeps its own auto-index 
source.
random() drops its private consumeOptionalRandomSharingFixed /
consumeOptionalRandomSharingOptions and calls the shared consumer (no behavior
change). random-item()'s randomItemBaseValue() drops its hand-rolled parsing, 
calls
the shared consumer, and resolves the parsed Sharing to a base value mirroring
random()'s evaluation.

Since random-item() now parses <random-key> identically to random(), two
previously-divergent random-item() behaviors change to match random() and the
spec: a bare `element-scoped` key is now a null-named <random-cache-key> shared
across instances (rather than a per-instance auto key, so it no longer consumes 
a
per-declaration auto index), and a <dashed-ident> as short as `--` is now 
accepted.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-computed-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-item-computed.html:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/css/CSSRandomKeyParser.cpp: Added.
(WebCore::CSSPropertyParserHelpers::consumeUnresolvedRandomKey):
* Source/WebCore/css/CSSRandomKeyParser.h: Added.
* Source/WebCore/css/calc/CSSCalcTree+Parser.cpp:
(WebCore::CSSCalc::consumeOptionalRandomSharing):
(WebCore::CSSCalc::consumeOptionalRandomSharingFixed): Deleted.
(WebCore::CSSCalc::consumeOptionalRandomSharingOptions): Deleted.
* Source/WebCore/style/StyleSubstitutionResolver.cpp:
(WebCore::Style::SubstitutionResolver::randomItemBaseValue):

Canonical link: https://commits.webkit.org/317259@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to