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