| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 if (style.usedTransformStyle3D() == TransformStyle3DPreserve3D) | 93 if (style.usedTransformStyle3D() == TransformStyle3DPreserve3D) |
| 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
in this part of code. | 102 // If the implementation of createsGroup changes, we need to be aware of that |
| 103 // in this part of code. |
| 103 ASSERT((layoutObject->isTransparent() || layoutObject->hasMask() || | 104 ASSERT((layoutObject->isTransparent() || layoutObject->hasMask() || |
| 104 layoutObject->hasFilterInducingProperty() || style.hasBlendMode()) == | 105 layoutObject->hasFilterInducingProperty() || style.hasBlendMode()) == |
| 105 layoutObject->createsGroup()); | 106 layoutObject->createsGroup()); |
| 106 | 107 |
| 107 if (style.hasMask()) | 108 if (style.hasMask()) |
| 108 reasons |= CompositingReasonMaskWithCompositedDescendants; | 109 reasons |= CompositingReasonMaskWithCompositedDescendants; |
| 109 | 110 |
| 110 if (style.hasFilterInducingProperty()) | 111 if (style.hasFilterInducingProperty()) |
| 111 reasons |= CompositingReasonFilterWithCompositedDescendants; | 112 reasons |= CompositingReasonFilterWithCompositedDescendants; |
| 112 | 113 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 125 | 126 |
| 126 if (layoutObject->hasReflection()) | 127 if (layoutObject->hasReflection()) |
| 127 reasons |= CompositingReasonReflectionWithCompositedDescendants; | 128 reasons |= CompositingReasonReflectionWithCompositedDescendants; |
| 128 | 129 |
| 129 ASSERT(!(reasons & ~CompositingReasonComboAllStyleDeterminedReasons)); | 130 ASSERT(!(reasons & ~CompositingReasonComboAllStyleDeterminedReasons)); |
| 130 return reasons; | 131 return reasons; |
| 131 } | 132 } |
| 132 | 133 |
| 133 bool CompositingReasonFinder::requiresCompositingForTransform( | 134 bool CompositingReasonFinder::requiresCompositingForTransform( |
| 134 LayoutObject* layoutObject) const { | 135 LayoutObject* layoutObject) const { |
| 135 // Note that we ask the layoutObject if it has a transform, because the style
may have transforms, | 136 // Note that we ask the layoutObject if it has a transform, because the style |
| 136 // but the layoutObject may be an inline that doesn't support them. | 137 // may have transforms, but the layoutObject may be an inline that doesn't |
| 138 // support them. |
| 137 return layoutObject->hasTransformRelatedProperty() && | 139 return layoutObject->hasTransformRelatedProperty() && |
| 138 layoutObject->style()->has3DTransform(); | 140 layoutObject->style()->has3DTransform(); |
| 139 } | 141 } |
| 140 | 142 |
| 141 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons( | 143 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons( |
| 142 const PaintLayer* layer) const { | 144 const PaintLayer* layer) const { |
| 143 CompositingReasons directReasons = CompositingReasonNone; | 145 CompositingReasons directReasons = CompositingReasonNone; |
| 144 LayoutObject* layoutObject = layer->layoutObject(); | 146 LayoutObject* layoutObject = layer->layoutObject(); |
| 145 | 147 |
| 146 if (layer->needsCompositedScrolling()) | 148 if (layer->needsCompositedScrolling()) |
| 147 directReasons |= CompositingReasonOverflowScrollingTouch; | 149 directReasons |= CompositingReasonOverflowScrollingTouch; |
| 148 | 150 |
| 149 // Composite |layer| if it is inside of an ancestor scrolling layer, but that | 151 // Composite |layer| if it is inside of an ancestor scrolling layer, but that |
| 150 // scrolling layer is not on the stacking context ancestor chain of |layer|. | 152 // scrolling layer is not on the stacking context ancestor chain of |layer|. |
| 151 // See the definition of the scrollParent property in Layer for more detail. | 153 // See the definition of the scrollParent property in Layer for more detail. |
| 152 if (const PaintLayer* scrollingAncestor = layer->ancestorScrollingLayer()) { | 154 if (const PaintLayer* scrollingAncestor = layer->ancestorScrollingLayer()) { |
| 153 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollParent()) | 155 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollParent()) |
| 154 directReasons |= CompositingReasonOverflowScrollingParent; | 156 directReasons |= CompositingReasonOverflowScrollingParent; |
| 155 } | 157 } |
| 156 | 158 |
| 157 // TODO(flackr): Rename functions and variables to include sticky position (i.
e. ScrollDependentPosition rather than PositionFixed). | 159 // TODO(flackr): Rename functions and variables to include sticky position |
| 160 // (i.e. ScrollDependentPosition rather than PositionFixed). |
| 158 if (requiresCompositingForScrollDependentPosition(layer)) | 161 if (requiresCompositingForScrollDependentPosition(layer)) |
| 159 directReasons |= CompositingReasonScrollDependentPosition; | 162 directReasons |= CompositingReasonScrollDependentPosition; |
| 160 | 163 |
| 161 directReasons |= layoutObject->additionalCompositingReasons(); | 164 directReasons |= layoutObject->additionalCompositingReasons(); |
| 162 | 165 |
| 163 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); | 166 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); |
| 164 return directReasons; | 167 return directReasons; |
| 165 } | 168 } |
| 166 | 169 |
| 167 bool CompositingReasonFinder::requiresCompositingForAnimation( | 170 bool CompositingReasonFinder::requiresCompositingForAnimation( |
| 168 const ComputedStyle& style) const { | 171 const ComputedStyle& style) const { |
| 169 if (style.subtreeWillChangeContents()) | 172 if (style.subtreeWillChangeContents()) |
| 170 return style.isRunningAnimationOnCompositor(); | 173 return style.isRunningAnimationOnCompositor(); |
| 171 | 174 |
| 172 return style.shouldCompositeForCurrentAnimations(); | 175 return style.shouldCompositeForCurrentAnimations(); |
| 173 } | 176 } |
| 174 | 177 |
| 175 bool CompositingReasonFinder::requiresCompositingForScrollDependentPosition( | 178 bool CompositingReasonFinder::requiresCompositingForScrollDependentPosition( |
| 176 const PaintLayer* layer) const { | 179 const PaintLayer* layer) const { |
| 177 if (layer->layoutObject()->style()->position() != FixedPosition && | 180 if (layer->layoutObject()->style()->position() != FixedPosition && |
| 178 layer->layoutObject()->style()->position() != StickyPosition) | 181 layer->layoutObject()->style()->position() != StickyPosition) |
| 179 return false; | 182 return false; |
| 180 | 183 |
| 181 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger) && | 184 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger) && |
| 182 (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() || | 185 (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() || |
| 183 !layer->backgroundIsKnownToBeOpaqueInRect( | 186 !layer->backgroundIsKnownToBeOpaqueInRect( |
| 184 LayoutRect(layer->boundingBoxForCompositing())))) { | 187 LayoutRect(layer->boundingBoxForCompositing())))) { |
| 185 return false; | 188 return false; |
| 186 } | 189 } |
| 187 // Don't promote fixed position elements that are descendants of a non-view co
ntainer, e.g. transformed elements. | 190 // Don't promote fixed position elements that are descendants of a non-view |
| 188 // They will stay fixed wrt the container rather than the enclosing frame. | 191 // container, e.g. transformed elements. They will stay fixed wrt the |
| 192 // container rather than the enclosing frame. |
| 189 if (layer->scrollsWithViewport()) | 193 if (layer->scrollsWithViewport()) |
| 190 return m_layoutView.frameView()->isScrollable(); | 194 return m_layoutView.frameView()->isScrollable(); |
| 191 return layer->layoutObject()->style()->position() == StickyPosition && | 195 return layer->layoutObject()->style()->position() == StickyPosition && |
| 192 layer->ancestorOverflowLayer()->scrollsOverflow(); | 196 layer->ancestorOverflowLayer()->scrollsOverflow(); |
| 193 } | 197 } |
| 194 | 198 |
| 195 } // namespace blink | 199 } // namespace blink |
| OLD | NEW |