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" |
| 11 #include "core/layout/LayoutView.h" | 11 #include "core/layout/LayoutView.h" |
| 12 #include "core/page/Page.h" | 12 #include "core/page/Page.h" |
| 13 #include "core/paint/PaintLayer.h" | 13 #include "core/paint/PaintLayer.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 namespace { | |
| 18 // TODO(smcgruer): Extract to common helper function. | |
| 19 StickyPositionScrollingConstraints* stickyConstraintsForLayoutObject( | |
| 20 const LayoutBoxModelObject* o) { | |
|
flackr
2017/02/22 22:40:15
Can we pass through the reference type instead of
smcgruer
2017/02/23 20:14:17
Used the original PaintLayer instead, and pulled t
| |
| 21 if (!o || !o->layer()->ancestorOverflowLayer()) | |
|
flackr
2017/02/22 22:40:15
o should never be null afaict. Since we're calling
smcgruer
2017/02/23 20:14:17
Done.
| |
| 22 return nullptr; | |
| 23 | |
| 24 PaintLayerScrollableArea* scrollableArea = | |
| 25 o->layer()->ancestorOverflowLayer()->getScrollableArea(); | |
| 26 auto it = scrollableArea->stickyConstraintsMap().find(o->layer()); | |
| 27 if (it == scrollableArea->stickyConstraintsMap().end()) | |
| 28 return nullptr; | |
|
flackr
2017/02/22 22:40:15
Can this happen? We only call this function for st
smcgruer
2017/02/23 20:14:17
Done.
| |
| 29 | |
| 30 return &it->value; | |
| 31 } | |
| 32 } // namespace | |
| 33 | |
| 17 CompositingReasonFinder::CompositingReasonFinder(LayoutView& layoutView) | 34 CompositingReasonFinder::CompositingReasonFinder(LayoutView& layoutView) |
| 18 : m_layoutView(layoutView), | 35 : m_layoutView(layoutView), |
| 19 m_compositingTriggers( | 36 m_compositingTriggers( |
| 20 static_cast<CompositingTriggerFlags>(AllCompositingTriggers)) { | 37 static_cast<CompositingTriggerFlags>(AllCompositingTriggers)) { |
| 21 updateTriggers(); | 38 updateTriggers(); |
| 22 } | 39 } |
| 23 | 40 |
| 24 void CompositingReasonFinder::updateTriggers() { | 41 void CompositingReasonFinder::updateTriggers() { |
| 25 m_compositingTriggers = 0; | 42 m_compositingTriggers = 0; |
| 26 | 43 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 !layer->backgroundIsKnownToBeOpaqueInRect( | 241 !layer->backgroundIsKnownToBeOpaqueInRect( |
| 225 LayoutRect(layer->boundingBoxForCompositing())) || | 242 LayoutRect(layer->boundingBoxForCompositing())) || |
| 226 layer->compositesWithTransform() || layer->compositesWithOpacity())) { | 243 layer->compositesWithTransform() || layer->compositesWithOpacity())) { |
| 227 return false; | 244 return false; |
| 228 } | 245 } |
| 229 // Don't promote fixed position elements that are descendants of a non-view | 246 // Don't promote fixed position elements that are descendants of a non-view |
| 230 // container, e.g. transformed elements. They will stay fixed wrt the | 247 // container, e.g. transformed elements. They will stay fixed wrt the |
| 231 // container rather than the enclosing frame. | 248 // container rather than the enclosing frame. |
| 232 if (layer->sticksToViewport()) | 249 if (layer->sticksToViewport()) |
| 233 return m_layoutView.frameView()->isScrollable(); | 250 return m_layoutView.frameView()->isScrollable(); |
| 234 return layer->layoutObject().style()->position() == EPosition::kSticky && | 251 |
| 235 layer->ancestorOverflowLayer()->scrollsOverflow(); | 252 if (layer->layoutObject().style()->position() != EPosition::kSticky) |
| 253 return false; | |
| 254 | |
| 255 // Don't promote nested sticky elements; the compositor can't handle them. | |
| 256 // TODO(smcgruer): Add cc nested sticky support (http://crbug.com/672710) | |
| 257 StickyPositionScrollingConstraints* constraints = | |
| 258 stickyConstraintsForLayoutObject(&layer->layoutObject()); | |
| 259 return layer->ancestorOverflowLayer()->scrollsOverflow() && | |
| 260 !constraints->hasAncestorStickyElement(); | |
|
flackr
2017/02/22 22:40:15
stickyConstraintsForLayoutObject can return null b
smcgruer
2017/02/23 20:14:17
Done.
| |
| 236 } | 261 } |
| 237 | 262 |
| 238 } // namespace blink | 263 } // namespace blink |
| OLD | NEW |