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

Changeset 288512 in webkit


Ignore:
Timestamp:
Jan 24, 2022, 5:55:41 PM (5 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r288111. rdar://problem/87699260

[:has() pseudo-class] Disallow nested :has()
​https://bugs.webkit.org/show_bug.cgi?id=235231

Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

  • web-platform-tests/css/selectors/has-argument-with-explicit-scope.tentative-expected.txt:
  • web-platform-tests/css/selectors/has-basic-expected.txt:
  • web-platform-tests/css/selectors/parsing/parse-has-expected.txt:

Source/WebCore:

Nested case ':has(:has(foo))' adds no meaningful capability and would complicate invalidation.
See ​https://github.com/w3c/csswg-drafts/issues/6952 for more details.

  • css/parser/CSSSelectorParser.cpp: (WebCore::CSSSelectorParser::consumePseudo):

Also set m_resistDefaultNamespace like other logical combination pseudo-classes.

  • css/parser/CSSSelectorParser.h:

git-svn-id: ​https://svn.webkit.org/repository/webkit/trunk@288111 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-613-branch
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog

    r288511 r288512  
     12022-01-24  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r288111. rdar://problem/87699260
     4
     5    [:has() pseudo-class] Disallow nested :has()
     6    https://bugs.webkit.org/show_bug.cgi?id=235231
     7   
     8    Reviewed by Dean Jackson.
     9   
     10    LayoutTests/imported/w3c:
     11   
     12    * web-platform-tests/css/selectors/has-argument-with-explicit-scope.tentative-expected.txt:
     13    * web-platform-tests/css/selectors/has-basic-expected.txt:
     14    * web-platform-tests/css/selectors/parsing/parse-has-expected.txt:
     15   
     16    Source/WebCore:
     17   
     18    Nested case ':has(:has(foo))' adds no meaningful capability and would complicate invalidation.
     19    See https://github.com/w3c/csswg-drafts/issues/6952 for more details.
     20   
     21    * css/parser/CSSSelectorParser.cpp:
     22    (WebCore::CSSSelectorParser::consumePseudo):
     23   
     24    Also set m_resistDefaultNamespace like other logical combination pseudo-classes.
     25   
     26    * css/parser/CSSSelectorParser.h:
     27   
     28   
     29    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288111 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     30
     31    2022-01-17  Antti Koivisto  <antti@apple.com>
     32
     33            [:has() pseudo-class] Disallow nested :has()
     34            https://bugs.webkit.org/show_bug.cgi?id=235231
     35
     36            Reviewed by Dean Jackson.
     37
     38            * web-platform-tests/css/selectors/has-argument-with-explicit-scope.tentative-expected.txt:
     39            * web-platform-tests/css/selectors/has-basic-expected.txt:
     40            * web-platform-tests/css/selectors/parsing/parse-has-expected.txt:
     41
    1422022-01-24  Alan Coon  <alancoon@apple.com>
    243
  • branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-basic-expected.txt

    r285921 r288512  
    1010PASS .parent:has(:is(.target ~ .sibling .descendant)) matches expected elements
    1111PASS .sibling:has(.descendant) ~ .target matches expected elements
    12 PASS :has(.sibling:has(.descendant) ~ .target) matches expected elements
    13 PASS :has(.sibling:has(.descendant) ~ .target) ~ .parent > .descendant matches expected elements
     12FAIL :has(.sibling:has(.descendant) ~ .target) matches expected elements The string did not match the expected pattern.
     13FAIL :has(.sibling:has(.descendant) ~ .target) ~ .parent > .descendant matches expected elements The string did not match the expected pattern.
    1414PASS :has(> .parent) matches expected elements
    1515PASS :has(> .target) matches expected elements
  • branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-relative-argument-expected.txt

    r285921 r288512  
    3333PASS .y:has(> .g .h) .i matches expected elements
    3434PASS .y:has(.g .h) .i matches expected elements
    35 PASS .x:has(+ .y:has(> .g .h) .i) matches expected elements
    36 PASS .x:has(+ .y:has(.g .h) .i) matches expected elements
    37 PASS .x:has(+ .y:has(> .g .h) .i) ~ .j matches expected elements
    38 PASS .x:has(+ .y:has(.g .h) .i) ~ .j matches expected elements
    39 PASS .x:has(~ .y:has(> .g .h) .i) matches expected elements
    40 PASS .x:has(~ .y:has(.g .h) .i) matches expected elements
     35FAIL .x:has(+ .y:has(> .g .h) .i) matches expected elements The string did not match the expected pattern.
     36FAIL .x:has(+ .y:has(.g .h) .i) matches expected elements The string did not match the expected pattern.
     37FAIL .x:has(+ .y:has(> .g .h) .i) ~ .j matches expected elements The string did not match the expected pattern.
     38FAIL .x:has(+ .y:has(.g .h) .i) ~ .j matches expected elements The string did not match the expected pattern.
     39FAIL .x:has(~ .y:has(> .g .h) .i) matches expected elements The string did not match the expected pattern.
     40FAIL .x:has(~ .y:has(.g .h) .i) matches expected elements The string did not match the expected pattern.
    4141PASS .d .x:has(.e) matches expected elements
    4242PASS .d ~ .x:has(~ .e) matches expected elements
  • branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/parsing/parse-has-expected.txt

    r285921 r288512  
    1616PASS ".a .b:has(.c .d)" should be a valid selector
    1717PASS ".a .b:has(.c .d) .e" should be a valid selector
    18 PASS ".a:has(.b:has(.c))" should be a valid selector
     18FAIL ".a:has(.b:has(.c))" should be a valid selector The string did not match the expected pattern.
    1919PASS ".a:has(.b:is(.c .d))" should be a valid selector
    20 PASS ".a:has(.b:is(.c:has(.d) .e))" should be a valid selector
     20FAIL ".a:has(.b:is(.c:has(.d) .e))" should be a valid selector assert_equals: serialization should be canonical expected ".a:has(.b:is(.c:has(.d) .e))" but got ".a:has(.b:is())"
    2121PASS ".a:is(.b:has(.c) .d)" should be a valid selector
    2222PASS ".a:not(:has(.b))" should be a valid selector
  • branches/safari-613-branch/Source/WebCore/ChangeLog

    r288511 r288512  
     12022-01-24  Alan Coon  <alancoon@apple.com>
     2
     3        Cherry-pick r288111. rdar://problem/87699260
     4
     5    [:has() pseudo-class] Disallow nested :has()
     6    https://bugs.webkit.org/show_bug.cgi?id=235231
     7   
     8    Reviewed by Dean Jackson.
     9   
     10    LayoutTests/imported/w3c:
     11   
     12    * web-platform-tests/css/selectors/has-argument-with-explicit-scope.tentative-expected.txt:
     13    * web-platform-tests/css/selectors/has-basic-expected.txt:
     14    * web-platform-tests/css/selectors/parsing/parse-has-expected.txt:
     15   
     16    Source/WebCore:
     17   
     18    Nested case ':has(:has(foo))' adds no meaningful capability and would complicate invalidation.
     19    See https://github.com/w3c/csswg-drafts/issues/6952 for more details.
     20   
     21    * css/parser/CSSSelectorParser.cpp:
     22    (WebCore::CSSSelectorParser::consumePseudo):
     23   
     24    Also set m_resistDefaultNamespace like other logical combination pseudo-classes.
     25   
     26    * css/parser/CSSSelectorParser.h:
     27   
     28   
     29    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288111 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     30
     31    2022-01-17  Antti Koivisto  <antti@apple.com>
     32
     33            [:has() pseudo-class] Disallow nested :has()
     34            https://bugs.webkit.org/show_bug.cgi?id=235231
     35
     36            Reviewed by Dean Jackson.
     37
     38            Nested case ':has(:has(foo))' adds no meaningful capability and would complicate invalidation.
     39            See https://github.com/w3c/csswg-drafts/issues/6952 for more details.
     40
     41            * css/parser/CSSSelectorParser.cpp:
     42            (WebCore::CSSSelectorParser::consumePseudo):
     43
     44            Also set m_resistDefaultNamespace like other logical combination pseudo-classes.
     45
     46            * css/parser/CSSSelectorParser.h:
     47
    1482022-01-24  Alan Coon  <alancoon@apple.com>
    249
  • branches/safari-613-branch/Source/WebCore/css/parser/CSSSelectorParser.cpp

    r287222 r288512  
    687687        switch (selector->pseudoClassType()) {
    688688        case CSSSelector::PseudoClassNot: {
    689             SetForScope<bool> resistDefaultNamespace(m_resistDefaultNamespace, true);
     689            SetForScope resistDefaultNamespace(m_resistDefaultNamespace, true);
    690690            auto selectorList = makeUnique<CSSSelectorList>();
    691691            *selectorList = consumeComplexSelectorList(block);
    … …  
    735735        case CSSSelector::PseudoClassMatches:
    736736        case CSSSelector::PseudoClassAny: {
    737             SetForScope<bool> resistDefaultNamespace(m_resistDefaultNamespace, true);
     737            SetForScope resistDefaultNamespace(m_resistDefaultNamespace, true);
    738738            auto selectorList = makeUnique<CSSSelectorList>();
    739739            *selectorList = consumeForgivingComplexSelectorList(block);
    … …  
    752752        }
    753753        case CSSSelector::PseudoClassHas: {
     754            if (m_disallowHasPseudoClass)
     755                return nullptr;
     756            SetForScope resistDefaultNamespace(m_resistDefaultNamespace, true);
     757            SetForScope disallowNestedHas(m_disallowHasPseudoClass, true);
    754758            auto selectorList = makeUnique<CSSSelectorList>();
    755759            *selectorList = consumeForgivingRelativeSelectorList(block);
  • branches/safari-613-branch/Source/WebCore/css/parser/CSSSelectorParser.h

    r285054 r288512  
    9090    bool m_failedParsing { false };
    9191    bool m_disallowPseudoElements { false };
     92    bool m_disallowHasPseudoClass { false };
    9293    bool m_resistDefaultNamespace { false };
    9394    bool m_ignoreDefaultNamespace { false };
Note: See TracChangeset for help on using the changeset viewer.