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

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

Issue 2754983002: Composite sticky-positioned elements when they have composited descendants (Closed)
Patch Set: Address reviewer comments Created 3 years, 8 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 static bool RequiresCompositingOrSquashing(CompositingReasons reasons) { 159 static bool RequiresCompositingOrSquashing(CompositingReasons reasons) {
160 #if DCHECK_IS_ON() 160 #if DCHECK_IS_ON()
161 bool fast_answer = reasons != kCompositingReasonNone; 161 bool fast_answer = reasons != kCompositingReasonNone;
162 bool slow_answer = RequiresCompositing(reasons) || RequiresSquashing(reasons); 162 bool slow_answer = RequiresCompositing(reasons) || RequiresSquashing(reasons);
163 DCHECK_EQ(slow_answer, fast_answer); 163 DCHECK_EQ(slow_answer, fast_answer);
164 #endif 164 #endif
165 return reasons != kCompositingReasonNone; 165 return reasons != kCompositingReasonNone;
166 } 166 }
167 167
168 static CompositingReasons SubtreeReasonsForCompositing( 168 static CompositingReasons SubtreeReasonsForCompositing(
169 const CompositingReasonFinder& compositing_reason_finder,
169 PaintLayer* layer, 170 PaintLayer* layer,
170 bool has_composited_descendants, 171 bool has_composited_descendants,
171 bool has3d_transformed_descendants) { 172 bool has3d_transformed_descendants) {
172 CompositingReasons subtree_reasons = kCompositingReasonNone; 173 CompositingReasons subtree_reasons = kCompositingReasonNone;
173 174
174 // When a layer has composited descendants, some effects, like 2d transforms, 175 // When a layer has composited descendants, some effects, like 2d transforms,
175 // filters, masks etc must be implemented via compositing so that they also 176 // filters, masks etc must be implemented via compositing so that they also
176 // apply to those composited descendants. 177 // apply to those composited descendants.
177 if (has_composited_descendants) { 178 if (has_composited_descendants) {
178 subtree_reasons |= layer->PotentialCompositingReasonsFromStyle() & 179 subtree_reasons |= layer->PotentialCompositingReasonsFromStyle() &
179 kCompositingReasonComboCompositedDescendants; 180 kCompositingReasonComboCompositedDescendants;
180 181
181 if (layer->ShouldIsolateCompositedDescendants()) { 182 if (layer->ShouldIsolateCompositedDescendants()) {
182 DCHECK(layer->StackingNode()->IsStackingContext()); 183 DCHECK(layer->StackingNode()->IsStackingContext());
183 subtree_reasons |= kCompositingReasonIsolateCompositedDescendants; 184 subtree_reasons |= kCompositingReasonIsolateCompositedDescendants;
184 } 185 }
185 186
186 // FIXME: This should move into 187 // FIXME: This should move into
187 // CompositingReasonFinder::potentialCompositingReasonsFromStyle, but theres 188 // CompositingReasonFinder::potentialCompositingReasonsFromStyle, but theres
188 // a poor interaction with LayoutTextControlSingleLine, which sets this 189 // a poor interaction with LayoutTextControlSingleLine, which sets this
189 // hasOverflowClip directly. 190 // hasOverflowClip directly.
190 if (layer->GetLayoutObject().HasClipRelatedProperty()) 191 if (layer->GetLayoutObject().HasClipRelatedProperty())
191 subtree_reasons |= kCompositingReasonClipsCompositingDescendants; 192 subtree_reasons |= kCompositingReasonClipsCompositingDescendants;
192 193
193 if (layer->GetLayoutObject().Style()->GetPosition() == EPosition::kFixed) 194 if (compositing_reason_finder.RequiresCompositingForScrollDependentPosition(
195 layer, true)) {
flackr 2017/04/26 15:42:36 nit: the style, depending on where blink is at now
smcgruer 2017/04/26 18:05:46 Done.
194 subtree_reasons |= 196 subtree_reasons |=
195 kCompositingReasonPositionFixedWithCompositedDescendants; 197 kCompositingReasonPositionFixedOrStickyWithCompositedDescendants;
198 }
196 } 199 }
197 200
198 // A layer with preserve-3d or perspective only needs to be composited if 201 // A layer with preserve-3d or perspective only needs to be composited if
199 // there are descendant layers that will be affected by the preserve-3d or 202 // there are descendant layers that will be affected by the preserve-3d or
200 // perspective. 203 // perspective.
201 if (has3d_transformed_descendants) { 204 if (has3d_transformed_descendants) {
202 subtree_reasons |= layer->PotentialCompositingReasonsFromStyle() & 205 subtree_reasons |= layer->PotentialCompositingReasonsFromStyle() &
203 kCompositingReasonCombo3DDescendants; 206 kCompositingReasonCombo3DDescendants;
204 } 207 }
205 208
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 // into their compositing ancestor's backing, and so are still considered 493 // into their compositing ancestor's backing, and so are still considered
491 // for overlap. 494 // for overlap.
492 if (child_recursion_data.compositing_ancestor_ && 495 if (child_recursion_data.compositing_ancestor_ &&
493 !child_recursion_data.compositing_ancestor_->IsRootLayer()) 496 !child_recursion_data.compositing_ancestor_->IsRootLayer())
494 overlap_map.Add(layer, abs_bounds, !has_composited_scrolling_ancestor); 497 overlap_map.Add(layer, abs_bounds, !has_composited_scrolling_ancestor);
495 498
496 // Now check for reasons to become composited that depend on the state of 499 // Now check for reasons to become composited that depend on the state of
497 // descendant layers. 500 // descendant layers.
498 CompositingReasons subtree_compositing_reasons = 501 CompositingReasons subtree_compositing_reasons =
499 SubtreeReasonsForCompositing( 502 SubtreeReasonsForCompositing(
500 layer, child_recursion_data.subtree_is_compositing_, 503 compositing_reason_finder_, layer,
504 child_recursion_data.subtree_is_compositing_,
501 any_descendant_has3d_transform); 505 any_descendant_has3d_transform);
502 reasons_to_composite |= subtree_compositing_reasons; 506 reasons_to_composite |= subtree_compositing_reasons;
503 if (!will_be_composited_or_squashed && can_be_composited && 507 if (!will_be_composited_or_squashed && can_be_composited &&
504 RequiresCompositingOrSquashing(subtree_compositing_reasons)) { 508 RequiresCompositingOrSquashing(subtree_compositing_reasons)) {
505 child_recursion_data.compositing_ancestor_ = layer; 509 child_recursion_data.compositing_ancestor_ = layer;
506 // FIXME: this context push is effectively a no-op but needs to exist for 510 // FIXME: this context push is effectively a no-op but needs to exist for
507 // now, because the code is designed to push overlap information to the 511 // now, because the code is designed to push overlap information to the
508 // second-from-top context of the stack. 512 // second-from-top context of the stack.
509 overlap_map.BeginNewOverlapTestingContext(); 513 overlap_map.BeginNewOverlapTestingContext();
510 overlap_map.Add(layer, absolute_descendant_bounding_box, 514 overlap_map.Add(layer, absolute_descendant_bounding_box,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 descendant_has3d_transform |= 552 descendant_has3d_transform |=
549 any_descendant_has3d_transform || layer->Has3DTransform(); 553 any_descendant_has3d_transform || layer->Has3DTransform();
550 } 554 }
551 555
552 // At this point we have finished collecting all reasons to composite this 556 // At this point we have finished collecting all reasons to composite this
553 // layer. 557 // layer.
554 layer->SetCompositingReasons(reasons_to_composite); 558 layer->SetCompositingReasons(reasons_to_composite);
555 } 559 }
556 560
557 } // namespace blink 561 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698