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.
5 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_controller.h"
7 #include "content/browser/renderer_host/input/gesture_event_queue.h"
9 using blink::WebInputEvent
;
13 TouchscreenTapSuppressionController::TouchscreenTapSuppressionController(
14 GestureEventQueue
* geq
,
15 const TapSuppressionController::Config
& config
)
16 : gesture_event_queue_(geq
), controller_(this, config
) {
19 TouchscreenTapSuppressionController::~TouchscreenTapSuppressionController() {}
21 void TouchscreenTapSuppressionController::GestureFlingCancel() {
22 controller_
.GestureFlingCancel();
25 void TouchscreenTapSuppressionController::GestureFlingCancelAck(
27 controller_
.GestureFlingCancelAck(processed
);
30 bool TouchscreenTapSuppressionController::FilterTapEvent(
31 const GestureEventWithLatencyInfo
& event
) {
32 switch (event
.event
.type
) {
33 case WebInputEvent::GestureTapDown
:
34 if (!controller_
.ShouldDeferTapDown())
36 stashed_tap_down_
.reset(new GestureEventWithLatencyInfo(event
));
39 case WebInputEvent::GestureShowPress
:
40 if (!stashed_tap_down_
)
42 stashed_show_press_
.reset(new GestureEventWithLatencyInfo(event
));
45 case WebInputEvent::GestureTapUnconfirmed
:
46 return stashed_tap_down_
;
48 case WebInputEvent::GestureTapCancel
:
49 case WebInputEvent::GestureTap
:
50 case WebInputEvent::GestureDoubleTap
:
51 return controller_
.ShouldSuppressTapEnd();
59 void TouchscreenTapSuppressionController::DropStashedTapDown() {
60 stashed_tap_down_
.reset();
61 stashed_show_press_
.reset();
64 void TouchscreenTapSuppressionController::ForwardStashedTapDown() {
65 DCHECK(stashed_tap_down_
);
66 ScopedGestureEvent tap_down
= stashed_tap_down_
.Pass();
67 ScopedGestureEvent show_press
= stashed_show_press_
.Pass();
68 gesture_event_queue_
->ForwardGestureEvent(*tap_down
);
70 gesture_event_queue_
->ForwardGestureEvent(*show_press
);
73 } // namespace content