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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/gesture_event_queue.h
diff --git a/content/browser/renderer_host/input/gesture_event_queue.h b/content/browser/renderer_host/input/gesture_event_queue.h
new file mode 100644
index 0000000000000000000000000000000000000000..b22344433e6c068966628f29bcb245de1a195f3e
--- /dev/null
+++ b/content/browser/renderer_host/input/gesture_event_queue.h
@@ -0,0 +1,91 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_
+#define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_
+
+#include <deque>
+#include <queue>
+
+#include "base/callback.h"
+#include "content/browser/renderer_host/input/gesture_event_packet.h"
+#include "content/common/content_export.h"
+#include "content/port/common/input_event_ack_state.h"
+#include "third_party/WebKit/public/web/WebInputEvent.h"
+
+namespace content {
+
+class CONTENT_EXPORT GestureEventQueueClient {
+ public:
+ virtual void ForwardGestureEvent(const blink::WebGestureEvent&) = 0;
+ protected:
+ virtual ~GestureEventQueueClient() {}
+};
+
+// Handles dispatch of gestures created by the system. Gestures derived from
+// touches are forwarded or dropped depending on the disposition of the
+// generating touch sequence. Synthetic gestures will remain queued until all
+// preceding gestures have been dispatched, but will always be forwarded.
+class CONTENT_EXPORT GestureEventQueue {
+ public:
+ explicit GestureEventQueue(GestureEventQueueClient* client);
+ ~GestureEventQueue();
+
+ // To be called upon receipt of gesture-related events. In particular,
+ // |packet| contains [0, n] gestures that correspond to a given event. That
+ // event may be a touch, a touch timeout, or some other synthetic source.
+ // It is imperative that a single packet is received for *each* touch event,
+ // even those that did not produce a gesture.
+ void OnGestureEventPacket(const GestureEventPacket& packet);
+
+ // To be called upon receipt of *all* touch event acks.
+ void OnTouchEventAck(InputEventAckState ack_state);
+
+ private:
+ typedef base::Callback<void(const GestureEventPacket& packet)> PacketSender;
+
+ // Utility class for tracking gesture events and dispositions for a single
+ // gesture sequence. A single sequence corresponds to all gestures created
+ // between the first finger down and the last finger up.
+ class GestureSequence {
+ public:
+ GestureSequence();
+ ~GestureSequence();
+
+ void Push(const GestureEventPacket& packet);
+ void OnTouchEventAck(InputEventAckState ack_state,
+ const PacketSender& packet_handler);
+ bool IsGesturePrevented() const;
+ bool IsEmpty() const;
+
+ private:
+ std::queue<GestureEventPacket> sequence_;
+ enum GestureHandlingState {
+ PENDING,
+ ALLOWED,
+ ALWAYS_ALLOWED,
+ ALWAYS_PREVENTED
+ };
+ GestureHandlingState state_;
+ };
+
+ void SendPacket(const GestureEventPacket& packet);
+ void SendGesture(const blink::WebGestureEvent& gesture);
+ void CancelTapIfNecessary();
+ void CancelFlingIfNecessary();
+ GestureSequence& Head();
+ GestureSequence& Tail();
+
+ GestureEventQueueClient* client_;
+ PacketSender packet_sender_;
+ std::queue<GestureSequence> sequences_;
+ bool outstanding_tap_;
+ bool outstanding_fling_;
+
+ DISALLOW_COPY_AND_ASSIGN(GestureEventQueue);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_

Powered by Google App Engine
This is Rietveld 408576698