Title: [288512] branches/safari-613-branch
Revision
288512
Author
[email protected]
Date
2022-01-24 17:55:41 -0800 (Mon, 24 Jan 2022)

Log 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

Modified Paths

Diff

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog (288511 => 288512)


--- branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-01-25 01:55:37 UTC (rev 288511)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-01-25 01:55:41 UTC (rev 288512)
@@ -1,5 +1,46 @@
 2022-01-24  Alan Coon  <[email protected]>
 
+        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
+
+    2022-01-17  Antti Koivisto  <[email protected]>
+
+            [:has() pseudo-class] Disallow nested :has()
+            https://bugs.webkit.org/show_bug.cgi?id=235231
+
+            Reviewed by Dean Jackson.
+
+            * 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:
+
+2022-01-24  Alan Coon  <[email protected]>
+
         Cherry-pick r288107. rdar://problem/87425066
 
     REGRESSION(r281389): using font-variant-ligatures causes Unicode bidi isolation control characters to render

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-basic-expected.txt (288511 => 288512)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-basic-expected.txt	2022-01-25 01:55:37 UTC (rev 288511)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-basic-expected.txt	2022-01-25 01:55:41 UTC (rev 288512)
@@ -9,8 +9,8 @@
 PASS :has(:is(.target ~ .sibling .descendant)) matches expected elements
 PASS .parent:has(:is(.target ~ .sibling .descendant)) matches expected elements
 PASS .sibling:has(.descendant) ~ .target matches expected elements
-PASS :has(.sibling:has(.descendant) ~ .target) matches expected elements
-PASS :has(.sibling:has(.descendant) ~ .target) ~ .parent > .descendant matches expected elements
+FAIL :has(.sibling:has(.descendant) ~ .target) matches expected elements The string did not match the expected pattern.
+FAIL :has(.sibling:has(.descendant) ~ .target) ~ .parent > .descendant matches expected elements The string did not match the expected pattern.
 PASS :has(> .parent) matches expected elements
 PASS :has(> .target) matches expected elements
 PASS :has(> .parent, > .target) matches expected elements

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-relative-argument-expected.txt (288511 => 288512)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-relative-argument-expected.txt	2022-01-25 01:55:37 UTC (rev 288511)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-relative-argument-expected.txt	2022-01-25 01:55:41 UTC (rev 288512)
@@ -32,12 +32,12 @@
 PASS .y:has(.g .h) matches expected elements
 PASS .y:has(> .g .h) .i matches expected elements
 PASS .y:has(.g .h) .i matches expected elements
-PASS .x:has(+ .y:has(> .g .h) .i) matches expected elements
-PASS .x:has(+ .y:has(.g .h) .i) matches expected elements
-PASS .x:has(+ .y:has(> .g .h) .i) ~ .j matches expected elements
-PASS .x:has(+ .y:has(.g .h) .i) ~ .j matches expected elements
-PASS .x:has(~ .y:has(> .g .h) .i) matches expected elements
-PASS .x:has(~ .y:has(.g .h) .i) matches expected elements
+FAIL .x:has(+ .y:has(> .g .h) .i) matches expected elements The string did not match the expected pattern.
+FAIL .x:has(+ .y:has(.g .h) .i) matches expected elements The string did not match the expected pattern.
+FAIL .x:has(+ .y:has(> .g .h) .i) ~ .j matches expected elements The string did not match the expected pattern.
+FAIL .x:has(+ .y:has(.g .h) .i) ~ .j matches expected elements The string did not match the expected pattern.
+FAIL .x:has(~ .y:has(> .g .h) .i) matches expected elements The string did not match the expected pattern.
+FAIL .x:has(~ .y:has(.g .h) .i) matches expected elements The string did not match the expected pattern.
 PASS .d .x:has(.e) matches expected elements
 PASS .d ~ .x:has(~ .e) matches expected elements
 

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/parsing/parse-has-expected.txt (288511 => 288512)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/parsing/parse-has-expected.txt	2022-01-25 01:55:37 UTC (rev 288511)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/parsing/parse-has-expected.txt	2022-01-25 01:55:41 UTC (rev 288512)
@@ -15,9 +15,9 @@
 PASS ".a .b:has(.c)" should be a valid selector
 PASS ".a .b:has(.c .d)" should be a valid selector
 PASS ".a .b:has(.c .d) .e" should be a valid selector
