Frame's composited content is visible when the frame has visibility: hidden.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 May 2017 03:53:24 +0000 (03:53 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 May 2017 03:53:24 +0000 (03:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=125565
<rdar://problem/32196849>

Reviewed by Simon Fraser.

Source/WebCore:

Do not construct composited layers for hidden RenderWidgets (frameset, iframe, object).
Note that we still construct layers for the associated renderers as usual.

Tests: compositing/visibility/frameset-visibility-hidden.html
       compositing/visibility/iframe-visibility-hidden.html
       compositing/visibility/object-visibility-hidden.html

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresCompositingForPlugin):
(WebCore::RenderLayerCompositor::requiresCompositingForFrame):

LayoutTests:

* compositing/resources/visibility.html: Added.
* compositing/visibility/frameset-visibility-hidden-expected.html: Added.
* compositing/visibility/frameset-visibility-hidden.html: Added.
* compositing/visibility/iframe-visibility-hidden-expected.html: Added.
* compositing/visibility/iframe-visibility-hidden.html: Added.
* compositing/visibility/object-visibility-hidden-expected.html: Added.
* compositing/visibility/object-visibility-hidden.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/compositing/resources/visibility.html [new file with mode: 0644]
LayoutTests/compositing/visibility/frameset-visibility-hidden-expected.html [new file with mode: 0644]
LayoutTests/compositing/visibility/frameset-visibility-hidden.html [new file with mode: 0644]
LayoutTests/compositing/visibility/iframe-visibility-hidden-expected.html [new file with mode: 0644]
LayoutTests/compositing/visibility/iframe-visibility-hidden.html [new file with mode: 0644]
LayoutTests/compositing/visibility/object-visibility-hidden-expected.html [new file with mode: 0644]
LayoutTests/compositing/visibility/object-visibility-hidden.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayerCompositor.cpp

index 5a2971b..edb284c 100644 (file)
@@ -1,3 +1,19 @@
+2017-05-25  Zalan Bujtas  <zalan@apple.com>
+
+        Frame's composited content is visible when the frame has visibility: hidden.
+        https://bugs.webkit.org/show_bug.cgi?id=125565
+        <rdar://problem/32196849>
+
+        Reviewed by Simon Fraser.
+
+        * compositing/resources/visibility.html: Added.
+        * compositing/visibility/frameset-visibility-hidden-expected.html: Added.
+        * compositing/visibility/frameset-visibility-hidden.html: Added.
+        * compositing/visibility/iframe-visibility-hidden-expected.html: Added.
+        * compositing/visibility/iframe-visibility-hidden.html: Added.
+        * compositing/visibility/object-visibility-hidden-expected.html: Added.
+        * compositing/visibility/object-visibility-hidden.html: Added.
+
 2017-05-25  Brent Fulgham  <bfulgham@apple.com>
 
         Gracefully handle missing localStorage support in results.html
