Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
| index 096496646d08d65e0cdb5cfd35bebedfa4fe21d3..94b8866c0d2c770b66973500df785246b0d1b869 100644 |
| --- a/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
| +++ b/third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp |
| @@ -282,8 +282,7 @@ void CompositedLayerMapping::UpdateBackdropFilters(const ComputedStyle& style) { |
| } |
| void CompositedLayerMapping::UpdateStickyConstraints( |
| - const ComputedStyle& style, |
| - const PaintLayer* compositing_container) { |
| + const ComputedStyle& style) { |
| bool sticky = style.GetPosition() == EPosition::kSticky; |
| const PaintLayer* ancestor_overflow_layer = |
| owning_layer_.AncestorOverflowLayer(); |
| @@ -297,6 +296,7 @@ void CompositedLayerMapping::UpdateStickyConstraints( |
| } |
| WebLayerStickyPositionConstraint web_constraint; |
| + WebSize sticky_main_thread_offset; |
|
smcgruer
2017/05/26 17:14:12
Nit; this method is explicitly about sticky, we co
yigu
2017/05/26 18:04:21
Done.
|
| if (sticky) { |
| const StickyConstraintsMap& constraints_map = |
| ancestor_overflow_layer->GetScrollableArea()->GetStickyConstraintsMap(); |
| @@ -307,42 +307,8 @@ void CompositedLayerMapping::UpdateStickyConstraints( |
| // composited layer. This information is used by the compositor side to |
| // compute the additional offset required to keep the element stuck under |
| // compositor scrolling. |
| - // |
| - // Starting from the scroll container relative location, removing the |
| - // enclosing layer's offset and the content offset in the composited layer |
| - // results in the parent-layer relative offset. |
| - FloatPoint parent_relative_sticky_box_offset = |
| - constraints.ScrollContainerRelativeStickyBoxRect().Location(); |
| - |
| - // The enclosing layers offset returned from |convertToLayerCoords| must be |
| - // adjusted for both scroll and ancestor sticky elements. |
| - LayoutPoint enclosing_layer_offset; |
| - compositing_container->ConvertToLayerCoords(ancestor_overflow_layer, |
| - enclosing_layer_offset); |
| - DCHECK(!ScrollParent() || ScrollParent() == ancestor_overflow_layer); |
| - if (!ScrollParent() && compositing_container != ancestor_overflow_layer) { |
| - enclosing_layer_offset += LayoutSize( |
| - ancestor_overflow_layer->GetScrollableArea()->GetScrollOffset()); |
| - } |
| - // TODO(smcgruer): Until http://crbug.com/702229 is fixed, the nearest |
| - // sticky ancestor may be non-composited which will make this offset wrong. |
| - if (const LayoutBoxModelObject* ancestor = |
| - constraints.NearestStickyAncestor()) { |
| - enclosing_layer_offset -= |
| - RoundedIntSize(constraints_map.at(ancestor->Layer()) |
| - .GetTotalContainingBlockStickyOffset()); |
| - } |
| - |
| - DCHECK(!content_offset_in_compositing_layer_dirty_); |
| - parent_relative_sticky_box_offset.MoveBy( |
| - FloatPoint(-enclosing_layer_offset) - |
| - FloatSize(ContentOffsetInCompositingLayer())); |
| - |
| - if (compositing_container != ancestor_overflow_layer) { |
| - parent_relative_sticky_box_offset.MoveBy( |
| - FloatPoint(compositing_container->GetCompositedLayerMapping() |
| - ->ContentOffsetInCompositingLayer())); |
| - } |
| + sticky_main_thread_offset = |
| + RoundedIntSize(GetLayoutObject().StickyPositionOffset()); |
| web_constraint.is_sticky = true; |
| web_constraint.is_anchored_left = |
| @@ -361,8 +327,6 @@ void CompositedLayerMapping::UpdateStickyConstraints( |
| web_constraint.right_offset = constraints.RightOffset(); |
| web_constraint.top_offset = constraints.TopOffset(); |
| web_constraint.bottom_offset = constraints.BottomOffset(); |
| - web_constraint.parent_relative_sticky_box_offset = |
| - RoundedIntPoint(parent_relative_sticky_box_offset); |
| web_constraint.scroll_container_relative_sticky_box_rect = |
| EnclosingIntRect(constraints.ScrollContainerRelativeStickyBoxRect()); |
| web_constraint.scroll_container_relative_containing_block_rect = |
| @@ -397,6 +361,7 @@ void CompositedLayerMapping::UpdateStickyConstraints( |
| } |
| graphics_layer_->SetStickyPositionConstraint(web_constraint); |
| + graphics_layer_->SetStickyMainThreadOffset(sticky_main_thread_offset); |
| } |
| void CompositedLayerMapping::UpdateLayerBlendMode(const ComputedStyle& style) { |
| @@ -1113,7 +1078,7 @@ void CompositedLayerMapping::UpdateGraphicsLayerGeometry( |
| graphics_layer_parent_location); |
| UpdateContentsOffsetInCompositingLayer( |
| snapped_offset_from_composited_ancestor, graphics_layer_parent_location); |
| - UpdateStickyConstraints(GetLayoutObject().StyleRef(), compositing_container); |
| + UpdateStickyConstraints(GetLayoutObject().StyleRef()); |
| UpdateSquashingLayerGeometry( |
| graphics_layer_parent_location, compositing_container, squashed_layers_, |
| squashing_layer_.get(), |