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

Side by Side Diff: cc/trees/draw_property_utils.cc

Issue 2733633002: Handle nested position:sticky elements correctly (compositor) (Closed)
Patch Set: Fix unittest Created 3 years, 9 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 // 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 "cc/trees/draw_property_utils.h" 5 #include "cc/trees/draw_property_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 elastic_overscroll); 1493 elastic_overscroll);
1494 } 1494 }
1495 1495
1496 void UpdateElasticOverscroll(PropertyTrees* property_trees, 1496 void UpdateElasticOverscroll(PropertyTrees* property_trees,
1497 const Layer* overscroll_elasticity_layer, 1497 const Layer* overscroll_elasticity_layer,
1498 const gfx::Vector2dF& elastic_overscroll) { 1498 const gfx::Vector2dF& elastic_overscroll) {
1499 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, 1499 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer,
1500 elastic_overscroll); 1500 elastic_overscroll);
1501 } 1501 }
1502 1502
1503 gfx::Vector2dF CalculateTotalStickyOffsetToScroller(
1504 Layer* layer,
1505 int scroll_ancestor_layer_id) {
1506 // Find nearest ancestor which is sticky, up to the scroller.
flackr 2017/03/09 20:22:08 Isn't this ancestor part of the constraints passed
smcgruer 2017/03/10 16:37:10 |layer| might not be sticky.
smcgruer 2017/03/10 16:38:38 Oh I think I just realized what you meant. We only
smcgruer 2017/03/14 22:04:06 Done.
1507 while (layer && !layer->sticky_position_constraint().is_sticky) {
1508 layer = layer->parent();
flackr 2017/03/09 20:22:08 Can you verify whether this chain is correct in th
smcgruer 2017/03/14 22:04:05 No longer relevant, we don't do this walk.
1509 if (!layer || layer->id() == scroll_ancestor_layer_id)
1510 return gfx::Vector2dF();
1511 }
1512
1513 // Walk all sticky layers from the current layer to the ancestor scroller
1514 // layer. We achieve this by walking the |nearest_layer_shifting_sticky_box|
1515 // when available (which is the nearest sticky element between us and our
1516 // containing block), and |nearest_layer_shifting_containing_block| otherwise
1517 // (which is the nearest sticky element between our containing block and the
1518 // ancestor scroller).
1519 //
1520 // Once both of these are null, we have no more sticky ancestors to our scroll
1521 // ancestor layer.
1522 LayerStickyPositionConstraint constraints =
1523 layer->sticky_position_constraint();
1524 gfx::Vector2dF sticky_to_remove(constraints.local_sticky_offset);
1525 Layer* nextSticky = constraints.nearest_layer_shifting_sticky_box
1526 ? constraints.nearest_layer_shifting_sticky_box
1527 : constraints.nearest_layer_shifting_containing_block;
1528 while (nextSticky) {
flackr 2017/03/09 20:22:08 Can we cache the accumulated offset like we do on
smcgruer 2017/03/14 22:04:06 No longer relevant, this code is gone.
1529 constraints = nextSticky->sticky_position_constraint();
1530 sticky_to_remove += constraints.local_sticky_offset;
1531 nextSticky = constraints.nearest_layer_shifting_sticky_box
1532 ? constraints.nearest_layer_shifting_sticky_box
1533 : constraints.nearest_layer_shifting_containing_block;
1534 }
1535 return sticky_to_remove;
1536 }
1537
1503 } // namespace draw_property_utils 1538 } // namespace draw_property_utils
1504 1539
1505 } // namespace cc 1540 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698