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

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: More 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 "content/browser/renderer_host/input/gesture_event_packet.h"
11 #include "content/common/content_export.h"
12 #include "content/port/common/input_event_ack_state.h"
13 #include "third_party/WebKit/public/web/WebInputEvent.h"
14
15 namespace content {
16
17 class CONTENT_EXPORT GestureEventQueueClient {
18 public:
19 virtual void ForwardGestureEvent(const blink::WebGestureEvent&) = 0;
20 protected:
21 virtual ~GestureEventQueueClient() {}
22 };
23
24 // Handles dispatch of gestures created by the system. Gestures derived from
25 // touches are forwarded or dropped depending on the disposition of the
26 // generating touch sequence. Synthetic gestures are dispatched immediately.
27 class CONTENT_EXPORT GestureEventQueue {
28 public:
29 explicit GestureEventQueue(GestureEventQueueClient* client);
30 ~GestureEventQueue();
31
32 // To be called upon receipt of gesture-related events. In particular,
33 // |packet| contains [0, n] gestures that correspond to a given event. That
34 // event may be a touch, a touch timeout, or some other synthetic source.
35 // It is imperative that a single packet is received for *each* touch event,
36 // even those that did not produce a gesture.
37 void OnGestureEventPacket(const GestureEventPacket& packet);
38
39 // To be called upon receipt of *all* touch event acks.
40 void OnTouchEventAck(InputEventAckState ack_state);
41
42 private:
43 // Utility class for tracking gesture events and dispositions for a single
44 // gesture sequence. A single sequence corresponds to all gestures created
45 // between the first finger down and the last finger up.
46 class GestureSequence {
47 public:
48 GestureSequence();
49 ~GestureSequence();
50
51 void Push(const GestureEventPacket& packet);
52 GestureEventPacket OnTouchEventAck(InputEventAckState ack_state);
53 bool IsGestureAllowed() const;
54 bool IsEmpty() const;
55
56 private:
57 std::deque<GestureEventPacket> sequence_;
58 InputEventAckState ack_state_;
59 };
60
61 void Forward(const GestureEventPacket& packet);
62 void Forward(const blink::WebGestureEvent& gesture);
63 void CancelTapIfNecessary();
64 void CancelFlingIfNecessary();
65 GestureSequence& Head();
66 GestureSequence& Tail();
67
68 GestureEventQueueClient* client_;
69 std::deque<GestureSequence> sequences_;
70 bool outstanding_tap_;
71 bool outstanding_fling_;
72
73 DISALLOW_COPY_AND_ASSIGN(GestureEventQueue);
74 };
75
76 } // namespace content
77
78 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698