Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1943)

Unified Diff: Source/core/rendering/RenderLayerCompositor.cpp

Issue 13828004: Avoid compositing fixed-position elements if they cannot scroll (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased and addressed feedback Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderLayerCompositor.cpp
diff --git a/Source/core/rendering/RenderLayerCompositor.cpp b/Source/core/rendering/RenderLayerCompositor.cpp
index 47b0ee0de0f6bde965e04d947f347ac8bcfd414c..6bf4e713bc94d892cf8e74035e865ae2838024c5 100644
--- a/Source/core/rendering/RenderLayerCompositor.cpp
+++ b/Source/core/rendering/RenderLayerCompositor.cpp
@@ -1967,6 +1967,32 @@ bool RenderLayerCompositor::requiresCompositingForPosition(RenderObject* rendere
return false;
}
+ // If the fixed-position element does not have any scrollable ancestor between it and
+ // its container, then we do not need to spend compositor resources for it. Start by
+ // assuming we can opt-out (i.e. no scrollable ancestor), and refine the answer below.
+ bool hasScrollableAncestor = false;
+
+ // The FrameView has the scrollbars associated with the top level viewport, so we have to
+ // check the FrameView in addition to the hierarchy of ancestors.
+ FrameView* frameView = m_renderView->frameView();
+ if (frameView && frameView->isScrollable())
+ hasScrollableAncestor = true;
enne (OOO) 2013/05/02 01:04:07 Thanks, this is way clearer.
+
+ RenderLayer* ancestor = layer->parent();
+ while (ancestor && !hasScrollableAncestor) {
+ if (frameView->containsScrollableArea(ancestor))
+ hasScrollableAncestor = true;
+ if (ancestor->renderer() == m_renderView)
+ break;
+ ancestor = ancestor->parent();
+ }
+
+ if (!hasScrollableAncestor) {
+ if (viewportConstrainedNotCompositedReason)
+ *viewportConstrainedNotCompositedReason = RenderLayer::NotCompositedForUnscrollableAncestors;
+ return false;
+ }
+
// Subsequent tests depend on layout. If we can't tell now, just keep things the way they are until layout is done.
if (!m_inPostLayoutUpdate) {
m_reevaluateCompositingAfterLayout = true;
« no previous file with comments | « Source/core/rendering/RenderLayer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698