OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_PACKET_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_PACKET_H_ | |
7 | |
8 #include "content/common/content_export.h" | |
9 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
10 | |
11 namespace content { | |
12 | |
13 // Acts as a transport container for gestures created by a particular event, be | |
14 // that synthetic or otherwise. | |
15 class CONTENT_EXPORT GestureEventPacket { | |
16 public: | |
17 enum GestureSource { | |
18 TOUCH_BEGIN, // The start of a new gesture sequence. | |
19 TOUCH, // Continuation of an existing gesture sequence. | |
20 TOUCH_TIMEOUT, // Timeout from an existing gesture sequence. | |
21 SYNTHETIC, // Non-touch-derived gesture sequence. | |
22 GESTURE_SOURCE_DEFAULT = TOUCH | |
23 }; | |
24 | |
25 GestureEventPacket(); | |
26 explicit GestureEventPacket(GestureSource source); | |
27 ~GestureEventPacket(); | |
28 | |
29 void Push(const blink::WebGestureEvent& gesture); | |
30 | |
31 const blink::WebGestureEvent& gesture(size_t i) const { return gestures_[i]; } | |
32 size_t gesture_count() const { return gesture_count_; } | |
33 GestureSource gesture_source() const { return gesture_source_; } | |
34 | |
35 // Utility methods for creating a packet from a particular event. | |
36 static GestureEventPacket FromTouch(const blink::WebTouchEvent& event); | |
37 static GestureEventPacket FromGesture(GestureSource source, | |
38 const blink::WebGestureEvent& event); | |
39 | |
40 private: | |
41 enum { kMaxGesturesPerTouch = 5 }; | |
tdresser
2014/01/23 16:32:43
Using an enum for a single constant isn't very com
jdduke (slow)
2014/01/23 22:52:34
I think the enum might be a bit more clear here as
| |
42 blink::WebGestureEvent gestures_[kMaxGesturesPerTouch]; | |
43 size_t gesture_count_; | |
44 GestureSource gesture_source_; | |
45 }; | |
46 | |
47 } // namespace content | |
48 | |
49 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_PACKET_H_ | |
OLD | NEW |