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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool CompositingReasonFinder::requiresCompositingForAnimation( | 173 bool CompositingReasonFinder::requiresCompositingForAnimation( |
| 174 const ComputedStyle& style) const { | 174 const ComputedStyle& style) const { |
| 175 if (style.subtreeWillChangeContents()) | 175 if (style.subtreeWillChangeContents()) |
| 176 return style.isRunningAnimationOnCompositor(); | 176 return style.isRunningAnimationOnCompositor(); |
| 177 | 177 |
| 178 return style.shouldCompositeForCurrentAnimations(); | 178 return style.shouldCompositeForCurrentAnimations(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Check if current layer has layout object that contains properties that cause | |
| 182 // main thread scrolling. | |
| 183 void CompositingReasonFinder::updateMainThreadScrollingReasonDueToLayoutObject( | |
| 184 const PaintLayer* layer) const { | |
| 185 // TODO(yigu) Keeping the reasons in PaintLayerScrollableArea | |
| 186 // is not ideal. When a layout becomes to non-scrollable | |
|
bokan
2016/12/13 14:38:57
nit: "layout becomes to" -> "layer becomes"
bokan
2016/12/13 14:38:57
Also, perhaps counterintuitively, I believe all la
yigu
2016/12/13 20:54:10
Done.
yigu
2016/12/13 20:54:10
Done.
| |
| 187 // the reasons kept in that scrollable area cannot be updated | |
| 188 // in the frameView correctly. | |
| 189 // If current layer has opacity and has not been recorded, add the layer into | |
| 190 // frameView and vice versa. | |
| 191 if (!layer || !layer->getScrollableArea()) | |
| 192 return; | |
| 193 if (layer->compositesWithOpacity() != | |
| 194 layer->getScrollableArea()->hasMainThreadScrollingReason( | |
| 195 MainThreadScrollingReason::kHasOpacity)) { | |
| 196 layer->getScrollableArea()->flipMainThreadScrollingReason( | |
| 197 MainThreadScrollingReason::kHasOpacity); | |
| 198 layer->layoutObject() | |
| 199 ->frameView() | |
| 200 ->adjustMainThreadReasonsDueToLayoutObject( | |
| 201 MainThreadScrollingReason::kHasOpacity, | |
| 202 layer->compositesWithOpacity()); | |
| 203 } | |
| 204 } | |
| 205 | |
| 181 bool CompositingReasonFinder::requiresCompositingForScrollDependentPosition( | 206 bool CompositingReasonFinder::requiresCompositingForScrollDependentPosition( |
| 182 const PaintLayer* layer) const { | 207 const PaintLayer* layer) const { |
| 183 if (layer->layoutObject()->style()->position() != FixedPosition && | 208 if (layer->layoutObject()->style()->position() != FixedPosition && |
| 184 layer->layoutObject()->style()->position() != StickyPosition) | 209 layer->layoutObject()->style()->position() != StickyPosition) |
| 185 return false; | 210 return false; |
| 186 | 211 |
| 212 updateMainThreadScrollingReasonDueToLayoutObject(layer); | |
|
bokan
2016/12/13 14:38:57
This is only meant for Fixed/Sticky layers? The na
yigu
2016/12/13 20:54:10
No. It should be moved somewhere else.
| |
| 213 | |
| 187 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger) && | 214 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger) && |
| 188 (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() || | 215 (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() || |
| 189 !layer->backgroundIsKnownToBeOpaqueInRect( | 216 !layer->backgroundIsKnownToBeOpaqueInRect( |
| 190 LayoutRect(layer->boundingBoxForCompositing())) || | 217 LayoutRect(layer->boundingBoxForCompositing())) || |
| 191 layer->compositesWithTransform() || layer->compositesWithOpacity())) { | 218 layer->compositesWithTransform() || layer->compositesWithOpacity())) { |
| 192 return false; | 219 return false; |
| 193 } | 220 } |
| 194 // Don't promote fixed position elements that are descendants of a non-view | 221 // Don't promote fixed position elements that are descendants of a non-view |
| 195 // container, e.g. transformed elements. They will stay fixed wrt the | 222 // container, e.g. transformed elements. They will stay fixed wrt the |
| 196 // container rather than the enclosing frame. | 223 // container rather than the enclosing frame. |
| 197 if (layer->sticksToViewport()) | 224 if (layer->sticksToViewport()) |
| 198 return m_layoutView.frameView()->isScrollable(); | 225 return m_layoutView.frameView()->isScrollable(); |
| 199 return layer->layoutObject()->style()->position() == StickyPosition && | 226 return layer->layoutObject()->style()->position() == StickyPosition && |
| 200 layer->ancestorOverflowLayer()->scrollsOverflow(); | 227 layer->ancestorOverflowLayer()->scrollsOverflow(); |
| 201 } | 228 } |
| 202 | 229 |
| 203 } // namespace blink | 230 } // namespace blink |
| OLD | NEW |