Chromium Code Reviews| Index: cc/layers/layer.cc |
| diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc |
| index 3446f38d659eca9b59008e00b341ce81d6f840f6..e8d361d3399de393ef6a9a96937db2335365640c 100644 |
| --- a/cc/layers/layer.cc |
| +++ b/cc/layers/layer.cc |
| @@ -29,6 +29,7 @@ |
| #include "cc/trees/layer_tree_impl.h" |
| #include "cc/trees/mutable_properties.h" |
| #include "cc/trees/mutator_host.h" |
| +#include "cc/trees/scroll_node.h" |
| #include "cc/trees/transform_node.h" |
| #include "third_party/skia/include/core/SkImageFilter.h" |
| #include "ui/gfx/geometry/rect_conversions.h" |
| @@ -584,10 +585,39 @@ void Layer::SetPosition(const gfx::PointF& position) { |
| StickyPositionNodeData* sticky_data = |
| property_trees->transform_tree.StickyPositionData( |
| transform_tree_index()); |
| + gfx::Point sticky_box_offset( |
| + sticky_data->constraints.parent_relative_sticky_box_offset); |
| + |
| + // 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 ? |
|
smcgruer
2017/02/14 17:02:06
flackr : Thoughts on renaming this?
|
| + ScrollNode* scroll_ancestor = |
| + property_trees->scroll_tree.Node(scroll_tree_index()); |
| + if (scroll_ancestor->owning_layer_id == id()) { |
| + // We are a scroller, so we need our parent's scroll_ancestor instead. |
| + scroll_ancestor = |
| + property_trees->scroll_tree.Node(parent()->scroll_tree_index()); |
| + } |
| + if (parent()->id() != scroll_ancestor->owning_layer_id) { |
| + sticky_box_offset -= gfx::ScrollOffsetToFlooredVector2d( |
| + property_trees->scroll_tree.current_scroll_offset( |
| + scroll_ancestor->owning_layer_id)); |
| + sticky_box_offset += gfx::ToFlooredVector2d( |
| + draw_property_utils::CalculateTotalStickyOffsetToScroller( |
| + parent(), scroll_ancestor->owning_layer_id)); |
| + } |
| sticky_data->main_thread_offset = |
| - position.OffsetFromOrigin() - |
| - sticky_data->constraints.parent_relative_sticky_box_offset |
| - .OffsetFromOrigin(); |
| + 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(); |
| + } |
| } |
| transform_node->needs_local_transform_update = true; |
| transform_node->transform_changed = true; |