Title: [288304] trunk
Revision
288304
Author
[email protected]
Date
2022-01-20 10:14:41 -0800 (Thu, 20 Jan 2022)

Log Message

[: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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (288303 => 288304)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-01-20 18:09:17 UTC (rev 288303)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-01-20 18:14:41 UTC (rev 288304)
@@ -1,5 +1,16 @@
 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-20  Antti Koivisto  <[email protected]>
+
         [:has pseudo-class] Support :has(:not(foo))
         https://bugs.webkit.org/show_bug.cgi?id=235399
 

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited-expected.html (0 => 288304)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited-expected.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited-expected.html	2022-01-20 18:14:41 UTC (rev 288304)
@@ -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: trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited-ref.html (0 => 288304)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited-ref.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited-ref.html	2022-01-20 18:14:41 UTC (rev 288304)
@@ -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: trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited.html (0 => 288304)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-visited.html	2022-01-20 18:14:41 UTC (rev 288304)
@@ -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: trunk/Source/WebCore/ChangeLog (288303 => 288304)


--- trunk/Source/WebCore/ChangeLog	2022-01-20 18:09:17 UTC (rev 288303)
+++ trunk/Source/WebCore/ChangeLog	2022-01-20 18:14:41 UTC (rev 288304)
@@ -1,5 +1,22 @@
 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-20  Antti Koivisto  <[email protected]>
+
         [:has pseudo-class] Support :has(:not(foo))
         https://bugs.webkit.org/show_bug.cgi?id=235399
 

Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (288303 => 288304)


--- trunk/Source/WebCore/css/SelectorChecker.cpp	2022-01-20 18:09:17 UTC (rev 288303)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp	2022-01-20 18:14:41 UTC (rev 288304)
@@ -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