| 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/rendering/compositing/CompositingReasonFinder.h" | 6 #include "core/rendering/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_renderView.frameView()->isScrollable(); | 74 return m_renderView.frameView()->isScrollable(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 CompositingReasons CompositingReasonFinder::potentialCompositingReasonsFromStyle
(RenderObject* renderer) const | 77 CompositingReasons CompositingReasonFinder::potentialCompositingReasonsFromStyle
(RenderObject* 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 RenderStyle* style = renderer->style(); | 84 const RenderStyle* style = renderer->style(); |
| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 if (requiresCompositingForPositionFixed(layer)) | 164 if (requiresCompositingForPositionFixed(layer)) |
| 165 directReasons |= CompositingReasonPositionFixed; | 165 directReasons |= CompositingReasonPositionFixed; |
| 166 | 166 |
| 167 directReasons |= renderer->additionalCompositingReasons(); | 167 directReasons |= renderer->additionalCompositingReasons(); |
| 168 | 168 |
| 169 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); | 169 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); |
| 170 return directReasons; | 170 return directReasons; |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool CompositingReasonFinder::requiresCompositingForAnimation(RenderStyle* style
) const | 173 bool CompositingReasonFinder::requiresCompositingForAnimation(const RenderStyle*
style) const |
| 174 { | 174 { |
| 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 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const RenderLa
yer* layer) const | 181 bool CompositingReasonFinder::requiresCompositingForPositionFixed(const RenderLa
yer* layer) const |
| 182 { | 182 { |
| 183 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) | 183 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) |
| 184 return false; | 184 return false; |
| 185 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. | 185 // Don't promote fixed position elements that are descendants of a non-view
container, e.g. transformed elements. |
| 186 // They will stay fixed wrt the container rather than the enclosing frame. | 186 // They will stay fixed wrt the container rather than the enclosing frame. |
| 187 return layer->scrollsWithViewport() && m_renderView.frameView()->isScrollabl
e(); | 187 return layer->scrollsWithViewport() && m_renderView.frameView()->isScrollabl
e(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool CompositingReasonFinder::requiresCompositingForScrollBlocksOn(const RenderO
bject* renderer) const | 190 bool CompositingReasonFinder::requiresCompositingForScrollBlocksOn(const RenderO
bject* renderer) const |
| 191 { | 191 { |
| 192 // Note that the other requires* functions run at RenderObject::styleDidChan
ge time and so can rely | 192 // Note that the other requires* functions run at RenderObject::styleDidChan
ge time and so can rely |
| 193 // only on the style of their object. This function runs at CompositingRequ
irementsUpdater::update | 193 // only on the style of their object. This function runs at CompositingRequ
irementsUpdater::update |
| 194 // time, and so can consider the style of other objects. | 194 // time, and so can consider the style of other objects. |
| 195 RenderStyle* style = renderer->style(); | 195 const RenderStyle* style = renderer->style(); |
| 196 | 196 |
| 197 // We should only get here by CompositingReasonScrollBlocksOn being a potent
ial compositing reason. | 197 // We should only get here by CompositingReasonScrollBlocksOn being a potent
ial compositing reason. |
| 198 ASSERT(style->hasScrollBlocksOn() && !renderer->isDocumentElement()); | 198 ASSERT(style->hasScrollBlocksOn() && !renderer->isDocumentElement()); |
| 199 | 199 |
| 200 // scroll-blocks-on style is propagated from the document element to the doc
ument. | 200 // scroll-blocks-on style is propagated from the document element to the doc
ument. |
| 201 ASSERT(!renderer->isRenderView() | 201 ASSERT(!renderer->isRenderView() |
| 202 || !renderer->document().documentElement() | 202 || !renderer->document().documentElement() |
| 203 || !renderer->document().documentElement()->renderer() | 203 || !renderer->document().documentElement()->renderer() |
| 204 || renderer->document().documentElement()->renderer()->style()->scrollBl
ocksOn() == style->scrollBlocksOn()); | 204 || renderer->document().documentElement()->renderer()->style()->scrollBl
ocksOn() == style->scrollBlocksOn()); |
| 205 | 205 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 224 // Either way, we don't need to require compositing for scroll block
s on. This avoids | 224 // Either way, we don't need to require compositing for scroll block
s on. This avoids |
| 225 // enabling compositing by default, and avoids cluttering the root l
ayers compositing reasons. | 225 // enabling compositing by default, and avoids cluttering the root l
ayers compositing reasons. |
| 226 return false; | 226 return false; |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 | 229 |
| 230 return true; | 230 return true; |
| 231 } | 231 } |
| 232 | 232 |
| 233 } | 233 } |
| OLD | NEW |