⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 268966 in webkit


Ignore:
Timestamp:
Oct 26, 2020, 4:00:26 AM (6 years ago)
Author:
emilio
Message:

Drop sorting and deduplication of media queries.
​https://bugs.webkit.org/show_bug.cgi?id=217751

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/css/cssom/mediaquery-sort-dedup-expected.txt: annotate progression

Source/WebCore:

This matches what Gecko has shipped for ages.

The spec used to contain the sorting but not the de-duplication.

Both the spec and Chromium have been updated to match Gecko, see
​https://github.com/w3c/csswg-drafts/issues/5627

  • css/MediaQuery.cpp:

(WebCore::MediaQuery::MediaQuery): Don't sort / dedup

Tests: imported/w3c/web-platform-tests/css/cssom/mediaquery-sort-dedup.html

LayoutTests:

  • fast/media/media-query-serialization.html: Adjust to match spec.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r268964 r268966  
     12020-10-26  Emilio Cobos Álvarez  <emilio@crisal.io>
     2
     3        Drop sorting and deduplication of media queries.
     4        https://bugs.webkit.org/show_bug.cgi?id=217751
     5
     6        Reviewed by Simon Fraser.
     7
     8        * fast/media/media-query-serialization.html: Adjust to match spec.
     9
    1102020-10-26  Diego Pino Garcia  <dpino@igalia.com>
    211
  • trunk/LayoutTests/fast/media/media-query-serialization.html

    r155270 r268966  
    1717
    1818
    19 var expected = "not braille, tv and (max-width: 200px) and (min-width: 100px) and (orientation: landscape), (color)";
     19var expected = "not braille, tv and (orientation: landscape) and (min-width: 100px) and (max-width: 200px), (color) and (color)";
    2020shouldBe("document.styleSheets[0].media.mediaText", "expected");
    2121
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r268961 r268966  
     12020-10-26  Emilio Cobos Álvarez  <emilio@crisal.io>
     2
     3        Drop sorting and deduplication of media queries.
     4        https://bugs.webkit.org/show_bug.cgi?id=217751
     5
     6        Reviewed by Simon Fraser.
     7
     8        * web-platform-tests/css/cssom/mediaquery-sort-dedup-expected.txt: annotate progression
     9
    1102020-10-25  Emilio Cobos Álvarez  <emilio@crisal.io>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/cssom/mediaquery-sort-dedup-expected.txt

    r268961 r268966  
    11
    2 FAIL Media queries are not sorted lexicographically assert_equals: expected "(min-width: 10px) and (min-height: 10px)" but got "(min-height: 10px) and (min-width: 10px)"
    3 FAIL Media queries are not deduplicated assert_equals: expected "(color) and (color)" but got "(color)"
     2PASS Media queries are not sorted lexicographically
     3PASS Media queries are not deduplicated
    44
  • trunk/Source/WebCore/ChangeLog

    r268962 r268966  
     12020-10-26  Emilio Cobos Álvarez  <emilio@crisal.io>
     2
     3        Drop sorting and deduplication of media queries.
     4        https://bugs.webkit.org/show_bug.cgi?id=217751
     5
     6        Reviewed by Simon Fraser.
     7
     8        This matches what Gecko has shipped for ages.
     9
     10        The spec used to contain the sorting but not the de-duplication.
     11
     12        Both the spec and Chromium have been updated to match Gecko, see
     13        https://github.com/w3c/csswg-drafts/issues/5627
     14
     15        * css/MediaQuery.cpp:
     16        (WebCore::MediaQuery::MediaQuery): Don't sort / dedup
     17
     18        Tests: imported/w3c/web-platform-tests/css/cssom/mediaquery-sort-dedup.html
     19
    1202020-10-25  Sam Weinig  <weinig@apple.com>
    221
  • trunk/Source/WebCore/css/MediaQuery.cpp

    r233122 r268966  
    7575    , m_restrictor(restrictor)
    7676{
    77     std::sort(m_expressions.begin(), m_expressions.end(), [](auto& a, auto& b) {
    78         return codePointCompare(a.serialize(), b.serialize()) < 0;
    79     });
    80 
    81     // Remove all duplicated expressions.
    82     String key;
    83     for (int i = m_expressions.size() - 1; i >= 0; --i) {
    84 
    85         // If any expression is invalid the media query must be ignored.
    86         if (!m_ignored)
    87             m_ignored = !m_expressions[i].isValid();
    88 
    89         if (m_expressions[i].serialize() == key)
    90             m_expressions.remove(i);
    91         else
    92             key = m_expressions[i].serialize();
    93     }
    9477}
    9578
Note: See TracChangeset for help on using the changeset viewer.