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

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

Issue 2733633002: Handle nested position:sticky elements correctly (compositor) (Closed)
Patch Set: Addressed the easier reviewer comments. 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 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 elastic_overscroll); 1468 elastic_overscroll);
1469 } 1469 }
1470 1470
1471 void UpdateElasticOverscroll(PropertyTrees* property_trees, 1471 void UpdateElasticOverscroll(PropertyTrees* property_trees,
1472 const Layer* overscroll_elasticity_layer, 1472 const Layer* overscroll_elasticity_layer,
1473 const gfx::Vector2dF& elastic_overscroll) { 1473 const gfx::Vector2dF& elastic_overscroll) {
1474 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, 1474 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer,
1475 elastic_overscroll); 1475 elastic_overscroll);
1476 } 1476 }
1477 1477
1478 gfx::Vector2dF CalculateTotalStickyOffsetToScroller(
1479 Layer* layer,
1480 int scroll_ancestor_layer_id) {
1481 // Find nearest ancestor which is sticky, up to the scroller.
1482 while (layer && !layer->sticky_position_constraint().is_sticky) {
1483 layer = layer->parent();
1484 if (!layer || layer->id() == scroll_ancestor_layer_id)
1485 return gfx::Vector2dF();
1486 }
1487
1488 // Walk all sticky layers from the current layer to the ancestor scroller
1489 // layer. We achieve this by walking the |nearest_layer_shifting_sticky_box|
1490 // when available (which is the nearest sticky element between us and our
1491 // containing block), and |nearest_layer_shifting_containing_block| otherwise
1492 // (which is the nearest sticky element between our containing block and the
1493 // ancestor scroller).
1494 //
1495 // Once both of these are null, we have no more sticky ancestors to our scroll
1496 // ancestor layer.
1497 LayerStickyPositionConstraint constraints =
1498 layer->sticky_position_constraint();
1499 gfx::Vector2dF sticky_to_remove(constraints.local_sticky_offset);
1500 Layer* nextSticky = constraints.nearest_layer_shifting_sticky_box
1501 ? constraints.nearest_layer_shifting_sticky_box
1502 : constraints.nearest_layer_shifting_containing_block;
1503 while (nextSticky) {
1504 constraints = nextSticky->sticky_position_constraint();
1505 sticky_to_remove += constraints.local_sticky_offset;
1506 nextSticky = constraints.nearest_layer_shifting_sticky_box
1507 ? constraints.nearest_layer_shifting_sticky_box
1508 : constraints.nearest_layer_shifting_containing_block;
1509 }
1510 return sticky_to_remove;
1511 }
1512
1478 } // namespace draw_property_utils 1513 } // namespace draw_property_utils
1479 1514
1480 } // namespace cc 1515 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698