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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 directReasons |= CompositingReasonOverflowScrollingTouch; | 141 directReasons |= CompositingReasonOverflowScrollingTouch; |
142 | 142 |
143 // Composite |layer| if it is inside of an ancestor scrolling layer, but tha
t | 143 // Composite |layer| if it is inside of an ancestor scrolling layer, but tha
t |
144 // scrolling layer is not on the stacking context ancestor chain of |layer|. | 144 // scrolling layer is not on the stacking context ancestor chain of |layer|. |
145 // See the definition of the scrollParent property in Layer for more detail. | 145 // See the definition of the scrollParent property in Layer for more detail. |
146 if (const PaintLayer* scrollingAncestor = layer->ancestorScrollingLayer()) { | 146 if (const PaintLayer* scrollingAncestor = layer->ancestorScrollingLayer()) { |
147 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollParent
()) | 147 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollParent
()) |
148 directReasons |= CompositingReasonOverflowScrollingParent; | 148 directReasons |= CompositingReasonOverflowScrollingParent; |
149 } | 149 } |
150 | 150 |
151 if (requiresCompositingForPositionFixed(layer)) | 151 // TODO(flackr): Rename functions and variables to include sticky position (
i.e. ScrollDependentPosition rather than PositionFixed). |
152 directReasons |= CompositingReasonPositionFixed; | 152 if (requiresCompositingForScrollDependentPosition(layer)) |
| 153 directReasons |= CompositingReasonScrollDependentPosition; |
153 | 154 |
154 directReasons |= layoutObject->additionalCompositingReasons(); | 155 directReasons |= layoutObject->additionalCompositingReasons(); |
155 | 156 |
156 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); | 157 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); |
157 return directReasons; | 158 return directReasons; |
158 } | 159 } |
159 | 160 |
160 bool CompositingReasonFinder::requiresCompositingForAnimation(const ComputedStyl
e& style) const | 161 bool CompositingReasonFinder::requiresCompositingForAnimation(const ComputedStyl
e& style) const |
161 { | 162 { |
162 if (style.subtreeWillChangeContents()) | 163 if (style.subtreeWillChangeContents()) |
163 return style.isRunningAnimationOnCompositor(); | 164 return style.isRunningAnimationOnCompositor(); |
164 | 165 |
165 return style.shouldCompositeForCurrentAnimations(); | 166 return style.shouldCompositeForCurrentAnimations(); |
166 } | 167 } |
167 | 168 |
168 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const PaintLay
er* layer) const | 169 bool CompositingReasonFinder::requiresCompositingForScrollDependentPosition(cons
t PaintLayer* layer) const |
169 { | 170 { |
170 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) | 171 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) |
171 return false; | 172 return false; |
172 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. | 173 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. |
173 // They will stay fixed wrt the container rather than the enclosing frame. | 174 // They will stay fixed wrt the container rather than the enclosing frame. |
174 return layer->scrollsWithViewport() && m_layoutView.frameView()->isScrollabl
e(); | 175 if (layer->scrollsWithViewport()) |
| 176 return m_layoutView.frameView()->isScrollable(); |
| 177 return layer->layoutObject()->style()->position() == StickyPosition && layer
->ancestorOverflowLayer()->scrollsOverflow(); |
175 } | 178 } |
176 | 179 |
177 } // namespace blink | 180 } // namespace blink |
OLD | NEW |