| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/layout/compositing/CompositingReasonFinder.h" | 6 #include "core/layout/compositing/CompositingReasonFinder.h" |
| 7 | 7 |
| 8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return m_layoutView.frameView()->isScrollable(); | 74 return m_layoutView.frameView()->isScrollable(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 CompositingReasons CompositingReasonFinder::potentialCompositingReasonsFromStyle
(LayoutObject* renderer) const | 77 CompositingReasons CompositingReasonFinder::potentialCompositingReasonsFromStyle
(LayoutObject* renderer) const |
| 78 { | 78 { |
| 79 if (RuntimeEnabledFeatures::slimmingPaintCompositorLayerizationEnabled()) | 79 if (RuntimeEnabledFeatures::slimmingPaintCompositorLayerizationEnabled()) |
| 80 return CompositingReasonNone; | 80 return CompositingReasonNone; |
| 81 | 81 |
| 82 CompositingReasons reasons = CompositingReasonNone; | 82 CompositingReasons reasons = CompositingReasonNone; |
| 83 | 83 |
| 84 const LayoutStyle& style = renderer->styleRef(); | 84 const ComputedStyle& style = renderer->styleRef(); |
| 85 | 85 |
| 86 if (requiresCompositingForTransform(renderer)) | 86 if (requiresCompositingForTransform(renderer)) |
| 87 reasons |= CompositingReason3DTransform; | 87 reasons |= CompositingReason3DTransform; |
| 88 | 88 |
| 89 if (style.backfaceVisibility() == BackfaceVisibilityHidden) | 89 if (style.backfaceVisibility() == BackfaceVisibilityHidden) |
| 90 reasons |= CompositingReasonBackfaceVisibilityHidden; | 90 reasons |= CompositingReasonBackfaceVisibilityHidden; |
| 91 | 91 |
| 92 if (requiresCompositingForAnimation(style)) | 92 if (requiresCompositingForAnimation(style)) |
| 93 reasons |= CompositingReasonActiveAnimation; | 93 reasons |= CompositingReasonActiveAnimation; |
| 94 | 94 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 if (requiresCompositingForPositionFixed(layer)) | 167 if (requiresCompositingForPositionFixed(layer)) |
| 168 directReasons |= CompositingReasonPositionFixed; | 168 directReasons |= CompositingReasonPositionFixed; |
| 169 | 169 |
| 170 directReasons |= renderer->additionalCompositingReasons(); | 170 directReasons |= renderer->additionalCompositingReasons(); |
| 171 | 171 |
| 172 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); | 172 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); |
| 173 return directReasons; | 173 return directReasons; |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool CompositingReasonFinder::requiresCompositingForAnimation(const LayoutStyle&
style) const | 176 bool CompositingReasonFinder::requiresCompositingForAnimation(const ComputedStyl
e& style) const |
| 177 { | 177 { |
| 178 if (style.subtreeWillChangeContents()) | 178 if (style.subtreeWillChangeContents()) |
| 179 return style.isRunningAnimationOnCompositor(); | 179 return style.isRunningAnimationOnCompositor(); |
| 180 | 180 |
| 181 return style.shouldCompositeForCurrentAnimations(); | 181 return style.shouldCompositeForCurrentAnimations(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const Deprecat
edPaintLayer* layer) const | 184 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const Deprecat
edPaintLayer* layer) const |
| 185 { | 185 { |
| 186 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) | 186 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) |
| 187 return false; | 187 return false; |
| 188 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. | 188 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. |
| 189 // They will stay fixed wrt the container rather than the enclosing frame. | 189 // They will stay fixed wrt the container rather than the enclosing frame. |
| 190 return layer->scrollsWithViewport() && m_layoutView.frameView()->isScrollabl
e(); | 190 return layer->scrollsWithViewport() && m_layoutView.frameView()->isScrollabl
e(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool CompositingReasonFinder::requiresCompositingForScrollBlocksOn(const LayoutO
bject* renderer) const | 193 bool CompositingReasonFinder::requiresCompositingForScrollBlocksOn(const LayoutO
bject* renderer) const |
| 194 { | 194 { |
| 195 // Note that the other requires* functions run at LayoutObject::styleDidChan
ge time and so can rely | 195 // Note that the other requires* functions run at LayoutObject::styleDidChan
ge time and so can rely |
| 196 // only on the style of their object. This function runs at CompositingRequ
irementsUpdater::update | 196 // only on the style of their object. This function runs at CompositingRequ
irementsUpdater::update |
| 197 // time, and so can consider the style of other objects. | 197 // time, and so can consider the style of other objects. |
| 198 const LayoutStyle& style = renderer->styleRef(); | 198 const ComputedStyle& style = renderer->styleRef(); |
| 199 | 199 |
| 200 // We should only get here by CompositingReasonScrollBlocksOn being a potent
ial compositing reason. | 200 // We should only get here by CompositingReasonScrollBlocksOn being a potent
ial compositing reason. |
| 201 ASSERT(style.hasScrollBlocksOn() && !renderer->isDocumentElement()); | 201 ASSERT(style.hasScrollBlocksOn() && !renderer->isDocumentElement()); |
| 202 | 202 |
| 203 // scroll-blocks-on style is propagated from the document element to the doc
ument. | 203 // scroll-blocks-on style is propagated from the document element to the doc
ument. |
| 204 ASSERT(!renderer->isLayoutView() | 204 ASSERT(!renderer->isLayoutView() |
| 205 || !renderer->document().documentElement() | 205 || !renderer->document().documentElement() |
| 206 || !renderer->document().documentElement()->layoutObject() | 206 || !renderer->document().documentElement()->layoutObject() |
| 207 || renderer->document().documentElement()->layoutObject()->style()->scro
llBlocksOn() == style.scrollBlocksOn()); | 207 || renderer->document().documentElement()->layoutObject()->style()->scro
llBlocksOn() == style.scrollBlocksOn()); |
| 208 | 208 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 227 // Either way, we don't need to require compositing for scroll block
s on. This avoids | 227 // Either way, we don't need to require compositing for scroll block
s on. This avoids |
| 228 // enabling compositing by default, and avoids cluttering the root l
ayers compositing reasons. | 228 // enabling compositing by default, and avoids cluttering the root l
ayers compositing reasons. |
| 229 return false; | 229 return false; |
| 230 } | 230 } |
| 231 } | 231 } |
| 232 | 232 |
| 233 return true; | 233 return true; |
| 234 } | 234 } |
| 235 | 235 |
| 236 } | 236 } |
| OLD | NEW |