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

Log Message

Cherry-pick r288303. rdar://problem/87836127

    [:has pseudo-class] Support :has(:not(foo))
    https://bugs.webkit.org/show_bug.cgi?id=235399

    Reviewed by Darin Adler.

    LayoutTests/imported/w3c:

    * web-platform-tests/css/selectors/invalidation/has-with-not-expected.txt: Added.
    * web-platform-tests/css/selectors/invalidation/has-with-not.html: Added.

    Source/WebCore:

    This already works except for a filter bug.

    Test: imported/w3c/web-platform-tests/css/selectors/invalidation/has-with-not.html

    * style/HasSelectorFilter.h:
    (WebCore::Style::HasSelectorFilter::reject const):

    We shouldn't reject a selector if we have a null key.

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

Modified Paths

Added Paths

Diff

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


--- branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-01-25 01:56:22 UTC (rev 288521)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-01-25 01:56:26 UTC (rev 288522)
@@ -1,5 +1,43 @@
 2022-01-24  Alan Coon  <[email protected]>
 
+        Cherry-pick r288303. rdar://problem/87836127
+
+    [:has pseudo-class] Support :has(:not(foo))
+    https://bugs.webkit.org/show_bug.cgi?id=235399
+    
+    Reviewed by Darin Adler.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/css/selectors/invalidation/has-with-not-expected.txt: Added.
+    * web-platform-tests/css/selectors/invalidation/has-with-not.html: Added.
+    
+    Source/WebCore:
+    
+    This already works except for a filter bug.
+    
+    Test: imported/w3c/web-platform-tests/css/selectors/invalidation/has-with-not.html
+    
+    * style/HasSelectorFilter.h:
+    (WebCore::Style::HasSelectorFilter::reject const):
+    
+    We shouldn't reject a selector if we have a null key.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-20  Antti Koivisto  <[email protected]>
+
+            [:has pseudo-class] Support :has(:not(foo))
+            https://bugs.webkit.org/show_bug.cgi?id=235399
+
+            Reviewed by Darin Adler.
+
+            * web-platform-tests/css/selectors/invalidation/has-with-not-expected.txt: Added.
+            * web-platform-tests/css/selectors/invalidation/has-with-not.html: Added.
+
+2022-01-24  Alan Coon  <[email protected]>
+
         Cherry-pick r288264. rdar://problem/87745419
 
     Align our qualified name validation with the specification

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


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-with-not-expected.txt	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-with-not-expected.txt	2022-01-25 01:56:26 UTC (rev 288522)
@@ -0,0 +1,23 @@
+
+PASS Initial color
+PASS remove .test to subject_child
+PASS add .test from subject_child
+PASS remove .test to subject_descendant
+PASS add .test from subject_descendant
+PASS insert element div before subject_child
+PASS remove element div before subject_child
+PASS insert element div before subject_descendant
+PASS remove element div before subject_descendant
+PASS insert element div after subject_child
+PASS remove element div after subject_child
+PASS insert element div after subject_descendant
+PASS remove element div after subject_descendant
+PASS insert tree div>div before subject_child
+PASS remove tree div>div before subject_child
+PASS insert tree div>div before subject_descendant
+PASS remove tree div>div before subject_descendant
+PASS insert tree div.test after subject_child
+PASS remove tree div.test after subject_child
+PASS insert tree div.test after subject_descendant
+PASS remove tree div.test after subject_descendant
+

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


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-with-not.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-with-not.html	2022-01-25 01:56:26 UTC (rev 288522)
@@ -0,0 +1,107 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Selector Invalidation: :has() with :not()</title>
+<link rel="author" title="Antti Koivisto" href=""
+<script src=""
+<script src=""
+<link rel="help" href=""
+<style>
+div, main { color: grey }
+#subject:has(:not(.test)) { color: green }
+#subject:has(.test :not(.test)) { color: red }
+</style>
+
+<main id=main>
+    <div id=subject>
+        <div id=subject_child class=test>
+            <div id=subject_descendant class=test></div>
+        </div>
+    </div>
+</main>
+
+<script>
+const grey = 'rgb(128, 128, 128)';
+const red = 'rgb(255, 0, 0)';
+const green = 'rgb(0, 128, 0)';
+const blue = 'rgb(0, 0, 255)';
+
+function testColor(test_name, color) {
+    test(function() {
+        assert_equals(getComputedStyle(subject).color, color);
+    }, test_name);
+}
+
+function testClassChange(element, expectedColor)
+{
+    element.classList.remove('test');
+    testColor(`remove .test to ${element.id}`, expectedColor);
+    element.classList.add('test');
+    testColor(`add .test from ${element.id}`, grey);
+}
+
+function testElementInsertionBefore(beforeElement, expectedColor)
+{
+    const newElement = document.createElement('div');
+
+    beforeElement.before(newElement);
+    testColor(`insert element div before ${beforeElement.id}`, expectedColor);
+
+    newElement.remove();
+    testColor(`remove element div before ${beforeElement.id}`, grey);
+}
+
+function testElementInsertionAfter(afterElement, expectedColor)
+{
+    const newElement = document.createElement('div');
+
+    afterElement.after(newElement);
+    testColor(`insert element div after ${afterElement.id}`, expectedColor);
+
+    newElement.remove();
+    testColor(`remove element div after ${afterElement.id}`, grey);
+}
+
+function testTreeInsertionBefore(beforeElement, expectedColor)
+{
+    const newElement = document.createElement('div');
+    const newChild = document.createElement('div');
+    newElement.appendChild(newChild);
+
+    beforeElement.before(newElement);
+    testColor(`insert tree div>div before ${beforeElement.id}`, expectedColor);
+
+    newElement.remove();
+    testColor(`remove tree div>div before ${beforeElement.id}`, grey);
+}
+
+function testTreeInsertionAfter(afterElement, expectedColor)
+{
+    const newElement = document.createElement('div');
+    const newChild = document.createElement('div');
+    newElement.appendChild(newChild);
+
+    afterElement.after(newElement);
+    testColor(`insert tree div.test after ${afterElement.id}`, expectedColor);
+
+    newElement.remove();
+    testColor(`remove tree div.test after ${afterElement.id}`, grey);
+}
+
+testColor('Initial color', grey);
+
+testClassChange(subject_child, green);
+testClassChange(subject_descendant, red);
+
+testElementInsertionBefore(subject_child, green);
+testElementInsertionBefore(subject_descendant, red);
+
+testElementInsertionAfter(subject_child, green);
+testElementInsertionAfter(subject_descendant, red);
+
+testTreeInsertionBefore(subject_child, green);
+testTreeInsertionBefore(subject_descendant, red);
+
+testTreeInsertionAfter(subject_child, green);
+testTreeInsertionAfter(subject_descendant, red);
+
+</script>

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (288521 => 288522)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-01-25 01:56:22 UTC (rev 288521)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-01-25 01:56:26 UTC (rev 288522)
@@ -1,5 +1,49 @@
 2022-01-24  Alan Coon  <[email protected]>
 
