Revert 268405 "Make sure that ScratchBuffer::Allocate() always r..."
[chromium-blink-merge.git] / content / browser / renderer_host / input / touchscreen_tap_suppression_controller.cc
blob872cfb05b6b914c66e95362dec9aa8d593e8c420
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;
11 namespace content {
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(
26 bool processed) {
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())
35 return false;
36 stashed_tap_down_.reset(new GestureEventWithLatencyInfo(event));
37 return true;
39 case WebInputEvent::GestureShowPress:
40 if (!stashed_tap_down_)
41 return false;
42 stashed_show_press_.reset(new GestureEventWithLatencyInfo(event));
43 return true;
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();
53 default:
54 break;
56 return false;
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);
69 if (show_press)
70 gesture_event_queue_->ForwardGestureEvent(*show_press);
73 } // namespace content