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

Unified Diff: Source/core/rendering/compositing/CompositingReasonFinder.cpp

Issue 449723003: Simply rules for compositing fixed position elements (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Deleted Created 6 years, 4 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
Index: Source/core/rendering/compositing/CompositingReasonFinder.cpp
diff --git a/Source/core/rendering/compositing/CompositingReasonFinder.cpp b/Source/core/rendering/compositing/CompositingReasonFinder.cpp
index 7c3043b65c0058e565458ad535309ba15829a5d7..bae98d2cffcb571e10d78a1edd41acb6d01bb3bf 100644
--- a/Source/core/rendering/compositing/CompositingReasonFinder.cpp
+++ b/Source/core/rendering/compositing/CompositingReasonFinder.cpp
@@ -151,7 +151,7 @@ CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
directReasons |= CompositingReasonOverflowScrollingTouch;
}
- if (requiresCompositingForPositionFixed(renderer, layer, 0))
+ if (requiresCompositingForPositionFixed(renderer))
directReasons |= CompositingReasonPositionFixed;
directReasons |= renderer->additionalCompositingReasons(m_compositingTriggers);
@@ -168,84 +168,15 @@ bool CompositingReasonFinder::requiresCompositingForAnimation(RenderStyle* style
return style->shouldCompositeForCurrentAnimations();
}
-bool CompositingReasonFinder::requiresCompositingForPositionFixed(RenderObject* renderer, const RenderLayer* layer, RenderLayer::ViewportConstrainedNotCompositedReason* viewportConstrainedNotCompositedReason) const
+bool CompositingReasonFinder::requiresCompositingForPositionFixed(RenderObject* renderer) const
{
if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger))
return false;
-
- if (renderer->style()->position() != FixedPosition)
- return false;
-
- RenderObject* container = renderer->container();
- // If the renderer is not hooked up yet then we have to wait until it is.
- if (!container) {
- ASSERT(m_renderView.document().lifecycle().state() < DocumentLifecycle::InCompositingUpdate);
- // FIXME: Remove this and ASSERT(container) once we get rid of the incremental
- // allocateOrClearCompositedLayerMapping compositing update. This happens when
- // adding the renderer to the tree because we setStyle before addChild in
- // createRendererForElementIfNeeded.
- return false;
- }
-
// Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements.
// They will stay fixed wrt the container rather than the enclosing frame.
- if (container != &m_renderView) {
- if (viewportConstrainedNotCompositedReason)
- *viewportConstrainedNotCompositedReason = RenderLayer::NotCompositedForNonViewContainer;
- 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;
-
- RenderLayer* ancestor = layer->parent();
- while (ancestor && !hasScrollableAncestor) {
- if (ancestor->scrollsOverflow())
- 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.
- // FIXME: Get rid of this codepath once we get rid of the incremental compositing update in RenderLayer::styleChanged.
- if (m_renderView.document().lifecycle().state() < DocumentLifecycle::LayoutClean)
- return layer->hasCompositedLayerMapping();
-
- bool paintsContent = layer->isVisuallyNonEmpty() || layer->hasVisibleDescendant();
- if (!paintsContent) {
- if (viewportConstrainedNotCompositedReason)
- *viewportConstrainedNotCompositedReason = RenderLayer::NotCompositedForNoVisibleContent;
- return false;
- }
-
- // Fixed position elements that are invisible in the current view don't get their own layer.
- if (FrameView* frameView = m_renderView.frameView()) {
- ASSERT(m_renderView.document().lifecycle().state() == DocumentLifecycle::InCompositingUpdate);
- LayoutRect viewBounds = frameView->viewportConstrainedVisibleContentRect();
- LayoutRect layerBounds = layer->boundingBoxForCompositing(layer->compositor()->rootRenderLayer(), RenderLayer::ApplyBoundsChickenEggHacks);
- if (!viewBounds.intersects(enclosingIntRect(layerBounds))) {
- if (viewportConstrainedNotCompositedReason)
- *viewportConstrainedNotCompositedReason = RenderLayer::NotCompositedForBoundsOutOfView;
- return false;
- }
- }
-
- return true;
+ return renderer->style()->position() == FixedPosition
+ && renderer->container() == &m_renderView
+ && m_renderView.frameView()->isScrollable();
}
}
« no previous file with comments | « Source/core/rendering/compositing/CompositingReasonFinder.h ('k') | Source/core/rendering/compositing/RenderLayerCompositor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698