Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 50e6a9b7f52c6933ff612f652a67c0558781af54
https://github.com/WebKit/WebKit/commit/50e6a9b7f52c6933ff612f652a67c0558781af54
Author: Ahmad Saleem <[email protected]>
Date: 2026-10-05 (Mon, 05 Oct 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/functions/function-shadow-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/functions/function-shadow.html
M Source/WebCore/style/StyleScope.h
Log Message:
-----------
Tree-scoped var() and custom-function references inside an @function fail to
resolve when the function is called from a :host rule
https://bugs.webkit.org/show_bug.cgi?id=324997
rdar://188206030
Reviewed by Antti Koivisto.
This patch aligns WebKit with Blink / Chromium.
resolveTreeScopedReference() walks from the reference's own scope out through
its enclosing host scopes, decrementing the ScopeOrdinal at each step to name
the scope a match was found in. The decrement is correct for the slot chain
(FirstSlot -> Element) and the containing-host chain (Element ->
ContainingHost),
but not for a reference that starts in the element's own shadow tree.
ScopeOrdinal is not a contiguous range: Shadow is int8_t max (127) while the
host of a shadow tree is the element's own tree, Element (0). These are not
numerically adjacent, so `--scopeOrdinal` turned Shadow (127) into 126, i.e.
SlotLimit, rather than Element.
The top-level lookup still succeeded because the resolved Scope is handed to
the callback directly and the construct is matched by name. But the returned
ordinal was wrong: for a custom function this ordinal is stamped onto the
function body's declarations and used as their lookup scope, so any var() or
nested dashed-function reference in the body was later resolved against
SlotLimit. Scope::forOrdinal() maps that through assignedSlotForScopeOrdinal(),
which returns null, so the nested reference failed and the whole function
evaluated to the guaranteed-invalid value.
Special-case the transition out of the element's own shadow tree so the first
host step lands on Element; every subsequent step remains a normal decrement.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/functions/function-shadow-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/functions/function-shadow.html:
* Source/WebCore/style/StyleScope.h:
(WebCore::Style::resolveTreeScopedReference):
Canonical link: https://commits.webkit.org/322679@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications