| 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 "CSSPropertyNames.h" | 8 #include "CSSPropertyNames.h" |
| 9 #include "HTMLNames.h" | 9 #include "HTMLNames.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 return false; | 93 return false; |
| 94 | 94 |
| 95 FrameView* frameView = m_renderView.frameView(); | 95 FrameView* frameView = m_renderView.frameView(); |
| 96 return frameView->isScrollable(); | 96 return frameView->isScrollable(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 CompositingReasons CompositingReasonFinder::styleDeterminedReasons(RenderObject*
renderer) const | 99 CompositingReasons CompositingReasonFinder::styleDeterminedReasons(RenderObject*
renderer) const |
| 100 { | 100 { |
| 101 CompositingReasons directReasons = CompositingReasonNone; | 101 CompositingReasons directReasons = CompositingReasonNone; |
| 102 | 102 |
| 103 RenderStyle* style = renderer->style(); |
| 104 |
| 103 if (requiresCompositingForTransform(renderer)) | 105 if (requiresCompositingForTransform(renderer)) |
| 104 directReasons |= CompositingReason3DTransform; | 106 directReasons |= CompositingReason3DTransform; |
| 105 | 107 |
| 106 if (requiresCompositingForBackfaceVisibilityHidden(renderer)) | |
| 107 directReasons |= CompositingReasonBackfaceVisibilityHidden; | |
| 108 | |
| 109 if (requiresCompositingForAnimation(renderer)) | |
| 110 directReasons |= CompositingReasonActiveAnimation; | |
| 111 | |
| 112 if (requiresCompositingForFilters(renderer)) | 108 if (requiresCompositingForFilters(renderer)) |
| 113 directReasons |= CompositingReasonFilters; | 109 directReasons |= CompositingReasonFilters; |
| 114 | 110 |
| 115 if (requiresCompositingForWillChangeCompositingHint(renderer)) | 111 if (style->backfaceVisibility() == BackfaceVisibilityHidden) |
| 112 directReasons |= CompositingReasonBackfaceVisibilityHidden; |
| 113 |
| 114 if (style->shouldCompositeForCurrentAnimations()) |
| 115 directReasons |= CompositingReasonActiveAnimation; |
| 116 |
| 117 if (style->hasWillChangeCompositingHint()) |
| 116 directReasons |= CompositingReasonWillChangeCompositingHint; | 118 directReasons |= CompositingReasonWillChangeCompositingHint; |
| 117 | 119 |
| 118 ASSERT(!(directReasons & ~CompositingReasonComboAllStyleDeterminedReasons)); | 120 ASSERT(!(directReasons & ~CompositingReasonComboAllStyleDeterminedReasons)); |
| 119 return directReasons; | 121 return directReasons; |
| 120 } | 122 } |
| 121 | 123 |
| 122 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend
erer) const | 124 bool CompositingReasonFinder::requiresCompositingForTransform(RenderObject* rend
erer) const |
| 123 { | 125 { |
| 124 // Note that we ask the renderer if it has a transform, because the style ma
y have transforms, | 126 // Note that we ask the renderer if it has a transform, because the style ma
y have transforms, |
| 125 // but the renderer may be an inline that doesn't suppport them. | 127 // but the renderer may be an inline that doesn't suppport them. |
| 126 return renderer->hasTransform() && renderer->style()->transform().has3DOpera
tion(); | 128 return renderer->hasTransform() && renderer->style()->transform().has3DOpera
tion(); |
| 127 } | 129 } |
| 128 | 130 |
| 129 bool CompositingReasonFinder::requiresCompositingForBackfaceVisibilityHidden(Ren
derObject* renderer) const | |
| 130 { | |
| 131 return renderer->style()->backfaceVisibility() == BackfaceVisibilityHidden; | |
| 132 } | |
| 133 | |
| 134 bool CompositingReasonFinder::requiresCompositingForFilters(RenderObject* render
er) const | 131 bool CompositingReasonFinder::requiresCompositingForFilters(RenderObject* render
er) const |
| 135 { | 132 { |
| 136 if (!(m_compositingTriggers & FilterTrigger)) | 133 if (!(m_compositingTriggers & FilterTrigger)) |
| 137 return false; | 134 return false; |
| 138 | 135 |
| 139 return renderer->hasFilter(); | 136 return renderer->hasFilter(); |
| 140 } | 137 } |
| 141 | 138 |
| 142 bool CompositingReasonFinder::requiresCompositingForWillChangeCompositingHint(co
nst RenderObject* renderer) const | |
| 143 { | |
| 144 return renderer->style()->hasWillChangeCompositingHint(); | |
| 145 } | |
| 146 | |
| 147 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
t RenderLayer* layer, bool* needToRecomputeCompositingRequirements) const | 139 CompositingReasons CompositingReasonFinder::nonStyleDeterminedDirectReasons(cons
t RenderLayer* layer, bool* needToRecomputeCompositingRequirements) const |
| 148 { | 140 { |
| 149 CompositingReasons directReasons = CompositingReasonNone; | 141 CompositingReasons directReasons = CompositingReasonNone; |
| 150 RenderObject* renderer = layer->renderer(); | 142 RenderObject* renderer = layer->renderer(); |
| 151 | 143 |
| 152 if (hasOverflowScrollTrigger()) { | 144 if (hasOverflowScrollTrigger()) { |
| 153 if (requiresCompositingForOutOfFlowClipping(layer)) | 145 if (layer->isUnclippedDescendant()) |
| 154 directReasons |= CompositingReasonOutOfFlowClipping; | 146 directReasons |= CompositingReasonOutOfFlowClipping; |
| 155 | 147 |
| 156 if (requiresCompositingForOverflowScrollingParent(layer)) | 148 if (layer->scrollParent()) |
| 157 directReasons |= CompositingReasonOverflowScrollingParent; | 149 directReasons |= CompositingReasonOverflowScrollingParent; |
| 150 |
| 151 if (layer->needsCompositedScrolling()) |
| 152 directReasons |= CompositingReasonOverflowScrollingTouch; |
| 158 } | 153 } |
| 159 | 154 |
| 160 if (requiresCompositingForOverflowScrolling(layer)) | |
| 161 directReasons |= CompositingReasonOverflowScrollingTouch; | |
| 162 | |
| 163 if (requiresCompositingForPositionSticky(renderer, layer)) | 155 if (requiresCompositingForPositionSticky(renderer, layer)) |
| 164 directReasons |= CompositingReasonPositionSticky; | 156 directReasons |= CompositingReasonPositionSticky; |
| 165 | 157 |
| 166 if (requiresCompositingForPositionFixed(renderer, layer, 0, needToRecomputeC
ompositingRequirements)) | 158 if (requiresCompositingForPositionFixed(renderer, layer, 0, needToRecomputeC
ompositingRequirements)) |
| 167 directReasons |= CompositingReasonPositionFixed; | 159 directReasons |= CompositingReasonPositionFixed; |
| 168 | 160 |
| 169 directReasons |= renderer->additionalCompositingReasons(m_compositingTrigger
s); | 161 directReasons |= renderer->additionalCompositingReasons(m_compositingTrigger
s); |
| 170 | 162 |
| 171 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); | 163 ASSERT(!(directReasons & CompositingReasonComboAllStyleDeterminedReasons)); |
| 172 return directReasons; | 164 return directReasons; |
| 173 } | 165 } |
| 174 | 166 |
| 175 bool CompositingReasonFinder::requiresCompositingForAnimation(RenderObject* rend
erer) const | |
| 176 { | |
| 177 return renderer->style()->shouldCompositeForCurrentAnimations(); | |
| 178 } | |
| 179 | |
| 180 bool CompositingReasonFinder::requiresCompositingForOutOfFlowClipping(const Rend
erLayer* layer) const | |
| 181 { | |
| 182 return layer->isUnclippedDescendant(); | |
| 183 } | |
| 184 | |
| 185 bool CompositingReasonFinder::requiresCompositingForOverflowScrollingParent(cons
t RenderLayer* layer) const | |
| 186 { | |
| 187 if (!hasOverflowScrollTrigger()) | |
| 188 return false; | |
| 189 return layer->scrollParent(); | |
| 190 } | |
| 191 | |
| 192 bool CompositingReasonFinder::requiresCompositingForOverflowScrolling(const Rend
erLayer* layer) const | |
| 193 { | |
| 194 return layer->needsCompositedScrolling(); | |
| 195 } | |
| 196 | |
| 197 bool CompositingReasonFinder::requiresCompositingForPosition(RenderObject* rende
rer, const RenderLayer* layer, RenderLayer::ViewportConstrainedNotCompositedReas
on* viewportConstrainedNotCompositedReason, bool* needToRecomputeCompositingRequ
irements) const | 167 bool CompositingReasonFinder::requiresCompositingForPosition(RenderObject* rende
rer, const RenderLayer* layer, RenderLayer::ViewportConstrainedNotCompositedReas
on* viewportConstrainedNotCompositedReason, bool* needToRecomputeCompositingRequ
irements) const |
| 198 { | 168 { |
| 199 return requiresCompositingForPositionSticky(renderer, layer) || requiresComp
ositingForPositionFixed(renderer, layer, viewportConstrainedNotCompositedReason,
needToRecomputeCompositingRequirements); | 169 return requiresCompositingForPositionSticky(renderer, layer) || requiresComp
ositingForPositionFixed(renderer, layer, viewportConstrainedNotCompositedReason,
needToRecomputeCompositingRequirements); |
| 200 } | 170 } |
| 201 | 171 |
| 202 bool CompositingReasonFinder::requiresCompositingForPositionSticky(RenderObject*
renderer, const RenderLayer* layer) const | 172 bool CompositingReasonFinder::requiresCompositingForPositionSticky(RenderObject*
renderer, const RenderLayer* layer) const |
| 203 { | 173 { |
| 204 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) | 174 if (!(m_compositingTriggers & ViewportConstrainedPositionedTrigger)) |
| 205 return false; | 175 return false; |
| 206 if (renderer->style()->position() != StickyPosition) | 176 if (renderer->style()->position() != StickyPosition) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 if (viewportConstrainedNotCompositedReason) | 257 if (viewportConstrainedNotCompositedReason) |
| 288 *viewportConstrainedNotCompositedReason = RenderLayer::NotCompos
itedForBoundsOutOfView; | 258 *viewportConstrainedNotCompositedReason = RenderLayer::NotCompos
itedForBoundsOutOfView; |
| 289 return false; | 259 return false; |
| 290 } | 260 } |
| 291 } | 261 } |
| 292 | 262 |
| 293 return true; | 263 return true; |
| 294 } | 264 } |
| 295 | 265 |
| 296 } | 266 } |
| OLD | NEW |