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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 bool CompositingReasonFinder::RequiresCompositingForTransformAnimation( | 209 bool CompositingReasonFinder::RequiresCompositingForTransformAnimation( |
210 const ComputedStyle& style) { | 210 const ComputedStyle& style) { |
211 return style.SubtreeWillChangeContents() | 211 return style.SubtreeWillChangeContents() |
212 ? style.IsRunningTransformAnimationOnCompositor() | 212 ? style.IsRunningTransformAnimationOnCompositor() |
213 : style.HasCurrentTransformAnimation(); | 213 : style.HasCurrentTransformAnimation(); |
214 } | 214 } |
215 | 215 |
216 bool CompositingReasonFinder::RequiresCompositingForScrollDependentPosition( | 216 bool CompositingReasonFinder::RequiresCompositingForScrollDependentPosition( |
217 const PaintLayer* layer, | 217 const PaintLayer* layer, |
218 bool ignore_lcd_text) const { | 218 bool ignore_lcd_text) const { |
219 if (layer->GetLayoutObject().Style()->GetPosition() != EPosition::kFixed && | 219 if (!layer->GetLayoutObject().Style()->HasViewportConstrainedPosition() && |
220 layer->GetLayoutObject().Style()->GetPosition() != EPosition::kSticky) | 220 !layer->GetLayoutObject().Style()->HasStickyConstrainedPosition()) |
221 return false; | 221 return false; |
222 | 222 |
223 if (!(ignore_lcd_text || | 223 if (!(ignore_lcd_text || |
224 (compositing_triggers_ & kViewportConstrainedPositionedTrigger)) && | 224 (compositing_triggers_ & kViewportConstrainedPositionedTrigger)) && |
225 (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() || | 225 (!RuntimeEnabledFeatures::compositeOpaqueFixedPositionEnabled() || |
226 !layer->BackgroundIsKnownToBeOpaqueInRect( | 226 !layer->BackgroundIsKnownToBeOpaqueInRect( |
227 LayoutRect(layer->BoundingBoxForCompositing())) || | 227 LayoutRect(layer->BoundingBoxForCompositing())) || |
228 layer->CompositesWithTransform() || layer->CompositesWithOpacity())) { | 228 layer->CompositesWithTransform() || layer->CompositesWithOpacity())) { |
229 return false; | 229 return false; |
230 } | 230 } |
231 // Don't promote fixed position elements that are descendants of a non-view | 231 // Don't promote fixed position elements that are descendants of a non-view |
232 // container, e.g. transformed elements. They will stay fixed wrt the | 232 // container, e.g. transformed elements. They will stay fixed wrt the |
233 // container rather than the enclosing frame. | 233 // container rather than the enclosing frame. |
234 EPosition position = layer->GetLayoutObject().Style()->GetPosition(); | 234 EPosition position = layer->GetLayoutObject().Style()->GetPosition(); |
235 if (position == EPosition::kFixed) | 235 if (position == EPosition::kFixed) |
236 return layer->FixedToViewport() && | 236 return layer->FixedToViewport() && |
237 layout_view_.GetFrameView()->IsScrollable(); | 237 layout_view_.GetFrameView()->IsScrollable(); |
238 DCHECK_EQ(position, EPosition::kSticky); | 238 DCHECK_EQ(position, EPosition::kSticky); |
239 | 239 |
240 // Don't promote sticky position elements that cannot move with scrolls. | 240 // Don't promote sticky position elements that cannot move with scrolls. |
241 if (!layer->SticksToScroller()) | 241 if (!layer->SticksToScroller()) |
242 return false; | 242 return false; |
243 if (layer->AncestorOverflowLayer()->IsRootLayer()) | 243 if (layer->AncestorOverflowLayer()->IsRootLayer()) |
244 return layout_view_.GetFrameView()->IsScrollable(); | 244 return layout_view_.GetFrameView()->IsScrollable(); |
245 return layer->AncestorOverflowLayer()->ScrollsOverflow(); | 245 return layer->AncestorOverflowLayer()->ScrollsOverflow(); |
246 } | 246 } |
247 | 247 |
248 } // namespace blink | 248 } // namespace blink |
OLD | NEW |