Commit 70165b9c authored by Kaan Alsan's avatar Kaan Alsan Committed by Commit Bot

Simplify snap area rect calculation

Use the kIgnoreScrollOffset flag when calculating a snap area's rect
relative to its snap container, rather than adding the scroll offset
later in the calculation.

Bug: 1016785
Change-Id: Ifbc1c46c5f95e0d8871286be260c2ee219e15e4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1902008Reviewed-by: default avatarYi Gu <yigu@chromium.org>
Reviewed-by: default avatarMajid Valipour <majidvp@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Kaan Alsan <alsan@google.com>
Cr-Commit-Position: refs/heads/master@{#714239}
parent 56873941
...@@ -277,22 +277,11 @@ cc::SnapAreaData SnapCoordinator::CalculateSnapAreaData( ...@@ -277,22 +277,11 @@ cc::SnapAreaData SnapCoordinator::CalculateSnapAreaData(
// tree, as the snap_container is found by walking up the layout tree in // tree, as the snap_container is found by walking up the layout tree in
// FindSnapContainer(). Under this assumption, // FindSnapContainer(). Under this assumption,
// snap_area.LocalToAncestorRect() returns the snap_area's position relative // snap_area.LocalToAncestorRect() returns the snap_area's position relative
// to its container's border box. And the |area| below represents the // to the snap container's border box, while ignoring scroll offset.
// snap_area rect in respect to the snap_container.
PhysicalRect area_rect = snap_area.PhysicalBorderBoxRect(); PhysicalRect area_rect = snap_area.PhysicalBorderBoxRect();
area_rect = snap_area.LocalToAncestorRect(area_rect, &snap_container, area_rect = snap_area.LocalToAncestorRect(
kTraverseDocumentBoundaries); area_rect, &snap_container,
ScrollableArea* scrollable_area = kTraverseDocumentBoundaries | kIgnoreScrollOffset);
ScrollableArea::GetForScrolling(&snap_container);
if (scrollable_area) {
if (snap_container.IsLayoutView()) {
area_rect = snap_container.GetFrameView()->FrameToDocument(area_rect);
} else {
area_rect.Move(PhysicalOffset::FromFloatPointRound(
scrollable_area->ScrollPosition()));
}
}
LayoutRectOutsets area_margin( LayoutRectOutsets area_margin(
area_style->ScrollMarginTop(), area_style->ScrollMarginRight(), area_style->ScrollMarginTop(), area_style->ScrollMarginRight(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment