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

Log Message

Cherry-pick r288304. rdar://problem/87836459

    [:has() pseudo-class] Ignore :visited inside :has()
    https://bugs.webkit.org/show_bug.cgi?id=235404

    Reviewed by Sam Weinig.

    LayoutTests/imported/w3c:

    * web-platform-tests/css/selectors/has-visited-expected.html: Added.
    * web-platform-tests/css/selectors/has-visited-ref.html: Added.
    * web-platform-tests/css/selectors/has-visited.html: Added.

    Source/WebCore:

    Tests: imported/w3c/web-platform-tests/css/selectors/has-visited.html

    * css/SelectorChecker.cpp:
    (WebCore::SelectorChecker::matchHasPseudoClass const):

    Make this more similar to :is/:not():
    Use the current SelectorChecker with a different context rather than a nested SelectorChecker.
    Use matchRecursively.
    Setup the functional pseudo-class bits for the context.

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

Modified Paths

Added Paths

Diff

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


--- branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-01-25 01:56:26 UTC (rev 288522)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-01-25 01:56:30 UTC (rev 288523)
@@ -1,5 +1,46 @@
 2022-01-24  Alan Coon  <[email protected]>
 
+        Cherry-pick r288304. rdar://problem/87836459
+
+    [:has() pseudo-class] Ignore :visited inside :has()
+    https://bugs.webkit.org/show_bug.cgi?id=235404
+    
+    Reviewed by Sam Weinig.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/css/selectors/has-visited-expected.html: Added.
+    * web-platform-tests/css/selectors/has-visited-ref.html: Added.
+    * web-platform-tests/css/selectors/has-visited.html: Added.
+    
+    Source/WebCore:
+    
+    Tests: imported/w3c/web-platform-tests/css/selectors/has-visited.html
+    
+    * css/SelectorChecker.cpp:
+    (WebCore::SelectorChecker::matchHasPseudoClass const):
+    
+    Make this more similar to :is/:not():
+    Use the current SelectorChecker with a different context rather than a nested SelectorChecker.
+    Use matchRecursively.
+    Setup the functional pseudo-class bits for the context.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288304 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-20  Antti Koivisto  <[email protected]>
+
+            [:has() pseudo-class] Ignore :visited inside :has()
+            https://bugs.webkit.org/show_bug.cgi?id=235404
+
+            Reviewed by Sam Weinig.
+
+            * web-platform-tests/css/selectors/has-visited-expected.html: Added.
+            * web-platform-tests/css/selectors/has-visited-ref.html: Added.
+            * web-platform-tests/css/selectors/has-visited.html: Added.
+
+2022-01-24  Alan Coon  <[email protected]>
+
         Cherry-pick r288303. rdar://problem/87836127
 
     [:has pseudo-class] Support :has(:not(foo))

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


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited-expected.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited-expected.html	2022-01-25 01:56:30 UTC (rev 288523)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>:has combined with :visited/:link</title>
+<link rel="author" title="Byungwoo Lee" href=""
+<link rel="help" href=""
+<style>
+  #parent1 {
+    color: green;
+  }
+  #parent2 {
+    color: black;
+  }
+  #parent3 {
+    color: yellowgreen;
+  }
+</style>
+<main>
+  <div id=parent1>
+    <div>parent color should be green with <a href="" link</a>.</div>
+  </div>
+  <div id=parent2>
+    <div>parent color should be black with <a href="" link</a>.</div>
+  </div>
+  <div id=parent3>
+    <div>parent color should be yellowgreen with <a href="" link</a>.</div>
+  </div>
+</main>
\ No newline at end of file

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


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited-ref.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited-ref.html	2022-01-25 01:56:30 UTC (rev 288523)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>:has combined with :visited/:link</title>
+<link rel="author" title="Byungwoo Lee" href=""
+<link rel="help" href=""
+<style>
+  #parent1 {
+    color: green;
+  }
+  #parent2 {
+    color: black;
+  }
+  #parent3 {
+    color: yellowgreen;
+  }
+</style>
+<main>
+  <div id=parent1>
+    <div>parent color should be green with <a href="" link</a>.</div>
+  </div>
+  <div id=parent2>
+    <div>parent color should be black with <a href="" link</a>.</div>
+  </div>
+  <div id=parent3>
+    <div>parent color should be yellowgreen with <a href="" link</a>.</div>
+  </div>
+</main>
\ No newline at end of file

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


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited.html	2022-01-25 01:56:30 UTC (rev 288523)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>:has combined with :visited/:link</title>
+<link rel="author" title="Byungwoo Lee" href=""
+<link rel="help" href=""
+<link rel="match" href=""
+<style>
+  #parent1:has(:link) {
+    color: green;
+  }
+  #parent2:has(:visited) {
+    color: yellow;
+  }
+  #parent3:has(:any-link) {
+    color: yellowgreen;
+  }
+</style>
+<main>
+  <div id=parent1>
+    <div>parent color should be green with <a href="" link</a>.</div>
+  </div>
+  <div id=parent2>
+    <div>parent color should be black with <a href="" link</a>.</div>
+  </div>
+  <div id=parent3>
+    <div>parent color should be yellowgreen with <a href="" link</a>.</div>
+  </div>
+</main>
\ No newline at end of file

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


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-01-25 01:56:26 UTC (rev 288522)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-01-25 01:56:30 UTC (rev 288523)
@@ -1,5 +1,52 @@
 2022-01-24  Alan Coon  <[email protected]>
 
