Title: [173184] trunk
Revision
173184
Author
[email protected]
Date
2014-09-02 13:20:25 -0700 (Tue, 02 Sep 2014)

Log Message

Avoid backing store allocation with some combinations of replaced elements, masking and visibility:hidden
https://bugs.webkit.org/show_bug.cgi?id=136400

Reviewed by Tim Horton.
Source/WebCore:

RenderLayer::isVisuallyNonEmpty() would return true for replaced elements (e.g. images)
with visibility:hidden, and for layers with a mask, and both would cause additional
backing store in some cases.

We can move the hasVisibleContent() to the top of the function, since visibility:hidden
will always hide any content of this layer. The hasMask() check can also be removed;
a mask can only mask content that is already visible; it never contributes additional
pixels.

Tests: compositing/backing/masked-child-no-backing.html
       compositing/backing/replaced-child-no-backing.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects):

LayoutTests:

* compositing/backing/masked-child-no-backing-expected.txt: Added.
* compositing/backing/masked-child-no-backing.html: Added.
* compositing/backing/replaced-child-no-backing-expected.txt: Added.
* compositing/backing/replaced-child-no-backing.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (173183 => 173184)


--- trunk/LayoutTests/ChangeLog	2014-09-02 20:14:31 UTC (rev 173183)
+++ trunk/LayoutTests/ChangeLog	2014-09-02 20:20:25 UTC (rev 173184)
@@ -1,5 +1,17 @@
 2014-09-02  Simon Fraser  <[email protected]>
 
+        Avoid backing store allocation with some combinations of replaced elements, masking and visibility:hidden
+        https://bugs.webkit.org/show_bug.cgi?id=136400
+
+        Reviewed by Tim Horton.
+
+        * compositing/backing/masked-child-no-backing-expected.txt: Added.
+        * compositing/backing/masked-child-no-backing.html: Added.
+        * compositing/backing/replaced-child-no-backing-expected.txt: Added.
+        * compositing/backing/replaced-child-no-backing.html: Added.
+
+2014-09-02  Simon Fraser  <[email protected]>
+
         Non-composited child RenderLayers cause allocation of unncessary backing store
         https://bugs.webkit.org/show_bug.cgi?id=136375
 

Added: trunk/LayoutTests/compositing/backing/masked-child-no-backing-expected.txt (0 => 173184)


