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

Unified Diff: ui/events/gesture_detection/touch_disposition_gesture_filter.h

Issue 182383007: Make the ContentGestureProvider a ui::FilteredGestureProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test fix Created 6 years, 10 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: ui/events/gesture_detection/touch_disposition_gesture_filter.h
diff --git a/ui/events/gesture_detection/touch_disposition_gesture_filter.h b/ui/events/gesture_detection/touch_disposition_gesture_filter.h
index 7721fe11c28009d90887990303b76cae219670a6..334d5caceddee3ad022b7797e9a2d108c7b0c5d3 100644
--- a/ui/events/gesture_detection/touch_disposition_gesture_filter.h
+++ b/ui/events/gesture_detection/touch_disposition_gesture_filter.h
@@ -7,6 +7,7 @@
#include <queue>
+#include "ui/events/event_constants.h"
#include "ui/events/gesture_detection/bitset_32.h"
#include "ui/events/gesture_detection/gesture_detection_export.h"
#include "ui/events/gesture_detection/gesture_event_data_packet.h"
@@ -41,64 +42,42 @@ class GESTURE_DETECTION_EXPORT TouchDispositionGestureFilter {
};
PacketResult OnGesturePacket(const GestureEventDataPacket& packet);
- // TODO(jdduke): Consider adoption of ui::EventResult.
- enum TouchEventAck {
- CONSUMED,
- NOT_CONSUMED,
- NO_CONSUMER_EXISTS
- };
// To be called upon receipt of *all* touch event acks.
- void OnTouchEventAck(TouchEventAck ack_result);
+ void OnTouchEventAck(bool event_consumed);
// Whether there are any active gesture sequences still queued in the filter.
bool IsEmpty() const;
private:
- // Utility class for tracking gesture events and dispositions for a single
- // gesture sequence. A single sequence corresponds to all gestures created
+ // A single GestureSequence 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 {
+ typedef std::queue<GestureEventDataPacket> GestureSequence;
+
+ // Utility class for maintaining the touch and gesture handling state for the
+ // current gesture sequence.
+ class GestureHandlingState {
public:
- struct GestureHandlingState {
- GestureHandlingState();
- // True iff the sequence has had at least one touch acked.
- bool seen_ack;
- // True iff the sequence has had any touch down event consumed.
- bool start_consumed;
- // True iff the first ack received for this sequence reported that no
- // consumer exists.
- bool no_consumer;
- };
-
- GestureSequence();
- ~GestureSequence();
-
- void Push(const GestureEventDataPacket& packet);
- void Pop();
- const GestureEventDataPacket& Front() const;
- void UpdateState(GestureEventDataPacket::GestureSource gesture_source,
- TouchEventAck ack_state);
- bool IsEmpty() const;
- const GestureHandlingState& state() const { return state_; };
+ GestureHandlingState();
- private:
- std::queue<GestureEventDataPacket> packets_;
- GestureHandlingState state_;
- };
- bool IsGesturePrevented(GestureEventType type,
- TouchEventAck current,
- const GestureSequence::GestureHandlingState& state)
- const;
+ // To be called on each touch event ack.
+ void OnTouchEventAck(bool event_consumed, bool is_touch_start_event);
- void UpdateAndDispatchPackets(GestureSequence* sequence,
- TouchEventAck ack_result);
+ // Returns true iff the gesture should be dropped.
+ bool Filter(GestureEventType type);
- void FilterAndSendPacket(
- const GestureEventDataPacket& packet,
- const GestureSequence::GestureHandlingState& sequence_state,
- TouchEventAck ack_state);
+ private:
+ // True iff the sequence has had any touch down event consumed.
+ bool start_touch_consumed_;
+ // True iff the most recently ack'ed touch event was consumed.
+ bool current_touch_consumed_;
+ // If the previous gesture of a given type was dropped instead of being
+ // dispatched, its type will occur in this set. Cleared when a new touch
tdresser 2014/03/03 19:44:32 Update comment. (No longer cleared)
jdduke (slow) 2014/03/03 22:33:17 Done.
+ // sequence begins to be acked.
+ BitSet32 last_gesture_of_type_dropped_;
tdresser 2014/03/03 19:44:32 Why does the last_gesture_of_type_dropped_ need to
jdduke (slow) 2014/03/03 22:33:17 Are you thinking of the double-tap case? I don't s
tdresser 2014/03/04 13:48:35 You're right, this is fine. I was forgetting that
+ };
+ void FilterAndSendPacket(const GestureEventDataPacket& packet);
void SendGesture(const GestureEventData& gesture);
void CancelTapIfNecessary();
void CancelFlingIfNecessary();
@@ -109,10 +88,7 @@ class GESTURE_DETECTION_EXPORT TouchDispositionGestureFilter {
TouchDispositionGestureFilterClient* client_;
std::queue<GestureSequence> sequences_;
- // If the previous gesture of a given type was dropped instead of being
- // dispatched, its type will occur in this set. Cleared when a new touch
- // sequence begins to be acked.
- BitSet32 last_event_of_type_dropped_;
+ GestureHandlingState state_;
// Bookkeeping for inserting synthetic Gesture{Tap,Fling}Cancel events
// when necessary, e.g., GestureTapCancel when scrolling begins, or

Powered by Google App Engine
This is Rietveld 408576698