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

Side by Side Diff: content/browser/renderer_host/touchpad_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, 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_TAP_SUPPRESSION_CONTROLLER_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_TOUCHPAD_TAP_SUPPRESSION_CONTROLLER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_TAP_SUPPRESSION_CONTROLLER_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_TOUCHPAD_TAP_SUPPRESSION_CONTROLLER_H_
7 7
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/timer.h" 9 #include "base/timer.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 class MockRenderWidgetHost; 14 class MockRenderWidgetHost;
15 class RenderWidgetHostImpl; 15 class RenderWidgetHostImpl;
16 16
17 // Controls the suppression of taps (rapid mousedown/mouseup sequences) 17 // Controls the suppression of taps (rapid mousedown/mouseup sequences)
18 // immediately following the dispatch of a WebGestureFlingCancel event. 18 // immediately following the dispatch of a WebGestureFlingCancel event.
19 // Only mousedown/mouseup of sufficient speed and within a specified time 19 // Only mousedown/mouseup of sufficient speed and within a specified time
20 // window after a WebGestureFlingCancel are suppressed. 20 // window after a WebGestureFlingCancel are suppressed.
21 class TapSuppressionController { 21 class TouchpadTapSuppressionController {
22 public: 22 public:
23 23
24 explicit TapSuppressionController(RenderWidgetHostImpl*); 24 explicit TouchpadTapSuppressionController(RenderWidgetHostImpl*);
25 ~TapSuppressionController(); 25 ~TouchpadTapSuppressionController();
26 26
27 // Called on the arrival of a mouse up event. Returns true if the hosting RWHV 27 // Called on the arrival of a mouse up event. Returns true if the hosting RWHV
28 // should suppress the remaining mouseup handling at this time. 28 // should suppress the remaining mouseup handling at this time.
29 bool ShouldSuppressMouseUp(); 29 bool ShouldSuppressMouseUp();
30 30
31 // Called on a mouse down. Returns true if the hosting RWHV should not 31 // Called on a mouse down. Returns true if the hosting RWHV should not
32 // continue with handling the mouse down event at this time. 32 // continue with handling the mouse down event at this time.
33 bool ShouldDeferMouseDown( 33 bool ShouldDeferMouseDown(const WebKit::WebMouseEvent& event);
34 const WebKit::WebMouseEvent& event);
35 34
36 // Called on an ack of WebGestureFlingCancel event. |processed| is true when 35 // Called on an ack of WebGestureFlingCancel event. |processed| is true when
37 // the GestureFlingCancel actually stopped a fling and therefore should 36 // the GestureFlingCancel actually stopped a fling and therefore should
38 // suppress the forwarding of the following tap. 37 // suppress the forwarding of the following tap.
39 void GestureFlingCancelAck(bool processed); 38 void GestureFlingCancelAck(bool processed);
40 39
41 // Called on the dispatch of a WebGestureFlingCancel event. 40 // Called on the dispatch of a WebGestureFlingCancel event.
42 void GestureFlingCancel(double cancel_time); 41 void GestureFlingCancel(double cancel_time);
43 42
44 private: 43 private:
45 friend class MockRenderWidgetHost; 44 friend class MockRenderWidgetHost;
46 45
47 enum State { 46 enum State {
48 NOTHING, 47 NOTHING,
49 GFC_IN_PROGRESS, 48 GFC_IN_PROGRESS,
50 MD_STASHED, 49 MD_STASHED,
51 LAST_CANCEL_STOPPED_FLING, 50 LAST_CANCEL_STOPPED_FLING,
52 }; 51 };
53 52
54 // Invoked once the maximum time deemed a tap from a mouse down event 53 // Invoked once the maximum time deemed a tap from a mouse down event
55 // has expired. If the mouse up has not yet arrived, indicates that the mouse 54 // has expired. If the mouse up has not yet arrived, indicates that the mouse
56 // down / mouse up pair do not form a tap. 55 // down / mouse up pair do not form a tap.
57 void MouseDownTimerExpired(); 56 void MouseDownTimerExpired();
58 57
59 // Only a RenderWidgetHostViewImpl can own an instance. 58 // Only a RenderWidgetHostViewImpl can own an instance.
60 RenderWidgetHostImpl* render_widget_host_; 59 RenderWidgetHostImpl* render_widget_host_;
61 base::OneShotTimer<TapSuppressionController> mouse_down_timer_; 60 base::OneShotTimer<TouchpadTapSuppressionController> mouse_down_timer_;
62 WebKit::WebMouseEvent stashed_mouse_down_; 61 WebKit::WebMouseEvent stashed_mouse_down_;
63 State state_; 62 State state_;
64 63
65 // TODO(rjkroege): During debugging, the event times did not prove reliable. 64 // TODO(rjkroege): During debugging, the event times did not prove reliable.
66 // Replace the use of base::TimeTicks with an accurate event time when they 65 // Replace the use of base::TimeTicks with an accurate event time when they
67 // become available post http://crbug.com/119556. 66 // become available post http://crbug.com/119556.
68 base::TimeTicks fling_cancel_time_; 67 base::TimeTicks fling_cancel_time_;
69 68
70 DISALLOW_COPY_AND_ASSIGN(TapSuppressionController); 69 DISALLOW_COPY_AND_ASSIGN(TouchpadTapSuppressionController);
71 }; 70 };
72 71
73 } // namespace content 72 } // namespace content
74 73
75 #endif // CONTENT_BROWSER_RENDERER_HOST_TAP_SUPPRESSION_CONTROLLER_H_ 74 #endif // CONTENT_BROWSER_RENDERER_HOST_TOUCHPAD_TAP_SUPPRESSION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698