Title: [289284] branches/safari-613-branch
Revision
289284
Author
[email protected]
Date
2022-02-07 18:54:02 -0800 (Mon, 07 Feb 2022)

Log Message

Cherry-pick r288196. rdar://problem/87768936

    [:has() pseudo-class] Compute specificity correctly
    https://bugs.webkit.org/show_bug.cgi?id=235351

    Reviewed by Alexey Shvayka.

    LayoutTests/imported/w3c:

    * web-platform-tests/css/selectors/has-complexity.html:

    Fix specificity used in this test.

    * web-platform-tests/css/selectors/has-specificity-expected.txt: Added.
    * web-platform-tests/css/selectors/has-specificity.html: Added.

    Source/WebCore:

    "The specificity of an ':is()', ':not()', or ':has()' pseudo-class is replaced by
    the specificity of the most specific complex selector in its selector list argument."

    https://www.w3.org/TR/selectors-4/#specificity-rules

    Test: imported/w3c/web-platform-tests/css/selectors/has-specificity.html

    * css/CSSSelector.cpp:
    (WebCore::simpleSelectorSpecificityInternal):

    Compute :has() specificity like :is() and :not().

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

Modified Paths

Added Paths

Diff

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


--- branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-02-08 02:53:58 UTC (rev 289283)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-02-08 02:54:02 UTC (rev 289284)
@@ -1,5 +1,54 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r288196. rdar://problem/87768936
+
+    [:has() pseudo-class] Compute specificity correctly
+    https://bugs.webkit.org/show_bug.cgi?id=235351
+    
+    Reviewed by Alexey Shvayka.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/css/selectors/has-complexity.html:
+    
+    Fix specificity used in this test.
+    
+    * web-platform-tests/css/selectors/has-specificity-expected.txt: Added.
+    * web-platform-tests/css/selectors/has-specificity.html: Added.
+    
+    Source/WebCore:
+    
+    "The specificity of an ':is()', ':not()', or ':has()' pseudo-class is replaced by
+    the specificity of the most specific complex selector in its selector list argument."
+    
+    https://www.w3.org/TR/selectors-4/#specificity-rules
+    
+    Test: imported/w3c/web-platform-tests/css/selectors/has-specificity.html
+    
+    * css/CSSSelector.cpp:
+    (WebCore::simpleSelectorSpecificityInternal):
+    
+    Compute :has() specificity like :is() and :not().
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288196 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-19  Antti Koivisto  <[email protected]>
+
+            [:has() pseudo-class] Compute specificity correctly
+            https://bugs.webkit.org/show_bug.cgi?id=235351
+
+            Reviewed by Alexey Shvayka.
+
+            * web-platform-tests/css/selectors/has-complexity.html:
+
+            Fix specificity used in this test.
+
+            * web-platform-tests/css/selectors/has-specificity-expected.txt: Added.
+            * web-platform-tests/css/selectors/has-specificity.html: Added.
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r288132. rdar://problem/87569029
 
     CSP: Improve handling of multiple policies

