| Index: cc/layers/layer.cc
|
| diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
|
| index 2b4566a539e0545d7e7c843b7869c66447dd4e50..d90d60ecd9848e1f09bea122cb75ddf1ab7ef90a 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"
|
| @@ -593,10 +594,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 ?
|
| + 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;
|
|
|