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

Unified Diff: content/browser/renderer_host/touchscreen_tap_suppression_controller_aura.cc

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_aura.cc
diff --git a/content/browser/renderer_host/touchscreen_tap_suppression_controller_aura.cc b/content/browser/renderer_host/touchscreen_tap_suppression_controller_aura.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fb27086a58b9c727a63d85a85ee0a38b2987b390
--- /dev/null
+++ b/content/browser/renderer_host/touchscreen_tap_suppression_controller_aura.cc
@@ -0,0 +1,161 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
rjkroege 2013/02/05 16:00:07 you need this on windows and aura. So it is misnam
mohsen 2013/02/06 16:13:06 Isn't it the case for touchpad TSC, too? Don't we
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/renderer_host/touchscreen_tap_suppression_controller.h"
+
+#include "base/command_line.h"
+#include "base/debug/trace_event.h"
+#include "base/logging.h"
+#include "base/string_number_conversions.h"
+#include "content/browser/renderer_host/gesture_event_filter.h"
+#include "content/browser/renderer_host/render_widget_host_impl.h"
+#include "content/public/common/content_switches.h"
+#include "ui/base/gestures/gesture_configuration.h"
+
+namespace content {
+
+TouchscreenTapSuppressionController::TouchscreenTapSuppressionController(
+ RenderWidgetHostImpl* rwhv,
+ GestureEventFilter* gef)
+ : render_widget_host_(rwhv),
+ gesture_event_filter_(gef),
+ state_(TouchscreenTapSuppressionController::NOTHING) {
+}
+
+TouchscreenTapSuppressionController::~TouchscreenTapSuppressionController() { }
+
+void TouchscreenTapSuppressionController::GestureFlingCancel(
+ double cancel_time) {
+ switch (state_) {
+ case NOTHING:
+ case GFC_IN_PROGRESS:
+ case LAST_CANCEL_STOPPED_FLING:
+ state_ = GFC_IN_PROGRESS;
+ break;
+ case GTD_STASHED:
+ break;
+ }
+}
+
+void TouchscreenTapSuppressionController::GestureFlingCancelAck(
+ bool processed) {
+ switch (state_) {
+ case NOTHING:
+ NOTREACHED() << "GFC_Ack without a GFC";
+ break;
+ case GFC_IN_PROGRESS:
+ if (processed)
+ fling_cancel_time_ = base::TimeTicks::Now();
+ state_ = LAST_CANCEL_STOPPED_FLING;
+ break;
+ case GTD_STASHED:
+ if (!processed) {
+ TRACE_EVENT0(
+ "browser",
+ "TouchscreenTapSuppressionController::GestureFlingCancelAck");
+ tap_down_timer_.Stop();
+ gesture_event_filter_->ForwardGestureEventForDeferral(
+ stashed_tap_down_);
+ state_ = NOTHING;
+ } // Else waiting for the timer to release the mouse event.
+ break;
+ case LAST_CANCEL_STOPPED_FLING:
+ break;
+ }
+}
+
+bool TouchscreenTapSuppressionController::ShouldDeferGestureTapDown(
+ const WebKit::WebGestureEvent& event) {
+ switch (state_) {
+ case NOTHING:
+ return false;
+ case GFC_IN_PROGRESS:
+ tap_down_timer_.Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(
+ ui::GestureConfiguration::semi_long_press_time_in_seconds() *
+ 1000),
+ this,
+ &TouchscreenTapSuppressionController::GestureTapDownTimerExpired);
+ stashed_tap_down_ = event;
+ state_ = GTD_STASHED;
+ return true;
+ case GTD_STASHED:
+ NOTREACHED() << "GestureTapDown on GTD_STASHED state";
+ state_ = NOTHING;
+ return false;
+ case LAST_CANCEL_STOPPED_FLING:
+ if ((base::TimeTicks::Now() - fling_cancel_time_).InMilliseconds()
+ < ui::GestureConfiguration::fling_max_cancel_to_down_time_in_ms()) {
+ state_ = GTD_STASHED;
+ tap_down_timer_.Start(
+ FROM_HERE,
+ base::TimeDelta::FromMilliseconds(
+ ui::GestureConfiguration::semi_long_press_time_in_seconds() *
+ 1000),
+ this,
+ &TouchscreenTapSuppressionController::GestureTapDownTimerExpired);
+ stashed_tap_down_ = event;
+ return true;
+ }
+ state_ = NOTHING;
+ return false;
+ }
+ NOTREACHED() << "Invalid state";
+ return false;
+}
+
+bool TouchscreenTapSuppressionController::ShouldSuppressGestureTap() {
+ switch (state_) {
+ case NOTHING:
+ case GFC_IN_PROGRESS:
+ return false;
+ case GTD_STASHED:
+ tap_down_timer_.Stop();
+ state_ = NOTHING;
+ return true;
+ case LAST_CANCEL_STOPPED_FLING:
+ NOTREACHED() << "Invalid GestureTap on LAST_CANCEL_STOPPED_FLING state";
+ return false;
+ }
+ NOTREACHED() << "Invalid state";
+ return false;
+}
+
+bool TouchscreenTapSuppressionController::ShouldSuppressGestureTapCancel() {
+ switch (state_) {
+ case NOTHING:
+ case GFC_IN_PROGRESS:
+ return false;
+ case GTD_STASHED:
+ tap_down_timer_.Stop();
+ state_ = NOTHING;
+ return true;
+ case LAST_CANCEL_STOPPED_FLING:
+ NOTREACHED() << "GestureTapCancel on LAST_CANCEL_STOPPED_FLING state";
+ return false;
+ }
+ NOTREACHED() << "Invalid state";
+ return false;
+}
+
+void TouchscreenTapSuppressionController::GestureTapDownTimerExpired() {
+ switch (state_) {
+ case NOTHING:
+ case GFC_IN_PROGRESS:
+ case LAST_CANCEL_STOPPED_FLING:
+ NOTREACHED() << "Timer fired on invalid state.";
+ state_ = NOTHING;
+ break;
+ case GTD_STASHED:
+ TRACE_EVENT0(
+ "browser",
+ "TouchscreenTapSuppressionController::GestureTapDownTimerExpired");
+ gesture_event_filter_->ForwardGestureEventSkipDeferral(stashed_tap_down_);
+ state_ = NOTHING;
+ break;
+ }
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698