Revert of Output closure-compiled JavaScript files (patchset #10 id:180001 of https...
[chromium-blink-merge.git] / ui / events / gesture_detection / gesture_event_data_packet.h
blob25424b60e4825daaf7ae7b42ccf574129a0b81ee
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
3 // found in the LICENSE file.
5 #ifndef UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_
6 #define UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_
8 #include "base/containers/stack_container.h"
9 #include "ui/events/gesture_detection/gesture_detection_export.h"
10 #include "ui/events/gesture_detection/gesture_event_data.h"
12 namespace ui {
14 class MotionEvent;
16 // Acts as a transport container for gestures created (directly or indirectly)
17 // by a touch event.
18 class GESTURE_DETECTION_EXPORT GestureEventDataPacket {
19 public:
20 enum GestureSource {
21 UNDEFINED = -1, // Used only for a default-constructed packet.
22 INVALID, // The source of the gesture was invalid.
23 TOUCH_SEQUENCE_START, // The start of a new gesture sequence.
24 TOUCH_SEQUENCE_END, // The end of a gesture sequence.
25 TOUCH_SEQUENCE_CANCEL, // The gesture sequence was cancelled.
26 TOUCH_START, // A touch down occured during a gesture sequence.
27 TOUCH_MOVE, // A touch move occured during a gesture sequence.
28 TOUCH_END, // A touch up occured during a gesture sequence.
29 TOUCH_TIMEOUT, // Timeout from an existing gesture sequence.
32 enum class AckState {
33 PENDING,
34 CONSUMED,
35 UNCONSUMED,
38 GestureEventDataPacket();
39 GestureEventDataPacket(const GestureEventDataPacket& other);
40 ~GestureEventDataPacket();
41 GestureEventDataPacket& operator=(const GestureEventDataPacket& other);
43 // Factory methods for creating a packet from a particular event.
44 static GestureEventDataPacket FromTouch(const ui::MotionEvent& touch);
45 static GestureEventDataPacket FromTouchTimeout(
46 const GestureEventData& gesture);
48 void Push(const GestureEventData& gesture);
50 const base::TimeTicks& timestamp() const { return timestamp_; }
51 const GestureEventData& gesture(size_t i) const { return gestures_[i]; }
52 size_t gesture_count() const { return gestures_->size(); }
53 GestureSource gesture_source() const { return gesture_source_; }
54 const gfx::PointF& touch_location() const { return touch_location_; }
55 const gfx::PointF& raw_touch_location() const { return raw_touch_location_; }
57 // We store the ack with the packet until the packet reaches the
58 // head of the queue, and then we handle the ack.
59 void Ack(bool event_consumed);
60 AckState ack_state() { return ack_state_; }
62 private:
63 GestureEventDataPacket(base::TimeTicks timestamp,
64 GestureSource source,
65 const gfx::PointF& touch_location,
66 const gfx::PointF& raw_touch_location);
68 enum { kTypicalMaxGesturesPerTouch = 5 };
69 base::TimeTicks timestamp_;
70 base::StackVector<GestureEventData, kTypicalMaxGesturesPerTouch> gestures_;
71 gfx::PointF touch_location_;
72 gfx::PointF raw_touch_location_;
73 GestureSource gesture_source_;
74 AckState ack_state_;
77 } // namespace ui
79 #endif // UI_EVENTS_GESTURE_DETECTION_GESTURE_EVENT_DATA_PACKET_H_