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..84f297a176eba86b9d9d26f0f6e1cfd7ab650cd2 |
| --- /dev/null |
| +++ b/content/browser/renderer_host/input/gesture_event_queue.h |
| @@ -0,0 +1,83 @@ |
| +// 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. |
| +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; |
|
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.
|
| + |
| + // 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 IsGestureAllowed() const; |
| + bool IsEmpty() const; |
| + |
| + private: |
| + std::deque<GestureEventPacket> sequence_; |
| + InputEventAckState ack_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_; |
| + bool outstanding_tap_; |
| + bool outstanding_fling_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(GestureEventQueue); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_ |