Commit 693af506 authored by Alex Ilin's avatar Alex Ilin Committed by Commit Bot

Revert "[synthesized scroll] Fix wheel-event precision on android."

This reverts commit bad70cb2.

Reason for revert: SyntheticInputTest.SlowSmoothScrollWheel is
still flaky on Android. https://crbug.com/1086450

Original change's description:
> [synthesized scroll] Fix wheel-event precision on android.
> 
> Update API to set fractional wheel deltas on android, and remove the
> code that explicitly used to remove precision.
> 
> BUG=1085890
> 
> Change-Id: Ifd18df07637b2fa28288de62bf538f65f7a4d0a7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2213406
> Commit-Queue: Sadrul Chowdhury <sadrul@chromium.org>
> Reviewed-by: David Bokan <bokan@chromium.org>
> Reviewed-by: Yaron Friedman <yfriedman@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#771639}

TBR=sadrul@chromium.org,yfriedman@chromium.org,bokan@chromium.org,nzolghadr@chromium.org

Change-Id: Ib671a1db643144448de054fc93b43a2ad87e4805
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1085890, 1086450
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2215824Reviewed-by: default avatarAlex Ilin <alexilin@chromium.org>
Commit-Queue: Alex Ilin <alexilin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771760}
parent 15219c0b
...@@ -38,8 +38,8 @@ SyntheticGestureTargetAndroid::SyntheticGestureTargetAndroid( ...@@ -38,8 +38,8 @@ SyntheticGestureTargetAndroid::SyntheticGestureTargetAndroid(
SyntheticGestureTargetAndroid::~SyntheticGestureTargetAndroid() = default; SyntheticGestureTargetAndroid::~SyntheticGestureTargetAndroid() = default;
void SyntheticGestureTargetAndroid::TouchSetPointer(int index, void SyntheticGestureTargetAndroid::TouchSetPointer(int index,
float x, int x,
float y, int y,
int id) { int id) {
TRACE_EVENT0("input", "SyntheticGestureTargetAndroid::TouchSetPointer"); TRACE_EVENT0("input", "SyntheticGestureTargetAndroid::TouchSetPointer");
JNIEnv* env = base::android::AttachCurrentThread(); JNIEnv* env = base::android::AttachCurrentThread();
...@@ -48,10 +48,10 @@ void SyntheticGestureTargetAndroid::TouchSetPointer(int index, ...@@ -48,10 +48,10 @@ void SyntheticGestureTargetAndroid::TouchSetPointer(int index,
env, java_ref_, index, x * scale_factor, y * scale_factor, id); env, java_ref_, index, x * scale_factor, y * scale_factor, id);
} }
void SyntheticGestureTargetAndroid::TouchSetScrollDeltas(float x, void SyntheticGestureTargetAndroid::TouchSetScrollDeltas(int x,
float y, int y,
float dx, int dx,
float dy) { int dy) {
TRACE_EVENT0("input", "SyntheticGestureTargetAndroid::TouchSetScrollDeltas"); TRACE_EVENT0("input", "SyntheticGestureTargetAndroid::TouchSetScrollDeltas");
JNIEnv* env = base::android::AttachCurrentThread(); JNIEnv* env = base::android::AttachCurrentThread();
......
...@@ -47,8 +47,8 @@ class SyntheticGestureTargetAndroid : public SyntheticGestureTargetBase { ...@@ -47,8 +47,8 @@ class SyntheticGestureTargetAndroid : public SyntheticGestureTargetBase {
float GetMinScalingSpanInDips() const override; float GetMinScalingSpanInDips() const override;
private: private:
void TouchSetPointer(int index, float x, float y, int id); void TouchSetPointer(int index, int x, int y, int id);
void TouchSetScrollDeltas(float x, float y, float dx, float dy); void TouchSetScrollDeltas(int x, int y, int dx, int dy);
void TouchInject(MotionEventAction action, void TouchInject(MotionEventAction action,
int pointer_count, int pointer_count,
base::TimeTicks time); base::TimeTicks time);
......
...@@ -157,9 +157,15 @@ IN_PROC_BROWSER_TEST_F(SyntheticInputTest, SmoothScrollWheel) { ...@@ -157,9 +157,15 @@ IN_PROC_BROWSER_TEST_F(SyntheticInputTest, SmoothScrollWheel) {
"document.scrollingElement.scrollTop")); "document.scrollingElement.scrollTop"));
} }
// Wheel events lose precision on android (crbug.com/934649)
#if defined(OS_ANDROID)
#define MAYBE_SlowSmoothScrollWheel DISABLED_SlowSmoothScrollWheel
#else
#define MAYBE_SlowSmoothScrollWheel SlowSmoothScrollWheel
#endif
// This test ensures that slow synthetic wheel scrolling does not lose precision // This test ensures that slow synthetic wheel scrolling does not lose precision
// over time. // over time.
IN_PROC_BROWSER_TEST_F(SyntheticInputTest, SlowSmoothScrollWheel) { IN_PROC_BROWSER_TEST_F(SyntheticInputTest, MAYBE_SlowSmoothScrollWheel) {
LoadURL(R"HTML( LoadURL(R"HTML(
data:text/html;charset=utf-8, data:text/html;charset=utf-8,
<!DOCTYPE html> <!DOCTYPE html>
...@@ -193,18 +199,14 @@ IN_PROC_BROWSER_TEST_F(SyntheticInputTest, SlowSmoothScrollWheel) { ...@@ -193,18 +199,14 @@ IN_PROC_BROWSER_TEST_F(SyntheticInputTest, SlowSmoothScrollWheel) {
runner_ = std::make_unique<base::RunLoop>(); runner_ = std::make_unique<base::RunLoop>();
auto* web_contents = shell()->web_contents(); RenderFrameSubmissionObserver scroll_offset_wait(shell()->web_contents());
RenderFrameSubmissionObserver scroll_offset_wait(web_contents);
std::unique_ptr<SyntheticSmoothScrollGesture> gesture( std::unique_ptr<SyntheticSmoothScrollGesture> gesture(
new SyntheticSmoothScrollGesture(params)); new SyntheticSmoothScrollGesture(params));
GetRenderWidgetHost()->QueueSyntheticGesture( GetRenderWidgetHost()->QueueSyntheticGesture(
std::move(gesture), std::move(gesture),
base::BindOnce(&SyntheticInputTest::OnSyntheticGestureCompleted, base::BindOnce(&SyntheticInputTest::OnSyntheticGestureCompleted,
base::Unretained(this))); base::Unretained(this)));
float device_scale_factor = scroll_offset_wait.WaitForScrollOffset(gfx::Vector2dF(0.f, 1024.f));
web_contents->GetRenderWidgetHostView()->GetDeviceScaleFactor();
scroll_offset_wait.WaitForScrollOffset(
gfx::Vector2dF(0.f, 1024.f * device_scale_factor));
EXPECT_EQ(1024, EvalJs(shell()->web_contents(), EXPECT_EQ(1024, EvalJs(shell()->web_contents(),
"document.scrollingElement.scrollTop")); "document.scrollingElement.scrollTop"));
......
...@@ -172,6 +172,23 @@ void SyntheticSmoothMoveGesture::ForwardMouseWheelInputEvents( ...@@ -172,6 +172,23 @@ void SyntheticSmoothMoveGesture::ForwardMouseWheelInputEvents(
base::TimeTicks event_timestamp = ClampTimestamp(timestamp); base::TimeTicks event_timestamp = ClampTimestamp(timestamp);
gfx::Vector2dF delta = GetPositionDeltaAtTime(event_timestamp) - gfx::Vector2dF delta = GetPositionDeltaAtTime(event_timestamp) -
current_move_segment_total_delta_; current_move_segment_total_delta_;
// Android MotionEvents that carry mouse wheel ticks and the tick
// granularity. Since it's not easy to change this granularity, it means
// we can only scroll in terms of number of these ticks. Note also: if
// the delta is smaller than one tick size we wont send an event or
// accumulate it in current_move_segment_total_delta_ so that we don't
// consider that delta applied. If we did, slow scrolls would be entirely
// lost since we'd send 0 ticks in each event but assume delta was
// applied.
int pixels_per_wheel_tick = target->GetMouseWheelMinimumGranularity();
if (pixels_per_wheel_tick) {
int wheel_ticks_x = static_cast<int>(delta.x() / pixels_per_wheel_tick);
int wheel_ticks_y = static_cast<int>(delta.y() / pixels_per_wheel_tick);
delta = gfx::Vector2dF(wheel_ticks_x * pixels_per_wheel_tick,
wheel_ticks_y * pixels_per_wheel_tick);
}
if (delta.x() || delta.y()) { if (delta.x() || delta.y()) {
blink::WebMouseWheelEvent::Phase phase = blink::WebMouseWheelEvent::Phase phase =
needs_scroll_begin_ ? blink::WebMouseWheelEvent::kPhaseBegan needs_scroll_begin_ ? blink::WebMouseWheelEvent::kPhaseBegan
......
...@@ -44,7 +44,7 @@ public class MotionEventSynthesizerImpl implements MotionEventSynthesizer { ...@@ -44,7 +44,7 @@ public class MotionEventSynthesizerImpl implements MotionEventSynthesizer {
* @param toolType ToolType property of the point. * @param toolType ToolType property of the point.
*/ */
@Override @Override
public void setPointer(int index, float x, float y, int id, int toolType) { public void setPointer(int index, int x, int y, int id, int toolType) {
assert (0 <= index && index < MAX_NUM_POINTERS); assert (0 <= index && index < MAX_NUM_POINTERS);
PointerCoords coords = new PointerCoords(); PointerCoords coords = new PointerCoords();
...@@ -67,7 +67,7 @@ public class MotionEventSynthesizerImpl implements MotionEventSynthesizer { ...@@ -67,7 +67,7 @@ public class MotionEventSynthesizerImpl implements MotionEventSynthesizer {
* @param x Y coordinate of the point. * @param x Y coordinate of the point.
* @param id Id property of the point. * @param id Id property of the point.
*/ */
public void setPointer(int index, float x, float y, int id) { public void setPointer(int index, int x, int y, int id) {
setPointer(index, x, y, id, MotionEvent.TOOL_TYPE_UNKNOWN); setPointer(index, x, y, id, MotionEvent.TOOL_TYPE_UNKNOWN);
} }
...@@ -79,7 +79,7 @@ public class MotionEventSynthesizerImpl implements MotionEventSynthesizer { ...@@ -79,7 +79,7 @@ public class MotionEventSynthesizerImpl implements MotionEventSynthesizer {
* @param dx Delta along the X coordinate. * @param dx Delta along the X coordinate.
* @param dy Delta along the Y coordinate. * @param dy Delta along the Y coordinate.
*/ */
public void setScrollDeltas(float x, float y, float dx, float dy) { public void setScrollDeltas(int x, int y, int dx, int dy) {
setPointer(0, x, y, 0); setPointer(0, x, y, 0);
mPointerCoords[0].setAxisValue(MotionEvent.AXIS_HSCROLL, dx); mPointerCoords[0].setAxisValue(MotionEvent.AXIS_HSCROLL, dx);
mPointerCoords[0].setAxisValue(MotionEvent.AXIS_VSCROLL, dy); mPointerCoords[0].setAxisValue(MotionEvent.AXIS_VSCROLL, dy);
......
...@@ -31,12 +31,12 @@ public class SyntheticGestureTarget { ...@@ -31,12 +31,12 @@ public class SyntheticGestureTarget {
} }
@CalledByNative @CalledByNative
private void setPointer(int index, float x, float y, int id) { private void setPointer(int index, int x, int y, int id) {
mMotionEventSynthesizer.setPointer(index, x, y, id); mMotionEventSynthesizer.setPointer(index, x, y, id);
} }
@CalledByNative @CalledByNative
private void setScrollDeltas(float x, float y, float dx, float dy) { private void setScrollDeltas(int x, int y, int dx, int dy) {
mMotionEventSynthesizer.setScrollDeltas(x, y, dx, dy); mMotionEventSynthesizer.setScrollDeltas(x, y, dx, dy);
} }
} }
...@@ -25,7 +25,7 @@ public interface MotionEventSynthesizer { ...@@ -25,7 +25,7 @@ public interface MotionEventSynthesizer {
* @param id Id property of the point. * @param id Id property of the point.
* @param toolType ToolType property of the point. * @param toolType ToolType property of the point.
*/ */
void setPointer(int index, float x, float y, int id, int toolType); void setPointer(int index, int x, int y, int id, int toolType);
/** /**
* Injects a synthetic action with the preset points and delta. * Injects a synthetic action with the preset points and delta.
......
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