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

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..c634a83ef80d258ea52f727caee96014ef114dc2 100644
--- a/content/browser/renderer_host/input/tap_suppression_controller.cc
+++ b/content/browser/renderer_host/input/tap_suppression_controller.cc
@@ -10,11 +10,14 @@
namespace content {
+// 500ms is the timeout for long press. The max_tap_gap_time should be large
+// enough to suppress the long press if needed. 50ms extra delay is added to
+// make sure that the stashed tap down event is not forwarded before
+// suppressing the long press.
tdresser 2016/12/07 19:53:21 Clarify this comment - the long press could happen
sahel 2016/12/09 16:49:12 Done.
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/07 19:53:21 Should the long press time be passed in as a param
sahel 2016/12/09 16:49:12 Done.
TapSuppressionController::TapSuppressionController(
TapSuppressionControllerClient* client,
@@ -34,6 +37,7 @@ void TapSuppressionController::GestureFlingCancel() {
case NOTHING:
case GFC_IN_PROGRESS:
case LAST_CANCEL_STOPPED_FLING:
+ case SUPPRESSING_TAPS:
state_ = GFC_IN_PROGRESS;
break;
case TAP_DOWN_STASHED:
@@ -46,6 +50,7 @@ void TapSuppressionController::GestureFlingCancelAck(bool processed) {
switch (state_) {
case DISABLED:
case NOTHING:
+ case SUPPRESSING_TAPS:
break;
case GFC_IN_PROGRESS:
if (processed)
@@ -57,7 +62,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 +96,10 @@ bool TapSuppressionController::ShouldDeferTapDown() {
state_ = NOTHING;
return false;
}
+ // Stop suppressing tap end events.
+ case SUPPRESSING_TAPS:
+ state_ = NOTHING;
+ return false;
}
NOTREACHED() << "Invalid state";
return false;
@@ -101,12 +112,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, change the state
+ // to "SUPPRESSING_TAPS" when the stashed tap down is dropped.
+ state_ = SUPPRESSING_TAPS;
StopTapDownTimer();
client_->DropStashedTapDown();
return true;
case LAST_CANCEL_STOPPED_FLING:
NOTREACHED() << "Invalid tap end on LAST_CANCEL_STOPPED_FLING state";
+ case SUPPRESSING_TAPS:
+ return true;
}
return false;
}
@@ -128,6 +144,7 @@ void TapSuppressionController::TapDownTimerExpired() {
switch (state_) {
case DISABLED:
case NOTHING:
+ case SUPPRESSING_TAPS:
NOTREACHED() << "Timer fired on invalid state.";
break;
case GFC_IN_PROGRESS:
@@ -138,8 +155,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_ = SUPPRESSING_TAPS;
break;
}
}

Powered by Google App Engine
This is Rietveld 408576698