Index: content/browser/renderer_host/input/motion_event_android.h |
diff --git a/content/browser/renderer_host/input/motion_event_android.h b/content/browser/renderer_host/input/motion_event_android.h |
index 15cac96ff98938fc8864e5de7cd45b68e211ab0b..88096839f26bce919ab59b65a228bc933223c7a7 100644 |
--- a/content/browser/renderer_host/input/motion_event_android.h |
+++ b/content/browser/renderer_host/input/motion_event_android.h |
@@ -10,71 +10,73 @@ |
#include "base/android/scoped_java_ref.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/time/time.h" |
+#include "ui/events/gesture_detection/motion_event.h" |
namespace content { |
-// Utility wrapper class for Android's android.view.MotionEvent. |
-class MotionEventAndroid { |
+// Implementation of ui::MotionEvent wrapping a native Android MotionEvent. |
+class MotionEventAndroid : public ui::MotionEvent { |
public: |
- // Note: These constants are taken directly from android.view.MotionEvent. |
- // Do NOT under any circumstances change these values. |
- enum Action { |
- ACTION_DOWN = 0, |
- ACTION_UP = 1, |
- ACTION_MOVE = 2, |
- ACTION_CANCEL = 3, |
- // Purposefully removed, as there is no analogous action in Chromium. |
- // ACTION_OUTSIDE = 4, |
- ACTION_POINTER_DOWN = 5, |
- ACTION_POINTER_UP = 6 |
- }; |
- |
- explicit MotionEventAndroid(jobject event); |
- ~MotionEventAndroid(); |
- |
- Action GetActionMasked() const; |
- size_t GetActionIndex() const; |
- size_t GetPointerCount() const; |
- int GetPointerId(size_t pointer_index) const; |
+ MotionEventAndroid(JNIEnv* env, jobject event, bool recycle); |
+ virtual ~MotionEventAndroid(); |
+ |
+ // ui::MotionEvent methods. |
+ virtual Action GetAction() const OVERRIDE; |
+ virtual int GetActionIndex() const OVERRIDE; |
+ virtual size_t GetPointerCount() const OVERRIDE; |
+ virtual int GetPointerId(size_t pointer_index) const OVERRIDE; |
+ virtual float GetX(size_t pointer_index) const OVERRIDE; |
+ virtual float GetY(size_t pointer_index) const OVERRIDE; |
+ virtual float GetTouchMajor(size_t pointer_index) const OVERRIDE; |
+ virtual base::TimeTicks GetEventTime() const OVERRIDE; |
+ virtual size_t GetHistorySize() const OVERRIDE; |
+ virtual base::TimeTicks GetHistoricalEventTime( |
+ size_t historical_index) const OVERRIDE; |
+ virtual float GetHistoricalTouchMajor( |
+ size_t pointer_index, |
+ size_t historical_index) const OVERRIDE; |
+ virtual float GetHistoricalX( |
+ size_t pointer_index, |
+ size_t historical_index) const OVERRIDE; |
+ virtual float GetHistoricalY( |
+ size_t pointer_index, |
+ size_t historical_index) const OVERRIDE; |
+ virtual scoped_ptr<MotionEvent> Clone() const OVERRIDE; |
+ virtual scoped_ptr<MotionEvent> Cancel() const OVERRIDE; |
+ |
+ // Additional Android MotionEvent methods. |
float GetPressure() const { return GetPressure(0); } |
float GetPressure(size_t pointer_index) const; |
- float GetX() const { return GetX(0); } |
- float GetY() const { return GetY(0); } |
- float GetX(size_t pointer_index) const; |
- float GetY(size_t pointer_index) const; |
- float GetRawX() const { return GetX(); } |
- float GetRawY() const { return GetY(); } |
- float GetTouchMajor() const { return GetTouchMajor(0); } |
- float GetTouchMajor(size_t pointer_index) const; |
float GetTouchMinor() const { return GetTouchMinor(0); } |
float GetTouchMinor(size_t pointer_index) const; |
float GetOrientation() const; |
- base::TimeTicks GetEventTime() const; |
base::TimeTicks GetDownTime() const; |
- size_t GetHistorySize() const; |
- base::TimeTicks GetHistoricalEventTime(size_t historical_index) const; |
- float GetHistoricalTouchMajor(size_t pointer_index, |
- size_t historical_index) const; |
- float GetHistoricalX(size_t pointer_index, size_t historical_index) const; |
- float GetHistoricalY(size_t pointer_index, size_t historical_index) const; |
- |
static bool RegisterMotionEventAndroid(JNIEnv* env); |
- static scoped_ptr<MotionEventAndroid> Obtain(const MotionEventAndroid& event); |
- static scoped_ptr<MotionEventAndroid> Obtain(base::TimeTicks down_time, |
- base::TimeTicks event_time, |
- Action action, |
- float x, |
- float y); |
+ static base::android::ScopedJavaLocalRef<jobject> Obtain( |
+ const MotionEventAndroid& event); |
+ static base::android::ScopedJavaLocalRef<jobject> Obtain( |
+ base::TimeTicks down_time, |
+ base::TimeTicks event_time, |
+ Action action, |
+ float x, |
+ float y); |
private: |
- MotionEventAndroid(const base::android::ScopedJavaLocalRef<jobject>& event, |
- bool should_recycle); |
+ MotionEventAndroid(const MotionEventAndroid& other, bool clone); |
// The Java reference to the underlying MotionEvent. |
base::android::ScopedJavaGlobalRef<jobject> event_; |
+ base::TimeTicks cached_time_; |
+ Action cached_action_; |
+ size_t cached_pointer_count_; |
+ size_t cached_history_size_; |
+ int cached_action_index_; |
+ float cached_x_; |
+ float cached_y_; |
+ |
// Whether |event_| should be recycled on destruction. This will only be true |
// for those events generated via |Obtain(...)|. |
bool should_recycle_; |