Chromium Code Reviews| 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..3039d0e684272b50683ce62b82171e6054e3c1ed |
| --- /dev/null |
| +++ b/content/browser/renderer_host/input/gesture_event_queue.h |
| @@ -0,0 +1,89 @@ |
| +// 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 "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 are dispatched immediately. |
|
tdresser
2014/01/23 16:32:43
Synthetic gestures are currently not always dispat
jdduke (slow)
2014/01/23 22:52:34
Good catch.
|
| +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::deque<GestureEventPacket> sequence_; |
|
tdresser
2014/01/23 16:32:43
This should just be an std::queue, shouldn't it? U
jdduke (slow)
2014/01/23 22:52:34
Done.
|
| + enum GestureHandlingState { |
| + PENDING, |
|
Rick Byers
2014/01/23 20:45:29
Please add a brief comment describing the semantic
jdduke (slow)
2014/01/24 05:34:40
Done.
|
| + 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::deque<GestureSequence> sequences_; |
|
tdresser
2014/01/23 16:32:43
std::queue?
jdduke (slow)
2014/01/23 22:52:34
Done.
|
| + bool outstanding_tap_; |
|
Rick Byers
2014/01/23 20:45:29
Can you add a comment for these two making it clea
jdduke (slow)
2014/01/24 05:34:40
bool fantastic_fling_? ;) Done.
|
| + bool outstanding_fling_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GestureEventQueue); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_ |