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

Unified Diff: content/browser/renderer_host/touchscreen_tap_suppression_controller.h

Issue 12087140: Suppress touchscreen tap immediately after a GestureFlingCancel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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/touchscreen_tap_suppression_controller.h
diff --git a/content/browser/renderer_host/touchscreen_tap_suppression_controller.h b/content/browser/renderer_host/touchscreen_tap_suppression_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..dfe8e229a3e60b71da3fb514558c845eb480b54d
--- /dev/null
+++ b/content/browser/renderer_host/touchscreen_tap_suppression_controller.h
@@ -0,0 +1,81 @@
+// Copyright (c) 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_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_
rjkroege 2013/02/05 16:00:07 there is a lot of code here in-common with touchpa
+#define CONTENT_BROWSER_RENDERER_HOST_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_
+
+#include "base/time.h"
+#include "base/timer.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
+
+namespace content {
+
+class GestureEventFilter;
+class MockRenderWidgetHost;
+class RenderWidgetHostImpl;
+
+// Controls the suppression of touchscreen taps (rapid gesture tapdown/tap
+// sequences) immediately following the dispatch of a GestureFlingCancel event.
+// Only tapdown/tap's of sufficient speed and within a specified time window
+// after a GestureFlingCancel are suppressed.
+class TouchscreenTapSuppressionController {
+ public:
+ explicit TouchscreenTapSuppressionController(RenderWidgetHostImpl* rwhv,
+ GestureEventFilter* gef);
+ ~TouchscreenTapSuppressionController();
+
+ // Called on the dispatch of a GestureFlingCancel event.
+ void GestureFlingCancel(double cancel_time);
+
+ // Called on an ack of GestureFlingCancel event. |processed| is true when
+ // the GestureFlingCancel actually stopped a fling and therefore should
+ // suppress the forwarding of the following tap.
+ void GestureFlingCancelAck(bool processed);
+
+ // Called on a gesture tapdown. Returns true if the hosting RWHV should not
+ // continue with handling the gesture tapdown event at this time.
+ bool ShouldDeferGestureTapDown(const WebKit::WebGestureEvent& event);
+
+ // Called on the arrival of a gesture tap event. Returns true if the hosting
+ // RWHV should suppress the remaining gesture tap handling at this time.
+ bool ShouldSuppressGestureTap();
+
+ // Called on the arrival of a gesture tapcancel event. Returns true if the
+ // hosting RWHV should suppress the remaining gesture tapcancel handling at
+ // this time.
+ bool ShouldSuppressGestureTapCancel();
+
+ private:
+ friend class MockRenderWidgetHost;
+
+ enum State {
+ NOTHING,
+ GFC_IN_PROGRESS,
+ GTD_STASHED,
+ LAST_CANCEL_STOPPED_FLING,
+ };
+
+ // Invoked once the maximum time deemed a tap from a gesture tapdown event
+ // has expired. If the gesture tap has not yet arrived, indicates that the
+ // gesture tapdown/tap pair do not form a tap.
+ void GestureTapDownTimerExpired();
+
+ RenderWidgetHostImpl* render_widget_host_;
+ GestureEventFilter* gesture_event_filter_;
+
+ base::OneShotTimer<TouchscreenTapSuppressionController> tap_down_timer_;
+ WebKit::WebGestureEvent stashed_tap_down_;
+ State state_;
+
+ // TODO(rjkroege): During debugging, the event times did not prove reliable.
rjkroege 2013/02/05 16:00:07 You're adding this code. You get to take the TODO
mohsen 2013/02/06 16:13:06 Yep, Sorry :-) Done.
+ // Replace the use of base::TimeTicks with an accurate event time when they
+ // become available post http://crbug.com/119556.
+ base::TimeTicks fling_cancel_time_;
+
+ DISALLOW_COPY_AND_ASSIGN(TouchscreenTapSuppressionController);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698