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

Side by Side Diff: content/browser/renderer_host/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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
mohsen 2013/02/04 15:09:05 This file is renamed to touchpad_tap_suppression_c
rjkroege 2013/02/05 16:00:07 You used git mv to change its name yes?
mohsen 2013/02/06 16:13:06 No. I just renamed (also changed contents) and the
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/tap_suppression_controller.h"
6
7 #include "base/command_line.h"
8 #include "base/debug/trace_event.h"
9 #include "base/logging.h"
10 #include "base/string_number_conversions.h"
11 #include "content/browser/renderer_host/render_widget_host_impl.h"
12 #include "content/public/common/content_switches.h"
13 #include "ui/base/gestures/gesture_configuration.h"
14
15 namespace content {
16
17 TapSuppressionController::TapSuppressionController(RenderWidgetHostImpl* rwhv)
18 : render_widget_host_(rwhv),
19 state_(TapSuppressionController::NOTHING) {
20 }
21
22 TapSuppressionController::~TapSuppressionController() { }
23
24 bool TapSuppressionController::ShouldSuppressMouseUp() {
25 switch (state_) {
26 case NOTHING:
27 case GFC_IN_PROGRESS:
28 return false;
29 case MD_STASHED:
30 state_ = NOTHING;
31 mouse_down_timer_.Stop();
32 return true;
33 case LAST_CANCEL_STOPPED_FLING:
34 NOTREACHED() << "Invalid MouseUp on LAST_CANCEL_STOPPED_FLING state";
35 }
36 return false;
37 }
38
39 bool TapSuppressionController::ShouldDeferMouseDown(
40 const WebKit::WebMouseEvent& event) {
41 switch (state_) {
42 case NOTHING:
43 return false;
44 case GFC_IN_PROGRESS:
45 mouse_down_timer_.Start(
46 FROM_HERE,
47 base::TimeDelta::FromMilliseconds(
48 ui::GestureConfiguration::fling_max_tap_gap_time_in_ms()),
49 this,
50 &TapSuppressionController::MouseDownTimerExpired);
51 stashed_mouse_down_ = event;
52 state_ = MD_STASHED;
53 return true;
54 case MD_STASHED:
55 NOTREACHED() << "MouseDown on MD_STASHED state";
56 state_ = NOTHING;
57 return false;
58 case LAST_CANCEL_STOPPED_FLING:
59 if ((base::TimeTicks::Now() - fling_cancel_time_).InMilliseconds()
60 < ui::GestureConfiguration::fling_max_cancel_to_down_time_in_ms()) {
61 state_ = MD_STASHED;
62 mouse_down_timer_.Start(
63 FROM_HERE,
64 base::TimeDelta::FromMilliseconds(
65 ui::GestureConfiguration::fling_max_tap_gap_time_in_ms()),
66 this,
67 &TapSuppressionController::MouseDownTimerExpired);
68 stashed_mouse_down_ = event;
69 return true;
70 } else {
71 state_ = NOTHING;
72 return false;
73 }
74 }
75 return false;
76 }
77
78 void TapSuppressionController::GestureFlingCancelAck(bool processed) {
79 switch (state_) {
80 case NOTHING:
81 NOTREACHED() << "GFC_Ack without a GFC";
82 break;
83 case GFC_IN_PROGRESS:
84 if (processed)
85 fling_cancel_time_ = base::TimeTicks::Now();
86 state_ = LAST_CANCEL_STOPPED_FLING;
87 break;
88 case MD_STASHED:
89 if (!processed) {
90 TRACE_EVENT0("browser",
91 "TapSuppressionController::GestureFlingCancelAck");
92 mouse_down_timer_.Stop();
93 render_widget_host_->ForwardMouseEventImmediately(stashed_mouse_down_);
94 state_ = NOTHING;
95 } // Else waiting for the timer to release the mouse event.
96 break;
97 case LAST_CANCEL_STOPPED_FLING:
98 break;
99 }
100 }
101
102 void TapSuppressionController::GestureFlingCancel(double cancel_time) {
103 switch (state_) {
104 case NOTHING:
105 case GFC_IN_PROGRESS:
106 case LAST_CANCEL_STOPPED_FLING:
107 state_ = GFC_IN_PROGRESS;
108 break;
109 case MD_STASHED:
110 break;
111 }
112 }
113
114 void TapSuppressionController::MouseDownTimerExpired() {
115 switch (state_) {
116 case NOTHING:
117 case GFC_IN_PROGRESS:
118 case LAST_CANCEL_STOPPED_FLING:
119 NOTREACHED() << "Timer fired on invalid state.";
120 state_ = NOTHING;
121 break;
122 case MD_STASHED:
123 TRACE_EVENT0("browser",
124 "TapSuppressionController::MouseDownTimerExpired");
125 render_widget_host_->ForwardMouseEventImmediately(stashed_mouse_down_);
126 state_ = NOTHING;
127 break;
128 }
129 }
130
131 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698