+        Cherry-pick r288304. rdar://problem/87836459
+
+    [:has() pseudo-class] Ignore :visited inside :has()
+    https://bugs.webkit.org/show_bug.cgi?id=235404
+    
+    Reviewed by Sam Weinig.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/css/selectors/has-visited-expected.html: Added.
+    * web-platform-tests/css/selectors/has-visited-ref.html: Added.
+    * web-platform-tests/css/selectors/has-visited.html: Added.
+    
+    Source/WebCore:
+    
+    Tests: imported/w3c/web-platform-tests/css/selectors/has-visited.html
+    
+    * css/SelectorChecker.cpp:
+    (WebCore::SelectorChecker::matchHasPseudoClass const):
+    
+    Make this more similar to :is/:not():
+    Use the current SelectorChecker with a different context rather than a nested SelectorChecker.
+    Use matchRecursively.
+    Setup the functional pseudo-class bits for the context.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288304 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-20  Antti Koivisto  <[email protected]>
+
+            [:has() pseudo-class] Ignore :visited inside :has()
+            https://bugs.webkit.org/show_bug.cgi?id=235404
+
+            Reviewed by Sam Weinig.
+
+            Tests: imported/w3c/web-platform-tests/css/selectors/has-visited.html
+
+            * css/SelectorChecker.cpp:
+            (WebCore::SelectorChecker::matchHasPseudoClass const):
+
+            Make this more similar to :is/:not():
+            Use the current SelectorChecker with a different context rather than a nested SelectorChecker.
+            Use matchRecursively.
+            Setup the functional pseudo-class bits for the context.
+
+2022-01-24  Alan Coon  <[email protected]>
+
         Cherry-pick r288303. rdar://problem/87836127
 
     [:has pseudo-class] Support :has(:not(foo))

Modified: branches/safari-613-branch/Source/WebCore/css/SelectorChecker.cpp (288522 => 288523)


--- branches/safari-613-branch/Source/WebCore/css/SelectorChecker.cpp	2022-01-25 01:56:26 UTC (rev 288522)
+++ branches/safari-613-branch/Source/WebCore/css/SelectorChecker.cpp	2022-01-25 01:56:30 UTC (rev 288523)
@@ -1310,14 +1310,18 @@
             return false;
     }
 
-    SelectorChecker hasChecker(element.document());
+    CheckingContext hasCheckingContext(SelectorChecker::Mode::ResolvingStyle);
+    hasCheckingContext.scope = &element;
+
     bool matchedInsideScope = false;
 
     auto checkRelative = [&](auto& elementToCheck) {
-        CheckingContext hasCheckingContext(SelectorChecker::Mode::ResolvingStyle);
-        hasCheckingContext.scope = &element;
+        LocalContext hasContext(hasSelector, elementToCheck, VisitedMatchType::Disabled, PseudoId::None);
+        hasContext.inFunctionalPseudoClass = true;
+        hasContext.pseudoElementEffective = false;
 
-        auto result = hasChecker.match(hasSelector, elementToCheck, hasCheckingContext);
+        PseudoIdSet ignorePseudoElements;
+        auto result = matchRecursively(hasCheckingContext, hasContext, ignorePseudoElements).match == Match::SelectorMatches;
 
         if (hasCheckingContext.matchedInsideScope)
             matchedInsideScope = true;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to