Changeset 289789 in webkit


Ignore:
Timestamp:
Feb 14, 2022 10:29:39 PM (5 months ago)
Author:
Antti Koivisto
Message:

[CSS Container Queries] Support range operators in size queries
https://bugs.webkit.org/show_bug.cgi?id=236600

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

  • 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:

Source/WebCore:

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:

LayoutTests:

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r289787 r289789  
     12022-02-14  Antti Koivisto  <antti@apple.com>
     2
     3        [CSS Container Queries] Support range operators in size queries
     4        https://bugs.webkit.org/show_bug.cgi?id=236600
     5
     6        Reviewed by Sam Weinig.
     7
     8        * TestExpectations:
     9
    1102022-02-14  Ryosuke Niwa  <rniwa@webkit.org>
    211
  • trunk/LayoutTests/TestExpectations

    r289742 r289789  
    47574757webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/display-in-container.html [ ImageOnlyFailure ]
    47584758webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/pseudo-elements-002.tentative.html [ ImageOnlyFailure ]
    4759 webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/multicol-inside-container.html [ ImageOnlyFailure ]
    4760 webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-bfc-floats.html [ ImageOnlyFailure ]
    47614759
    47624760# Flaky css-contain test
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r289742 r289789  
     12022-02-14  Antti Koivisto  <antti@apple.com>
     2
     3        [CSS Container Queries] Support range operators in size queries
     4        https://bugs.webkit.org/show_bug.cgi?id=236600
     5
     6        Reviewed by Sam Weinig.
     7
     8        * web-platform-tests/css/css-contain/container-queries/size-feature-evaluation-expected.txt:
     9        * web-platform-tests/css/css-contain/container-queries/unsupported-axis-expected.txt:
     10
    1112022-02-14  Antti Koivisto  <antti@apple.com>
    212
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/size-feature-evaluation-expected.txt

    r289742 r289789  
    11Test
    22
    3 FAIL size(width < 100px) (.horizontal) assert_equals: expected "" but got "true"
    4 FAIL size(width >= 100px) (.horizontal) assert_equals: expected "true" but got ""
     3PASS size(width < 100px) (.horizontal)
     4PASS size(width >= 100px) (.horizontal)
    55PASS size(min-width: 100px) (.horizontal)
    66PASS size(min-width: 101px) (.horizontal)
    77PASS size(max-width: 100px) (.horizontal)
    88PASS size(max-width: 99px) (.horizontal)
    9 FAIL size(height < 200px) (.horizontal) assert_equals: expected "" but got "true"
    10 FAIL size(height >= 200px) (.horizontal) assert_equals: expected "true" but got ""
     9PASS size(height < 200px) (.horizontal)
     10PASS size(height >= 200px) (.horizontal)
    1111PASS size(min-height: 200px) (.horizontal)
    1212PASS size(min-height: 201px) (.horizontal)
     
    2929FAIL size(aspect-ratio: 1/2) (.horizontal) assert_equals: expected "true" but got ""
    3030PASS size(aspect-ratio: 2/1) (.horizontal)
    31 FAIL size(width < 100px) (.vertical) assert_equals: expected "" but got "true"
    32 FAIL size(width >= 100px) (.vertical) assert_equals: expected "true" but got ""
     31PASS size(width < 100px) (.vertical)
     32PASS size(width >= 100px) (.vertical)
    3333PASS size(min-width: 100px) (.vertical)
    3434PASS size(min-width: 101px) (.vertical)
    3535PASS size(max-width: 100px) (.vertical)
    3636PASS size(max-width: 99px) (.vertical)
    37 FAIL size(height < 200px) (.vertical) assert_equals: expected "" but got "true"
    38 FAIL size(height >= 200px) (.vertical) assert_equals: expected "true" but got ""
     37PASS size(height < 200px) (.vertical)
     38PASS size(height >= 200px) (.vertical)
    3939PASS size(min-height: 200px) (.vertical)
    4040PASS size(min-height: 201px) (.vertical)
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/unsupported-axis-expected.txt

    r289222 r289789  
    11Test
    22
    3 FAIL size(width > 0px) assert_equals: expected "true" but got ""
    4 PASS size(height > 0px)
    5 FAIL size((height > 0px) or (width > 0px)) assert_equals: expected "true" but got ""
    6 FAIL size((width > 0px) or (height > 0px)) assert_equals: expected "true" but got ""
     3PASS size(width > 0px)
     4FAIL size(height > 0px) assert_equals: expected "" but got "true"
     5PASS size((height > 0px) or (width > 0px))
     6PASS size((width > 0px) or (height > 0px))
    77FAIL size((orientation: landscape) or (width > 0px)) assert_equals: expected "true" but got ""
    88FAIL size((width > 0px) or (orientation: landscape)) assert_equals: expected "true" but got ""
  • trunk/Source/WebCore/ChangeLog

    r289778 r289789  
     12022-02-14  Antti Koivisto  <antti@apple.com>
     2
     3        [CSS Container Queries] Support range operators in size queries
     4        https://bugs.webkit.org/show_bug.cgi?id=236600
     5
     6        Reviewed by Sam Weinig.
     7
     8        Support (width > 100px) and similar.
     9
     10        * css/ContainerQueryParser.cpp:
     11        (WebCore::ContainerQueryParser::consumeSizeQuery):
     12        (WebCore::ContainerQueryParser::consumeSizeFeature):
     13
     14        Factor into a function.
     15        Add operator support. No reverse (100px < width) or full range (10px < width < 100px) yet.
     16        The evaluator supports these already.
     17
     18        * css/ContainerQueryParser.h:
     19
    1202022-02-14  Dan Glastonbury  <djg@apple.com>
    221
  • trunk/Source/WebCore/css/ContainerQueryParser.cpp

    r289742 r289789  
    144144    }
    145145
     146    auto sizeFeature = consumeSizeFeature(range);
     147    if (!sizeFeature)
     148        return { };
     149
     150    range.consumeWhitespace();
     151    if (!range.atEnd())
     152        return { };
     153
     154    return { *sizeFeature };
     155}
     156
     157std::optional<CQ::SizeFeature> ContainerQueryParser::consumeSizeFeature(CSSParserTokenRange& range)
     158{
     159    // FIXME: Support value-first (100px < width) and full range (100px < width < 200px) notations.
     160
    146161    auto nameToken = range.consumeIncludingWhitespace();
     162    ASSERT(nameToken.type() == IdentToken);
     163
    147164    auto name = nameToken.value();
    148165
     
    150167        return CQ::SizeFeature { CQ::ComparisonOperator::True, name.toAtomString(), { } };
    151168
    152     auto opToken = range.consumeIncludingWhitespace();
    153     if (range.atEnd())
    154         return { };
    155 
    156     // FIXME: Support '<' style operators and ranges.
    157     auto op = CQ::ComparisonOperator::Equal;
    158     if (opToken.type() == ColonToken) {
    159         if (name.startsWith("min-"))
    160             op = CQ::ComparisonOperator::GreaterThanOrEqual;
    161         else if (name.startsWith("max-"))
    162             op = CQ::ComparisonOperator::LessThanOrEqual;
    163 
    164         if (op != CQ::ComparisonOperator::Equal)
    165             name = name.substring(4);
    166         if (name.isEmpty())
    167             return { };
    168     }
     169    auto consumeOperator = [&]() -> std::optional<CQ::ComparisonOperator> {
     170        auto opToken = range.consume();
     171        if (range.atEnd())
     172            return { };
     173        if (opToken.type() == ColonToken) {
     174            if (name.startsWith("min-")) {
     175                name = name.substring(4);
     176                return CQ::ComparisonOperator::GreaterThanOrEqual;
     177            }
     178            if (name.startsWith("max-")) {
     179                name = name.substring(4);
     180                return CQ::ComparisonOperator::LessThanOrEqual;
     181            }
     182            return CQ::ComparisonOperator::Equal;
     183        }
     184        if (opToken.type() == DelimiterToken) {
     185            switch (opToken.delimiter()) {
     186            case '=':
     187                return CQ::ComparisonOperator::Equal;
     188            case '<':
     189                if (range.peek().type() == DelimiterToken && range.peek().delimiter() == '=') {
     190                    range.consume();
     191                    return CQ::ComparisonOperator::LessThanOrEqual;
     192                }
     193                return CQ::ComparisonOperator::LessThan;
     194            case '>':
     195                if (range.peek().type() == DelimiterToken && range.peek().delimiter() == '=') {
     196                    range.consume();
     197                    return CQ::ComparisonOperator::GreaterThanOrEqual;
     198                }
     199                return CQ::ComparisonOperator::GreaterThan;
     200            default:
     201                return { };
     202            }
     203        }
     204        return { };
     205    };
     206
     207    auto op = consumeOperator();
     208    if (!op)
     209        return { };
     210
     211    range.consumeWhitespace();
    169212
    170213    auto length = CSSPropertyParserHelpers::consumeLength(range, m_context.mode, ValueRange::All);
     
    172215        return { };
    173216
    174     return CQ::SizeFeature { op, name.toAtomString(), length };
    175 }
    176 
    177 }
     217    return CQ::SizeFeature { *op, name.toAtomString(), length };
     218}
     219
     220}
  • trunk/Source/WebCore/css/ContainerQueryParser.h

    r289742 r289789  
    3838    std::optional<CQ::SizeQuery> consumeSizeQuery(CSSParserTokenRange&);
    3939    template<typename ConditionType> std::optional<ConditionType> consumeCondition(CSSParserTokenRange&);
     40    std::optional<CQ::SizeFeature> consumeSizeFeature(CSSParserTokenRange&);
    4041
    4142    ContainerQueryParser(const CSSParserContext& context)
Note: See TracChangeset for help on using the changeset viewer.