--- trunk/LayoutTests/compositing/backing/masked-child-no-backing-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/backing/masked-child-no-backing-expected.txt	2014-09-02 20:20:25 UTC (rev 173184)
@@ -0,0 +1,22 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 2
+        (GraphicsLayer
+          (position 18.00 10.00)
+          (bounds 200.00 200.00)
+        )
+        (GraphicsLayer
+          (position 18.00 220.00)
+          (bounds 200.00 200.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/compositing/backing/masked-child-no-backing.html (0 => 173184)


--- trunk/LayoutTests/compositing/backing/masked-child-no-backing.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/backing/masked-child-no-backing.html	2014-09-02 20:20:25 UTC (rev 173184)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        .container {
+            position: relative;
+            height: 200px;
+            width: 200px;
+            margin: 10px;
+        }
+        
+        .composited {
+            -webkit-transform: translateZ(0);
+        }
+        
+        .child {
+            position: absolute;
+            height: 180px;
+            width: 180px;
+            margin: 10px;
+        }
+        
+        .masked {
+            -webkit-mask: linear-gradient(black, transparent);
+        }
+        
+        .grandchild {
+            position: absolute;
+            top: 10px;
+            left: 10px;
+            width: 150px;
+            height: 150px;
+            background-color: silver;
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function dumpLayers()
+        {
+            var layersResult = document.getElementById('layers');
+            if (window.testRunner)
+                layersResult.innerText = window.internals.layerTreeAsText(document);
+        }
+
+        window.addEventListener('load', dumpLayers, false)
+    </script>
+</head>
+<body>
+    <div class="composited container"><div class="masked child"></div></div>
+    <div class="composited container"><div class="masked child"><div class="grandchild"></div></div></div>
+
+<pre id="layers">Layer tree goes here in DRT</pre>
+</body>
+</html>

Added: trunk/LayoutTests/compositing/backing/replaced-child-no-backing-expected.txt (0 => 173184)


--- trunk/LayoutTests/compositing/backing/replaced-child-no-backing-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/compositing/backing/replaced-child-no-backing-expected.txt	2014-09-02 20:20:25 UTC (rev 173184)
@@ -0,0 +1,25 @@
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 2
+        (GraphicsLayer
+          (position 18.00 10.00)
+          (anchor 0.50 0.49)
+          (bounds 200.00 204.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 18.00 220.00)
+          (anchor 0.50 0.49)
+          (bounds 200.00 204.00)
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/compositing/backing/replaced-child-no-backing.html (0 => 173184)


--- trunk/LayoutTests/compositing/backing/replaced-child-no-backing.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/backing/replaced-child-no-backing.html	2014-09-02 20:20:25 UTC (rev 173184)
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        .container {
+            height: 200px;
+            width: 200px;
+            margin: 10px;
+        }
+        
+        .composited {
+            -webkit-transform: translateZ(0);
+        }
+        
+        .child {
+            position: relative;
+            height: 100%;
+            width: 100%;
+        }
+
+        .grandchild {
+            position: absolute;
+            top: 10px;
+            left: 10px;
+            width: 150px;
+            height: 150px;
+            background-color: silver;
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function dumpLayers()
+        {
+            var layersResult = document.getElementById('layers');
+            if (window.testRunner)
+                layersResult.innerText = window.internals.layerTreeAsText(document);
+        }
+
+        window.addEventListener('load', dumpLayers, false)
+    </script>
+</head>
+<body>
+    <div class="composited container"><img class="child" src=""
+    <div class="composited container"><img class="child" src="" style="visibility:hidden"></div>
+
+<pre id="layers">Layer tree goes here in DRT</pre>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (173183 => 173184)


--- trunk/Source/WebCore/ChangeLog	2014-09-02 20:14:31 UTC (rev 173183)
+++ trunk/Source/WebCore/ChangeLog	2014-09-02 20:20:25 UTC (rev 173184)
@@ -1,3 +1,25 @@
+2014-09-02  Simon Fraser  <[email protected]>
+
+        Avoid backing store allocation with some combinations of replaced elements, masking and visibility:hidden
+        https://bugs.webkit.org/show_bug.cgi?id=136400
+
+        Reviewed by Tim Horton.
+        
+        RenderLayer::isVisuallyNonEmpty() would return true for replaced elements (e.g. images)
+        with visibility:hidden, and for layers with a mask, and both would cause additional
+        backing store in some cases.
+        
+        We can move the hasVisibleContent() to the top of the function, since visibility:hidden
+        will always hide any content of this layer. The hasMask() check can also be removed;
+        a mask can only mask content that is already visible; it never contributes additional
+        pixels.
+
+        Tests: compositing/backing/masked-child-no-backing.html
+               compositing/backing/replaced-child-no-backing.html
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::calculateClipRects):
+
 2014-09-02  Joseph Pecoraro  <[email protected]>
 
         Use jsNontrivialString for strings we know are more than a single character

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (173183 => 173184)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-09-02 20:14:31 UTC (rev 173183)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2014-09-02 20:20:25 UTC (rev 173184)
@@ -6316,11 +6316,13 @@
 {
     ASSERT(!m_visibleDescendantStatusDirty);
 
-    if (hasVisibleContent() && hasNonEmptyChildRenderers())
+    if (!hasVisibleContent())
+        return false;
+
+    if (hasNonEmptyChildRenderers())
         return true;
 
-    // FIXME: a visibility:hidden replaced element should return false here.
-    if (renderer().isReplaced() || renderer().hasMask())
+    if (renderer().isReplaced())
         return true;
 
     if (hasVisibleBoxDecorations())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to