Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9334b44ff7ef9b546018ba0417e9f0f0cfaddc22
https://github.com/WebKit/WebKit/commit/9334b44ff7ef9b546018ba0417e9f0f0cfaddc22
Author: Antti Koivisto <[email protected]>
Date: 2026-08-07 (Fri, 07 Aug 2026)
Changed paths:
M LayoutTests/TestExpectations
M
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-cascade-007-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-cascade-parent-style-change-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-cascade-parent-style-change.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-cascade-shadow-boundary-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-cascade-shadow-boundary.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-currentcolor-computed-inheritance-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-pseudos-inheritance-computed-001-expected.txt
M Source/WebCore/css/CSSProperties.json
M Source/WebCore/css/CSSProperty.h
M Source/WebCore/css/query/ContainerQueryFeatures.cpp
M Source/WebCore/css/scripts/process-css-properties.py
M Source/WebCore/css/scripts/test/TestCSSProperties.json
M
Source/WebCore/css/scripts/test/TestCSSPropertiesResults/CSSPropertyNames.gperf
M
Source/WebCore/css/scripts/test/TestCSSPropertiesResults/StyleBuilderGenerated.cpp
M Source/WebCore/rendering/style/RenderStyleConstants.h
M Source/WebCore/style/MatchedDeclarationsCache.cpp
M Source/WebCore/style/PropertyAllowlist.cpp
M Source/WebCore/style/PseudoElementIdentifier.h
M Source/WebCore/style/StyleBuilder.cpp
M Source/WebCore/style/StyleBuilder.h
M Source/WebCore/style/StyleBuilderCustom.h
M Source/WebCore/style/StyleBuilderGenerated.h
M Source/WebCore/style/StyleBuilderState.h
M Source/WebCore/style/StyleBuilderStateInlines.h
M Source/WebCore/style/StyleResolver.cpp
M Source/WebCore/style/StyleResolver.h
M Source/WebCore/style/StyleTreeResolver.cpp
M Source/WebCore/style/computed/StyleComputedStyleBase+GettersInlines.h
M Source/WebCore/style/computed/StyleComputedStyleBase+SettersInlines.h
M Source/WebCore/style/computed/StyleComputedStyleBase.h
M Source/WebCore/style/computed/data/StyleInheritedData.cpp
M Source/WebCore/style/computed/data/StyleInheritedData.h
M Tools/Scripts/webkitpy/style/checkers/jsonchecker.py
Log Message:
-----------
[Custom Highlight] ::highlight() pseudo-elements should inherit from the
parent element's highlight.
https://bugs.webkit.org/show_bug.cgi?id=320716
rdar://183702060
Reviewed by Alan Baradlay.
Implement per-property highlight cascade per
https://drafts.csswg.org/css-pseudo-4/#highlight-cascade
"When any supported property is not given a value by the cascade, or given a
value of inherit or unset,
its specified value is determined by inheritance from the corresponding
highlight pseudo-element of its
originating element’s parent element. This occurs regardless of whether that
property is an inherited property."
This requires adding highlight specific inheritance paths to style builder.
Test:
imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-cascade-parent-style-change.html
* LayoutTests/TestExpectations:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-cascade-007-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-cascade-parent-style-change-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-cascade-parent-style-change.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-cascade-shadow-boundary-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-cascade-shadow-boundary.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-currentcolor-computed-inheritance-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/highlight-cascade/highlight-pseudos-inheritance-computed-001-expected.txt:
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/CSSProperty.h:
* Source/WebCore/css/query/ContainerQueryFeatures.cpp:
(WebCore::CQ::Features::StyleFeatureSchema::evaluateRange const):
Designated initializers for BuilderContext, so that adding a member doesn't
silently shift
the arguments. Same for ResolutionContext in StyleTreeResolver.cpp below.
* Source/WebCore/css/scripts/process-css-properties.py:
(StylePropertyCodeGenProperties):
(StylePropertyCodeGenProperties.from_json):
(applies_to_highlight_pseudo_elements):
(inherits_in_highlight_pseudo_elements):
(GenerateCSSPropertyNames):
* Source/WebCore/css/scripts/test/TestCSSProperties.json:
*
Source/WebCore/css/scripts/test/TestCSSPropertiesResults/CSSPropertyNames.gperf:
*
Source/WebCore/css/scripts/test/TestCSSPropertiesResults/StyleBuilderGenerated.cpp:
(WebCore::Style::BuilderFunctions::applyHighlightInheritTestColorPropertyWithVisitedLinkSupport):
(WebCore::Style::BuilderFunctions::applyHighlightInheritTestRenderStyleHasExplicitlySetPolicyAllAuthorOrigin):
(WebCore::Style::BuilderGenerated::applyHighlightInheritAllProperties):
(WebCore::Style::BuilderGenerated::applyHighlightProperty):
New applies-to-highlight-pseudo-elements codegen property. It generates the
allowlist
predicate and an applyHighlightInherit<Property>() reading the parent highlight
style
instead of the parent style. Its "yes-without-inheritance" value is for fill
and stroke,
which stay allowed but keep inheriting from the originating element: the
applicable
property list has 'fill-color' and 'stroke-color', which we don't support,
rather than
the SVG paint properties.
style-builder-custom takes HighlightInitial, HighlightInherit and
HighlightValue for the
properties that need more than reading a value out of the parent highlight
style.
* Source/WebCore/rendering/style/RenderStyleConstants.h:
A highlight pseudo-element exists whenever it exists for the parent element,
since it
inherits from it even with no rules of its own. The bits get propagated to the
children
so that the early return in RenderElement::resolvePseudoElementStyle() keeps
working
without gating out descendants that match nothing themselves.
* Source/WebCore/style/MatchedDeclarationsCache.cpp:
(WebCore::Style::MatchedDeclarationsCache::isCacheable):
The parent highlight style is not part of the cache key, and
copyNonInheritedFrom() on a
hit would drop the inherited background-color and text-decoration values.
* Source/WebCore/style/PropertyAllowlist.cpp:
(WebCore::Style::isValidHighlightStyleProperty):
The allowlist is generated now. Custom properties are not in the applicable
property list
but are allowed, since they can be substituted into the properties that are.
* Source/WebCore/style/StyleBuilder.cpp:
(WebCore::Style::Builder::applyHighlightInheritance):
(WebCore::Style::Builder::applyProperty):
* Source/WebCore/style/StyleBuilder.h:
A highlight style applies every property through applyHighlightProperty(),
which uses the
highlight version of a function where there is one and otherwise falls back to
applyProperty(), so the normal path has no highlight code in it.
unset inherits instead of resolving to the initial value, which is what makes
the
non-inherited properties like background-color participate.
* Source/WebCore/style/StyleBuilderCustom.h:
(WebCore::Style::BuilderCustom::applyHighlightInitialColor):
(WebCore::Style::BuilderCustom::applyHighlightValueColor):
(WebCore::Style::BuilderCustom::applyHighlightInheritColor):
currentcolor in a highlight pseudo-element is the originating element's color,
so the
chain inherits the keyword rather than the color it resolved to. These are the
only
functions that write the bit for it.
* Source/WebCore/style/StyleBuilderGenerated.h:
* Source/WebCore/style/StyleBuilderState.h:
* Source/WebCore/style/StyleBuilderStateInlines.h:
(WebCore::Style::BuilderState::isBuildingHighlightStyle const):
parentHighlightStyle() returns a pointer, since it is null at the start of the
chain,
where the inherited value is the initial value except for color.
* Source/WebCore/style/StyleResolver.cpp:
(WebCore::Style::Resolver::State::State):
(WebCore::Style::Resolver::State::parentHighlightStyle const):
(WebCore::Style::Resolver::builderContext const):
(WebCore::Style::Resolver::unadjustedStyleForElement):
(WebCore::Style::parentHighlightStyleIgnoringPendingUpdate):
(WebCore::Style::Resolver::styleForPseudoElement):
(WebCore::Style::Resolver::applyMatchedProperties):
* Source/WebCore/style/StyleResolver.h:
The chain is resolved one level per style, each cached in the ancestor's style,
and
follows the flat tree like the rest of inheritance, so it continues past a
shadow
boundary to the host. A highlight pseudo-element with no rules of its own now
gets a
style too, so that it can pass the inherited values on to its descendants.
The parent highlight style comes in with the ResolutionContext, because
highlight styles
are also re-resolved during tree resolution, where the parent's existing
computed style
is the one being replaced. The lazy paths still walk up to find it, which is
correct
there since nothing is being resolved.
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::makeResolutionContext):
(WebCore::Style::TreeResolver::makeResolutionContextForPseudoElement):
(WebCore::Style::TreeResolver::makeResolutionContextForInheritedFirstLine):
(WebCore::Style::TreeResolver::resolveAgainInDifferentContext):
(WebCore::Style::TreeResolver::applyCascadeAfterAnimation):
* Source/WebCore/style/computed/StyleComputedStyleBase+GettersInlines.h:
(WebCore::Style::ComputedStyleBase::colorIsCurrentColorForHighlight const):
(WebCore::Style::ComputedStyleBase::highlightPseudoElementTypes const):
* Source/WebCore/style/computed/StyleComputedStyleBase+SettersInlines.h:
(WebCore::Style::ComputedStyleBase::setColorIsCurrentColorForHighlight):
* Source/WebCore/style/computed/StyleComputedStyleBase.h:
* Source/WebCore/style/computed/data/StyleInheritedData.cpp:
(WebCore::Style::InheritedData::InheritedData):
(WebCore::Style::InheritedData::fastPathInheritedEqual const):
(WebCore::Style::InheritedData::fastPathInheritFrom):
(WebCore::Style::InheritedData::dumpDifferences const):
* Source/WebCore/style/computed/data/StyleInheritedData.h:
The bit lives with the color it describes, so it travels with inheritFrom() and
the fast
path without any handling of its own.
* Tools/Scripts/webkitpy/style/checkers/jsonchecker.py:
(JSONCSSPropertiesChecker.check_codegen_properties):
Canonical link: https://commits.webkit.org/318779@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications