diff options
author | jdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-19 06:18:35 +0000 |
---|---|---|
committer | jdduke@chromium.org <jdduke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-19 06:18:35 +0000 |
commit | 6326f8fba293931900a577d575c79ffe5e99f522 (patch) | |
tree | 3d7d5e789b7c43328fb98723906a3d615fdd33b6 /webkit | |
parent | f3c8b8b99b00e7cc9c069c3353256ecd988d3852 (diff) | |
download | chromium_src-6326f8fba293931900a577d575c79ffe5e99f522.zip chromium_src-6326f8fba293931900a577d575c79ffe5e99f522.tar.gz chromium_src-6326f8fba293931900a577d575c79ffe5e99f522.tar.bz2 |
[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
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/child/fling_animator_impl_android.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/webkit/child/fling_animator_impl_android.cc b/webkit/child/fling_animator_impl_android.cc index 668076b..4abee7d 100644 --- a/webkit/child/fling_animator_impl_android.cc +++ b/webkit/child/fling_animator_impl_android.cc @@ -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 |