WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-236600-20220214213448.patch (text/plain), 11.34 KB, created by
Antti Koivisto
on 2022-02-14 11:34:50 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Antti Koivisto
Created:
2022-02-14 11:34:50 PST
Size:
11.34 KB
patch
obsolete
>Subversion Revision: 289742 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 0636d3a25cda69841e86c75ef40f05f433b2ba26..1938a86af1cdc7f7ddc7cf898a80138f88bbfa5f 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2022-02-14 Antti Koivisto <antti@apple.com> >+ >+ [CSS Container Queries] Support range operators in size queries >+ https://bugs.webkit.org/show_bug.cgi?id=236600 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Support (width > 100px) and similar. >+ >+ * css/ContainerQueryParser.cpp: >+ (WebCore::ContainerQueryParser::consumeSizeQuery): >+ (WebCore::ContainerQueryParser::consumeSizeFeature): >+ >+ Factor into a function. >+ Add operator support. No reverse (100px < width) or full range (10px < width < 100px) yet. >+ The evaluator supports these already. >+ >+ * css/ContainerQueryParser.h: >+ > 2022-02-14 Antti Koivisto <antti@apple.com> > > [CSS Container Queries] Implement full query parser and evaluator >diff --git a/Source/WebCore/css/ContainerQueryParser.cpp b/Source/WebCore/css/ContainerQueryParser.cpp >index df874222e112f67be17189eaad397996a2891c81..08b95363bfb07746a67470caba668557f6a3b821 100644 >--- a/Source/WebCore/css/ContainerQueryParser.cpp >+++ b/Source/WebCore/css/ContainerQueryParser.cpp >@@ -143,35 +143,78 @@ std::optional<CQ::SizeQuery> ContainerQueryParser::consumeSizeQuery(CSSParserTok > return { *sizeCondition }; > } > >+ auto sizeFeature = consumeSizeFeature(range); >+ if (!sizeFeature) >+ return { }; >+ >+ range.consumeWhitespace(); >+ if (!range.atEnd()) >+ return { }; >+ >+ return { *sizeFeature }; >+} >+ >+std::optional<CQ::SizeFeature> ContainerQueryParser::consumeSizeFeature(CSSParserTokenRange& range) >+{ >+ // FIXME: Support value-first (width < 100px) and full range (100px < width < 200px) notations. >+ > auto nameToken = range.consumeIncludingWhitespace(); >+ ASSERT(nameToken.type() == IdentToken); >+ > auto name = nameToken.value(); > > if (range.atEnd()) > return CQ::SizeFeature { CQ::ComparisonOperator::True, name.toAtomString(), { } }; > >- auto opToken = range.consumeIncludingWhitespace(); >- if (range.atEnd()) >+ auto consumeOperator = [&]() -> std::optional<CQ::ComparisonOperator> { >+ auto opToken = range.consume(); >+ if (range.atEnd()) >+ return { }; >+ if (opToken.type() == ColonToken) { >+ if (name.startsWith("min-")) { >+ name = name.substring(4); >+ return CQ::ComparisonOperator::GreaterThanOrEqual; >+ } >+ if (name.startsWith("max-")) { >+ name = name.substring(4); >+ return CQ::ComparisonOperator::LessThanOrEqual; >+ } >+ return CQ::ComparisonOperator::Equal; >+ } >+ if (opToken.type() == DelimiterToken) { >+ switch (opToken.delimiter()) { >+ case '=': >+ return CQ::ComparisonOperator::Equal; >+ case '<': >+ if (range.peek().type() == DelimiterToken && range.peek().delimiter() == '=') { >+ range.consume(); >+ return CQ::ComparisonOperator::LessThanOrEqual; >+ } >+ return CQ::ComparisonOperator::LessThan; >+ case '>': >+ if (range.peek().type() == DelimiterToken && range.peek().delimiter() == '=') { >+ range.consume(); >+ return CQ::ComparisonOperator::GreaterThanOrEqual; >+ } >+ return CQ::ComparisonOperator::GreaterThan; >+ default: >+ return { }; >+ } >+ } >+ return { }; >+ }; >+ >+ auto op = consumeOperator(); >+ if (!op) > return { }; > >- // FIXME: Support '<' style operators and ranges. >- auto op = CQ::ComparisonOperator::Equal; >- if (opToken.type() == ColonToken) { >- if (name.startsWith("min-")) >- op = CQ::ComparisonOperator::GreaterThanOrEqual; >- else if (name.startsWith("max-")) >- op = CQ::ComparisonOperator::LessThanOrEqual; >- >- if (op != CQ::ComparisonOperator::Equal) >- name = name.substring(4); >- if (name.isEmpty()) >- return { }; >- } >+ range.consumeWhitespace(); > > auto length = CSSPropertyParserHelpers::consumeLength(range, m_context.mode, ValueRange::All); > if (!length) > return { }; > >- return CQ::SizeFeature { op, name.toAtomString(), length }; >+ return CQ::SizeFeature { *op, name.toAtomString(), length }; > } > > } >diff --git a/Source/WebCore/css/ContainerQueryParser.h b/Source/WebCore/css/ContainerQueryParser.h >index ba47c46852fc402a566e62c6a01db9f2c24f36fe..94a99be39c028b9d04935a97cb61120496fec714 100644 >--- a/Source/WebCore/css/ContainerQueryParser.h >+++ b/Source/WebCore/css/ContainerQueryParser.h >@@ -37,6 +37,7 @@ private: > std::optional<CQ::ContainerQuery> consumeContainerQuery(CSSParserTokenRange&); > std::optional<CQ::SizeQuery> consumeSizeQuery(CSSParserTokenRange&); > template<typename ConditionType> std::optional<ConditionType> consumeCondition(CSSParserTokenRange&); >+ std::optional<CQ::SizeFeature> consumeSizeFeature(CSSParserTokenRange&); > > ContainerQueryParser(const CSSParserContext& context) > : m_context(context) { } >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index dafc4072902285348a3a7e1e35d6e2e8d83007b9..5bf85d2742b18995788a128c6281ac16d583fccc 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,12 @@ >+2022-02-14 Antti Koivisto <antti@apple.com> >+ >+ [CSS Container Queries] Support range operators in size queries >+ https://bugs.webkit.org/show_bug.cgi?id=236600 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestExpectations: >+ > 2022-02-14 Antti Koivisto <antti@apple.com> > > [CSS Container Queries] Implement full query parser and evaluator >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index f1693662458a799a1a6d1095a5f25c8013465111..8b8e93b88d856c5a0f2a93f8ee549d6224189cb3 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,13 @@ >+2022-02-14 Antti Koivisto <antti@apple.com> >+ >+ [CSS Container Queries] Support range operators in size queries >+ https://bugs.webkit.org/show_bug.cgi?id=236600 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * web-platform-tests/css/css-contain/container-queries/size-feature-evaluation-expected.txt: >+ * web-platform-tests/css/css-contain/container-queries/unsupported-axis-expected.txt: >+ > 2022-02-14 Antti Koivisto <antti@apple.com> > > [CSS Container Queries] Implement full query parser and evaluator >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index 8fd3eb077c3f6d597e51ab10e9b7d430cf5d31a6..ee83bc7547835d922bf1d7c16ba55311bb38dba9 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -4756,8 +4756,6 @@ imported/w3c/web-platform-tests/css/css-contain/contain-html-overflow-004.html [ > # Container queries > webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/display-in-container.html [ ImageOnlyFailure ] > webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/pseudo-elements-002.tentative.html [ ImageOnlyFailure ] >-webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/multicol-inside-container.html [ ImageOnlyFailure ] >-webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-bfc-floats.html [ ImageOnlyFailure ] > > # Flaky css-contain test > imported/w3c/web-platform-tests/css/css-contain/content-visibility/animation-display-lock.html [ Failure Pass ] >diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/size-feature-evaluation-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/size-feature-evaluation-expected.txt >index 9b4b97c6744231658df105ab347fc3a44c900bee..52a4336d53144144f34c8d36475759ee9a44aa0b 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/size-feature-evaluation-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/size-feature-evaluation-expected.txt >@@ -1,13 +1,13 @@ > Test > >-FAIL size(width < 100px) (.horizontal) assert_equals: expected "" but got "true" >-FAIL size(width >= 100px) (.horizontal) assert_equals: expected "true" but got "" >+PASS size(width < 100px) (.horizontal) >+PASS size(width >= 100px) (.horizontal) > PASS size(min-width: 100px) (.horizontal) > PASS size(min-width: 101px) (.horizontal) > PASS size(max-width: 100px) (.horizontal) > PASS size(max-width: 99px) (.horizontal) >-FAIL size(height < 200px) (.horizontal) assert_equals: expected "" but got "true" >-FAIL size(height >= 200px) (.horizontal) assert_equals: expected "true" but got "" >+PASS size(height < 200px) (.horizontal) >+PASS size(height >= 200px) (.horizontal) > PASS size(min-height: 200px) (.horizontal) > PASS size(min-height: 201px) (.horizontal) > PASS size(max-height: 200px) (.horizontal) >@@ -28,14 +28,14 @@ PASS size(orientation: landscape) (.horizontal) > FAIL size(orientation: portrait) (.horizontal) assert_equals: expected "true" but got "" > FAIL size(aspect-ratio: 1/2) (.horizontal) assert_equals: expected "true" but got "" > PASS size(aspect-ratio: 2/1) (.horizontal) >-FAIL size(width < 100px) (.vertical) assert_equals: expected "" but got "true" >-FAIL size(width >= 100px) (.vertical) assert_equals: expected "true" but got "" >+PASS size(width < 100px) (.vertical) >+PASS size(width >= 100px) (.vertical) > PASS size(min-width: 100px) (.vertical) > PASS size(min-width: 101px) (.vertical) > PASS size(max-width: 100px) (.vertical) > PASS size(max-width: 99px) (.vertical) >-FAIL size(height < 200px) (.vertical) assert_equals: expected "" but got "true" >-FAIL size(height >= 200px) (.vertical) assert_equals: expected "true" but got "" >+PASS size(height < 200px) (.vertical) >+PASS size(height >= 200px) (.vertical) > PASS size(min-height: 200px) (.vertical) > PASS size(min-height: 201px) (.vertical) > PASS size(max-height: 200px) (.vertical) >diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/unsupported-axis-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/unsupported-axis-expected.txt >index 428d43f19a20205ce4dad937a0b0ecad0f4d7502..854547125f58f237934b3b71ccdc52193f33d7c1 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/unsupported-axis-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/unsupported-axis-expected.txt >@@ -1,9 +1,9 @@ > Test > >-FAIL size(width > 0px) assert_equals: expected "true" but got "" >-PASS size(height > 0px) >-FAIL size((height > 0px) or (width > 0px)) assert_equals: expected "true" but got "" >-FAIL size((width > 0px) or (height > 0px)) assert_equals: expected "true" but got "" >+PASS size(width > 0px) >+FAIL size(height > 0px) assert_equals: expected "" but got "true" >+PASS size((height > 0px) or (width > 0px)) >+PASS size((width > 0px) or (height > 0px)) > FAIL size((orientation: landscape) or (width > 0px)) assert_equals: expected "true" but got "" > FAIL size((width > 0px) or (orientation: landscape)) assert_equals: expected "true" but got "" > PASS size((height > 0px) or (orientation: landscape))
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 236600
:
451928
|
451991