Chromium Code Reviews| Index: content/browser/renderer_host/input/touch_disposition_gesture_filter.h |
| diff --git a/content/browser/renderer_host/input/touch_disposition_gesture_filter.h b/content/browser/renderer_host/input/touch_disposition_gesture_filter.h |
| index f2acc3b47c1b1ab6001cd16fa4f1315264baa3a3..2d854af09af72d1071d0897da8b4671c4fe57149 100644 |
| --- a/content/browser/renderer_host/input/touch_disposition_gesture_filter.h |
| +++ b/content/browser/renderer_host/input/touch_disposition_gesture_filter.h |
| @@ -5,14 +5,26 @@ |
| #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_DISPOSITION_GESTURE_FILTER_H_ |
| #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_DISPOSITION_GESTURE_FILTER_H_ |
| -#include <deque> |
| +#include <map> |
| #include <queue> |
| +#include <set> |
| #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 { |
| + |
| +enum RequiredTouches { |
| + RT_NONE = 0, |
| + RT_START = 1 << 0, |
| + RT_MOVE = 1 << 1, |
| + RT_CURRENT = 1 << 2, |
| +}; |
| + |
| +} // namespace |
| + |
| namespace content { |
| // Interface with which the |TouchDispositionGestureFilter| forwards gestures |
| @@ -50,12 +62,46 @@ class CONTENT_EXPORT TouchDispositionGestureFilter { |
| bool IsEmpty() const; |
| private: |
| + struct DispositionHandlingInfo { |
|
jdduke (slow)
2014/02/13 16:53:06
It looks to me like all of the DispositionHandling
tdresser
2014/02/13 18:14:09
Done.
|
| + // A bitwise-OR of |RequiredTouches|. |
| + int required_touches; |
| + blink::WebInputEvent::Type antecedent_event_type; |
| + }; |
| + |
| + DispositionHandlingInfo Info(int required_touches) const { |
|
jdduke (slow)
2014/02/13 16:53:06
Let's use constructors for this instead of factory
tdresser
2014/02/13 18:14:09
Done.
|
| + DispositionHandlingInfo info; |
| + info.required_touches = required_touches; |
| + return info; |
| + } |
| + |
| + DispositionHandlingInfo Info( |
| + int required_touches, |
| + blink::WebInputEvent::Type antecedent_event_type) const { |
| + DispositionHandlingInfo info; |
| + info.required_touches = required_touches; |
| + info.antecedent_event_type = antecedent_event_type; |
| + return info; |
| + } |
| + |
| // 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, including gestures |
| // generated by timeouts from a statinoary finger. |
| class GestureSequence { |
| public: |
| + struct GestureHandlingState { |
| + GestureHandlingState() { |
|
jdduke (slow)
2014/02/13 16:53:06
Nit: Move constructor impl into .cc.
tdresser
2014/02/13 18:14:09
Done.
|
| + seen_ack = false; |
| + start_consumed = false; |
| + move_consumed = false; |
| + no_consumer = false; |
| + } |
| + bool seen_ack; |
| + bool start_consumed; |
| + bool move_consumed; |
| + bool no_consumer; |
| + }; |
| + |
| GestureSequence(); |
| ~GestureSequence(); |
| @@ -63,23 +109,30 @@ class CONTENT_EXPORT TouchDispositionGestureFilter { |
| void Pop(); |
| const GestureEventPacket& Front() const; |
| void UpdateState(InputEventAckState ack_state); |
|
jdduke (slow)
2014/02/13 16:53:06
Do we still need this method?
tdresser
2014/02/13 18:14:09
Yikes, nope. Good catch.
|
| - bool IsGesturePrevented() const; |
| + void UpdateState(GestureEventPacket::GestureSource gesture_source, |
| + InputEventAckState ack_state); |
| bool IsEmpty() const; |
| + const GestureHandlingState& state() const { return state_; }; |
| private: |
| std::queue<GestureEventPacket> packets_; |
| - enum GestureHandlingState { |
| - PENDING, // The sequence has yet to receive an ack. |
| - ALLOWED_UNTIL_PREVENTED, // Gestures in the sequence are allowed until |
| - // a source touch is preventDefault'ed. |
| - ALWAYS_ALLOWED, // All remaining sequence gestures are forwarded. |
| - ALWAYS_PREVENTED // All remaining sequence gestures are dropped. |
| - }; |
| GestureHandlingState state_; |
| }; |
| + bool IsGesturePrevented(blink::WebInputEvent::Type type, |
| + InputEventAckState current, |
| + const GestureSequence::GestureHandlingState& state) |
| + const; |
| + |
| + DispositionHandlingInfo GetDispositionHandlingInfo( |
| + blink::WebInputEvent::Type type) const; |
| + |
| void UpdateAndDispatchPackets(GestureSequence* sequence, |
| InputEventAckState ack_result); |
| - void SendPacket(const GestureEventPacket& packet); |
| + |
| + void FilterAndSendPacket(const GestureEventPacket& packet, |
| + const GestureSequence& sequence, |
| + InputEventAckState ack_state); |
| + |
| void SendGesture(const blink::WebGestureEvent& gesture); |
| void CancelTapIfNecessary(); |
| void CancelFlingIfNecessary(); |
| @@ -89,6 +142,9 @@ class CONTENT_EXPORT TouchDispositionGestureFilter { |
| TouchDispositionGestureFilterClient* client_; |
| std::queue<GestureSequence> sequences_; |
| + std::set<blink::WebInputEvent::Type> |
| + last_event_of_type_dropped_; |
| + |
| // Bookkeeping for inserting synthetic Gesture{Tap,Fling}Cancel events |
| // when necessary, e.g., GestureTapCancel when scrolling begins, or |
| // GestureFlingCancel when a user taps following a GestureFlingStart. |