Chromium Code Reviews| 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 "core/layout/compositing/CompositingReasonFinder.h" | 5 #include "core/layout/compositing/CompositingReasonFinder.h" |
| 6 | 6 |
| 7 #include "core/CSSPropertyNames.h" | 7 #include "core/CSSPropertyNames.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 | 34 |
| 35 bool CompositingReasonFinder::isMainFrame() const { | 35 bool CompositingReasonFinder::isMainFrame() const { |
| 36 return m_layoutView.document().isInMainFrame(); | 36 return m_layoutView.document().isInMainFrame(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 CompositingReasons CompositingReasonFinder::directReasons( | 39 CompositingReasons CompositingReasonFinder::directReasons( |
| 40 const PaintLayer* layer) const { | 40 const PaintLayer* layer) const { |
| 41 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 41 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 42 return CompositingReasonNone; | 42 return CompositingReasonNone; |
| 43 | 43 |
| 44 ASSERT(potentialCompositingReasonsFromStyle(layer->layoutObject()) == | 44 DCHECK(potentialCompositingReasonsFromStyle(layer->layoutObject()) == |
|
flackr
2016/10/06 17:23:44
nit: DCHECK_EQ(potentialCompositingReasonsFromStyl
| |
| 45 layer->potentialCompositingReasonsFromStyle()); | 45 layer->potentialCompositingReasonsFromStyle()); |
| 46 CompositingReasons styleDeterminedDirectCompositingReasons = | 46 CompositingReasons styleDeterminedDirectCompositingReasons = |
| 47 layer->potentialCompositingReasonsFromStyle() & | 47 layer->potentialCompositingReasonsFromStyle() & |
| 48 CompositingReasonComboAllDirectStyleDeterminedReasons; | 48 CompositingReasonComboAllDirectStyleDeterminedReasons; |
| 49 | 49 |
| 50 return styleDeterminedDirectCompositingReasons | | 50 return styleDeterminedDirectCompositingReasons | |
| 51 nonStyleDeterminedDirectReasons(layer); | 51 nonStyleDeterminedDirectReasons(layer); |
| 52 } | 52 } |
| 53 | 53 |
| 54 // This information doesn't appear to be incorporated into CompositingReasons. | 54 // This information doesn't appear to be incorporated into CompositingReasons. |
| 55 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const { | 55 bool CompositingReasonFinder::requiresCompositingForScrollableFrame() const { |
| 56 // Need this done first to determine overflow. | 56 // Need this done first to determine overflow. |
| 57 ASSERT(!m_layoutView.needsLayout()); | 57 DCHECK(!m_layoutView.needsLayout()); |
| 58 if (isMainFrame()) | 58 if (isMainFrame()) |
| 59 return false; | 59 return false; |
| 60 | 60 |
| 61 if (!(m_compositingTriggers & ScrollableInnerFrameTrigger)) | 61 if (!(m_compositingTriggers & ScrollableInnerFrameTrigger)) |
| 62 return false; | 62 return false; |
| 63 | 63 |
| 64 return m_layoutView.frameView()->isScrollable(); | 64 return m_layoutView.frameView()->isScrollable(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 CompositingReasons | 67 CompositingReasons |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 94 reasons |= CompositingReasonPreserve3DWith3DDescendants; | 94 reasons |= CompositingReasonPreserve3DWith3DDescendants; |
| 95 | 95 |
| 96 if (style.hasPerspective()) | 96 if (style.hasPerspective()) |
| 97 reasons |= CompositingReasonPerspectiveWith3DDescendants; | 97 reasons |= CompositingReasonPerspectiveWith3DDescendants; |
| 98 | 98 |
| 99 if (style.hasCompositorProxy()) | 99 if (style.hasCompositorProxy()) |
| 100 reasons |= CompositingReasonCompositorProxy; | 100 reasons |= CompositingReasonCompositorProxy; |
| 101 | 101 |
| 102 // If the implementation of createsGroup changes, we need to be aware of that | 102 // If the implementation of createsGroup changes, we need to be aware of that |
| 103 // in this part of code. | 103 // in this part of code. |
| 104 ASSERT((layoutObject->isTransparent() || layoutObject->hasMask() || | 104 DCHECK((layoutObject->isTransparent() || layoutObject->hasMask() || |
| 105 layoutObject->hasFilterInducingProperty() || style.hasBlendMode()) == | 105 layoutObject->hasFilterInducingProperty() || style.hasBlendMode()) == |
| 106 layoutObject->createsGroup()); | 106 layoutObject->createsGroup()); |
| 107 | 107 |
| 108 if (style.hasMask()) | 108 if (style.hasMask()) |
| 109 reasons |= CompositingReasonMaskWithCompositedDescendants; | 109 reasons |= CompositingReasonMaskWithCompositedDescendants; |
| 110 | 110 |
| 111 if (style.hasFilterInducingProperty()) | 111 if (style.hasFilterInducingProperty()) |
| 112 reasons |= CompositingReasonFilterWithCompositedDescendants; | 112 reasons |= CompositingReasonFilterWithCompositedDescendants; |
| 113 | 113 |
| 114 if (style.hasBackdropFilter()) | 114 if (style.hasBackdropFilter()) |
| 115 reasons |= CompositingReasonBackdropFilter; | 115 reasons |= CompositingReasonBackdropFilter; |
| 116 | 116 |
| 117 // See Layer::updateTransform for an explanation of why we check both. | 117 // See Layer::updateTransform for an explanation of why we check both. |
| 118 if (layoutObject->hasTransformRelatedProperty() && style.hasTransform()) | 118 if (layoutObject->hasTransformRelatedProperty() && style.hasTransform()) |
| 119 reasons |= CompositingReasonTransformWithCompositedDescendants; | 119 reasons |= CompositingReasonTransformWithCompositedDescendants; |
| 120 | 120 |
| 121 if (layoutObject->isTransparent()) | 121 if (layoutObject->isTransparent()) |
| 122 reasons |= CompositingReasonOpacityWithCompositedDescendants; | 122 reasons |= CompositingReasonOpacityWithCompositedDescendants; |
| 123 | 123 |
| 124 if (style.hasBlendMode()) | 124 if (style.hasBlendMode()) |
| 125 reasons |= CompositingReasonBlendingWithCompositedDescendants; | 125 reasons |= CompositingReasonBlendingWithCompositedDescendants; |
| 126 | 126 |
| 127 if (layoutObject->hasReflection()) | 127 if (layoutObject->hasReflection()) |
| 128 reasons |= CompositingReasonReflectionWithCompositedDescendants; | 128 reasons |= CompositingReasonReflectionWithCompositedDescendants; |
| 129 | 129 |
| 130 ASSERT(!(reasons & ~CompositingReasonComboAllStyleDeterminedReasons)); | 130 DCHECK(!(reasons & ~CompositingReasonComboAllStyleDeterminedReasons)); |
| 131 return reasons; | 131 return reasons; |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool CompositingReasonFinder::requiresCompositingForTransform( | 134 bool CompositingReasonFinder::requiresCompositingForTransform( |
| 135 LayoutObject* layoutObject) const { | 135 LayoutObject* layoutObject) const { |
| 136 // Note that we ask the layoutObject if it has a transform, because the style | 136 // Note that we ask the layoutObject if it has a transform, because the style |
| 137 // may have transforms, but the layoutObject may be an inline that doesn't | 137 // may have transforms, but the layoutObject may be an inline that doesn't |
| 138 // support them. | 138 // support them. |
| 139 return layoutObject->hasTransformRelatedProperty() && | 139 return layoutObject->hasTransformRelatedProperty() && |
| 140 layoutObject->style()->has3DTransform(); | 140 layoutObject->style()->has3DTransform(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons( | 143 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons( |
| 144 const PaintLayer* layer) const { | 144 const PaintLayer* layer) const { |
| 145 CompositingReasons directReasons = CompositingReasonNone; | 145 CompositingReasons directReasons = CompositingReasonNone; |
| 146 LayoutObject* layoutObject = layer->layoutObject(); | 146 LayoutObject* layoutObject = layer->layoutObject(); |
| 147 | 147 |
| 148 if (m_compositingTriggers & OverflowScrollTrigger && layer->clipParent()) | |
| 149 directReasons |= CompositingReasonOutOfFlowClipping; | |
| 150 | |
| 148 if (layer->needsCompositedScrolling()) | 151 if (layer->needsCompositedScrolling()) |
| 149 directReasons |= CompositingReasonOverflowScrollingTouch; | 152 directReasons |= CompositingReasonOverflowScrollingTouch; |
| 150 | 153 |
| 151 // Composite |layer| if it is inside of an ancestor scrolling layer, but that | 154 // Composite |layer| if it is inside of an ancestor scrolling layer, but that |
| 152 // scrolling layer is not on the stacking context ancestor chain of |layer|. | 155 // scrolling layer is not on the stacking context ancestor chain of |layer|. |
| 153 // See the definition of the scrollParent property in Layer for more detail. | 156 // See the definition of the scrollParent property in Layer for more detail. |
| 154 if (const PaintLayer* scrollingAncestor = layer->ancestorScrollingLayer()) { | 157 if (const PaintLayer* scrollingAncestor = layer->ancestorScrollingLayer()) { |
| 155 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollParent()) | 158 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollParent()) |
| 156 directReasons |= CompositingReasonOverflowScrollingParent; | 159 directReasons |= CompositingReasonOverflowScrollingParent; |
| 157 } | 160 } |
| 158 | 161 |
| 159 // TODO(flackr): Rename functions and variables to include sticky position | 162 // TODO(flackr): Rename functions and variables to include sticky position |
| 160 // (i.e. ScrollDependentPosition rather than PositionFixed). | 163 // (i.e. ScrollDependentPosition rather than PositionFixed). |
| 161 if (requiresCompositingForScrollDependentPosition(layer)) | 164 if (requiresCompositingForScrollDependentPosition(layer)) |
| 162 directReasons |= CompositingReasonScrollDependentPosition; | 165 directReasons |= CompositingReasonScrollDependentPosition; |
| 163 | 166 |
| 164 directReasons |= layoutObject->additionalCompositingReasons(); | 167 directReasons |= layoutObject->additionalCompositingReasons(); |
| 165 | 168 |
| 166 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); | 169 DCHECK(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); |
| 167 return directReasons; | 170 return directReasons; |
| 168 } | 171 } |
| 169 | 172 |
| 170 bool CompositingReasonFinder::requiresCompositingForAnimation( | 173 bool CompositingReasonFinder::requiresCompositingForAnimation( |
| 171 const ComputedStyle& style) const { | 174 const ComputedStyle& style) const { |
| 172 if (style.subtreeWillChangeContents()) | 175 if (style.subtreeWillChangeContents()) |
| 173 return style.isRunningAnimationOnCompositor(); | 176 return style.isRunningAnimationOnCompositor(); |
| 174 | 177 |
| 175 return style.shouldCompositeForCurrentAnimations(); | 178 return style.shouldCompositeForCurrentAnimations(); |
| 176 } | 179 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 190 // Don't promote fixed position elements that are descendants of a non-view | 193 // Don't promote fixed position elements that are descendants of a non-view |
| 191 // container, e.g. transformed elements. They will stay fixed wrt the | 194 // container, e.g. transformed elements. They will stay fixed wrt the |
| 192 // container rather than the enclosing frame. | 195 // container rather than the enclosing frame. |
| 193 if (layer->scrollsWithViewport()) | 196 if (layer->scrollsWithViewport()) |
| 194 return m_layoutView.frameView()->isScrollable(); | 197 return m_layoutView.frameView()->isScrollable(); |
| 195 return layer->layoutObject()->style()->position() == StickyPosition && | 198 return layer->layoutObject()->style()->position() == StickyPosition && |
| 196 layer->ancestorOverflowLayer()->scrollsOverflow(); | 199 layer->ancestorOverflowLayer()->scrollsOverflow(); |
| 197 } | 200 } |
| 198 | 201 |
| 199 } // namespace blink | 202 } // namespace blink |
| OLD | NEW |