| 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 15 matching lines...) Expand all Loading... |
| 26 m_compositingTriggers = 0; | 26 m_compositingTriggers = 0; |
| 27 | 27 |
| 28 Settings& settings = m_layoutView.document().page()->settings(); | 28 Settings& settings = m_layoutView.document().page()->settings(); |
| 29 if (settings.preferCompositingToLCDTextEnabled()) { | 29 if (settings.preferCompositingToLCDTextEnabled()) { |
| 30 m_compositingTriggers |= ScrollableInnerFrameTrigger; | 30 m_compositingTriggers |= ScrollableInnerFrameTrigger; |
| 31 m_compositingTriggers |= OverflowScrollTrigger; | 31 m_compositingTriggers |= OverflowScrollTrigger; |
| 32 m_compositingTriggers |= ViewportConstrainedPositionedTrigger; | 32 m_compositingTriggers |= ViewportConstrainedPositionedTrigger; |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 | 35 |
| 36 bool CompositingReasonFinder::hasOverflowScrollTrigger() const | |
| 37 { | |
| 38 return m_compositingTriggers & OverflowScrollTrigger; | |
| 39 } | |
| 40 | |
| 41 bool CompositingReasonFinder::isMainFrame() const | 36 bool CompositingReasonFinder::isMainFrame() const |
| 42 { | 37 { |
| 43 return m_layoutView.document().isInMainFrame(); | 38 return m_layoutView.document().isInMainFrame(); |
| 44 } | 39 } |
| 45 | 40 |
| 46 CompositingReasons CompositingReasonFinder::directReasons(const PaintLayer* laye
r) const | 41 CompositingReasons CompositingReasonFinder::directReasons(const PaintLayer* laye
r) const |
| 47 { | 42 { |
| 48 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 43 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| 49 return CompositingReasonNone; | 44 return CompositingReasonNone; |
| 50 | 45 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // Note that we ask the layoutObject if it has a transform, because the styl
e may have transforms, | 130 // Note that we ask the layoutObject if it has a transform, because the styl
e may have transforms, |
| 136 // but the layoutObject may be an inline that doesn't support them. | 131 // but the layoutObject may be an inline that doesn't support them. |
| 137 return layoutObject->hasTransformRelatedProperty() && layoutObject->style()-
>has3DTransform(); | 132 return layoutObject->hasTransformRelatedProperty() && layoutObject->style()-
>has3DTransform(); |
| 138 } | 133 } |
| 139 | 134 |
| 140 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
t PaintLayer* layer) const | 135 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
t PaintLayer* layer) const |
| 141 { | 136 { |
| 142 CompositingReasons directReasons = CompositingReasonNone; | 137 CompositingReasons directReasons = CompositingReasonNone; |
| 143 LayoutObject* layoutObject = layer->layoutObject(); | 138 LayoutObject* layoutObject = layer->layoutObject(); |
| 144 | 139 |
| 145 if (hasOverflowScrollTrigger()) { | 140 if (layer->needsCompositedScrolling()) |
| 146 if (layer->clipParent()) | 141 directReasons |= CompositingReasonOverflowScrollingTouch; |
| 147 directReasons |= CompositingReasonOutOfFlowClipping; | |
| 148 | |
| 149 if (layer->needsCompositedScrolling()) | |
| 150 directReasons |= CompositingReasonOverflowScrollingTouch; | |
| 151 } | |
| 152 | 142 |
| 153 // 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 |
| 154 // scrolling layer is not not on the stacking context ancestor chain of |lay
er|. | 144 // scrolling layer is not on the stacking context ancestor chain of |layer|. |
| 155 // 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. |
| 156 if (const PaintLayer* scrollingAncestor = layer->ancestorScrollingLayer()) { | 146 if (const PaintLayer* scrollingAncestor = layer->ancestorScrollingLayer()) { |
| 157 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollParent
()) | 147 if (scrollingAncestor->needsCompositedScrolling() && layer->scrollParent
()) |
| 158 directReasons |= CompositingReasonOverflowScrollingParent; | 148 directReasons |= CompositingReasonOverflowScrollingParent; |
| 159 } | 149 } |
| 160 | 150 |
| 161 if (requiresCompositingForPositionFixed(layer)) | 151 if (requiresCompositingForPositionFixed(layer)) |
| 162 directReasons |= CompositingReasonPositionFixed; | 152 directReasons |= CompositingReasonPositionFixed; |
| 163 | 153 |
| 164 directReasons |= layoutObject->additionalCompositingReasons(); | 154 directReasons |= layoutObject->additionalCompositingReasons(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 178 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const PaintLay
er* layer) const | 168 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const PaintLay
er* layer) const |
| 179 { | 169 { |
| 180 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) | 170 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) |
| 181 return false; | 171 return false; |
| 182 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. | 172 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. |
| 183 // They will stay fixed wrt the container rather than the enclosing frame. | 173 // They will stay fixed wrt the container rather than the enclosing frame. |
| 184 return layer->scrollsWithViewport() && m_layoutView.frameView()->isScrollabl
e(); | 174 return layer->scrollsWithViewport() && m_layoutView.frameView()->isScrollabl
e(); |
| 185 } | 175 } |
| 186 | 176 |
| 187 } // namespace blink | 177 } // namespace blink |
| OLD | NEW |