+        Cherry-pick r288303. rdar://problem/87836127
+
+    [:has pseudo-class] Support :has(:not(foo))
+    https://bugs.webkit.org/show_bug.cgi?id=235399
+    
+    Reviewed by Darin Adler.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/css/selectors/invalidation/has-with-not-expected.txt: Added.
+    * web-platform-tests/css/selectors/invalidation/has-with-not.html: Added.
+    
+    Source/WebCore:
+    
+    This already works except for a filter bug.
+    
+    Test: imported/w3c/web-platform-tests/css/selectors/invalidation/has-with-not.html
+    
+    * style/HasSelectorFilter.h:
+    (WebCore::Style::HasSelectorFilter::reject const):
+    
+    We shouldn't reject a selector if we have a null key.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288303 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-20  Antti Koivisto  <[email protected]>
+
+            [:has pseudo-class] Support :has(:not(foo))
+            https://bugs.webkit.org/show_bug.cgi?id=235399
+
+            Reviewed by Darin Adler.
+
+            This already works except for a filter bug.
+
+            Test: imported/w3c/web-platform-tests/css/selectors/invalidation/has-with-not.html
+
+            * style/HasSelectorFilter.h:
+            (WebCore::Style::HasSelectorFilter::reject const):
+
+            We shouldn't reject a selector if we have a null key.
+
+2022-01-24  Alan Coon  <[email protected]>
+
         Cherry-pick r288275. rdar://problem/87707090
 
     AVAudioSessionCaptureDeviceManager is not always computing the right default input device

Modified: branches/safari-613-branch/Source/WebCore/style/HasSelectorFilter.h (288521 => 288522)


--- branches/safari-613-branch/Source/WebCore/style/HasSelectorFilter.h	2022-01-25 01:56:22 UTC (rev 288521)
+++ branches/safari-613-branch/Source/WebCore/style/HasSelectorFilter.h	2022-01-25 01:56:26 UTC (rev 288522)
@@ -48,9 +48,8 @@
     static Key makeKey(const CSSSelector& hasSelector);
 
     bool reject(const CSSSelector& hasSelector) const { return reject(makeKey(hasSelector)); }
-    bool reject(Key key) const { return !m_filter.mayContain(key); }
+    bool reject(Key key) const { return key && !m_filter.mayContain(key); }
 
-
 private:
     void add(const Element&);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to