Refactor some code that is used to check whether a layer needs backing store
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Mar 2012 20:59:59 +0000 (20:59 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Mar 2012 20:59:59 +0000 (20:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=80917

Reviewed by Dean Jackson.

Move some code out of isSimpleContainerCompositingLayer() in two new
methods to make the code more self-descriptive.

No behavior change, so no tests.

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::paintsBoxDecorations):
(WebCore::RenderLayerBacking::paintsChildren):
(WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
* rendering/RenderLayerBacking.h:
(RenderLayerBacking):

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h

index 0d5c830..04370f2 100644 (file)
@@ -1,3 +1,22 @@
+2012-03-12  Simon Fraser  <simon.fraser@apple.com>
+
+        Refactor some code that is used to check whether a layer needs backing store
+        https://bugs.webkit.org/show_bug.cgi?id=80917
+
+        Reviewed by Dean Jackson.
+
+        Move some code out of isSimpleContainerCompositingLayer() in two new
+        methods to make the code more self-descriptive.
+        
+        No behavior change, so no tests.
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::paintsBoxDecorations):
+        (WebCore::RenderLayerBacking::paintsChildren):
+        (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
+        * rendering/RenderLayerBacking.h:
+        (RenderLayerBacking):
+
 2012-03-13  Daniel Bates  <dbates@webkit.org>
 
         REGRESSION(r99369): File input button doesn't highlight when pressed
index daed5c2..1f34c3e 100644 (file)
@@ -786,6 +786,31 @@ void RenderLayerBacking::updateBackgroundColor()
     m_graphicsLayer->setContentsToBackgroundColor(rendererBackgroundColor());
 }
 
+bool RenderLayerBacking::paintsBoxDecorations() const
+{
+    if (!m_owningLayer->hasVisibleContent())
+        return false;
+
+    if (hasBoxDecorationsOrBackground(renderer()))
+        return true;
+
+    if (m_owningLayer->hasOverflowControls())
+        return true;
+
+    return false;
+}
+
+bool RenderLayerBacking::paintsChildren() const
+{
+    if (m_owningLayer->hasVisibleContent() && containsNonEmptyRenderers())
+        return true;
+        
+    if (hasVisibleNonCompositingDescendantLayers())
+        return true;
+
+    return false;
+}
+
 // A "simple container layer" is a RenderLayer which has no visible content to render.
 // It may have no children, or all its children may be themselves composited.
 // This is a useful optimization, because it allows us to avoid allocating backing store.
@@ -796,21 +821,8 @@ bool RenderLayerBacking::isSimpleContainerCompositingLayer() const
         renderObject->hasMask())            // masks require special treatment
         return false;
 
-    RenderStyle* style = renderObject->style();
-    bool isVisible = m_owningLayer->hasVisibleContent();
-
-    // Reject anything that has a border, a border-radius or outline,
-    // or any background (color or image).
-    // FIXME: we could optimize layers for simple backgrounds.
-    if (isVisible && hasBoxDecorationsOrBackground(renderObject))
-        return false;
-
-    if (isVisible && m_owningLayer->hasOverflowControls())
+    if (paintsBoxDecorations() || paintsChildren())
         return false;
-
-    // If we have got this far and the renderer has no children, then we're ok.
-    if (!renderObject->firstChild())
-        return true;
     
     if (renderObject->node() && renderObject->node()->isDocumentNode()) {
         // Look to see if the root object has a non-simple background
@@ -818,7 +830,7 @@ bool RenderLayerBacking::isSimpleContainerCompositingLayer() const
         if (!rootObject)
             return false;
         
-        style = rootObject->style();
+        RenderStyle* style = rootObject->style();
         
         // Reject anything that has a border, a border-radius or outline,
         // or is not a simple background (no background, or solid color).
@@ -837,13 +849,6 @@ bool RenderLayerBacking::isSimpleContainerCompositingLayer() const
             return false;
     }
 
-    // Check to see if all the renderer's children are compositing layers.
-    if (isVisible && containsNonEmptyRenderers())
-        return false;
-        
-    if (hasVisibleNonCompositingDescendantLayers())
-        return false;
-    
     return true;
 }
 
index a75e318..4728c1c 100644 (file)
@@ -186,6 +186,9 @@ private:
     
     bool isMainFrameRenderViewLayer() const;
     
+    bool paintsBoxDecorations() const;
+    bool paintsChildren() const;
+
     // Returns true if this compositing layer has no visible content.
     bool isSimpleContainerCompositingLayer() const;
     // Returns true if this layer has content that needs to be rendered by painting into the backing store.