Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ae3c47183d329b9d9d4c04a594cef7359dc00700
      
https://github.com/WebKit/WebKit/commit/ae3c47183d329b9d9d4c04a594cef7359dc00700
  Author: Joanne Pan <[email protected]>
  Date:   2026-08-11 (Tue, 11 Aug 2026)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/local-inherit-substitution-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/custom-property-explicit-inherit-invalidation-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/custom-property-explicit-inherit-invalidation.html
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/inherit-function-basic-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/inherit-function-invalidation-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/inherit-function-parsing-expected.txt
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M Source/WebCore/css/CSSSubstitutionValue.cpp
    M Source/WebCore/css/CSSSubstitutionValue.h
    M Source/WebCore/css/parser/CSSParserContext.cpp
    M Source/WebCore/css/parser/CSSParserContext.h
    M Source/WebCore/css/parser/CSSSubstitutionParser.cpp
    M Source/WebCore/style/PropertyCascade.cpp
    M Source/WebCore/style/StyleSubstitutionResolver.cpp
    M Source/WebCore/style/StyleSubstitutionResolver.h

  Log Message:
  -----------
  [css-values-5 inherit()] Implement inherit() substitution function
https://bugs.webkit.org/show_bug.cgi?id=320984
rdar://184017733

Reviewed by Antti Koivisto.

Implement the inherit() arbitrary substitution function, which resolves to the
inherited value of a custom property, meaning the parent's computed value, with
an optional second argument as a fallback when the first resolves to the
guaranteed-invalid value.

<inherit()> = inherit( <custom-property-name>, <declaration-value>? )

The argument grammar is the same as attr()'s, so parsing and argument
substitution are shared with it. The first argument is substituted before being
parsed as a custom property name, and failing that parse falls through to the
fallback rather than being an error.

Inside a custom function the parent is the calling context's element, whose
custom properties resolve lazily, so the read forces that property first.
Otherwise the result would depend on the calling element's declaration order.

The cascade now re-applies a declaration containing inherit() when the parent's
non-inherited style changes, where it previously recognised only a literally
written inherit keyword. This covers custom property declarations too, which
also fixes the pre-existing case of `--y: inherit` on a non-inherited
registered property. A declaration that only reads such a property, as in
`border-color: var(--y)`, is still not re-applied; that is the more general
problem tracked in bug 321094.

Behind the CSSInheritFunctionEnabled setting, off by default.

* 
LayoutTests/imported/w3c/web-platform-tests/css/css-mixins/local-inherit-substitution-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/custom-property-explicit-inherit-invalidation-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-properties-values-api/custom-property-explicit-inherit-invalidation.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/inherit-function-basic-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/inherit-function-invalidation-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/css/css-values/inherit-function-parsing-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/css/CSSSubstitutionValue.cpp:
(WebCore::containsInheritFunctionToken):
(WebCore::CSSSubstitutionValue::CSSSubstitutionValue):
* Source/WebCore/css/CSSSubstitutionValue.h:
(WebCore::CSSSubstitutionValue::containsInheritFunction const):
* Source/WebCore/css/parser/CSSParserContext.cpp:
(WebCore::CSSParserContext::CSSParserContext):
(WebCore::add):
* Source/WebCore/css/parser/CSSParserContext.h:
* Source/WebCore/css/parser/CSSSubstitutionParser.cpp:
(WebCore::classifyBlock):
(WebCore::isValidDeclarationValueAndFallback):
* Source/WebCore/style/PropertyCascade.cpp:
(WebCore::Style::explicitlyInheritsFromParent):
(WebCore::Style::PropertyCascade::addMatch):
* Source/WebCore/style/StyleSubstitutionResolver.cpp:
(WebCore::Style::SubstitutionResolver::substituteInheritFunction):
(WebCore::Style::SubstitutionResolver::substituteDeclarationValueAndFallback):
(WebCore::Style::SubstitutionResolver::substituteAttrFunction):
(WebCore::Style::SubstitutionResolver::substituteTokenRange):
* Source/WebCore/style/StyleSubstitutionResolver.h:

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



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

Reply via email to