Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_H_ | |
|
rjkroege
2013/02/05 16:00:07
there is a lot of code here in-common with touchpa
| |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_TOUCHSCREEN_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 GestureEventFilter; | |
| 15 class MockRenderWidgetHost; | |
| 16 class RenderWidgetHostImpl; | |
| 17 | |
| 18 // Controls the suppression of touchscreen taps (rapid gesture tapdown/tap | |
| 19 // sequences) immediately following the dispatch of a GestureFlingCancel event. | |
| 20 // Only tapdown/tap's of sufficient speed and within a specified time window | |
| 21 // after a GestureFlingCancel are suppressed. | |
| 22 class TouchscreenTapSuppressionController { | |
| 23 public: | |
| 24 explicit TouchscreenTapSuppressionController(RenderWidgetHostImpl* rwhv, | |
| 25 GestureEventFilter* gef); | |
| 26 ~TouchscreenTapSuppressionController(); | |
| 27 | |
| 28 // Called on the dispatch of a GestureFlingCancel event. | |
| 29 void GestureFlingCancel(double cancel_time); | |
| 30 | |
| 31 // Called on an ack of GestureFlingCancel event. |processed| is true when | |
| 32 // the GestureFlingCancel actually stopped a fling and therefore should | |
| 33 // suppress the forwarding of the following tap. | |
| 34 void GestureFlingCancelAck(bool processed); | |
| 35 | |
| 36 // Called on a gesture tapdown. Returns true if the hosting RWHV should not | |
| 37 // continue with handling the gesture tapdown event at this time. | |
| 38 bool ShouldDeferGestureTapDown(const WebKit::WebGestureEvent& event); | |
| 39 | |
| 40 // Called on the arrival of a gesture tap event. Returns true if the hosting | |
| 41 // RWHV should suppress the remaining gesture tap handling at this time. | |
| 42 bool ShouldSuppressGestureTap(); | |
| 43 | |
| 44 // Called on the arrival of a gesture tapcancel event. Returns true if the | |
| 45 // hosting RWHV should suppress the remaining gesture tapcancel handling at | |
| 46 // this time. | |
| 47 bool ShouldSuppressGestureTapCancel(); | |
| 48 | |
| 49 private: | |
| 50 friend class MockRenderWidgetHost; | |
| 51 | |
| 52 enum State { | |
| 53 NOTHING, | |
| 54 GFC_IN_PROGRESS, | |
| 55 GTD_STASHED, | |
| 56 LAST_CANCEL_STOPPED_FLING, | |
| 57 }; | |
| 58 | |
| 59 // Invoked once the maximum time deemed a tap from a gesture tapdown event | |
| 60 // has expired. If the gesture tap has not yet arrived, indicates that the | |
| 61 // gesture tapdown/tap pair do not form a tap. | |
| 62 void GestureTapDownTimerExpired(); | |
| 63 | |
| 64 RenderWidgetHostImpl* render_widget_host_; | |
| 65 GestureEventFilter* gesture_event_filter_; | |
| 66 | |
| 67 base::OneShotTimer<TouchscreenTapSuppressionController> tap_down_timer_; | |
| 68 WebKit::WebGestureEvent stashed_tap_down_; | |
| 69 State state_; | |
| 70 | |
| 71 // TODO(rjkroege): During debugging, the event times did not prove reliable. | |
|
rjkroege
2013/02/05 16:00:07
You're adding this code. You get to take the TODO
mohsen
2013/02/06 16:13:06
Yep, Sorry :-) Done.
| |
| 72 // Replace the use of base::TimeTicks with an accurate event time when they | |
| 73 // become available post http://crbug.com/119556. | |
| 74 base::TimeTicks fling_cancel_time_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(TouchscreenTapSuppressionController); | |
| 77 }; | |
| 78 | |
| 79 } // namespace content | |
| 80 | |
| 81 #endif // CONTENT_BROWSER_RENDERER_HOST_TOUCHSCREEN_TAP_SUPPRESSION_CONTROLLER_ H_ | |
| OLD | NEW |