Commit a2ad51a8 authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[ScrollSnap] Invalidate SnapContainer when applying transform to target

This is a follow-up patch of crrev.com/c/1962567 to support transform
inducing resnapping.

Bug: 1028316
Change-Id: Ie1ae2f088919665c6ddfbf3d8a9dce119d066f8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008061Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732965}
parent eeea25ff
...@@ -491,6 +491,10 @@ void LayoutBox::UpdateScrollSnapMappingAfterStyleChange( ...@@ -491,6 +491,10 @@ void LayoutBox::UpdateScrollSnapMappingAfterStyleChange(
old_style.ScrollMarginTop() != StyleRef().ScrollMarginTop() || old_style.ScrollMarginTop() != StyleRef().ScrollMarginTop() ||
old_style.ScrollMarginRight() != StyleRef().ScrollMarginRight()) old_style.ScrollMarginRight() != StyleRef().ScrollMarginRight())
snap_coordinator.SnapAreaDidChange(*this, StyleRef().GetScrollSnapAlign()); snap_coordinator.SnapAreaDidChange(*this, StyleRef().GetScrollSnapAlign());
// Transform invalidates the snap area.
if (old_style.Transform() != StyleRef().Transform())
snap_coordinator.SnapAreaDidChange(*this, StyleRef().GetScrollSnapAlign());
} }
void LayoutBox::AddScrollSnapMapping() { void LayoutBox::AddScrollSnapMapping() {
......
This is a testharness.js-based test.
PASS Moving the current snap target should make the scroller resnap to it.
PASS Changing the layout of other elements should be able to cause resnapping to the target.
FAIL Transforming the current snap target should make the scroller resnap to it. assert_equals: expected 200 but got 100
PASS Applying two property changes that do not change the visual offset of the target should not change the scroll offset.
Harness: the test ran to completion.
...@@ -95,8 +95,6 @@ test(t => { ...@@ -95,8 +95,6 @@ test(t => {
assert_equals(scroller.scrollTop, 100); assert_equals(scroller.scrollTop, 100);
assert_equals(scroller.scrollLeft, 100); assert_equals(scroller.scrollLeft, 100);
// TODO(alsan): Chrome currently doesn't correctly re-snap due to transform.
// It seems to be an invalidation issue. http://crbug.com/1028316
initial_target.style.setProperty("transform", "translate(0,100px)"); initial_target.style.setProperty("transform", "translate(0,100px)");
assert_equals(scroller.scrollTop, 200); assert_equals(scroller.scrollTop, 200);
assert_equals(scroller.scrollLeft, 100); assert_equals(scroller.scrollLeft, 100);
......
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