-PASS ".a:has(.b:has(.c))" should be a valid selector
+FAIL ".a:has(.b:has(.c))" should be a valid selector The string did not match the expected pattern.
 PASS ".a:has(.b:is(.c .d))" should be a valid selector
-PASS ".a:has(.b:is(.c:has(.d) .e))" should be a valid selector
+FAIL ".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())"
 PASS ".a:is(.b:has(.c) .d)" should be a valid selector
 PASS ".a:not(:has(.b))" should be a valid selector
 PASS ".a:has(:not(.b))" should be a valid selector

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (288511 => 288512)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-01-25 01:55:37 UTC (rev 288511)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-01-25 01:55:41 UTC (rev 288512)
@@ -1,5 +1,52 @@
 2022-01-24  Alan Coon  <[email protected]>
 
+        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
+
+    2022-01-17  Antti Koivisto  <[email protected]>
+
+            [:has() pseudo-class] Disallow nested :has()
+            https://bugs.webkit.org/show_bug.cgi?id=235231
+
+            Reviewed by Dean Jackson.
+
+            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:
+
+2022-01-24  Alan Coon  <[email protected]>
+
         Cherry-pick r288107. rdar://problem/87425066
 
     REGRESSION(r281389): using font-variant-ligatures causes Unicode bidi isolation control characters to render

Modified: branches/safari-613-branch/Source/WebCore/css/parser/CSSSelectorParser.cpp (288511 => 288512)


--- branches/safari-613-branch/Source/WebCore/css/parser/CSSSelectorParser.cpp	2022-01-25 01:55:37 UTC (rev 288511)
+++ branches/safari-613-branch/Source/WebCore/css/parser/CSSSelectorParser.cpp	2022-01-25 01:55:41 UTC (rev 288512)
@@ -686,7 +686,7 @@
     if (selector->match() == CSSSelector::PseudoClass) {
         switch (selector->pseudoClassType()) {
         case CSSSelector::PseudoClassNot: {
-            SetForScope<bool> resistDefaultNamespace(m_resistDefaultNamespace, true);
+            SetForScope resistDefaultNamespace(m_resistDefaultNamespace, true);
             auto selectorList = makeUnique<CSSSelectorList>();
             *selectorList = consumeComplexSelectorList(block);
             if (!selectorList->first() || !block.atEnd())
@@ -734,7 +734,7 @@
         case CSSSelector::PseudoClassWhere:
         case CSSSelector::PseudoClassMatches:
         case CSSSelector::PseudoClassAny: {
-            SetForScope<bool> resistDefaultNamespace(m_resistDefaultNamespace, true);
+            SetForScope resistDefaultNamespace(m_resistDefaultNamespace, true);
             auto selectorList = makeUnique<CSSSelectorList>();
             *selectorList = consumeForgivingComplexSelectorList(block);
             if (!block.atEnd())
@@ -751,6 +751,10 @@
             return selector;
         }
         case CSSSelector::PseudoClassHas: {
+            if (m_disallowHasPseudoClass)
+                return nullptr;
+            SetForScope resistDefaultNamespace(m_resistDefaultNamespace, true);
+            SetForScope disallowNestedHas(m_disallowHasPseudoClass, true);
             auto selectorList = makeUnique<CSSSelectorList>();
             *selectorList = consumeForgivingRelativeSelectorList(block);
             if (selectorList->isEmpty() || !block.atEnd())

Modified: branches/safari-613-branch/Source/WebCore/css/parser/CSSSelectorParser.h (288511 => 288512)


--- branches/safari-613-branch/Source/WebCore/css/parser/CSSSelectorParser.h	2022-01-25 01:55:37 UTC (rev 288511)
+++ branches/safari-613-branch/Source/WebCore/css/parser/CSSSelectorParser.h	2022-01-25 01:55:41 UTC (rev 288512)
@@ -89,6 +89,7 @@
     const RefPtr<StyleSheetContents> m_styleSheet;
     bool m_failedParsing { false };
     bool m_disallowPseudoElements { false };
+    bool m_disallowHasPseudoClass { false };
     bool m_resistDefaultNamespace { false };
     bool m_ignoreDefaultNamespace { false };
     std::optional<CSSSelector::PseudoElementType> m_precedingPseudoElement;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to