| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "config.h" | 5 #include "config.h" | 
| 6 #include "core/layout/compositing/CompositingReasonFinder.h" | 6 #include "core/layout/compositing/CompositingReasonFinder.h" | 
| 7 | 7 | 
| 8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" | 
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" | 
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 43 { | 43 { | 
| 44     // FIXME: LocalFrame::isMainFrame() is probably better. | 44     // FIXME: LocalFrame::isMainFrame() is probably better. | 
| 45     return !m_layoutView.document().ownerElement(); | 45     return !m_layoutView.document().ownerElement(); | 
| 46 } | 46 } | 
| 47 | 47 | 
| 48 CompositingReasons CompositingReasonFinder::directReasons(const Layer* layer) co
     nst | 48 CompositingReasons CompositingReasonFinder::directReasons(const Layer* layer) co
     nst | 
| 49 { | 49 { | 
| 50     if (RuntimeEnabledFeatures::slimmingPaintCompositorLayerizationEnabled()) | 50     if (RuntimeEnabledFeatures::slimmingPaintCompositorLayerizationEnabled()) | 
| 51         return CompositingReasonNone; | 51         return CompositingReasonNone; | 
| 52 | 52 | 
| 53     ASSERT(potentialCompositingReasonsFromStyle(layer->renderer()) == layer->pot
     entialCompositingReasonsFromStyle()); | 53     ASSERT(potentialCompositingReasonsFromStyle(layer->layoutObject()) == layer-
     >potentialCompositingReasonsFromStyle()); | 
| 54     CompositingReasons styleDeterminedDirectCompositingReasons = layer->potentia
     lCompositingReasonsFromStyle() & CompositingReasonComboAllDirectStyleDeterminedR
     easons; | 54     CompositingReasons styleDeterminedDirectCompositingReasons = layer->potentia
     lCompositingReasonsFromStyle() & CompositingReasonComboAllDirectStyleDeterminedR
     easons; | 
| 55 | 55 | 
| 56     // Apply optimizations for scroll-blocks-on which require comparing style be
     tween objects. | 56     // Apply optimizations for scroll-blocks-on which require comparing style be
     tween objects. | 
| 57     if ((styleDeterminedDirectCompositingReasons & CompositingReasonScrollBlocks
     On) && !requiresCompositingForScrollBlocksOn(layer->renderer())) | 57     if ((styleDeterminedDirectCompositingReasons & CompositingReasonScrollBlocks
     On) && !requiresCompositingForScrollBlocksOn(layer->layoutObject())) | 
| 58         styleDeterminedDirectCompositingReasons &= ~CompositingReasonScrollBlock
     sOn; | 58         styleDeterminedDirectCompositingReasons &= ~CompositingReasonScrollBlock
     sOn; | 
| 59 | 59 | 
| 60     return styleDeterminedDirectCompositingReasons | nonStyleDeterminedDirectRea
     sons(layer); | 60     return styleDeterminedDirectCompositingReasons | nonStyleDeterminedDirectRea
     sons(layer); | 
| 61 } | 61 } | 
| 62 | 62 | 
| 63 // This information doesn't appear to be incorporated into CompositingReasons. | 63 // This information doesn't appear to be incorporated into CompositingReasons. | 
| 64 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const | 64 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const | 
| 65 { | 65 { | 
| 66     // Need this done first to determine overflow. | 66     // Need this done first to determine overflow. | 
| 67     ASSERT(!m_layoutView.needsLayout()); | 67     ASSERT(!m_layoutView.needsLayout()); | 
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 139 bool CompositingReasonFinder::requiresCompositingForTransform(LayoutObject* rend
     erer) const | 139 bool CompositingReasonFinder::requiresCompositingForTransform(LayoutObject* rend
     erer) const | 
| 140 { | 140 { | 
| 141     // Note that we ask the renderer if it has a transform, because the style ma
     y have transforms, | 141     // Note that we ask the renderer if it has a transform, because the style ma
     y have transforms, | 
| 142     // but the renderer may be an inline that doesn't support them. | 142     // but the renderer may be an inline that doesn't support them. | 
| 143     return renderer->hasTransformRelatedProperty() && renderer->style()->transfo
     rm().has3DOperation(); | 143     return renderer->hasTransformRelatedProperty() && renderer->style()->transfo
     rm().has3DOperation(); | 
| 144 } | 144 } | 
| 145 | 145 | 
| 146 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
     t Layer* layer) const | 146 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
     t Layer* layer) const | 
