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

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

Powered by Google App Engine
This is Rietveld 408576698