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..381352193c40bed32158b174f6d8276a63ed09a1 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 main_thread_offset; |
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())); |
- } |
+ main_thread_offset = |
+ RoundedIntSize(GetLayoutObject().StickyPositionOffset()); |
flackr
2017/05/31 14:08:23
We should probably use the cached sticky position
yigu
2017/06/01 15:15:19
Moved this logic to UpdateLayerPosition.
|
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(main_thread_offset); |
flackr
2017/05/31 14:08:23
Don't we need to update the sticky main thread off
yigu
2017/06/01 15:15:19
Done.
|
} |
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(), |