Commit 11bf6abb authored by David Bokan's avatar David Bokan Committed by Commit Bot

Fix small scroll deltas in synthetic gestures

SyntheticGestureTargetAura::GetTouchSlopInDips was subtracting 1 from
the slop configuration value. However,
GestureDetector::IsWithinTouchSlop would incorrectly return true if we
scrolled one pixel past the slop in this case. Additionally, there's no
need to ceil the touch slop adjustment in SyntheticSmoothMoveGesture
since we're sending float deltas.

Bug: 897520
Change-Id: I35725c603910b3c694d9eddf5fde31f1f6b9cf2e
Reviewed-on: https://chromium-review.googlesource.com/c/1293171Reviewed-by: default avatarQuinten Yearsley <qyearsley@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602458}
parent 45fe99b7
......@@ -163,8 +163,7 @@ IN_PROC_BROWSER_TEST_F(CompositedScrollingBrowserTest,
int scroll_distance =
DoTouchScroll(gfx::Point(50, 150), gfx::Vector2d(0, 100));
// The scroll distance is increased due to the rotation of the scroller.
EXPECT_EQ(std::floor(100 / std::cos(gfx::DegToRad(30.f))) - 1,
scroll_distance);
EXPECT_EQ(std::floor(100 / std::cos(gfx::DegToRad(30.f))), scroll_distance);
}
} // namespace content
......@@ -180,11 +180,8 @@ SyntheticGestureTargetAura::GetDefaultSyntheticGestureSourceType() const {
}
float SyntheticGestureTargetAura::GetTouchSlopInDips() const {
// - 1 because Aura considers a pointer to be moving if it has moved at least
// 'max_touch_move_in_pixels_for_click' pixels.
return ui::GestureConfiguration::GetInstance()
->max_touch_move_in_pixels_for_click() -
1;
->max_touch_move_in_pixels_for_click();
}
float SyntheticGestureTargetAura::GetSpanSlopInDips() const {
......
......@@ -12,12 +12,6 @@
namespace content {
namespace {
gfx::Vector2d CeilFromZero(const gfx::Vector2dF& vector) {
int x = vector.x() > 0 ? ceil(vector.x()) : floor(vector.x());
int y = vector.y() > 0 ? ceil(vector.y()) : floor(vector.y());
return gfx::Vector2d(x, y);
}
gfx::Vector2dF ProjectScalarOntoVector(float scalar,
const gfx::Vector2dF& vector) {
return gfx::ScaleVector2d(vector, scalar / vector.Length());
......@@ -334,8 +328,8 @@ void SyntheticSmoothMoveGesture::AddTouchSlopToFirstDistance(
DCHECK_GE(params_.distances.size(), 1ul);
gfx::Vector2dF& first_move_distance = params_.distances[0];
DCHECK_GT(first_move_distance.Length(), 0);
first_move_distance += CeilFromZero(ProjectScalarOntoVector(
target->GetTouchSlopInDips(), first_move_distance));
first_move_distance += ProjectScalarOntoVector(target->GetTouchSlopInDips(),
first_move_distance);
}
gfx::Vector2dF SyntheticSmoothMoveGesture::GetPositionDeltaAtTime(
......
......@@ -985,6 +985,13 @@ virtual/media-gpu-accelerated/external/wpt/media-source/mediasource-config-chang
virtual/media-gpu-accelerated/external/wpt/media-source/mediasource-config-change-mp4-av-framesize.html
virtual/media-gpu-accelerated/external/wpt/media-source/mediasource-config-change-mp4-v-framerate.html
# Test synthetic gestures since telemetry and layout tests rely on these being correct.
virtual/threaded/synthetic_gestures/synthetic-pinch-zoom-gesture-touchscreen-zoom-in-slow.html
virtual/threaded/synthetic_gestures/synthetic-pinch-zoom-gesture-touchscreen-zoom-out-slow.html
virtual/threaded/synthetic_gestures/synthetic-pinch-zoom-gesture-touchscreen.html
virtual/threaded/synthetic_gestures/smooth-scroll-tiny-delta.html
synthetic_gestures/smooth-scroll-tiny-delta.html
virtual/prefer_compositing_to_lcd_text/scrollbars/custom-scroll-corner-crash.html
virtual/prefer_compositing_to_lcd_text/scrollbars/viewport-scrollbar-corner-with-percent-padding-crash.html
virtual/stable/fast/css3-text/css3-text-decoration/stable/getComputedStyle-text-decoration.html
......@@ -995,9 +1002,6 @@ virtual/stable/web-animations-api/additive-animations-unsupported.html
virtual/stable/webexposed/internal-properties-should-not-be-exposed.html
virtual/threaded/animations/stability/pseudo-element-animation-with-marker-crash.html
virtual/threaded/printing/page-and-element-geometry-match.html
virtual/threaded/synthetic_gestures/synthetic-pinch-zoom-gesture-touchscreen-zoom-in-slow.html
virtual/threaded/synthetic_gestures/synthetic-pinch-zoom-gesture-touchscreen-zoom-out-slow.html
virtual/threaded/synthetic_gestures/synthetic-pinch-zoom-gesture-touchscreen.html
virtual/without-smil/svg/animations/exposed/effect.html
wake_lock/wakelock-api.html
wake_lock/wakelock-in-nested-frame.html
......
......@@ -81,7 +81,16 @@ const GestureSourceType = {
TOUCH_INPUT: 1,
MOUSE_INPUT: 2,
TOUCHPAD_INPUT:2,
PEN_INPUT: 3
PEN_INPUT: 3,
ToString: function(value) {
switch(value) {
case 0: return "DefaultInput";
case 1: return "Touchscreen";
case 2: return "MouseWheel/Touchpad";
case 3: return "Pen";
default: return "Invalid";
}
}
};
// Use this for speed to make gestures (effectively) instant. That is, finish
......
This directory serves as a base for virtual/threaded/synthetic_gestures/, for
which there are no base tests.
<!DOCTYPE html>
<script src='../resources/testharness.js'></script>
<script src='../resources/testharnessreport.js'></script>
<script src='../resources/gesture-util.js'></script>
<style>
body, html {
margin: 0;
height: 10000px;
}
</style>
<script>
// This test ensures that animated mouse wheel scrolls with tiny amounts are
// accurately propagated in the renderer.
async function tryScroll(distance, source) {
const x = 400;
const y = 300;
const precise_deltas = false;
const scrollYBefore = window.scrollY;
await waitForCompositorCommit();
await smoothScroll(distance,
x, y,
source,
'down',
SPEED_INSTANT,
precise_deltas);
await waitFor(() => { return window.scrollY - scrollYBefore >= distance; },
"Didn't scroll by expected amount: " + distance);
await waitForCompositorCommit();
}
window.onload = async () => {
const source_type = GestureSourceType.MOUSE_INPUT;
promise_test(async () => {
assert_equals(window.scrollY, 0);
await tryScroll(1, source_type);
assert_equals(window.scrollY, 1);
}, 'Synthetic animated ' + GestureSourceType.ToString(source_type) +
' gestures accurately scroll delta (0, 1).');
promise_test(async () => {
assert_equals(window.scrollY, 1);
await tryScroll(2, source_type);
assert_equals(window.scrollY, 3);
window.scrollTo(0, 0);
}, 'Synthetic animated ' + GestureSourceType.ToString(source_type) +
' gestures accurately scroll delta (0, 2).');
}
</script>
<!DOCTYPE html>
<script src='../resources/testharness.js'></script>
<script src='../resources/testharnessreport.js'></script>
<script src='../resources/gesture-util.js'></script>
<style>
body, html {
margin: 0;
height: 10000px;
}
</style>
<script>
// This test ensures that synthetic scrolls with tiny amounts are accurately
// propagated to the renderer.
async function tryScroll(distance, source) {
const x = 400;
const y = 300;
const precise_deltas = true;
const scrollYBefore = window.scrollY;
await waitForCompositorCommit();
await smoothScroll(distance,
x, y,
source,
'down',
SPEED_INSTANT,
precise_deltas);
await waitFor(() => { return window.scrollY - scrollYBefore >= distance; },
"Didn't scroll by expected amount: " + distance);
await waitForCompositorCommit();
}
window.onload = async () => {
const is_mac = navigator.platform.indexOf('Mac') == 0;
const sources_to_test = [];
sources_to_test.push(GestureSourceType.DEFAULT_INPUT);
// TODO(bokan): Mac doesn't support even synthetic touches.
// https://crbug.com/613672.
if (!is_mac)
sources_to_test.push(GestureSourceType.TOUCH_INPUT);
// Touchpad and Mouse are currently treated the same, if that changes, be
// sure to test both.
if (GestureSourceType.MOUSE_INPUT != GestureSourceType.TOUCHPAD_INPUT)
sources_to_test.push(GestureSourceType.MOUSE_INPUT);
sources_to_test.push(GestureSourceType.TOUCHPAD_INPUT);
// TODO(bokan): Pen input doesn't yet pass this test. crbug.com/897520.
//sources_to_test.push(GestureSourceType.PEN_INPUT);
for (let source_type of sources_to_test) {
promise_test(async () => {
assert_equals(window.scrollY, 0);
await tryScroll(1, source_type);
assert_equals(window.scrollY, 1);
}, 'Synthetic ' + GestureSourceType.ToString(source_type) +
' gestures accurately scroll delta (0, 1).');
promise_test(async () => {
assert_equals(window.scrollY, 1);
await tryScroll(2, source_type);
assert_equals(window.scrollY, 3);
window.scrollTo(0, 0);
}, 'Synthetic ' + GestureSourceType.ToString(source_type) +
' gestures accurately scroll delta (0, 2).');
}
}
</script>
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