diff --git a/LayoutTests/compositing/resources/visibility.html b/LayoutTests/compositing/resources/visibility.html
new file mode 100644 (file)
index 0000000..8602e10
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests visibility with frames and objects.</title>
+<style>
+div {
+    will-change: transform;
+    width: 50px;
+    height: 50px;
+    background-color: green;
+}
+</style>
+</head>
+<body>
+<div></div>
+</body>
+</html>
diff --git a/LayoutTests/compositing/visibility/frameset-visibility-hidden-expected.html b/LayoutTests/compositing/visibility/frameset-visibility-hidden-expected.html
new file mode 100644 (file)
index 0000000..3ecc0db
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests frames with visibility hidden</title>
+<style>
+div {
+       will-change: transform;
+       width: 50px;
+       height: 50px;
+       background-color: green;
+}
+</style>
+</head>
+<body>
+<div></div>
+</body>
+</html>
diff --git a/LayoutTests/compositing/visibility/frameset-visibility-hidden.html b/LayoutTests/compositing/visibility/frameset-visibility-hidden.html
new file mode 100644 (file)
index 0000000..bf3dff8
--- /dev/null
@@ -0,0 +1,6 @@
+<frameset cols="100, 100, 100, *">
+  <frame noresize frameborder=no src="data:text/html,<div style='will-change: transform; width: 50px; height: 50px; background-color: green;'><div style='visibility: visible;'></div>">
+  <frame noresize frameborder=no style="visibility: hidden" src="data:text/html,<div style='will-change: transform; width: 50px; height: 50px; background-color: red;'><div style='visibility: visible;'></div>">
+  <frame noresize frameborder=no style="visibility: hidden" src="data:text/html,<div style='will-change: transform; width: 50px; height: 50px; background-color: red;'><div style='visibility: hidden;'></div>">
+  <frame noresize frameborder=no style="visibility: collapse" src="data:text/html,<div style='will-change: transform; width: 50px; height: 50px; background-color: red;'><div style='visibility: visible;'></div>">
+</frameset>
diff --git a/LayoutTests/compositing/visibility/iframe-visibility-hidden-expected.html b/LayoutTests/compositing/visibility/iframe-visibility-hidden-expected.html
new file mode 100644 (file)
index 0000000..24af3aa
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests iframe with visibility hidden</title>
+<style>
+div {
+    margin: 8px;
+    margin-right: 26px;
+    width: 50px;
+    height: 50px;
+    background-color: green;
+    display: inline-block;
+}
+
+.positioned {
+    position: absolute;
+    left: 80px;
+    top: 8px;
+}
+</style>
+</head>
+<body>
+<div></div><div class=positioned></div>
+</body>
+</html>
diff --git a/LayoutTests/compositing/visibility/iframe-visibility-hidden.html b/LayoutTests/compositing/visibility/iframe-visibility-hidden.html
new file mode 100644 (file)
index 0000000..351c9cf
--- /dev/null
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests iframe with visibility hidden</title>
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+var iframe1IsVisible = false;
+var iframe2IsVisible = false;
+
+function makeiframe1Visible()
+{
+    document.getElementById("iframe1").style.visibility = "visible";
+    iframe1IsVisible = true;
+    elementIsVisibleNow();
+}
+
+function makeiframe2Visible()
+{
+    document.getElementById("iframe2").style.visibility = "visible";
+    iframe2IsVisible = true;
+    elementIsVisibleNow();
+}
+
+function elementIsVisibleNow()
+{
+    if (!iframe1IsVisible || !iframe2IsVisible)
+        return;
+    document.body.offsetHeight;
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+</script>
+<style>
+#iframe2 {
+    position: absolute;
+    left: 80px;
+    top: 8px;
+}
+</style>
+</head>
+<body>
+<iframe frameborder=no id=iframe1 onload="makeiframe1Visible()" width="80" height="80" style="visibility: hidden"
+    srcdoc="<div style='will-change: transform; width: 50px; height: 50px; background-color: green;'>
+          <div style='visibility: visible;'></div>
+        </div>">
+</iframe>
+<iframe frameborder=no id=iframe2 onload="makeiframe2Visible()" width="80" height="80" style="visibility: hidden"
+    srcdoc="
+        <video style='width: 50px; height: 50px; background-color: green;'>
+            <source src='movie.mp4' type='video/mp4'>
+        </video>">
+</iframe>
+<iframe frameborder=no width="80" height="80" style="visibility: hidden"
+    srcdoc="<div style='will-change: transform; width: 50px; height: 50px; background-color: red;'>
+          <div style='visibility: visible;'></div>
+        </div>">
+</iframe>
+</body>
+</html>
diff --git a/LayoutTests/compositing/visibility/object-visibility-hidden-expected.html b/LayoutTests/compositing/visibility/object-visibility-hidden-expected.html
new file mode 100644 (file)
index 0000000..239116d
--- /dev/null
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests object with visibility hidden</title>
+<style>
+div {
+       will-change: transform;
+       width: 50px;
+       height: 50px;
+       margin: 16px 0px 0px 8px;
+       background-color: green;
+}
+</style>
+</head>
+<body>
+<div></div>
+</body>
+</html>
diff --git a/LayoutTests/compositing/visibility/object-visibility-hidden.html b/LayoutTests/compositing/visibility/object-visibility-hidden.html
new file mode 100644 (file)
index 0000000..aa59abd
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests object with visibility hidden</title>
+</head>
+<body>
+<object style="visibility: visible" data="../resources/visibility.html" type="text/html" width="80" height="80"></object>
+<object style="visibility: collapse" data="../resources/visibility.html" type="text/html" width="80" height="80"></object>
+<object style="visibility: hidden" data="../resources/visibility.html" type="text/html" width="80" height="80"></object>
+</body>
+</html>
index 97c7a4d..df61b45 100644 (file)
@@ -1,3 +1,22 @@
+2017-05-25  Zalan Bujtas  <zalan@apple.com>
+
+        Frame's composited content is visible when the frame has visibility: hidden.
+        https://bugs.webkit.org/show_bug.cgi?id=125565
+        <rdar://problem/32196849>
+
+        Reviewed by Simon Fraser.
+
+        Do not construct composited layers for hidden RenderWidgets (frameset, iframe, object).
+        Note that we still construct layers for the associated renderers as usual. 
+
+        Tests: compositing/visibility/frameset-visibility-hidden.html
+               compositing/visibility/iframe-visibility-hidden.html
+               compositing/visibility/object-visibility-hidden.html
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::requiresCompositingForPlugin):
+        (WebCore::RenderLayerCompositor::requiresCompositingForFrame):
+
 2017-05-25  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         Unreviewed, build fix in GTK and WPE ports
index 5ae5bd9..a57a0b1 100644 (file)
@@ -2551,6 +2551,9 @@ bool RenderLayerCompositor::requiresCompositingForPlugin(RenderLayerModelObject&
     m_reevaluateCompositingAfterLayout = true;
     
     RenderWidget& pluginRenderer = downcast<RenderWidget>(renderer);
+    if (pluginRenderer.style().visibility() != VISIBLE)
+        return false;
+
     // If we can't reliably know the size of the plugin yet, don't change compositing state.
     if (pluginRenderer.needsLayout())
         return pluginRenderer.isComposited();
@@ -2566,6 +2569,9 @@ bool RenderLayerCompositor::requiresCompositingForFrame(RenderLayerModelObject&
         return false;
 
     auto& frameRenderer = downcast<RenderWidget>(renderer);
+    if (frameRenderer.style().visibility() != VISIBLE)
+        return false;
+
     if (!frameRenderer.requiresAcceleratedCompositing())
         return false;