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

Unified Diff: cc/trees/property_tree_builder.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
Index: cc/trees/property_tree_builder.cc
diff --git a/cc/trees/property_tree_builder.cc b/cc/trees/property_tree_builder.cc
index 375051ac04087affe87b921490b34eb9c0e83702..7508b87f0429481b9585fc56b4a2c1b211316a37 100644
--- a/cc/trees/property_tree_builder.cc
+++ b/cc/trees/property_tree_builder.cc
@@ -513,6 +513,19 @@ static inline bool ShouldFlattenTransform(LayerImpl* layer) {
return layer->test_properties()->should_flatten_transform;
}
+static inline gfx::Vector2dF CalculateTotalStickyOffsetToScroller(
+ LayerImpl* layer,
+ int scroll_ancestor_layer_id) {
+ return gfx::Vector2dF();
+}
+
+static inline gfx::Vector2dF CalculateTotalStickyOffsetToScroller(
+ Layer* layer,
+ int scroll_ancestor_layer_id) {
+ return draw_property_utils::CalculateTotalStickyOffsetToScroller(
+ layer, scroll_ancestor_layer_id);
+}
+
template <typename LayerType>
bool AddTransformNodeIfNeeded(
const DataForRecursion<LayerType>& data_from_ancestor,
@@ -759,10 +772,32 @@ bool AddTransformNodeIfNeeded(
.AddNodeAffectedByOuterViewportBoundsDelta(node->id);
}
}
- sticky_data->main_thread_offset =
- layer->position().OffsetFromOrigin() -
- sticky_data->constraints.parent_relative_sticky_box_offset
- .OffsetFromOrigin();
+
+ // The sticky box offset calculated in CompositedLayerMapping must be
+ // adjusted for the enclosing layer's scroll position and sticky offset.
+ // TODO(smcgruer): Maybe rename parent_relative_sticky_box_offset ?
+ gfx::Point sticky_box_offset(
+ sticky_data->constraints.parent_relative_sticky_box_offset);
+ if (Parent(layer)->id() != scroll_ancestor->owning_layer_id) {
+ sticky_box_offset -= gfx::ScrollOffsetToFlooredVector2d(
+ data_for_children->property_trees->scroll_tree.current_scroll_offset(
+ scroll_ancestor->owning_layer_id));
+ sticky_box_offset +=
+ gfx::ToFlooredVector2d(CalculateTotalStickyOffsetToScroller(
+ Parent(layer), scroll_ancestor->owning_layer_id));
+ }
+ sticky_data->main_thread_offset = layer->position().OffsetFromOrigin() -
+ sticky_box_offset.OffsetFromOrigin();
+ if (Layer* layer =
+ sticky_data->constraints.nearest_layer_shifting_sticky_box) {
+ sticky_data->nearest_node_shifting_sticky_box =
+ layer->transform_tree_index();
+ }
+ if (Layer* layer =
+ sticky_data->constraints.nearest_layer_shifting_containing_block) {
+ sticky_data->nearest_node_shifting_containing_block =
+ layer->transform_tree_index();
+ }
}
node->needs_local_transform_update = true;
« no previous file with comments | « cc/trees/property_tree.cc ('k') | third_party/WebKit/LayoutTests/compositing/overflow/composited-nested-sticky-deep.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698