OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef WEBKIT_GLUE_FLING_ANIMATOR_IMPL_ANDROID_H_ | 5 #ifndef WEBKIT_GLUE_FLING_ANIMATOR_IMPL_ANDROID_H_ |
6 #define WEBKIT_GLUE_FLING_ANIMATOR_IMPL_ANDROID_H_ | 6 #define WEBKIT_GLUE_FLING_ANIMATOR_IMPL_ANDROID_H_ |
7 | 7 |
8 #include "base/android/scoped_java_ref.h" | 8 #include "base/android/scoped_java_ref.h" |
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebFlingAnimator.h" | |
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" | 9 #include "third_party/WebKit/Source/Platform/chromium/public/WebFloatPoint.h" |
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebGestureCurve.h" | 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebGestureCurve.h" |
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebPoint.h" | |
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" | |
14 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" |
15 #include "ui/gfx/point.h" | 12 #include "ui/gfx/point.h" |
| 13 #include "ui/gfx/point_f.h" |
16 | 14 |
17 namespace WebKit { | 15 namespace WebKit { |
18 class WebGestureCurveTarget; | 16 class WebGestureCurveTarget; |
19 } | 17 } |
20 | 18 |
21 namespace webkit_glue { | 19 namespace webkit_glue { |
22 | 20 |
23 // TODO(rjkroege): Remove WebFlingAnimator once all of the gesture curve | 21 class FlingAnimatorImpl : public WebKit::WebGestureCurve { |
24 // implementation has moved to Chromium. | |
25 class FlingAnimatorImpl : public WebKit::WebFlingAnimator, | |
26 public WebKit::WebGestureCurve { | |
27 public: | 22 public: |
28 FlingAnimatorImpl(); | 23 FlingAnimatorImpl(); |
29 virtual ~FlingAnimatorImpl(); | 24 virtual ~FlingAnimatorImpl(); |
30 | 25 |
31 static FlingAnimatorImpl* CreateAndroidGestureCurve( | 26 static FlingAnimatorImpl* CreateAndroidGestureCurve( |
32 const WebKit::WebFloatPoint& velocity, | 27 const WebKit::WebFloatPoint& velocity, |
33 const WebKit::WebSize&); | 28 const WebKit::WebSize&); |
34 | 29 |
35 // WebKit::WebFlingAnimator methods. | |
36 virtual void startFling(const WebKit::WebFloatPoint& velocity, | |
37 const WebKit::WebRect& range); | |
38 // Returns true if the animation is not yet finished. | |
39 virtual bool updatePosition(); | |
40 virtual WebKit::WebPoint getCurrentPosition(); | |
41 virtual void cancelFling(); | |
42 | |
43 // WebKit::WebGestureCurve methods. | |
44 virtual bool apply(double time, | 30 virtual bool apply(double time, |
45 WebKit::WebGestureCurveTarget* target); | 31 WebKit::WebGestureCurveTarget* target); |
46 private: | 32 private: |
| 33 void StartFling(const gfx::PointF& velocity); |
| 34 // Returns true if the animation is not yet finished. |
| 35 bool UpdatePosition(); |
| 36 gfx::Point GetCurrentPosition(); |
| 37 virtual void CancelFling(); |
| 38 |
47 bool is_active_; | 39 bool is_active_; |
48 | 40 |
49 // Java OverScroller instance and methods. | 41 // Java OverScroller instance and methods. |
50 base::android::ScopedJavaGlobalRef<jobject> java_scroller_; | 42 base::android::ScopedJavaGlobalRef<jobject> java_scroller_; |
51 jmethodID fling_method_id_; | 43 jmethodID fling_method_id_; |
52 jmethodID abort_method_id_; | 44 jmethodID abort_method_id_; |
53 jmethodID compute_method_id_; | 45 jmethodID compute_method_id_; |
54 jmethodID getX_method_id_; | 46 jmethodID getX_method_id_; |
55 jmethodID getY_method_id_; | 47 jmethodID getY_method_id_; |
56 | 48 |
57 gfx::Point last_position_; | 49 gfx::Point last_position_; |
58 | 50 |
59 DISALLOW_COPY_AND_ASSIGN(FlingAnimatorImpl); | 51 DISALLOW_COPY_AND_ASSIGN(FlingAnimatorImpl); |
60 }; | 52 }; |
61 | 53 |
62 } // namespace webkit_glue | 54 } // namespace webkit_glue |
63 | 55 |
64 #endif // WEBKIT_GLUE_FLING_ANIMATOR_IMPL_ANDROID_H_ | 56 #endif // WEBKIT_GLUE_FLING_ANIMATOR_IMPL_ANDROID_H_ |
OLD | NEW |