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_QUEUE_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_ | |
7 | |
8 #include <deque> | |
9 | |
10 #include "base/callback.h" | |
11 #include "content/browser/renderer_host/input/gesture_event_packet.h" | |
12 #include "content/common/content_export.h" | |
13 #include "content/port/common/input_event_ack_state.h" | |
14 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
15 | |
16 namespace content { | |
17 | |
18 class CONTENT_EXPORT GestureEventQueueClient { | |
19 public: | |
20 virtual void ForwardGestureEvent(const blink::WebGestureEvent&) = 0; | |
21 protected: | |
22 virtual ~GestureEventQueueClient() {} | |
23 }; | |
24 | |
25 // Handles dispatch of gestures created by the system. Gestures derived from | |
26 // touches are forwarded or dropped depending on the disposition of the | |
27 // generating touch sequence. Synthetic gestures are dispatched immediately. | |
28 class CONTENT_EXPORT GestureEventQueue { | |
Rick Byers
2014/01/21 20:10:10
I think we need either more discussion of the desi
jdduke (slow)
2014/01/21 20:52:38
aelias@ and I talked about an eager GR a *long* ti
| |
29 public: | |
30 explicit GestureEventQueue(GestureEventQueueClient* client); | |
31 ~GestureEventQueue(); | |
32 | |
33 // To be called upon receipt of gesture-related events. In particular, | |
34 // |packet| contains [0, n] gestures that correspond to a given event. That | |
35 // event may be a touch, a touch timeout, or some other synthetic source. | |
36 // It is imperative that a single packet is received for *each* touch event, | |
37 // even those that did not produce a gesture. | |
38 void OnGestureEventPacket(const GestureEventPacket& packet); | |
39 | |
40 // To be called upon receipt of *all* touch event acks. | |
41 void OnTouchEventAck(InputEventAckState ack_state); | |
42 | |
43 // Determine the most restrictive touch handling state given the current touch | |
44 // sequence disposition and a new touch disposition. | |
45 static InputEventAckState GetMostRestrictiveState(InputEventAckState ack_old, | |
46 InputEventAckState ack_new); | |
47 | |
48 private: | |
49 typedef base::Callback<void(const GestureEventPacket& packet)> PacketSender; | |
50 | |
51 // Utility class for tracking gesture events and dispositions for a single | |
52 // gesture sequence. A single sequence corresponds to all gestures created | |
53 // between the first finger down and the last finger up. | |
54 class GestureSequence { | |
55 public: | |
56 GestureSequence(); | |
57 ~GestureSequence(); | |
58 | |
59 void Push(const GestureEventPacket& packet); | |
60 void OnTouchEventAck(InputEventAckState ack_state, | |
61 const PacketSender& packet_handler); | |
62 bool IsGestureAllowed() const; | |
63 bool IsEmpty() const; | |
64 | |
65 private: | |
66 std::deque<GestureEventPacket> sequence_; | |
67 InputEventAckState ack_state_; | |
Rick Byers
2014/01/21 20:10:10
maybe call this 'aggregate_ack_state' or something
jdduke (slow)
2014/01/21 20:52:38
As noted below, using the ack here is just bad on
| |
68 }; | |
69 | |
70 void SendPacket(const GestureEventPacket& packet); | |
71 void SendGesture(const blink::WebGestureEvent& gesture); | |
72 void CancelTapIfNecessary(); | |
73 void CancelFlingIfNecessary(); | |
74 GestureSequence& Head(); | |
75 GestureSequence& Tail(); | |
76 | |
77 GestureEventQueueClient* client_; | |
78 PacketSender packet_sender_; | |
79 std::deque<GestureSequence> sequences_; | |
80 bool outstanding_tap_; | |
81 bool outstanding_fling_; | |
82 | |
83 DISALLOW_COPY_AND_ASSIGN(GestureEventQueue); | |
84 }; | |
85 | |
86 } // namespace content | |
87 | |
88 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_ | |
OLD | NEW |