Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3b492a1ce76278e13f709737c5606545de35d189
https://github.com/WebKit/WebKit/commit/3b492a1ce76278e13f709737c5606545de35d189
Author: Antti Koivisto <[email protected]>
Date: 2026-08-27 (Thu, 27 Aug 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-definition-scope-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-definition-scope.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-parameter-scoping-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-parameter-scoping.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-relative-units-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-relative-units.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-in-custom-function.tentative-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-in-custom-function.tentative.html
M Source/WebCore/style/StyleBuilder.cpp
M Source/WebCore/style/StyleBuilder.h
M Source/WebCore/style/StyleSubstitutionResolver.cpp
M Source/WebCore/style/StyleSubstitutionResolver.h
Log Message:
-----------
[css-mixins-1] Registered function arguments should evaluate in calling
context
https://bugs.webkit.org/show_bug.cgi?id=322710
rdar://185975255
Reviewed by Sam Weinig.
Implement https://github.com/w3c/csswg-drafts/issues/14338
This mostly affects cycle detection:
@function --double(--len <length>) returns <length> { result: calc(var(--len) *
2); }
font-size: --double(1em);
used to be cycle because `em` unit was resolved in function context where we
can't reference the
property we are computing. In calling context it evaluates against parent
font-size which is fine.
A major benefit is that this allows significant code simplifications. We no
longer need to instantiate a separate
Style::Builder to resolve arguments.
Arguments are now computed directly against the calling element, so
first-valid() over the argument and
the default becomes a plain loop instead of a synthesized
-internal-first-valid() token stream that had
to be substituted a second time.
The hypothetical element the body is applied to now inherits a font, since
font-relative units resolve
against the element being styled rather than the parent style.
A default can reference an earlier parameter, so parameters are tracked while
they resolve. They are all
seeded first, so referencing a later one gives the guaranteed-invalid value
rather than the calling
element's property of that name. A <dashed-function> in a default is looked up
in the scope the function
was defined in.
Tests:
imported/w3c/web-platform-tests/css/css-mixins/function-definition-scope.html
imported/w3c/web-platform-tests/css/css-mixins/function-parameter-scoping.html
imported/w3c/web-platform-tests/css/css-mixins/function-relative-units.html
*
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-definition-scope-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-definition-scope.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-parameter-scoping-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-parameter-scoping.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-relative-units-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/function-relative-units.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-in-custom-function.tentative-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-values/random-in-custom-function.tentative.html:
* Source/WebCore/style/StyleBuilder.cpp:
(WebCore::Style::Builder::resolveCustomPropertyValue):
(WebCore::Style::Builder::computeCustomPropertyValueForSyntax):
* Source/WebCore/style/StyleBuilder.h:
* Source/WebCore/style/StyleSubstitutionResolver.cpp:
(WebCore::Style::SubstitutionResolver::propertyValueForVariableName):
(WebCore::Style::SubstitutionResolver::resolveAndRegisterDashedFunctionArguments):
(WebCore::Style::SubstitutionResolver::substituteDashedFunction):
(WebCore::Style::createFirstValidVariableData): Deleted.
* Source/WebCore/style/StyleSubstitutionResolver.h:
Canonical link: https://commits.webkit.org/320022@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications