Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a26c23b4add22f9150f91d6eab8e5e1bb8027216
      
https://github.com/WebKit/WebKit/commit/a26c23b4add22f9150f91d6eab8e5e1bb8027216
  Author: Joanne Pan <[email protected]>
  Date:   2026-08-13 (Thu, 13 Aug 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/style/StyleSubstitutionResolver.cpp

  Log Message:
  -----------
  [css-values-5 random-item()] auto <random-key> is not element-scoped, so 
every element shares one item
https://bugs.webkit.org/show_bug.cgi?id=321702
rdar://184845561

Reviewed by Tim Nguyen.

An `auto` <random-key> simplifies to element-scoped property-index-scoped, for
both random() and random-item(). random() does this; random-item() keyed its
`auto` document-wide instead, so every element with the same declaration 
selected
the same item rather than choosing independently. The key is mandatory for
random-item(), so `auto` is what authors write for default behaviour.

Pass ElementScoped when resolving random-item()'s `auto`, matching random().

The removed FIXME justified the document-wide key by there being no element in
every substitution context. resolveRandomBaseValue() already covers that: it
returns nullopt for element-scoped sharing when there is no element, the same
path random() takes. random-item-in-keyframe.html and
random-item-in-container-query.tentative.html are unaffected.

This makes the index collision described by the remaining FIXME reachable. Both
functions count `auto` indices from zero in separate spaces, so an auto random()
and an auto random-item() in one property value now agree on property, index and
element, and share a base value. Previously the differing scopes kept them in
separate maps and hid it. Measured over 40 samples of
`width: calc(random(auto, 0px, 400px) + random-item(auto, 0px, 1000px))`, 
results
consistent with sharing went from 22/40 to 40/40. Unifying the counters is
webkit.org/b/319919.

* 
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/style/StyleSubstitutionResolver.cpp:
(WebCore::Style::SubstitutionResolver::randomItemBaseValue):

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



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

Reply via email to