Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: content/browser/renderer_host/input/touchscreen_tap_suppression_controller.cc

Issue 260923003: Revert of Consolidate all touch/gesture related constants in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro ller.h" 5 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro ller.h"
6 6
7 #include "content/browser/renderer_host/input/gesture_event_queue.h" 7 #include "content/browser/renderer_host/input/gesture_event_queue.h"
8 #include "content/browser/renderer_host/input/tap_suppression_controller.h"
9 #include "ui/events/gestures/gesture_configuration.h"
10
11 #if defined(OS_ANDROID)
12 #include "ui/gfx/android/view_configuration.h"
13 #endif
8 14
9 using blink::WebInputEvent; 15 using blink::WebInputEvent;
10 16
11 namespace content { 17 namespace content {
12 18
13 TouchscreenTapSuppressionController::TouchscreenTapSuppressionController( 19 TouchscreenTapSuppressionController::TouchscreenTapSuppressionController(
14 GestureEventQueue* geq, 20 GestureEventQueue* geq)
15 const TapSuppressionController::Config& config) 21 : gesture_event_queue_(geq),
16 : gesture_event_queue_(geq), controller_(this, config) { 22 controller_(new TapSuppressionController(this)) {
17 } 23 }
18 24
19 TouchscreenTapSuppressionController::~TouchscreenTapSuppressionController() {} 25 TouchscreenTapSuppressionController::~TouchscreenTapSuppressionController() {}
20 26
21 void TouchscreenTapSuppressionController::GestureFlingCancel() { 27 void TouchscreenTapSuppressionController::GestureFlingCancel() {
22 controller_.GestureFlingCancel(); 28 controller_->GestureFlingCancel();
23 } 29 }
24 30
25 void TouchscreenTapSuppressionController::GestureFlingCancelAck( 31 void TouchscreenTapSuppressionController::GestureFlingCancelAck(
26 bool processed) { 32 bool processed) {
27 controller_.GestureFlingCancelAck(processed); 33 controller_->GestureFlingCancelAck(processed);
28 } 34 }
29 35
30 bool TouchscreenTapSuppressionController::FilterTapEvent( 36 bool TouchscreenTapSuppressionController::FilterTapEvent(
31 const GestureEventWithLatencyInfo& event) { 37 const GestureEventWithLatencyInfo& event) {
32 switch (event.event.type) { 38 switch (event.event.type) {
33 case WebInputEvent::GestureTapDown: 39 case WebInputEvent::GestureTapDown:
34 if (!controller_.ShouldDeferTapDown()) 40 if (!controller_->ShouldDeferTapDown())
35 return false; 41 return false;
36 stashed_tap_down_.reset(new GestureEventWithLatencyInfo(event)); 42 stashed_tap_down_.reset(new GestureEventWithLatencyInfo(event));
37 return true; 43 return true;
38 44
39 case WebInputEvent::GestureShowPress: 45 case WebInputEvent::GestureShowPress:
40 if (!stashed_tap_down_) 46 if (!stashed_tap_down_)
41 return false; 47 return false;
42 stashed_show_press_.reset(new GestureEventWithLatencyInfo(event)); 48 stashed_show_press_.reset(new GestureEventWithLatencyInfo(event));
43 return true; 49 return true;
44 50
45 case WebInputEvent::GestureTapUnconfirmed: 51 case WebInputEvent::GestureTapUnconfirmed:
46 return stashed_tap_down_; 52 return stashed_tap_down_;
47 53
48 case WebInputEvent::GestureTapCancel: 54 case WebInputEvent::GestureTapCancel:
49 case WebInputEvent::GestureTap: 55 case WebInputEvent::GestureTap:
50 case WebInputEvent::GestureDoubleTap: 56 case WebInputEvent::GestureDoubleTap:
51 return controller_.ShouldSuppressTapEnd(); 57 return controller_->ShouldSuppressTapEnd();
52 58
53 default: 59 default:
54 break; 60 break;
55 } 61 }
56 return false; 62 return false;
57 } 63 }
58 64
65 #if defined(OS_ANDROID)
66 // TODO(jdduke): Enable ui::GestureConfiguration on Android and initialize
67 // with parameters from ViewConfiguration.
68 int TouchscreenTapSuppressionController::MaxCancelToDownTimeInMs() {
69 return gfx::ViewConfiguration::GetTapTimeoutInMs();
70 }
71
72 int TouchscreenTapSuppressionController::MaxTapGapTimeInMs() {
73 return gfx::ViewConfiguration::GetLongPressTimeoutInMs();
74 }
75 #else
76 int TouchscreenTapSuppressionController::MaxCancelToDownTimeInMs() {
77 return ui::GestureConfiguration::fling_max_cancel_to_down_time_in_ms();
78 }
79
80 int TouchscreenTapSuppressionController::MaxTapGapTimeInMs() {
81 return static_cast<int>(
82 ui::GestureConfiguration::semi_long_press_time_in_seconds() * 1000);
83 }
84 #endif
85
59 void TouchscreenTapSuppressionController::DropStashedTapDown() { 86 void TouchscreenTapSuppressionController::DropStashedTapDown() {
60 stashed_tap_down_.reset(); 87 stashed_tap_down_.reset();
61 stashed_show_press_.reset(); 88 stashed_show_press_.reset();
62 } 89 }
63 90
64 void TouchscreenTapSuppressionController::ForwardStashedTapDown() { 91 void TouchscreenTapSuppressionController::ForwardStashedTapDown() {
65 DCHECK(stashed_tap_down_); 92 DCHECK(stashed_tap_down_);
66 ScopedGestureEvent tap_down = stashed_tap_down_.Pass(); 93 ScopedGestureEvent tap_down = stashed_tap_down_.Pass();
67 ScopedGestureEvent show_press = stashed_show_press_.Pass(); 94 ScopedGestureEvent show_press = stashed_show_press_.Pass();
68 gesture_event_queue_->ForwardGestureEvent(*tap_down); 95 gesture_event_queue_->ForwardGestureEvent(*tap_down);
69 if (show_press) 96 if (show_press)
70 gesture_event_queue_->ForwardGestureEvent(*show_press); 97 gesture_event_queue_->ForwardGestureEvent(*show_press);
71 } 98 }
72 99
73 } // namespace content 100 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698