1d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 2d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)// found in the LICENSE file. 4d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 5d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "config.h" 6d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/rendering/compositing/CompositingReasonFinder.h" 7d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 8d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/frame/FrameView.h" 9d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/frame/Settings.h" 10d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/page/Page.h" 11d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/rendering/RenderView.h" 12d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/rendering/compositing/RenderLayerCompositor.h" 13d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 14d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)namespace WebCore { 15d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 16d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)CompositingReasonFinder::CompositingReasonFinder(RenderView& renderView) 17d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) : m_renderView(renderView) 1807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch , m_compositingTriggers(static_cast<CompositingTriggerFlags>(AllCompositingTriggers)) 19d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 20a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch updateTriggers(); 21d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 22d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 23d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)void CompositingReasonFinder::updateTriggers() 24d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 2510f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch m_compositingTriggers = 0; 2610f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch 2710f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch Settings& settings = m_renderView.document().page()->settings(); 2810f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch if (settings.acceleratedCompositingForVideoEnabled()) 2910f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch m_compositingTriggers |= VideoTrigger; 3010f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch if (settings.acceleratedCompositingForCanvasEnabled()) 3110f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch m_compositingTriggers |= CanvasTrigger; 3210f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch if (settings.compositedScrollingForFramesEnabled()) 3310f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch m_compositingTriggers |= ScrollableInnerFrameTrigger; 3410f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch if (settings.acceleratedCompositingForFiltersEnabled()) 3510f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch m_compositingTriggers |= FilterTrigger; 3610f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch 3710f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch // We map both these settings to universal overlow scrolling. 3810f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch // FIXME: Replace these settings with a generic compositing setting for HighDPI. 3910f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch if (settings.acceleratedCompositingForOverflowScrollEnabled() || settings.compositorDrivenAcceleratedScrollingEnabled()) 40a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch m_compositingTriggers |= OverflowScrollTrigger; 4110f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch 4210f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch // FIXME: acceleratedCompositingForFixedPositionEnabled should be renamed acceleratedCompositingForViewportConstrainedPositionEnabled(). 4310f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch // Or the sticky and fixed position elements should be behind different flags. 4410f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch if (settings.acceleratedCompositingForFixedPositionEnabled()) 4510f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch m_compositingTriggers |= ViewportConstrainedPositionedTrigger; 46d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 47d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 48a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdochbool CompositingReasonFinder::hasOverflowScrollTrigger() const 49a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch{ 50a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch return m_compositingTriggers & OverflowScrollTrigger; 51a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch} 52a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 53d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)bool CompositingReasonFinder::isMainFrame() const 54d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 55d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // FIXME: LocalFrame::isMainFrame() is probably better. 56d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return !m_renderView.document().ownerElement(); 57d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 58d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 59f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)CompositingReasons CompositingReasonFinder::directReasons(const RenderLayer* layer) const 60d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 6107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch CompositingReasons styleReasons = layer->styleDeterminedCompositingReasons(); 6207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch ASSERT(styleDeterminedReasons(layer->renderer()) == styleReasons); 63f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) return styleReasons | nonStyleDeterminedDirectReasons(layer); 6407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch} 6507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch 6607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch// This information doesn't appear to be incorporated into CompositingReasons. 6707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochbool CompositingReasonFinder::requiresCompositingForScrollableFrame() const 6807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch{ 6907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch // Need this done first to determine overflow. 7007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch ASSERT(!m_renderView.needsLayout()); 7107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch if (isMainFrame()) 7207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch return false; 7307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch 7407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch if (!(m_compositingTriggers & ScrollableInnerFrameTrigger)) 7507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch return false; 7607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch 77f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) return m_renderView.frameView()->isScrollable(); 7807a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch} 7907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch 8007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben MurdochCompositingReasons CompositingReasonFinder::styleDeterminedReasons(RenderObject* renderer) const 8107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch{ 82d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) CompositingReasons directReasons = CompositingReasonNone; 83d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 84f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) RenderStyle* style = renderer->style(); 85f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) 86d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (requiresCompositingForTransform(renderer)) 87d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) directReasons |= CompositingReason3DTransform; 88d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 89f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (requiresCompositingForFilters(renderer)) 90f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) directReasons |= CompositingReasonFilters; 91f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) 92f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (style->backfaceVisibility() == BackfaceVisibilityHidden) 93d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) directReasons |= CompositingReasonBackfaceVisibilityHidden; 94d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 955d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) if (requiresCompositingForAnimation(style)) 96a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch directReasons |= CompositingReasonActiveAnimation; 97a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch 98f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (style->hasWillChangeCompositingHint() && !style->subtreeWillChangeContents()) 9910f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch directReasons |= CompositingReasonWillChangeCompositingHint; 10010f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch 10107a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch ASSERT(!(directReasons & ~CompositingReasonComboAllStyleDeterminedReasons)); 102d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return directReasons; 103d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 104d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 105d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* renderer) const 106d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 107d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Note that we ask the renderer if it has a transform, because the style may have transforms, 108d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // but the renderer may be an inline that doesn't suppport them. 10907a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch return renderer->hasTransform() && renderer->style()->transform().has3DOperation(); 110d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 111d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 11207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdochbool CompositingReasonFinder::requiresCompositingForFilters(RenderObject* renderer) const 113d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 11407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch if (!(m_compositingTriggers & FilterTrigger)) 115d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return false; 116d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 11707a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch return renderer->hasFilter(); 118d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 119d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 120f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(const RenderLayer* layer) const 121d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 12207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch CompositingReasons directReasons = CompositingReasonNone; 12307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch RenderObject* renderer = layer->renderer(); 124d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 125a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch if (hasOverflowScrollTrigger()) { 126f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) // IsUnclippedDescendant is only actually stale during the chicken/egg code path. 1275d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) // FIXME: Use compositingInputs().isUnclippedDescendant to ASSERT that 128f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) // this value isn't stale. 1295d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) if (layer->compositingInputs().isUnclippedDescendant) 13007a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch directReasons |= CompositingReasonOutOfFlowClipping; 131d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 132f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (layer->scrollParent()) 13307a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch directReasons |= CompositingReasonOverflowScrollingParent; 134d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 135f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (layer->needsCompositedScrolling()) 136f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) directReasons |= CompositingReasonOverflowScrollingTouch; 137f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) } 138d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 139f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (requiresCompositingForPositionFixed(renderer, layer, 0)) 1406f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch directReasons |= CompositingReasonPositionFixed; 141d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 14207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch directReasons |= renderer->additionalCompositingReasons(m_compositingTriggers); 143d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 14407a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); 14507a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch return directReasons; 146d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 147d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 1485d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)bool CompositingReasonFinder::requiresCompositingForAnimation(RenderStyle* style) const 149d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles){ 1505d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) if (style->subtreeWillChangeContents()) 1515d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) return style->isRunningAnimationOnCompositor(); 152d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 1535d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) return style->shouldCompositeForCurrentAnimations(); 1546f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch} 155d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 156f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles)bool CompositingReasonFinder::requiresCompositingForPositionFixed(RenderObject* renderer, const RenderLayer* layer, RenderLayer::ViewportConstrainedNotCompositedReason* viewportConstrainedNotCompositedReason) const 1576f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch{ 1586f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) 1596f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch return false; 160d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 1616f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch if (renderer->style()->position() != FixedPosition) 1626f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch return false; 163d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 164d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) RenderObject* container = renderer->container(); 165d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // If the renderer is not hooked up yet then we have to wait until it is. 166d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (!container) { 167d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) ASSERT(m_renderView.document().lifecycle().state() < DocumentLifecycle::InCompositingUpdate); 168d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) // FIXME: Remove this and ASSERT(container) once we get rid of the incremental 169d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) // allocateOrClearCompositedLayerMapping compositing update. This happens when 170d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) // adding the renderer to the tree because we setStyle before addChild in 171d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) // createRendererForElementIfNeeded. 172d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return false; 173d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 174d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 175d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Don't promote fixed position elements that are descendants of a non-view container, e.g. transformed elements. 176d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // They will stay fixed wrt the container rather than the enclosing frame. 177d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (container != &m_renderView) { 178d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (viewportConstrainedNotCompositedReason) 179d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) *viewportConstrainedNotCompositedReason = RenderLayer::NotCompositedForNonViewContainer; 180d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return false; 181d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 182d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 183d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // If the fixed-position element does not have any scrollable ancestor between it and 184d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // its container, then we do not need to spend compositor resources for it. Start by 185d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // assuming we can opt-out (i.e. no scrollable ancestor), and refine the answer below. 186d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool hasScrollableAncestor = false; 187d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 188d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // The FrameView has the scrollbars associated with the top level viewport, so we have to 189d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // check the FrameView in addition to the hierarchy of ancestors. 190d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) FrameView* frameView = m_renderView.frameView(); 191d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (frameView && frameView->isScrollable()) 192d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) hasScrollableAncestor = true; 193d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 194d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) RenderLayer* ancestor = layer->parent(); 195d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) while (ancestor && !hasScrollableAncestor) { 1966f543c786fc42989f552b4daa774ca5ff32fa697Ben Murdoch if (ancestor->scrollsOverflow()) 197d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) hasScrollableAncestor = true; 198d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (ancestor->renderer() == &m_renderView) 199d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) break; 200d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) ancestor = ancestor->parent(); 201d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 202d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 203d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (!hasScrollableAncestor) { 204d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (viewportConstrainedNotCompositedReason) 205d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) *viewportConstrainedNotCompositedReason = RenderLayer::NotCompositedForUnscrollableAncestors; 206d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return false; 207d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 208d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 209d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Subsequent tests depend on layout. If we can't tell now, just keep things the way they are until layout is done. 210d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) // FIXME: Get rid of this codepath once we get rid of the incremental compositing update in RenderLayer::styleChanged. 211f6b7aed3f7ce69aca0d7a032d144cbd088b04393Torne (Richard Coles) if (m_renderView.document().lifecycle().state() < DocumentLifecycle::LayoutClean) 212d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return layer->hasCompositedLayerMapping(); 213d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 214d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) bool paintsContent = layer->isVisuallyNonEmpty() || layer->hasVisibleDescendant(); 215d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (!paintsContent) { 216d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (viewportConstrainedNotCompositedReason) 217d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) *viewportConstrainedNotCompositedReason = RenderLayer::NotCompositedForNoVisibleContent; 218d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return false; 219d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 220d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 221d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) // Fixed position elements that are invisible in the current view don't get their own layer. 222d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (FrameView* frameView = m_renderView.frameView()) { 223d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) ASSERT(m_renderView.document().lifecycle().state() == DocumentLifecycle::InCompositingUpdate); 224d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) LayoutRect viewBounds = frameView->viewportConstrainedVisibleContentRect(); 225a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch LayoutRect layerBounds = layer->boundingBoxForCompositing(layer->compositor()->rootRenderLayer(), RenderLayer::ApplyBoundsChickenEggHacks); 226d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) if (!viewBounds.intersects(enclosingIntRect(layerBounds))) { 227d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) if (viewportConstrainedNotCompositedReason) 228d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) *viewportConstrainedNotCompositedReason = RenderLayer::NotCompositedForBoundsOutOfView; 229d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return false; 230d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 231d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) } 232d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 233d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) return true; 234d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 235d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 236d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)} 237