| 147 { | 147 { | 
| 148     CompositingReasons directReasons = CompositingReasonNone; | 148     CompositingReasons directReasons = CompositingReasonNone; | 
| 149     LayoutObject* renderer = layer->renderer(); | 149     LayoutObject* renderer = layer->layoutObject(); | 
| 150 | 150 | 
| 151     if (hasOverflowScrollTrigger()) { | 151     if (hasOverflowScrollTrigger()) { | 
| 152         if (layer->clipParent()) | 152         if (layer->clipParent()) | 
| 153             directReasons |= CompositingReasonOutOfFlowClipping; | 153             directReasons |= CompositingReasonOutOfFlowClipping; | 
| 154 | 154 | 
| 155         if (layer->needsCompositedScrolling()) | 155         if (layer->needsCompositedScrolling()) | 
| 156             directReasons |= CompositingReasonOverflowScrollingTouch; | 156             directReasons |= CompositingReasonOverflowScrollingTouch; | 
| 157     } | 157     } | 
| 158 | 158 | 
| 159     // Composite |layer| if it is inside of an ancestor scrolling layer, but tha
     t | 159     // Composite |layer| if it is inside of an ancestor scrolling layer, but tha
     t | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 196     // only on the style of their object.  This function runs at CompositingRequ
     irementsUpdater::update | 196     // only on the style of their object.  This function runs at CompositingRequ
     irementsUpdater::update | 
| 197     // time, and so can consider the style of other objects. | 197     // time, and so can consider the style of other objects. | 
| 198     const LayoutStyle& style = renderer->styleRef(); | 198     const LayoutStyle& style = renderer->styleRef(); | 
| 199 | 199 | 
| 200     // We should only get here by CompositingReasonScrollBlocksOn being a potent
     ial compositing reason. | 200     // We should only get here by CompositingReasonScrollBlocksOn being a potent
     ial compositing reason. | 
| 201     ASSERT(style.hasScrollBlocksOn() && !renderer->isDocumentElement()); | 201     ASSERT(style.hasScrollBlocksOn() && !renderer->isDocumentElement()); | 
| 202 | 202 | 
| 203     // scroll-blocks-on style is propagated from the document element to the doc
     ument. | 203     // scroll-blocks-on style is propagated from the document element to the doc
     ument. | 
| 204     ASSERT(!renderer->isLayoutView() | 204     ASSERT(!renderer->isLayoutView() | 
| 205         || !renderer->document().documentElement() | 205         || !renderer->document().documentElement() | 
| 206         || !renderer->document().documentElement()->renderer() | 206         || !renderer->document().documentElement()->layoutObject() | 
| 207         || renderer->document().documentElement()->renderer()->style()->scrollBl
     ocksOn() == style.scrollBlocksOn()); | 207         || renderer->document().documentElement()->layoutObject()->style()->scro
     llBlocksOn() == style.scrollBlocksOn()); | 
| 208 | 208 | 
| 209     // When a scroll occurs, it's the union of all bits set on the target elemen
     t's containing block | 209     // When a scroll occurs, it's the union of all bits set on the target elemen
     t's containing block | 
| 210     // chain that determines the behavior.  Thus we really only need a new layer
      if this object contains | 210     // chain that determines the behavior.  Thus we really only need a new layer
      if this object contains | 
| 211     // additional bits from those set by all objects in it's containing block ch
     ain.  But determining | 211     // additional bits from those set by all objects in it's containing block ch
     ain.  But determining | 
| 212     // this fully is probably more expensive than it's worth.  Instead we just h
     ave fast-paths here for | 212     // this fully is probably more expensive than it's worth.  Instead we just h
     ave fast-paths here for | 
| 213     // the most common cases of unnecessary layer creation. | 213     // the most common cases of unnecessary layer creation. | 
| 214     // Optimizing this fully would avoid layer explosion in pathological cases l
     ike '*' rules. | 214     // Optimizing this fully would avoid layer explosion in pathological cases l
     ike '*' rules. | 
| 215     // We could consider tracking the current state in CompositingRequirementsUp
     dater::update. | 215     // We could consider tracking the current state in CompositingRequirementsUp
     dater::update. | 
| 216 | 216 | 
| 217     // Ensure iframes don't get composited when they require no more blocking th
     an their parent. | 217     // Ensure iframes don't get composited when they require no more blocking th
     an their parent. | 
| 218     if (renderer->isLayoutView()) { | 218     if (renderer->isLayoutView()) { | 
| 219         if (const FrameView* parentFrame = toLayoutView(renderer)->frameView()->
     parentFrameView()) { | 219         if (const FrameView* parentFrame = toLayoutView(renderer)->frameView()->
     parentFrameView()) { | 
| 220             if (const LayoutView* parentRenderer = parentFrame->layoutView()) { | 220             if (const LayoutView* parentRenderer = parentFrame->layoutView()) { | 
| 221                 // Does this frame contain only blocks-on bits already present i
     n the parent frame? | 221                 // Does this frame contain only blocks-on bits already present i
     n the parent frame? | 
| 222                 if (!(style.scrollBlocksOn() & ~parentRenderer->style()->scrollB
     locksOn())) | 222                 if (!(style.scrollBlocksOn() & ~parentRenderer->style()->scrollB
     locksOn())) | 
| 223                     return false; | 223                     return false; | 
| 224             } | 224             } | 
| 225         } else { | 225         } else { | 
| 226             // The root frame will either always already be composited, or compo
     siting will be disabled. | 226             // The root frame will either always already be composited, or compo
     siting will be disabled. | 
| 227             // Either way, we don't need to require compositing for scroll block
     s on.  This avoids | 227             // Either way, we don't need to require compositing for scroll block
     s on.  This avoids | 
| 228             // enabling compositing by default, and avoids cluttering the root l
     ayers compositing reasons. | 228             // enabling compositing by default, and avoids cluttering the root l
     ayers compositing reasons. | 
| 229             return false; | 229             return false; | 
| 230         } | 230         } | 
| 231     } | 231     } | 
| 232 | 232 | 
| 233     return true; | 233     return true; | 
| 234 } | 234 } | 
| 235 | 235 | 
| 236 } | 236 } | 
| OLD | NEW | 
|---|