| Index: content/browser/renderer_host/input/fling/fling_curve_impl_android.cc
|
| diff --git a/webkit/child/fling_animator_impl_android.cc b/content/browser/renderer_host/input/fling/fling_curve_impl_android.cc
|
| similarity index 73%
|
| copy from webkit/child/fling_animator_impl_android.cc
|
| copy to content/browser/renderer_host/input/fling/fling_curve_impl_android.cc
|
| index 668076ba235cfa9decadaa14c13743552ecfba42..e4f524560ba51cad12575d1affbb61ac06458df8 100644
|
| --- a/webkit/child/fling_animator_impl_android.cc
|
| +++ b/content/browser/renderer_host/input/fling/fling_curve_impl_android.cc
|
| @@ -2,24 +2,22 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "webkit/child/fling_animator_impl_android.h"
|
| +#include "content/browser/renderer_host/input/fling/fling_curve_impl_android.h"
|
|
|
| #include "base/android/jni_android.h"
|
| #include "base/android/scoped_java_ref.h"
|
| #include "base/logging.h"
|
| #include "jni/OverScroller_jni.h"
|
| -#include "third_party/WebKit/public/platform/WebFloatSize.h"
|
| -#include "third_party/WebKit/public/platform/WebGestureCurveTarget.h"
|
| #include "ui/gfx/screen.h"
|
| #include "ui/gfx/vector2d.h"
|
|
|
| -namespace webkit_glue {
|
| +namespace content {
|
|
|
| namespace {
|
| static const float kEpsilon = 1e-4;
|
| }
|
|
|
| -FlingAnimatorImpl::FlingAnimatorImpl()
|
| +FlingCurveImplAndroid::FlingCurveImplAndroid()
|
| : is_active_(false) {
|
| // hold the global reference of the Java objects.
|
| JNIEnv* env = base::android::AttachCurrentThread();
|
| @@ -28,16 +26,16 @@ FlingAnimatorImpl::FlingAnimatorImpl()
|
| base::android::GetApplicationContext()));
|
| }
|
|
|
| -FlingAnimatorImpl::~FlingAnimatorImpl()
|
| +FlingCurveImplAndroid::~FlingCurveImplAndroid()
|
| {
|
| }
|
|
|
| //static
|
| -bool FlingAnimatorImpl::RegisterJni(JNIEnv* env) {
|
| +bool FlingCurveImplAndroid::RegisterJni(JNIEnv* env) {
|
| return JNI_OverScroller::RegisterNativesImpl(env);
|
| }
|
|
|
| -void FlingAnimatorImpl::StartFling(const gfx::PointF& velocity)
|
| +void FlingCurveImplAndroid::StartFling(const gfx::PointF& velocity)
|
| {
|
| // No bounds on the fling. See http://webkit.org/b/96403
|
| // Instead, use the largest possible bounds for minX/maxX/minY/maxY. The
|
| @@ -60,7 +58,7 @@ void FlingAnimatorImpl::StartFling(const gfx::PointF& velocity)
|
| INT_MIN, INT_MAX, INT_MIN, INT_MAX);
|
| }
|
|
|
| -void FlingAnimatorImpl::CancelFling()
|
| +void FlingCurveImplAndroid::CancelFling()
|
| {
|
| if (!is_active_)
|
| return;
|
| @@ -70,7 +68,7 @@ void FlingAnimatorImpl::CancelFling()
|
| JNI_OverScroller::Java_OverScroller_abortAnimation(env, java_scroller_.obj());
|
| }
|
|
|
| -bool FlingAnimatorImpl::UpdatePosition()
|
| +bool FlingCurveImplAndroid::UpdatePosition()
|
| {
|
| JNIEnv* env = base::android::AttachCurrentThread();
|
| bool result = JNI_OverScroller::Java_OverScroller_computeScrollOffset(
|
| @@ -79,7 +77,7 @@ bool FlingAnimatorImpl::UpdatePosition()
|
| return is_active_ = result;
|
| }
|
|
|
| -gfx::Point FlingAnimatorImpl::GetCurrentPosition()
|
| +gfx::Point FlingCurveImplAndroid::GetCurrentPosition()
|
| {
|
| JNIEnv* env = base::android::AttachCurrentThread();
|
| gfx::Point position(
|
| @@ -88,7 +86,7 @@ gfx::Point FlingAnimatorImpl::GetCurrentPosition()
|
| return position;
|
| }
|
|
|
| -float FlingAnimatorImpl::GetCurrentVelocity()
|
| +float FlingCurveImplAndroid::GetCurrentVelocity()
|
| {
|
| JNIEnv* env = base::android::AttachCurrentThread();
|
| // TODO(jdduke): Add Java-side hooks for getCurrVelocityX/Y, and return
|
| @@ -97,8 +95,8 @@ float FlingAnimatorImpl::GetCurrentVelocity()
|
| env, java_scroller_.obj());
|
| }
|
|
|
| -bool FlingAnimatorImpl::apply(double time,
|
| - blink::WebGestureCurveTarget* target) {
|
| +bool FlingCurveImplAndroid::Apply(double time_in_secs,
|
| + FlingCurveTarget* target) {
|
| if (!UpdatePosition())
|
| return false;
|
|
|
| @@ -107,11 +105,11 @@ bool FlingAnimatorImpl::apply(double time,
|
| last_position_ = current_position;
|
| float dpi_scale = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay()
|
| .device_scale_factor();
|
| - blink::WebFloatSize scroll_amount(diff.x() / dpi_scale,
|
| - diff.y() / dpi_scale);
|
| + gfx::PointF scroll_amount(diff.x() / dpi_scale,
|
| + diff.y() / dpi_scale);
|
|
|
| - float delta_time = time - last_time_;
|
| - last_time_ = time;
|
| + float delta_time = time_in_secs - last_time_;
|
| + last_time_ = time_in_secs;
|
|
|
| // Currently, the OverScroller only provides the velocity magnitude; use the
|
| // angle of the scroll delta to yield approximate x and y velocity components.
|
| @@ -127,22 +125,23 @@ bool FlingAnimatorImpl::apply(double time,
|
| }
|
| }
|
| last_velocity_ = current_velocity;
|
| - blink::WebFloatSize fling_velocity(current_velocity.x() / dpi_scale,
|
| + gfx::PointF fling_velocity(current_velocity.x() / dpi_scale,
|
| current_velocity.y() / dpi_scale);
|
| - target->notifyCurrentFlingVelocity(fling_velocity);
|
| + target->NotifyCurrentFlingVelocity(fling_velocity);
|
|
|
| // scrollBy() could delete this curve if the animation is over, so don't touch
|
| // any member variables after making that call.
|
| - target->scrollBy(scroll_amount);
|
| + target->ScrollBy(scroll_amount);
|
| return true;
|
| }
|
|
|
| -FlingAnimatorImpl* FlingAnimatorImpl::CreateAndroidGestureCurve(
|
| - const blink::WebFloatPoint& velocity,
|
| - const blink::WebSize&) {
|
| - FlingAnimatorImpl* gesture_curve = new FlingAnimatorImpl();
|
| +// static
|
| +FlingCurve* FlingCurve::Create(blink::WebGestureEvent::SourceDevice source,
|
| + const gfx::PointF& velocity,
|
| + const gfx::Point& cumulative_scroll) {
|
| + FlingCurveImplAndroid* gesture_curve = new FlingCurveImplAndroid();
|
| gesture_curve->StartFling(velocity);
|
| return gesture_curve;
|
| }
|
|
|
| -} // namespace webkit_glue
|
| +} // namespace content
|
|
|