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

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: Code cleanup 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
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 {
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 private:
44 typedef base::Callback<void(const GestureEventPacket& packet)> PacketSender;
tdresser 2014/01/17 15:24:17 I'm not super clear why you're adding a layer of a
jdduke (slow) 2014/01/17 19:38:04 Well, I'd like the GestureSequence to perform disp
tdresser 2014/01/17 19:43:34 Sounds reasonable.
45
46 // Utility class for tracking gesture events and dispositions for a single
47 // gesture sequence. A single sequence corresponds to all gestures created
48 // between the first finger down and the last finger up.
49 class GestureSequence {
50 public:
51 GestureSequence();
52 ~GestureSequence();
53
54 void Push(const GestureEventPacket& packet);
55 void OnTouchEventAck(InputEventAckState ack_state,
56 const PacketSender& packet_handler);
57 bool IsGestureAllowed() const;
58 bool IsEmpty() const;
59
60 private:
61 std::deque<GestureEventPacket> sequence_;
62 InputEventAckState ack_state_;
63 };
64
65 void SendPacket(const GestureEventPacket& packet);
66 void SendGesture(const blink::WebGestureEvent& gesture);
67 void CancelTapIfNecessary();
68 void CancelFlingIfNecessary();
69 GestureSequence& Head();
70 GestureSequence& Tail();
71
72 GestureEventQueueClient* client_;
73 PacketSender packet_sender_;
74 std::deque<GestureSequence> sequences_;
75 bool outstanding_tap_;
76 bool outstanding_fling_;
77
78 DISALLOW_COPY_AND_ASSIGN(GestureEventQueue);
79 };
80
81 } // namespace content
82
83 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698