| Index: cc/trees/draw_property_utils.cc
|
| diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc
|
| index a591845f38b5c02e7e5bde6a6c134e076acbc110..794b8c736fe6cd6623715633a10468b092166615 100644
|
| --- a/cc/trees/draw_property_utils.cc
|
| +++ b/cc/trees/draw_property_utils.cc
|
| @@ -1475,6 +1475,41 @@ void UpdateElasticOverscroll(PropertyTrees* property_trees,
|
| elastic_overscroll);
|
| }
|
|
|
| +gfx::Vector2dF CalculateTotalStickyOffsetToScroller(
|
| + Layer* layer,
|
| + int scroll_ancestor_layer_id) {
|
| + // Find nearest ancestor which is sticky, up to the scroller.
|
| + while (layer && !layer->sticky_position_constraint().is_sticky) {
|
| + layer = layer->parent();
|
| + if (!layer || layer->id() == scroll_ancestor_layer_id)
|
| + return gfx::Vector2dF();
|
| + }
|
| +
|
| + // Walk all sticky layers from the current layer to the ancestor scroller
|
| + // layer. We achieve this by walking the |nearest_layer_shifting_sticky_box|
|
| + // when available (which is the nearest sticky element between us and our
|
| + // containing block), and |nearest_layer_shifting_containing_block| otherwise
|
| + // (which is the nearest sticky element between our containing block and the
|
| + // ancestor scroller).
|
| + //
|
| + // Once both of these are null, we have no more sticky ancestors to our scroll
|
| + // ancestor layer.
|
| + LayerStickyPositionConstraint constraints =
|
| + layer->sticky_position_constraint();
|
| + gfx::Vector2dF sticky_to_remove(constraints.local_sticky_offset);
|
| + Layer* nextSticky = constraints.nearest_layer_shifting_sticky_box
|
| + ? constraints.nearest_layer_shifting_sticky_box
|
| + : constraints.nearest_layer_shifting_containing_block;
|
| + while (nextSticky) {
|
| + constraints = nextSticky->sticky_position_constraint();
|
| + sticky_to_remove += constraints.local_sticky_offset;
|
| + nextSticky = constraints.nearest_layer_shifting_sticky_box
|
| + ? constraints.nearest_layer_shifting_sticky_box
|
| + : constraints.nearest_layer_shifting_containing_block;
|
| + }
|
| + return sticky_to_remove;
|
| +}
|
| +
|
| } // namespace draw_property_utils
|
|
|
| } // namespace cc
|
|
|