Added: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-specificity-expected.txt (0 => 289284)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-specificity-expected.txt	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-specificity-expected.txt	2022-02-08 02:54:02 UTC (rev 289284)
@@ -0,0 +1,8 @@
+
+PASS :has(#foo) wins over :has(.foo)
+PASS :has(span#foo) wins over :has(#foo)
+PASS :has(.bar, #foo) has same specificity as :has(#foo, .bar)
+PASS :has(.bar, #foo) wins over :has(.foo, .bar)
+PASS :has(span + span) wins over :has(span)
+PASS :has(span, li, p) wins over :has(span, lo, p)
+

Added: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-specificity.html (0 => 289284)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-specificity.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-specificity.html	2022-02-08 02:54:02 UTC (rev 289284)
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<title>Specificity for complex :has selectors</title>
+<script src=""
+<script src=""
+<link rel="help" href=""
+<style>
+  main :has(#foo) { --t0:PASS; }
+  main :has(.foo) { --t0:FAIL; }
+
+  main :has(span#foo) { --t1:PASS; }
+  main :has(#foo) { --t1:FAIL; }
+
+  main :has(.bar, #foo) { --t2:FAIL; }
+  main :has(#foo, .bar) { --t2:PASS; }
+
+  main :has(.bar, #foo) { --t3:PASS; }
+  main :has(.foo, .bar) { --t3:FAIL; }
+
+  main :has(span + span) { --t4:PASS; }
+  main :has(span) { --t4:FAIL; }
+
+  main :has(span, li, #foo) { --t5:PASS; }
+  main :has(span, li, p) { --t5:FAIL; }
+</style>
+<main id=main>
+  <div id=div><p><span id=foo class=foo></span><span class=bar></span><li></li></p></div>
+</main>
+<script>
+  function test_value(name, description) {
+    test(function() {
+      let actual = getComputedStyle(div).getPropertyValue(name);
+      assert_equals(actual, 'PASS');
+    }, description);
+  }
+
+  test_value('--t0', ':has(#foo) wins over :has(.foo)');
+  test_value('--t1', ':has(span#foo) wins over :has(#foo)');
+  test_value('--t2', ':has(.bar, #foo) has same specificity as :has(#foo, .bar)');
+  test_value('--t3', ':has(.bar, #foo) wins over :has(.foo, .bar)');
+  test_value('--t4', ':has(span + span) wins over :has(span)');
+  test_value('--t5', ':has(span, li, p) wins over :has(span, lo, p)');
+</script>

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-complexity.html (289283 => 289284)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-complexity.html	2022-02-08 02:53:58 UTC (rev 289283)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-complexity.html	2022-02-08 02:54:02 UTC (rev 289284)
@@ -9,7 +9,7 @@
 div, main { color: grey }
 main:has(span) .subject { color: red }
 main:has(span + span) .subject { color: green }
-main:has(final) .subject { color: blue }
+main:has(span + final) .subject { color: blue }
 main:has(nonexistent + span) .subject { color: black }
 main:has(span) span { color: black }
 main:has(nonexistent) span { color: black }

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (289283 => 289284)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-02-08 02:53:58 UTC (rev 289283)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-02-08 02:54:02 UTC (rev 289284)
@@ -1,5 +1,59 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r288196. rdar://problem/87768936
+
+    [:has() pseudo-class] Compute specificity correctly
+    https://bugs.webkit.org/show_bug.cgi?id=235351
+    
+    Reviewed by Alexey Shvayka.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/css/selectors/has-complexity.html:
+    
+    Fix specificity used in this test.
+    
+    * web-platform-tests/css/selectors/has-specificity-expected.txt: Added.
+    * web-platform-tests/css/selectors/has-specificity.html: Added.
+    
+    Source/WebCore:
+    
+    "The specificity of an ':is()', ':not()', or ':has()' pseudo-class is replaced by
+    the specificity of the most specific complex selector in its selector list argument."
+    
+    https://www.w3.org/TR/selectors-4/#specificity-rules
+    
+    Test: imported/w3c/web-platform-tests/css/selectors/has-specificity.html
+    
+    * css/CSSSelector.cpp:
+    (WebCore::simpleSelectorSpecificityInternal):
+    
+    Compute :has() specificity like :is() and :not().
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288196 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-19  Antti Koivisto  <[email protected]>
+
+            [:has() pseudo-class] Compute specificity correctly
+            https://bugs.webkit.org/show_bug.cgi?id=235351
+
+            Reviewed by Alexey Shvayka.
+
+            "The specificity of an ':is()', ':not()', or ':has()' pseudo-class is replaced by
+            the specificity of the most specific complex selector in its selector list argument."
+
+            https://www.w3.org/TR/selectors-4/#specificity-rules
+
+            Test: imported/w3c/web-platform-tests/css/selectors/has-specificity.html
+
+            * css/CSSSelector.cpp:
+            (WebCore::simpleSelectorSpecificityInternal):
+
+            Compute :has() specificity like :is() and :not().
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r288185. rdar://problem/87709485
 
     [Cocoa] Do not change preferred AudioSession buffer size when VPIO is running

Modified: branches/safari-613-branch/Source/WebCore/css/CSSSelector.cpp (289283 => 289284)


--- branches/safari-613-branch/Source/WebCore/css/CSSSelector.cpp	2022-02-08 02:53:58 UTC (rev 289283)
+++ branches/safari-613-branch/Source/WebCore/css/CSSSelector.cpp	2022-02-08 02:54:02 UTC (rev 289284)
@@ -124,6 +124,7 @@
         case CSSSelector::PseudoClassIs:
         case CSSSelector::PseudoClassMatches:
         case CSSSelector::PseudoClassNot:
+        case CSSSelector::PseudoClassHas:
             return maxSpecificity(*simpleSelector.selectorList());
         case CSSSelector::PseudoClassWhere:
             return 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to