Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: content/browser/renderer_host/input/gesture_event_queue.h

Issue 120513005: [Android] Perform eager gesture recognition on MotionEvents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ZoomManager Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include <queue>
10
11 #include "base/callback.h"
12 #include "content/browser/renderer_host/input/gesture_event_packet.h"
13 #include "content/common/content_export.h"
14 #include "content/port/common/input_event_ack_state.h"
15 #include "third_party/WebKit/public/web/WebInputEvent.h"
16
17 namespace content {
18
19 class CONTENT_EXPORT GestureEventQueueClient {
20 public:
21 virtual void ForwardGestureEvent(const blink::WebGestureEvent&) = 0;
22 protected:
23 virtual ~GestureEventQueueClient() {}
24 };
25
26 // Handles dispatch of gestures created by the system. Gestures derived from
27 // touches are forwarded or dropped depending on the disposition of the
28 // generating touch sequence. Synthetic gestures will remain queued until all
29 // preceding gestures have been dispatched, but will always be forwarded.
30 class CONTENT_EXPORT GestureEventQueue {
31 public:
32 explicit GestureEventQueue(GestureEventQueueClient* client);
33 ~GestureEventQueue();
34
35 // To be called upon receipt of gesture-related events. In particular,
36 // |packet| contains [0, n] gestures that correspond to a given event. That
37 // event may be a touch, a touch timeout, or some other synthetic source.
38 // It is imperative that a single packet is received for *each* touch event,
39 // even those that did not produce a gesture.
40 void OnGestureEventPacket(const GestureEventPacket& packet);
41
42 // To be called upon receipt of *all* touch event acks.
43 void OnTouchEventAck(InputEventAckState ack_state);
44
45 private:
46 typedef base::Callback<void(const GestureEventPacket& packet)> PacketSender;
47
48 // Utility class for tracking gesture events and dispositions for a single
49 // gesture sequence. A single sequence corresponds to all gestures created
50 // between the first finger down and the last finger up.
51 class GestureSequence {
52 public:
53 GestureSequence();
54 ~GestureSequence();
55
56 void Push(const GestureEventPacket& packet);
57 void OnTouchEventAck(InputEventAckState ack_state,
58 const PacketSender& packet_handler);
59 bool IsGesturePrevented() const;
60 bool IsEmpty() const;
61
62 private:
63 std::queue<GestureEventPacket> sequence_;
64 enum GestureHandlingState {
65 PENDING,
66 ALLOWED,
67 ALWAYS_ALLOWED,
68 ALWAYS_PREVENTED
69 };
70 GestureHandlingState state_;
71 };
72
73 void SendPacket(const GestureEventPacket& packet);
74 void SendGesture(const blink::WebGestureEvent& gesture);
75 void CancelTapIfNecessary();
76 void CancelFlingIfNecessary();
77 GestureSequence& Head();
78 GestureSequence& Tail();
79
80 GestureEventQueueClient* client_;
81 PacketSender packet_sender_;
82 std::queue<GestureSequence> sequences_;
83 bool outstanding_tap_;
84 bool outstanding_fling_;
85
86 DISALLOW_COPY_AND_ASSIGN(GestureEventQueue);
87 };
88
89 } // namespace content
90
91 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698