+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
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.
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
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).
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;
}