| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_PACKET_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_PACKET_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_PACKET_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_PACKET_H_ |
| 7 | 7 |
| 8 #include "content/common/content_export.h" | 8 #include "content/common/content_export.h" |
| 9 #include "third_party/WebKit/public/web/WebInputEvent.h" | 9 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 // Acts as a transport container for gestures created (directly or indirectly) | 13 // Acts as a transport container for gestures created (directly or indirectly) |
| 14 // by a touch event. | 14 // by a touch event. |
| 15 class CONTENT_EXPORT GestureEventPacket { | 15 class CONTENT_EXPORT GestureEventPacket { |
| 16 public: | 16 public: |
| 17 enum GestureSource { | 17 enum GestureSource { |
| 18 INVALID = -1, // Used only for a default-constructed packet.. | 18 UNDEFINED = -1, // Used only for a default-constructed packet. |
| 19 TOUCH_BEGIN, // The start of a new gesture sequence. | 19 INVALID, // The source of the gesture was invalid. |
| 20 TOUCH, // Continuation of an existing gesture sequence. | 20 TOUCH_SEQUENCE_BEGIN, // The start of a new gesture sequence. |
| 21 TOUCH_TIMEOUT, // Timeout from an existing gesture sequence. | 21 TOUCH_SEQUENCE_END, // The end of gesture sequence. |
| 22 TOUCH_BEGIN, // A touch down occured during a gesture sequence. |
| 23 TOUCH_MOVE, // A touch move occured during a gesture sequence. |
| 24 TOUCH_END, // A touch up occured during a gesture sequence. |
| 25 TOUCH_TIMEOUT, // Timeout from an existing gesture sequence. |
| 22 }; | 26 }; |
| 23 | 27 |
| 24 GestureEventPacket(); | 28 GestureEventPacket(); |
| 25 ~GestureEventPacket(); | 29 ~GestureEventPacket(); |
| 26 | 30 |
| 27 // Factory methods for creating a packet from a particular event. | 31 // Factory methods for creating a packet from a particular event. |
| 28 static GestureEventPacket FromTouch(const blink::WebTouchEvent& event); | 32 static GestureEventPacket FromTouch(const blink::WebTouchEvent& event); |
| 29 static GestureEventPacket FromTouchTimeout( | 33 static GestureEventPacket FromTouchTimeout( |
| 30 const blink::WebGestureEvent& event); | 34 const blink::WebGestureEvent& event); |
| 31 | 35 |
| 32 void Push(const blink::WebGestureEvent& gesture); | 36 void Push(const blink::WebGestureEvent& gesture); |
| 33 | 37 |
| 34 const blink::WebGestureEvent& gesture(size_t i) const { return gestures_[i]; } | 38 const blink::WebGestureEvent& gesture(size_t i) const { return gestures_[i]; } |
| 35 size_t gesture_count() const { return gesture_count_; } | 39 size_t gesture_count() const { return gesture_count_; } |
| 36 GestureSource gesture_source() const { return gesture_source_; } | 40 GestureSource gesture_source() const { return gesture_source_; } |
| 37 | 41 |
| 38 private: | 42 private: |
| 39 explicit GestureEventPacket(GestureSource source); | 43 explicit GestureEventPacket(GestureSource source); |
| 40 | 44 |
| 41 enum { kMaxGesturesPerTouch = 5 }; | 45 enum { kMaxGesturesPerTouch = 5 }; |
| 42 blink::WebGestureEvent gestures_[kMaxGesturesPerTouch]; | 46 blink::WebGestureEvent gestures_[kMaxGesturesPerTouch]; |
| 43 size_t gesture_count_; | 47 size_t gesture_count_; |
| 44 GestureSource gesture_source_; | 48 GestureSource gesture_source_; |
| 45 }; | 49 }; |
| 46 | 50 |
| 47 } // namespace content | 51 } // namespace content |
| 48 | 52 |
| 49 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_PACKET_H_ | 53 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_PACKET_H_ |
| OLD | NEW |