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

Unified Diff: content/browser/renderer_host/input/tap_suppression_controller.cc

Issue 2542453003: Suppress LongPress/Tap, and TwoFingerTap when TapDown cancels a fling. (Closed)
Patch Set: Created 4 years 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/tap_suppression_controller.cc
diff --git a/content/browser/renderer_host/input/tap_suppression_controller.cc b/content/browser/renderer_host/input/tap_suppression_controller.cc
index 78b3a076d6d40b1b0db7f2c18cdb58fbb0c4f55a..686a413e2f5aa600598bd2373b8d949250f42cc8 100644
--- a/content/browser/renderer_host/input/tap_suppression_controller.cc
+++ b/content/browser/renderer_host/input/tap_suppression_controller.cc
@@ -13,7 +13,7 @@ namespace content {
TapSuppressionController::Config::Config()
: enabled(false),
max_cancel_to_down_time(base::TimeDelta::FromMilliseconds(180)),
- max_tap_gap_time(base::TimeDelta::FromMilliseconds(500)) {
+ max_tap_gap_time(base::TimeDelta::FromMilliseconds(550)) {
tdresser 2016/12/01 18:57:59 Why this change? This constant likely needs a comm
sahel 2016/12/06 15:18:13 This is set to 500ms, because that's the long pres
}
TapSuppressionController::TapSuppressionController(
@@ -34,6 +34,7 @@ void TapSuppressionController::GestureFlingCancel() {
case NOTHING:
case GFC_IN_PROGRESS:
case LAST_CANCEL_STOPPED_FLING:
+ case MUST_SUPPRESS_TAP_ENDS:
state_ = GFC_IN_PROGRESS;
break;
case TAP_DOWN_STASHED:
@@ -46,6 +47,7 @@ void TapSuppressionController::GestureFlingCancelAck(bool processed) {
switch (state_) {
case DISABLED:
case NOTHING:
+ case MUST_SUPPRESS_TAP_ENDS:
break;
case GFC_IN_PROGRESS:
if (processed)
@@ -57,7 +59,9 @@ void TapSuppressionController::GestureFlingCancelAck(bool processed) {
TRACE_EVENT0("browser",
"TapSuppressionController::GestureFlingCancelAck");
StopTapDownTimer();
- client_->ForwardStashedTapDown();
+ // If the fling cancel is not processed, forward all stashed
+ // gesture events.
+ client_->ForwardStashedGestureEvents();
state_ = NOTHING;
} // Else waiting for the timer to release the stashed tap down.
break;
@@ -89,6 +93,10 @@ bool TapSuppressionController::ShouldDeferTapDown() {
state_ = NOTHING;
return false;
}
+ // Stop suppressing tap end events.
+ case MUST_SUPPRESS_TAP_ENDS:
+ state_ = NOTHING;
+ return false;
}
NOTREACHED() << "Invalid state";
return false;
@@ -101,12 +109,17 @@ bool TapSuppressionController::ShouldSuppressTapEnd() {
case GFC_IN_PROGRESS:
return false;
case TAP_DOWN_STASHED:
- state_ = NOTHING;
+ // A tap cancel happens before long tap and two finger tap events. To
+ // drop the latter events as well as the tap cancel, don't change the
+ // state to NOTHING when the stashed tap down is dropped.
tdresser 2016/12/01 18:57:59 This comment feels related to the history of the f
sahel 2016/12/06 15:18:13 Done.
+ state_ = MUST_SUPPRESS_TAP_ENDS;
StopTapDownTimer();
client_->DropStashedTapDown();
return true;
case LAST_CANCEL_STOPPED_FLING:
NOTREACHED() << "Invalid tap end on LAST_CANCEL_STOPPED_FLING state";
+ case MUST_SUPPRESS_TAP_ENDS:
+ return true;
}
return false;
}
@@ -128,6 +141,7 @@ void TapSuppressionController::TapDownTimerExpired() {
switch (state_) {
case DISABLED:
case NOTHING:
+ case MUST_SUPPRESS_TAP_ENDS:
NOTREACHED() << "Timer fired on invalid state.";
break;
case GFC_IN_PROGRESS:
@@ -138,8 +152,10 @@ void TapSuppressionController::TapDownTimerExpired() {
case TAP_DOWN_STASHED:
TRACE_EVENT0("browser",
"TapSuppressionController::TapDownTimerExpired");
+ // When the timer expires, only forward the stashed tap down event, and
+ // drop other stashed gesture events (show press or long press).
client_->ForwardStashedTapDown();
- state_ = NOTHING;
+ state_ = MUST_SUPPRESS_TAP_ENDS;
break;
}
}

Powered by Google App Engine
This is Rietveld 408576698