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

Unified Diff: content/browser/renderer_host/input/touch_disposition_gesture_filter.h

Issue 156783006: Consuming a touch move prevents only the next scroll update. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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: 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..42f5008cdfd86ed20d5d98de1d33da553d483615 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,31 @@ class CONTENT_EXPORT TouchDispositionGestureFilter {
bool IsEmpty() const;
private:
+ struct DispositionHandlingInfo {
+ // RequireTouches, potentially |'ed together. // TODO - fix comment.
+ int required_touches;
+ blink::WebInputEvent::Type antecedent_event_type;
+ };
+
// 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() {
+ 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 +94,36 @@ class CONTENT_EXPORT TouchDispositionGestureFilter {
void Pop();
const GestureEventPacket& Front() const;
void UpdateState(InputEventAckState ack_state);
- 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;
+
+ void SetupDispositionHandlingTable();
+ void AddDispositionHandlingInfo(blink::WebInputEvent::Type type,
+ int required_touches);
+
+ void AddDispositionHandlingInfo(
+ blink::WebInputEvent::Type type,
+ int required_touches,
+ blink::WebInputEvent::Type antecedent_event_type);
+
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,12 +133,17 @@ class CONTENT_EXPORT TouchDispositionGestureFilter {
TouchDispositionGestureFilterClient* client_;
std::queue<GestureSequence> sequences_;
+ typedef std::map<blink::WebInputEvent::Type, DispositionHandlingInfo>
+ DispositionHandlingTable;
+ DispositionHandlingTable disposition_handling_table_;
+ 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.
bool needs_tap_ending_event_;
bool needs_fling_ending_event_;
-
DISALLOW_COPY_AND_ASSIGN(TouchDispositionGestureFilter);
};

Powered by Google App Engine
This is Rietveld 408576698