-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CSS Container Queries][Style queries] Basic evaluation support
https://bugs.webkit.org/show_bug.cgi?id=269061 rdar://122623247 Reviewed by Alan Baradlay. Evaluate @container style(--property:foo) queries. * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/at-container-style-parsing-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/at-container-style-serialization-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/custom-property-style-queries-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/custom-property-style-query-change-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/display-contents-dynamic-style-queries-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/nested-size-style-container-invalidation-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/pseudo-elements-005-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/query-evaluation-style-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/style-container-for-shadow-dom-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/style-container-invalidation-inheritance-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/style-query-with-unknown-width-expected.txt: * Source/WebCore/css/parser/CSSParserTokenRange.cpp: (WebCore::CSSParserTokenRange::consumeAllExcludingTrailingWhitespace): Add a helper. * Source/WebCore/css/parser/CSSParserTokenRange.h: * Source/WebCore/css/query/ContainerQuery.h: * Source/WebCore/css/query/ContainerQueryFeatures.cpp: Evaluate the query by looking up and comparing the property value. * Source/WebCore/css/query/GenericMediaQueryParser.cpp: (WebCore::MQ::consumeCustomPropertyValue): Don't include trailing whitespace to custom property value. (WebCore::MQ::FeatureParser::consumeBooleanOrPlainFeature): * Source/WebCore/style/ContainerQueryEvaluator.h: Pass the currently resolved style via ContainerQueryEvaluationState. * Source/WebCore/style/ContainerQueryEvaluator.cpp: (WebCore::Style::ContainerQueryEvaluator::ContainerQueryEvaluator): (WebCore::Style::styleForContainer): (WebCore::Style::ContainerQueryEvaluator::featureEvaluationContextForQuery const): Look up the currently resolved style for the container. It may not have yet been committed to the render tree. Allow containers that don't generate boxes. (WebCore::Style::ContainerQueryEvaluator::selectContainer): Similarly use the current style for container selection. Allow any element to be a container for style queries. * Source/WebCore/style/ContainerQueryEvaluator.h: * Source/WebCore/style/ElementRuleCollector.cpp: (WebCore::Style::ElementRuleCollector::containerQueriesMatch): * Source/WebCore/style/SelectorMatchingState.h: * Source/WebCore/style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::Scope::Scope): Pass a reference to the current style update to container query evaluation. (WebCore::Style::TreeResolver::pushParent): (WebCore::Style::TreeResolver::popParent): (WebCore::Style::TreeResolver::resolve): * Source/WebCore/style/StyleTreeResolver.h: * Source/WebCore/style/StyleUpdate.cpp: (WebCore::Style::Update::addInitialContainingBlockUpdate): * Source/WebCore/style/StyleUpdate.h: (WebCore::Style::Update::addInitialContainingBlockUpdate): Deleted. Canonical link: https://commits.webkit.org/274364@main
- Loading branch information
Showing
24 changed files
with
172 additions
and
112 deletions.
There are no files selected for viewing
18 changes: 9 additions & 9 deletions
18
...-platform-tests/css/css-contain/container-queries/at-container-style-parsing-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
|
||
FAIL style(--my-prop: foo) assert_equals: expected "true" but got "" | ||
FAIL style(--my-prop: foo - bar ()) assert_equals: expected "true" but got "" | ||
FAIL style(not ((--foo: calc(10px + 2em)) and ((--foo: url(x))))) assert_equals: expected "true" but got "" | ||
FAIL style((--foo: bar) or (--bar: 10px)) assert_equals: expected "true" but got "" | ||
FAIL style(--my-prop:) assert_equals: expected "true" but got "" | ||
FAIL style(--my-prop: ) assert_equals: expected "true" but got "" | ||
FAIL style(--foo: bar !important) assert_equals: expected "true" but got "" | ||
FAIL style(--foo) assert_equals: expected "true" but got "" | ||
PASS style(--foo: bar;) | ||
PASS style(--my-prop: foo) | ||
PASS style(--my-prop: foo - bar ()) | ||
PASS style(not ((--foo: calc(10px + 2em)) and ((--foo: url(x))))) | ||
PASS style((--foo: bar) or (--bar: 10px)) | ||
PASS style(--my-prop:) | ||
PASS style(--my-prop: ) | ||
PASS style(--foo: bar !important) | ||
PASS style(--foo) | ||
FAIL style(--foo: bar;) assert_equals: expected "" but got "true" | ||
PASS style(style(--foo: bar)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...m-tests/css/css-contain/container-queries/custom-property-style-query-change-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...sts/css/css-contain/container-queries/display-contents-dynamic-style-queries-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
This should be green | ||
|
||
PASS Initially the color is red | ||
FAIL After display and --foo changes, style() query causes the color to be green assert_equals: expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" | ||
PASS After display and --foo changes, style() query causes the color to be green | ||
|
2 changes: 1 addition & 1 deletion
2
...s/css/css-contain/container-queries/nested-size-style-container-invalidation-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Green? | ||
|
||
PASS Initially red | ||
FAIL Green after reducing width assert_equals: expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" | ||
PASS Green after reducing width | ||
|
2 changes: 1 addition & 1 deletion
2
...w3c/web-platform-tests/css/css-contain/container-queries/pseudo-elements-005-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
FAIL ::before pseudo element querying style() of originating element assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
PASS ::before pseudo element querying style() of originating element | ||
PASS ::before pseudo element not matching style() | ||
FAIL ::before pseudo element matching style() query after class change assert_equals: expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" | ||
|
22 changes: 11 additions & 11 deletions
22
.../web-platform-tests/css/css-contain/container-queries/query-evaluation-style-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
|
||
FAIL style((--foo: bar)) assert_equals: expected "true" but got "false" | ||
PASS style((--foo: bar)) | ||
PASS style((--baz: qux)) | ||
PASS style((unknown)) | ||
PASS unknown((--foo: bar)) | ||
PASS style(not (--foo: bar)) | ||
FAIL style(not (--baz: qux)) assert_equals: expected "true" but got "false" | ||
PASS style(not (--baz: qux)) | ||
PASS style(not (unknown)) | ||
FAIL style((--foo: bar) and (--foo: bar)) assert_equals: expected "true" but got "false" | ||
FAIL style((--foo: bar) and (--foo: bar) and (--foo: bar)) assert_equals: expected "true" but got "false" | ||
PASS style((--foo: bar) and (--foo: bar)) | ||
PASS style((--foo: bar) and (--foo: bar) and (--foo: bar)) | ||
PASS style((--baz: qux) and (--baz: qux)) | ||
PASS style((--baz: qux) and (--foo: bar) and (--foo: bar)) | ||
PASS style((--foo: bar) and (--baz: qux) and (--foo: bar)) | ||
PASS style((--foo: bar) and (--foo: bar) and (--baz: qux)) | ||
PASS style((unknown) and (--foo: bar) and (--foo: bar)) | ||
PASS style((--foo: bar) and (unknown) and (--foo: bar)) | ||
PASS style((--foo: bar) and (--foo: bar) and (unknown)) | ||
FAIL style((--foo: bar) or (--foo: bar)) assert_equals: expected "true" but got "false" | ||
FAIL style((--foo: bar) or (--foo: bar) or (--foo: bar)) assert_equals: expected "true" but got "false" | ||
PASS style((--foo: bar) or (--foo: bar)) | ||
PASS style((--foo: bar) or (--foo: bar) or (--foo: bar)) | ||
PASS style((--baz: qux) or (--baz: qux)) | ||
FAIL style((--baz: qux) or (--foo: bar) or (--foo: bar)) assert_equals: expected "true" but got "false" | ||
FAIL style((--foo: bar) or (--baz: qux) or (--foo: bar)) assert_equals: expected "true" but got "false" | ||
FAIL style((--foo: bar) or (--foo: bar) or (--baz: qux)) assert_equals: expected "true" but got "false" | ||
PASS style((--baz: qux) or (--foo: bar) or (--foo: bar)) | ||
PASS style((--foo: bar) or (--baz: qux) or (--foo: bar)) | ||
PASS style((--foo: bar) or (--foo: bar) or (--baz: qux)) | ||
PASS style((unknown) or (--foo: bar) or (--foo: bar)) | ||
PASS style((--foo: bar) or (unknown) or (--foo: bar)) | ||
PASS style((--foo: bar) or (--foo: bar) or (unknown)) | ||
PASS style((unknown) or (--baz: qux) or (--foo: bar)) | ||
PASS style(not ((--foo: bar) and (--foo: bar))) | ||
FAIL style(not ((--foo: bar) and (--baz: qux))) assert_equals: expected "true" but got "false" | ||
PASS style(not ((--foo: bar) and (--baz: qux))) | ||
PASS style((--foo: bar) and (not ((--baz: qux) or (--foo: bar)))) | ||
FAIL style((--baz: qux) or (not ((--baz: qux) and (--foo: bar)))) assert_equals: expected "true" but got "false" | ||
PASS style((--baz: qux) or (not ((--baz: qux) and (--foo: bar)))) | ||
PASS style((--baz: qux) or ((--baz: qux) and (--foo: bar))) | ||
|
22 changes: 11 additions & 11 deletions
22
...tform-tests/css/css-contain/container-queries/style-container-for-shadow-dom-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
|
||
FAIL Match container in outer tree assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
FAIL Match container in same tree, not walking flat tree ancestors assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
FAIL Match container in ::slotted selector's originating element tree assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
FAIL Match container in outer tree for :host assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
FAIL Match container in ::part selector's originating element tree assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
FAIL Match container for ::before in ::slotted selector's originating element tree assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
FAIL Match container in outer tree for :host::before assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
FAIL Match container for ::before in ::part selector's originating element tree assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
FAIL Match container for ::part selector's originating element tree for exportparts assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
FAIL Match container for slot light tree child fallback assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
PASS Match container in outer tree | ||
PASS Match container in same tree, not walking flat tree ancestors | ||
PASS Match container in ::slotted selector's originating element tree | ||
PASS Match container in outer tree for :host | ||
PASS Match container in ::part selector's originating element tree | ||
PASS Match container for ::before in ::slotted selector's originating element tree | ||
PASS Match container in outer tree for :host::before | ||
PASS Match container for ::before in ::part selector's originating element tree | ||
PASS Match container for ::part selector's originating element tree for exportparts | ||
PASS Match container for slot light tree child fallback | ||
PASS Should not match container inside shadow tree for ::part() | ||
FAIL A :host::part rule should match containers in the originating element tree assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
PASS A :host::part rule should match containers in the originating element tree | ||
|
2 changes: 1 addition & 1 deletion
2
...s/css/css-contain/container-queries/style-container-invalidation-inheritance-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
|
||
PASS Pre-conditions | ||
FAIL Changed --match inherits down descendants and affects container query assert_equals: expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" | ||
PASS Changed --match inherits down descendants and affects container query | ||
|
2 changes: 1 addition & 1 deletion
2
...tform-tests/css/css-contain/container-queries/style-query-with-unknown-width-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Should be green | ||
|
||
FAIL width query should evaluate to unknown and style query to true assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" | ||
PASS width query should evaluate to unknown and style query to true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.