Title: [287362] trunk
Revision
287362
Author
[email protected]
Date
2021-12-22 10:33:49 -0800 (Wed, 22 Dec 2021)

Log Message

[:has() pseudo-class] :has() selector does not render on first pass?
https://bugs.webkit.org/show_bug.cgi?id=234531

Reviewed by Simon Fraser.

Source/WebCore:

With :has() identical sibling elements can have different style which breaks the current
assumptions of the style sharing optimization.

Test: fast/selectors/has-style-sharing.html

* style/StyleSharingResolver.cpp:
(WebCore::Style::SharingResolver::resolve):

Disable style sharing in presence of :has() rules for now.

For a less heavy-handed approach we need to start testing for :has() rules similar to what is already done
for sibling and attribute rules.

LayoutTests:

Test case by Alex Riviere.

* fast/selectors/has-style-sharing-expected.html: Added.
* fast/selectors/has-style-sharing.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (287361 => 287362)


--- trunk/LayoutTests/ChangeLog	2021-12-22 18:24:04 UTC (rev 287361)
+++ trunk/LayoutTests/ChangeLog	2021-12-22 18:33:49 UTC (rev 287362)
@@ -1,3 +1,15 @@
+2021-12-22  Antti Koivisto  <[email protected]>
+
+        [:has() pseudo-class] :has() selector does not render on first pass?
+        https://bugs.webkit.org/show_bug.cgi?id=234531
+
+        Reviewed by Simon Fraser.
+
+        Test case by Alex Riviere.
+
+        * fast/selectors/has-style-sharing-expected.html: Added.
+        * fast/selectors/has-style-sharing.html: Added.
+
 2021-12-22  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r285087.

Added: trunk/LayoutTests/fast/selectors/has-style-sharing-expected.html (0 => 287362)


--- trunk/LayoutTests/fast/selectors/has-style-sharing-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/has-style-sharing-expected.html	2021-12-22 18:33:49 UTC (rev 287362)
@@ -0,0 +1,13 @@
+<style>
+.border {
+  border: 2px red solid;
+}
+</style>
+<div>
+  <p>This div will have nothing</p>
+</div>
+<div class="border">
+  <ul>
+      <li>This list will have a border because of :has.
+  </ul>
+</div>

Added: trunk/LayoutTests/fast/selectors/has-style-sharing.html (0 => 287362)


--- trunk/LayoutTests/fast/selectors/has-style-sharing.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/has-style-sharing.html	2021-12-22 18:33:49 UTC (rev 287362)
@@ -0,0 +1,13 @@
+<style>
+*:has(> .parent-border) {
+  border: 2px red solid;
+}
+</style>
+<div>
+  <p>This div will have nothing</p>
+</div>
+<div>
+  <ul class="parent-border">
+    <li>This list will have a border because of :has.
+  </ul>
+</div>

Modified: trunk/Source/WebCore/ChangeLog (287361 => 287362)


--- trunk/Source/WebCore/ChangeLog	2021-12-22 18:24:04 UTC (rev 287361)
+++ trunk/Source/WebCore/ChangeLog	2021-12-22 18:33:49 UTC (rev 287362)
@@ -1,3 +1,23 @@
+2021-12-22  Antti Koivisto  <[email protected]>
+
+        [:has() pseudo-class] :has() selector does not render on first pass?
+        https://bugs.webkit.org/show_bug.cgi?id=234531
+
+        Reviewed by Simon Fraser.
+
+        With :has() identical sibling elements can have different style which breaks the current
+        assumptions of the style sharing optimization.
+
+        Test: fast/selectors/has-style-sharing.html
+
+        * style/StyleSharingResolver.cpp:
+        (WebCore::Style::SharingResolver::resolve):
+
+        Disable style sharing in presence of :has() rules for now.
+
+        For a less heavy-handed approach we need to start testing for :has() rules similar to what is already done
+        for sibling and attribute rules.
+
 2021-12-22  Michael Saboff  <[email protected]>
 
         Fix WebCore install headers with alternate build

Modified: trunk/Source/WebCore/style/StyleSharingResolver.cpp (287361 => 287362)


--- trunk/Source/WebCore/style/StyleSharingResolver.cpp	2021-12-22 18:24:04 UTC (rev 287361)
+++ trunk/Source/WebCore/style/StyleSharingResolver.cpp	2021-12-22 18:33:49 UTC (rev 287362)
@@ -107,6 +107,9 @@
         if (keyframeEffectStack->hasEffectWithImplicitKeyframes())
             return nullptr;
     }
+    // FIXME: Do something smarter here, for example RuleSet based matching like with attribute/sibling selectors.
+    if (Scope::forNode(element).usesHasPseudoClass())
+        return nullptr;
 
     Context context {
         update,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to