• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_controller.h"
6 
7 #include "content/browser/renderer_host/input/gesture_event_queue.h"
8 
9 using blink::WebInputEvent;
10 
11 namespace content {
12 
TouchscreenTapSuppressionController(GestureEventQueue * geq,const TapSuppressionController::Config & config)13 TouchscreenTapSuppressionController::TouchscreenTapSuppressionController(
14     GestureEventQueue* geq,
15     const TapSuppressionController::Config& config)
16     : gesture_event_queue_(geq), controller_(this, config) {
17 }
18 
~TouchscreenTapSuppressionController()19 TouchscreenTapSuppressionController::~TouchscreenTapSuppressionController() {}
20 
GestureFlingCancel()21 void TouchscreenTapSuppressionController::GestureFlingCancel() {
22   controller_.GestureFlingCancel();
23 }
24 
GestureFlingCancelAck(bool processed)25 void TouchscreenTapSuppressionController::GestureFlingCancelAck(
26     bool processed) {
27   controller_.GestureFlingCancelAck(processed);
28 }
29 
FilterTapEvent(const GestureEventWithLatencyInfo & event)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;
38 
39     case WebInputEvent::GestureShowPress:
40       if (!stashed_tap_down_)
41         return false;
42       stashed_show_press_.reset(new GestureEventWithLatencyInfo(event));
43       return true;
44 
45     case WebInputEvent::GestureTapUnconfirmed:
46       return stashed_tap_down_;
47 
48     case WebInputEvent::GestureTapCancel:
49     case WebInputEvent::GestureTap:
50     case WebInputEvent::GestureDoubleTap:
51       return controller_.ShouldSuppressTapEnd();
52 
53     default:
54       break;
55   }
56   return false;
57 }
58 
DropStashedTapDown()59 void TouchscreenTapSuppressionController::DropStashedTapDown() {
60   stashed_tap_down_.reset();
61   stashed_show_press_.reset();
62 }
63 
ForwardStashedTapDown()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);
71 }
72 
73 }  // namespace content
74