summaryrefslogtreecommitdiffstats
path: root/webkit/glue/fling_animator_impl_android.cc
diff options
context:
space:
mode:
authorrjkroege@chromium.org <rjkroege@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-20 17:25:25 +0000
committerrjkroege@chromium.org <rjkroege@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-20 17:25:25 +0000
commitc6bc596128ab251185edf80b074065ae733faf1a (patch)
tree74c7916c88fdf0dd4b02b69f74386bb17db87875 /webkit/glue/fling_animator_impl_android.cc
parent28ea7319d47a0dbf87860641d6fc70ae3464b50b (diff)
downloadchromium_src-c6bc596128ab251185edf80b074065ae733faf1a.zip
chromium_src-c6bc596128ab251185edf80b074065ae733faf1a.tar.gz
chromium_src-c6bc596128ab251185edf80b074065ae733faf1a.tar.bz2
Extend FlingAnimatorImpl instances to serve as WebKit::WebGestureCurve's
Currently, WebFlingAnimatorToGestureCurveAdapter wraps a WebFlingAnimator instance provided by FlingAnimatorImpl into a PlatformGestureCurve. The functionality previously provided by a PlatformGestureCurve is now provided by code resident in Chromium that implements WebGestureCurve. This change adds WebFlingAnimatorToGestureCurveAdapter functionality to FlingAnimatorImpl so that a FlingAnimatorImpl also implements a WebGestureCurve and can be used as one on the Android platform. BUG=157656 Review URL: https://chromiumcodereview.appspot.com/11368113 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168821 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/fling_animator_impl_android.cc')
-rw-r--r--webkit/glue/fling_animator_impl_android.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/webkit/glue/fling_animator_impl_android.cc b/webkit/glue/fling_animator_impl_android.cc
index 56e7e8b..dfe1ada4 100644
--- a/webkit/glue/fling_animator_impl_android.cc
+++ b/webkit/glue/fling_animator_impl_android.cc
@@ -7,6 +7,8 @@
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
#include "base/logging.h"
+#include "third_party/WebKit/Source/Platform/chromium/public/WebGestureCurveTarget.h"
+#include "ui/gfx/vector2d.h"
using base::android::AttachCurrentThread;
using base::android::CheckException;
@@ -98,4 +100,25 @@ WebKit::WebPoint FlingAnimatorImpl::getCurrentPosition()
return position;
}
+bool FlingAnimatorImpl::apply(double time,
+ WebKit::WebGestureCurveTarget* target) {
+ if (!updatePosition())
+ return false;
+
+ gfx::Point current_position = getCurrentPosition();
+ gfx::Vector2d diff(current_position - last_position_);
+ WebKit::WebPoint scroll_amount(diff.x(), diff.y());
+ target->scrollBy(scroll_amount);
+ last_position_ = current_position;
+ return true;
+}
+
+FlingAnimatorImpl* FlingAnimatorImpl::CreateAndroidGestureCurve(
+ const WebKit::WebFloatPoint& velocity,
+ const WebKit::WebSize&) {
+ FlingAnimatorImpl* gesture_curve = new FlingAnimatorImpl();
+ gesture_curve->startFling(velocity, WebKit::WebRect());
+ return gesture_curve;
+}
+
} // namespace webkit_glue