Chromium Code Reviews| Index: cc/trees/draw_property_utils.cc |
| diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc |
| index c5128934db98361f1c752b674aa0a11b06d49455..7baa04e779ba1fbfd9220931408396e5c1f81122 100644 |
| --- a/cc/trees/draw_property_utils.cc |
| +++ b/cc/trees/draw_property_utils.cc |
| @@ -1500,6 +1500,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. |
|
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.
|
| + while (layer && !layer->sticky_position_constraint().is_sticky) { |
| + 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.
|
| + 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) { |
|
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.
|
| + 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 |