Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: deb93ad60b5703b71dfdccc9aee62753e6ca4612
https://github.com/WebKit/WebKit/commit/deb93ad60b5703b71dfdccc9aee62753e6ca4612
Author: Antti Koivisto <[email protected]>
Date: 2026-07-07 (Tue, 07 Jul 2026)
Changed paths:
A LayoutTests/fast/css/container-style-range-query-invalidation-expected.txt
A LayoutTests/fast/css/container-style-range-query-invalidation.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/at-container-style-parsing-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/at-container-style-serialization-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/query-evaluation-style-expected.txt
M Source/WebCore/css/CSSCustomPropertyValue.cpp
M Source/WebCore/css/CSSCustomPropertyValue.h
M Source/WebCore/css/query/ContainerQuery.cpp
M Source/WebCore/css/query/ContainerQuery.h
M Source/WebCore/css/query/ContainerQueryFeatures.cpp
M Source/WebCore/css/query/ContainerQueryParser.cpp
M Source/WebCore/css/query/ContainerQueryParser.h
M Source/WebCore/css/query/GenericMediaQueryEvaluator.cpp
M Source/WebCore/css/query/GenericMediaQueryParser.cpp
M Source/WebCore/css/query/GenericMediaQueryParser.h
M Source/WebCore/css/query/GenericMediaQuerySerialization.cpp
M Source/WebCore/css/query/GenericMediaQueryTypes.h
M Source/WebCore/style/StyleScopeRuleSets.cpp
Log Message:
-----------
[css-conditional-5] Support style query ranges
https://bugs.webkit.org/show_bug.cgi?id=318679
rdar://181488548
Reviewed by Alan Baradlay.
Support range syntax in style queries:
@container style(10px < --foo <= 100px) { ... }
https://drafts.csswg.org/css-conditional-5/#typedef-style-range
Test: fast/css/container-style-range-query-invalidation.html
* LayoutTests/fast/css/container-style-range-query-invalidation-expected.txt:
Added.
* LayoutTests/fast/css/container-style-range-query-invalidation.html: Added.
Covers invalidation when the queried property is a comparison bound, the far
operand of a
two-property comparison, or referenced via var() in the range center.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/at-container-style-parsing-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/query-evaluation-style-expected.txt:
Now passing.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-conditional/container-queries/at-container-style-serialization-expected.txt:
Rebaselined: range operators now serialize with a trailing space per spec.
* Source/WebCore/css/CSSCustomPropertyValue.cpp:
(WebCore::CSSCustomPropertyValue::tokens const):
Return the tokens of an unresolved (substitution) value instead of asserting.
Style range
operands inspect these tokens to detect a bare <custom-property-name>.
* Source/WebCore/css/CSSCustomPropertyValue.h:
Make tokens() public.
* Source/WebCore/css/query/ContainerQuery.cpp:
(WebCore::CQ::collectCustomPropertyNames):
Collect every custom property a feature reads so mutations on the container
invalidate style:
the queried property, a bare-name range operand, and var() references at any
depth.
* Source/WebCore/css/query/ContainerQuery.h:
* Source/WebCore/css/query/ContainerQueryFeatures.cpp:
(WebCore::CQ::Features::evaluateStyleRangeValue):
Evaluate a resolved operand into a categorized value. <number> is tried first
so a unitless
zero categorizes as a number.
(WebCore::CQ::Features::styleRangeValuesShareCategory):
The comparison is invalid unless the operands share a category, with a unitless
zero allowed
against a <number> or <length>.
(WebCore::CQ::Features::StyleFeatureSchema::StyleFeatureSchema):
style() is now a Range feature.
(WebCore::CQ::Features::StyleFeatureSchema::evaluateRange const):
Resolve the center and bounds against the container and evaluate the
comparisons. The
resolution builder is created lazily so literal-only ranges skip it, and plain
(non-substitution)
values bypass the builder entirely.
* Source/WebCore/css/query/ContainerQueryParser.cpp:
(WebCore::CQ::consumeStyleRangeFeature):
Split operands on top-level comparison delimiters, capture each as an
unresolved declaration
value, and store a bare-name center in `name` (other centers in `subject`).
Reject three-operand
ranges whose comparisons disagree in direction or use '='.
(WebCore::CQ::consumeStyleFeature):
Parse boolean, plain and <style-range> style() features.
(WebCore::CQ::ContainerQueryParser::consumeAndValidateFeature):
Route style() features through the dedicated custom-property parser. Its
operands are custom
properties captured unresolved, and fitting that into the generic
boolean/plain/range path is
more trouble than a dedicated one.
* Source/WebCore/css/query/ContainerQueryParser.h:
* Source/WebCore/css/query/GenericMediaQueryEvaluator.cpp:
Use the shared compare() helper.
* Source/WebCore/css/query/GenericMediaQueryParser.cpp:
(WebCore::MQ::bareCustomPropertyName):
Shared helper: a single ident token that is a custom-property name.
(WebCore::MQ::FeatureParser::consumeFeatureName):
(WebCore::MQ::FeatureParser::consumeCustomPropertyValue):
Expose as FeatureParser members so the container-query style() parser can reuse
them.
(WebCore::MQ::FeatureParser::consumeRangeComparisonOperator):
Split the range operator parsing out of consumeRangeFeature so <style-range>
can reuse it.
(WebCore::MQ::FeatureParser::consumeRangeFeature):
Use the shared isConsistentThreeWayComparison() helper.
(WebCore::MQ::FeatureParser::validateFeatureAgainstSchema):
style() features are validated by consumeStyleFeature, not here.
* Source/WebCore/css/query/GenericMediaQueryParser.h:
(WebCore::MQ::GenericMediaQueryParser<ConcreteParser>::consumeQueryInParens):
Dispatch consumeAndValidateFeature through the concrete parser so
ContainerQueryParser can
override it for style().
* Source/WebCore/css/query/GenericMediaQuerySerialization.cpp:
(WebCore::MQ::serialize):
Serialize a non-name range center from `subject`.
* Source/WebCore/css/query/GenericMediaQueryTypes.h:
Add Feature::subject for a non-name style-range center. Move the shared
compare() and
isConsistentThreeWayComparison() helpers here so the size-range and style-range
parsers and
evaluators share them.
* Source/WebCore/style/StyleScopeRuleSets.cpp:
(WebCore::Style::ScopeRuleSets::customPropertyNamesInStyleContainerQueries
const):
Use collectCustomPropertyNames so range operands register for invalidation.
Canonical link: https://commits.webkit.org/316653@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications