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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/draw_property_utils.cc
diff --git a/cc/trees/draw_property_utils.cc b/cc/trees/draw_property_utils.cc
index bd839f0937b4e7ec78a1a321b5e5fa597dd0d42a..28daeb72ea46fb5f3c312f57c091fe8195ccea74 100644
--- a/cc/trees/draw_property_utils.cc
+++ b/cc/trees/draw_property_utils.cc
@@ -1563,6 +1563,42 @@ 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.cached_computed_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.cached_computed_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
« 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