Commit 6326f8fb authored by jdduke@chromium.org's avatar jdduke@chromium.org

[Android] Use DIP coordinates for GestureFlingStart events

The OverScroller used to generate fling updates on Android works in pixel space.
Consequently, GestureFlingStart velocities were forwarded also in pixel space.
This exceptional case is unnecessary and confusing, as all other gestures
components are provided as DIPs.  Adopt DIPs for GestureFlingStart, instead
scaling the velocity to pixels when generating the OverScroller object.

BUG=332418

Review URL: https://codereview.chromium.org/170993003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251963 0039d316-1c4b-4281-b951-d872f2087c98
parent f3c8b8b9
......@@ -1182,10 +1182,8 @@ void ContentViewCoreImpl::FlingStart(JNIEnv* env, jobject obj, jlong time_ms,
WebGestureEvent event = MakeGestureEvent(
WebInputEvent::GestureFlingStart, time_ms, x, y);
// Velocity should not be scaled by DIP since that interacts poorly with the
// deceleration constants. The DIP scaling is done on the renderer.
event.data.flingStart.velocityX = vx;
event.data.flingStart.velocityY = vy;
event.data.flingStart.velocityX = vx / GetDpiScale();
event.data.flingStart.velocityY = vy / GetDpiScale();
SendGestureEvent(event);
}
......
......@@ -53,10 +53,14 @@ void FlingAnimatorImpl::StartFling(const gfx::PointF& velocity)
JNIEnv* env = base::android::AttachCurrentThread();
// The OverScroller deceleration constants work in pixel space. DIP scaling
// will be performed in |apply()| on the generated fling updates.
float dpi_scale = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay()
.device_scale_factor();
JNI_OverScroller::Java_OverScroller_flingV_I_I_I_I_I_I_I_I(
env, java_scroller_.obj(), 0, 0,
static_cast<int>(velocity.x()),
static_cast<int>(velocity.y()),
static_cast<int>(velocity.x() * dpi_scale),
static_cast<int>(velocity.y() * dpi_scale),
INT_MIN, INT_MAX, INT_MIN, INT_MAX);
}
......@@ -108,7 +112,7 @@ bool FlingAnimatorImpl::apply(double time,
float dpi_scale = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay()
.device_scale_factor();
blink::WebFloatSize scroll_amount(diff.x() / dpi_scale,
diff.y() / dpi_scale);
diff.y() / dpi_scale);
float delta_time = time - last_time_;
last_time_ = time;
......@@ -128,7 +132,7 @@ bool FlingAnimatorImpl::apply(double time,
}
last_velocity_ = current_velocity;
blink::WebFloatSize fling_velocity(current_velocity.x() / dpi_scale,
current_velocity.y() / dpi_scale);
current_velocity.y() / dpi_scale);
target->notifyCurrentFlingVelocity(fling_velocity);
// scrollBy() could delete this curve if the animation is over, so don't touch
......
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