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

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

Issue 2636253002: Handle nested position:sticky elements (Closed)
Patch Set: Rebase Created 3 years, 10 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
« no previous file with comments | « cc/trees/draw_property_utils.h ('k') | cc/trees/draw_property_utils_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 elastic_overscroll); 1556 elastic_overscroll);
1557 } 1557 }
1558 1558
1559 void UpdateElasticOverscroll(PropertyTrees* property_trees, 1559 void UpdateElasticOverscroll(PropertyTrees* property_trees,
1560 const Layer* overscroll_elasticity_layer, 1560 const Layer* overscroll_elasticity_layer,
1561 const gfx::Vector2dF& elastic_overscroll) { 1561 const gfx::Vector2dF& elastic_overscroll) {
1562 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, 1562 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer,
1563 elastic_overscroll); 1563 elastic_overscroll);
1564 } 1564 }
1565 1565
1566 gfx::Vector2dF CalculateTotalStickyOffsetToScroller(
1567 Layer* layer,
1568 int scroll_ancestor_layer_id) {
1569 // Find nearest ancestor which is sticky, up to the scroller.
1570 while (layer && !layer->sticky_position_constraint().is_sticky) {
1571 layer = layer->parent();
1572 if (!layer || layer->id() == scroll_ancestor_layer_id)
1573 return gfx::Vector2dF();
1574 }
1575
1576 // Walk all sticky layers from the current layer to the ancestor scroller
1577 // layer. We achieve this by walking the |nearest_layer_shifting_sticky_box|
1578 // when available (which is the nearest sticky element between us and our
1579 // containing block), and |nearest_layer_shifting_containing_block| otherwise
1580 // (which is the nearest sticky element between our containing block and the
1581 // ancestor scroller).
1582 //
1583 // Once both of these are null, we have no more sticky ancestors to our scroll
1584 // ancestor layer.
1585 LayerStickyPositionConstraint constraints =
1586 layer->sticky_position_constraint();
1587 gfx::Vector2dF sticky_to_remove(constraints.cached_computed_sticky_offset);
1588 Layer* nextSticky = constraints.nearest_layer_shifting_sticky_box
1589 ? constraints.nearest_layer_shifting_sticky_box
1590 : constraints.nearest_layer_shifting_containing_block;
1591 while (nextSticky) {
1592 constraints = nextSticky->sticky_position_constraint();
1593 sticky_to_remove += constraints.cached_computed_sticky_offset;
1594 nextSticky = constraints.nearest_layer_shifting_sticky_box
1595 ? constraints.nearest_layer_shifting_sticky_box
1596 : constraints.nearest_layer_shifting_containing_block;
1597 }
1598
1599 return sticky_to_remove;
1600 }
1601
1566 } // namespace draw_property_utils 1602 } // namespace draw_property_utils
1567 1603
1568 } // namespace cc 1604 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/draw_property_utils.h ('k') | cc/trees/draw_property_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698