Toggling "display: contents" to "display: none" fails to hide the element
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 18:27:55 +0000 (18:27 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 18:27:55 +0000 (18:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188259
<rdar://problem/42886896>

Reviewed by Simon Fraser.

Source/WebCore:

Test: fast/css/display-contents-to-none.html

* style/StyleTreeResolver.cpp:
(WebCore::Style::affectsRenderedSubtree):

An element with 'display:contents' has a rendered subtree.

LayoutTests:

* fast/css/display-contents-to-none-expected.html: Added.
* fast/css/display-contents-to-none.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/css/display-contents-to-none-expected.html [new file with mode: 0644]
LayoutTests/fast/css/display-contents-to-none.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/style/StyleTreeResolver.cpp

index ebef537..d0e0d68 100644 (file)
@@ -1,3 +1,14 @@
+2019-03-25  Antti Koivisto  <antti@apple.com>
+
+        Toggling "display: contents" to "display: none" fails to hide the element
+        https://bugs.webkit.org/show_bug.cgi?id=188259
+        <rdar://problem/42886896>
+
+        Reviewed by Simon Fraser.
+
+        * fast/css/display-contents-to-none-expected.html: Added.
+        * fast/css/display-contents-to-none.html: Added.
+
 2019-03-25  Diego Pino Garcia  <dpino@igalia.com>
 
         [GTK] Gardening, update expected results for several smart-delete-paragraph tests 
diff --git a/LayoutTests/fast/css/display-contents-to-none-expected.html b/LayoutTests/fast/css/display-contents-to-none-expected.html
new file mode 100644 (file)
index 0000000..8710a2c
--- /dev/null
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This test passes if it doesn't say FAIL below.</p>
+</body>
+</html>
diff --git a/LayoutTests/fast/css/display-contents-to-none.html b/LayoutTests/fast/css/display-contents-to-none.html
new file mode 100644 (file)
index 0000000..9ecb9be
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This test passes if it doesn't say FAIL below.</p>
+<div style="display: contents"><span>FAIL</span></div>
+<div style="display: contents">FAIL</div>
+<script>
+for (const div of document.querySelectorAll('div')) {
+    div.getBoundingClientRect();
+    div.style.display = 'none';
+}
+</script>
+</body>
+</html>
index 3ed2981..c72add9 100644 (file)
@@ -1,3 +1,18 @@
+2019-03-25  Antti Koivisto  <antti@apple.com>
+
+        Toggling "display: contents" to "display: none" fails to hide the element
+        https://bugs.webkit.org/show_bug.cgi?id=188259
+        <rdar://problem/42886896>
+
+        Reviewed by Simon Fraser.
+
+        Test: fast/css/display-contents-to-none.html
+
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::affectsRenderedSubtree):
+
+        An element with 'display:contents' has a rendered subtree.
+
 2019-03-25  Justin Fan  <justin_fan@apple.com>
 
         Update WebGPU class names based on sketch.idl
index 055a589..ec6a683 100644 (file)
@@ -158,10 +158,10 @@ static void resetStyleForNonRenderedDescendants(Element& current)
 
 static bool affectsRenderedSubtree(Element& element, const RenderStyle& newStyle)
 {
-    if (element.renderer())
-        return true;
     if (newStyle.display() != DisplayType::None)
         return true;
+    if (element.renderOrDisplayContentsStyle())
+        return true;
     if (element.rendererIsNeeded(newStyle))
         return true;
     return false;