OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
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_INPUT_GESTURE_EVENT_FILTER_H_ | |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_FILTER_H_ | |
7 | |
8 #include <deque> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/timer/timer.h" | |
13 #include "content/browser/renderer_host/input/base_gesture_event_filter.h" | |
14 #include "content/browser/renderer_host/input/gesture_event_filter_client.h" | |
15 #include "content/common/content_export.h" | |
16 #include "content/port/browser/event_with_latency_info.h" | |
17 #include "content/port/common/input_event_ack_state.h" | |
18 #include "third_party/WebKit/public/web/WebInputEvent.h" | |
19 #include "ui/gfx/transform.h" | |
20 | |
21 namespace content { | |
22 class GestureEventFilterTest; | |
23 class InputRouter; | |
24 class MockRenderWidgetHost; | |
25 class TouchpadTapSuppressionController; | |
26 class TouchpadTapSuppressionControllerClient; | |
27 class TouchscreenTapSuppressionController; | |
28 | |
29 // Adds the following filters on top of BaseGestureEventFilter's filtering | |
30 // 1. Zero-velocity fling-starts from touchpad are filtered. | |
31 // 2. Unnecessary GestureFlingCancel events are filtered. These are | |
32 // GestureFlingCancels that have no corresponding GestureFlingStart in the | |
33 // queue. | |
34 // 3. Taps immediately after a GestureFlingCancel (caused by the same tap) are | |
35 // filtered. | |
36 class CONTENT_EXPORT GestureEventFilter : public BaseGestureEventFilter { | |
37 public: | |
38 // Both |client| and |touchpad_client| must outlive the GestureEventFilter. | |
39 GestureEventFilter(GestureEventFilterClient* client, | |
40 TouchpadTapSuppressionControllerClient* touchpad_client); | |
41 ~GestureEventFilter(); | |
42 | |
43 // Overridden from BaseGestureEventFilter. | |
44 virtual bool ShouldForward(const GestureEventWithLatencyInfo&) OVERRIDE; | |
45 virtual void ProcessGestureAck(InputEventAckState ack_result, | |
46 WebKit::WebInputEvent::Type type, | |
47 const ui::LatencyInfo& latency) OVERRIDE; | |
48 | |
49 // Sets the state of the |fling_in_progress_| field to indicate that a fling | |
50 // is definitely not in progress. | |
51 void FlingHasBeenHalted(); | |
52 | |
53 // Returns the |TouchpadTapSuppressionController| instance. | |
54 TouchpadTapSuppressionController* GetTouchpadTapSuppressionController(); | |
55 | |
56 private: | |
57 friend class MockRenderWidgetHost; | |
58 friend class GestureEventFilterTest; | |
59 | |
60 // Overridden from BaseGestureEventFilter. | |
61 virtual bool ShouldForwardScrollEndingEvent( | |
62 const GestureEventWithLatencyInfo& event) OVERRIDE; | |
63 virtual bool ShouldForwardForCoalescing( | |
64 const GestureEventWithLatencyInfo& gesture_event) OVERRIDE; | |
65 | |
66 // Returns |true| if the given GestureFlingCancel should be discarded | |
67 // as unnecessary. | |
68 bool ShouldDiscardFlingCancelEvent( | |
69 const GestureEventWithLatencyInfo& gesture_event) const; | |
70 | |
71 // Sub-filter for removing zero-velocity fling-starts from touchpad. | |
72 bool ShouldForwardForZeroVelocityFlingStart( | |
73 const GestureEventWithLatencyInfo& gesture_event) const; | |
74 | |
75 // Sub-filter for removing unnecessary GestureFlingCancels. | |
76 bool ShouldForwardForGFCFiltering( | |
77 const GestureEventWithLatencyInfo& gesture_event) const; | |
78 | |
79 // Sub-filter for suppressing taps immediately after a GestureFlingCancel. | |
80 bool ShouldForwardForTapSuppression( | |
81 const GestureEventWithLatencyInfo& gesture_event); | |
82 | |
83 // True if a GestureFlingStart is in progress on the renderer or | |
84 // queued without a subsequent queued GestureFlingCancel event. | |
85 bool fling_in_progress_; | |
86 | |
87 // An object tracking the state of touchpad on the delivery of mouse events to | |
88 // the renderer to filter mouse immediately after a touchpad fling canceling | |
89 // tap. | |
90 // TODO(mohsen): Move touchpad tap suppression out of GestureEventFilter since | |
91 // GEF is meant to only be used for touchscreen gesture events. | |
92 scoped_ptr<TouchpadTapSuppressionController> | |
93 touchpad_tap_suppression_controller_; | |
94 | |
95 // An object tracking the state of touchscreen on the delivery of gesture tap | |
96 // events to the renderer to filter taps immediately after a touchscreen fling | |
97 // canceling tap. | |
98 scoped_ptr<TouchscreenTapSuppressionController> | |
99 touchscreen_tap_suppression_controller_; | |
100 | |
101 DISALLOW_COPY_AND_ASSIGN(GestureEventFilter); | |
102 }; | |
103 | |
104 } // namespace content | |
105 | |
106 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_FILTER_H_ | |
OLD | NEW |