Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositingRequirementsUpdater.cpp

Issue 2845613002: Fix the bug that sticky element may not be correctly invalidated due to non-promotion (Closed)
Patch Set: bug fix Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2014 Google Inc. All rights reserved. 3 * Copyright (C) 2014 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 Vector<OverlapMapContainers> overlap_stack_; 140 Vector<OverlapMapContainers> overlap_stack_;
141 }; 141 };
142 142
143 class CompositingRequirementsUpdater::RecursionData { 143 class CompositingRequirementsUpdater::RecursionData {
144 public: 144 public:
145 explicit RecursionData(PaintLayer* compositing_ancestor) 145 explicit RecursionData(PaintLayer* compositing_ancestor)
146 : compositing_ancestor_(compositing_ancestor), 146 : compositing_ancestor_(compositing_ancestor),
147 subtree_is_compositing_(false), 147 subtree_is_compositing_(false),
148 has_unisolated_composited_blending_descendant_(false), 148 has_unisolated_composited_blending_descendant_(false),
149 testing_overlap_(true), 149 testing_overlap_(true),
150 has_composited_non_root_ancestor_(false),
150 has_composited_scrolling_ancestor_(false) {} 151 has_composited_scrolling_ancestor_(false) {}
151 152
152 PaintLayer* compositing_ancestor_; 153 PaintLayer* compositing_ancestor_;
153 bool subtree_is_compositing_; 154 bool subtree_is_compositing_;
154 bool has_unisolated_composited_blending_descendant_; 155 bool has_unisolated_composited_blending_descendant_;
155 bool testing_overlap_; 156 bool testing_overlap_;
157 // Ancestors may be composited but not have composited scrolling layer.
158 bool has_composited_non_root_ancestor_;
156 bool has_composited_scrolling_ancestor_; 159 bool has_composited_scrolling_ancestor_;
157 }; 160 };
158 161
159 static bool RequiresCompositingOrSquashing(CompositingReasons reasons) { 162 static bool RequiresCompositingOrSquashing(CompositingReasons reasons) {
160 #if DCHECK_IS_ON() 163 #if DCHECK_IS_ON()
161 bool fast_answer = reasons != kCompositingReasonNone; 164 bool fast_answer = reasons != kCompositingReasonNone;
162 bool slow_answer = RequiresCompositing(reasons) || RequiresSquashing(reasons); 165 bool slow_answer = RequiresCompositing(reasons) || RequiresSquashing(reasons);
163 DCHECK_EQ(slow_answer, fast_answer); 166 DCHECK_EQ(slow_answer, fast_answer);
164 #endif 167 #endif
165 return reasons != kCompositingReasonNone; 168 return reasons != kCompositingReasonNone;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 } 369 }
367 370
368 reasons_to_composite |= overlap_compositing_reason; 371 reasons_to_composite |= overlap_compositing_reason;
369 372
370 // The children of this layer don't need to composite, unless there is 373 // The children of this layer don't need to composite, unless there is
371 // a compositing layer among them, so start by inheriting the compositing 374 // a compositing layer among them, so start by inheriting the compositing
372 // ancestor with m_subtreeIsCompositing set to false. 375 // ancestor with m_subtreeIsCompositing set to false.
373 RecursionData child_recursion_data = current_recursion_data; 376 RecursionData child_recursion_data = current_recursion_data;
374 child_recursion_data.subtree_is_compositing_ = false; 377 child_recursion_data.subtree_is_compositing_ = false;
375 378
379 if (layer->SticksToScroller() &&
380 layer->AncestorOverflowLayer()->ScrollsOverflow() &&
381 current_recursion_data.has_composited_non_root_ancestor_) {
382 reasons_to_composite |= kCompositingReasonScrollDependentPosition;
chrishtr 2017/05/10 17:48:44 You don't need current_recursion_data.has_composit
yigu 2017/05/10 18:04:13 Done.
383 }
384
376 bool will_be_composited_or_squashed = 385 bool will_be_composited_or_squashed =
377 can_be_composited && RequiresCompositingOrSquashing(reasons_to_composite); 386 can_be_composited && RequiresCompositingOrSquashing(reasons_to_composite);
378 if (will_be_composited_or_squashed) { 387 if (will_be_composited_or_squashed) {
379 // This layer now acts as the ancestor for kids. 388 // This layer now acts as the ancestor for kids.
380 child_recursion_data.compositing_ancestor_ = layer; 389 child_recursion_data.compositing_ancestor_ = layer;
381 390
382 // Here we know that all children and the layer's own contents can blindly 391 // Here we know that all children and the layer's own contents can blindly
383 // paint into this layer's backing, until a descendant is composited. So, we 392 // paint into this layer's backing, until a descendant is composited. So, we
384 // don't need to check for overlap with anything behind this layer. 393 // don't need to check for overlap with anything behind this layer.
385 overlap_map.BeginNewOverlapTestingContext(); 394 overlap_map.BeginNewOverlapTestingContext();
386 // This layer is going to be composited, so children can safely ignore the 395 // This layer is going to be composited, so children can safely ignore the
387 // fact that there's an animation running behind this layer, meaning they 396 // fact that there's an animation running behind this layer, meaning they
388 // can rely on the overlap map testing again. 397 // can rely on the overlap map testing again.
389 child_recursion_data.testing_overlap_ = true; 398 child_recursion_data.testing_overlap_ = true;
399
400 // Tell the descendants they have composited non-root ancestor.
401 if (!layer->IsRootLayer())
402 child_recursion_data.has_composited_non_root_ancestor_ = true;
390 } 403 }
391 404
392 #if DCHECK_IS_ON() 405 #if DCHECK_IS_ON()
393 LayerListMutationDetector mutation_checker(layer->StackingNode()); 406 LayerListMutationDetector mutation_checker(layer->StackingNode());
394 #endif 407 #endif
395 408
396 bool any_descendant_has3d_transform = false; 409 bool any_descendant_has3d_transform = false;
397 bool will_have_foreground_layer = false; 410 bool will_have_foreground_layer = false;
398 411
399 if (layer->StackingNode()->IsStackingContext()) { 412 if (layer->StackingNode()->IsStackingContext()) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 descendant_has3d_transform |= 570 descendant_has3d_transform |=
558 any_descendant_has3d_transform || layer->Has3DTransform(); 571 any_descendant_has3d_transform || layer->Has3DTransform();
559 } 572 }
560 573
561 // At this point we have finished collecting all reasons to composite this 574 // At this point we have finished collecting all reasons to composite this
562 // layer. 575 // layer.
563 layer->SetCompositingReasons(reasons_to_composite); 576 layer->SetCompositingReasons(reasons_to_composite);
564 } 577 }
565 578
566 } // namespace blink 579 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698