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

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

Issue 235003005: Consolidate all touch/gesture related constants in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused headers 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
(Empty)
1 // Copyright 2014 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/input_router_config_helper.h"
6
7 #include "base/command_line.h"
8 #include "content/public/common/content_switches.h"
9 #include "ui/events/gesture_detection/gesture_detector.h"
10
11 #if defined(USE_AURA)
12 #include "ui/events/gestures/gesture_configuration.h"
13 #elif defined(OS_ANDROID)
14 #include "ui/gfx/android/view_configuration.h"
15 #include "ui/gfx/screen.h"
16 #endif
17
18 namespace content {
19 namespace {
20
21 #if defined(USE_AURA)
22
23 // Default debouncing interval duration: if a scroll is in progress, non-scroll
24 // events during this interval are deferred to either its end or discarded on
25 // receipt of another GestureScrollUpdate.
26 const int kDebouncingIntervalTimeMs = 30;
27
28 GestureEventQueue::Config GetGestureEventQueueConfig() {
29 GestureEventQueue::Config config;
30
31 #if defined(OS_CHROMEOS)
32 // TODO(jdduke): Disable and remove entirely when issues with spurious
33 // scroll end detection on the Pixel are resolved, crbug.com/353702.
34 config.debounce_interval =
35 base::TimeDelta::FromMilliseconds(kDebouncingIntervalTimeMs);
36 #endif
37
38 config.touchscreen_tap_suppression_config.enabled = true;
39 config.touchscreen_tap_suppression_config.max_cancel_to_down_time =
40 base::TimeDelta::FromMilliseconds(
41 ui::GestureConfiguration::fling_max_cancel_to_down_time_in_ms());
42
43 config.touchscreen_tap_suppression_config.max_tap_gap_time =
44 base::TimeDelta::FromMilliseconds(static_cast<int>(
45 ui::GestureConfiguration::semi_long_press_time_in_seconds() * 1000));
46
47 config.touchpad_tap_suppression_config.enabled = true;
48 config.touchpad_tap_suppression_config.max_cancel_to_down_time =
49 base::TimeDelta::FromMilliseconds(
50 ui::GestureConfiguration::fling_max_cancel_to_down_time_in_ms());
51
52 config.touchpad_tap_suppression_config.max_tap_gap_time =
53 base::TimeDelta::FromMilliseconds(static_cast<int>(
54 ui::GestureConfiguration::fling_max_tap_gap_time_in_ms() * 1000));
55
56 return config;
57 }
58
59 TouchEventQueue::Config GetTouchEventQueueConfig() {
60 TouchEventQueue::Config config;
61
62 config.touchmove_slop_suppression_length_dips =
63 ui::GestureConfiguration::max_touch_move_in_pixels_for_click();
64
65 return config;
66 }
67
68 #elif defined(OS_ANDROID)
69
70 // Default time allowance for the touch ack delay before the touch sequence is
71 // cancelled.
72 const int kTouchAckTimeoutDelayMs = 200;
73
74 GestureEventQueue::Config GetGestureEventQueueConfig() {
75 GestureEventQueue::Config config;
76
77 config.touchscreen_tap_suppression_config.enabled = true;
78 config.touchscreen_tap_suppression_config.max_cancel_to_down_time =
79 base::TimeDelta::FromMilliseconds(
80 gfx::ViewConfiguration::GetTapTimeoutInMs());
81 config.touchscreen_tap_suppression_config.max_tap_gap_time =
82 base::TimeDelta::FromMilliseconds(
83 gfx::ViewConfiguration::GetLongPressTimeoutInMs());
84
85 return config;
86 }
87
88 TouchEventQueue::Config GetTouchEventQueueConfig() {
89 TouchEventQueue::Config config;
90
91 config.touch_ack_timeout_delay =
92 base::TimeDelta::FromMilliseconds(kTouchAckTimeoutDelayMs);
93 config.touch_ack_timeout_supported = true;
94
95 const double touch_slop_length_pixels =
96 static_cast<double>(gfx::ViewConfiguration::GetTouchSlopInPixels());
97 const double device_scale_factor =
98 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().device_scale_factor();
99 config.touchmove_slop_suppression_length_dips =
100 touch_slop_length_pixels / device_scale_factor;
101
102 return config;
103 }
104
105 #else
106
107 GestureEventQueue::Config GetGestureEventQueueConfig() {
108 return GestureEventQueue::Config();
109 }
110
111 TouchEventQueue::Config GetTouchEventQueueConfig() {
112 TouchEventQueue::Config config;
113 config.touchmove_slop_suppression_length_dips =
114 GestureDetector::Config().touch_slop;
115 return config;
116 }
117
118 #endif
119
120 TouchEventQueue::TouchScrollingMode GetTouchScrollingMode() {
121 std::string modeString =
122 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
123 switches::kTouchScrollingMode);
124 if (modeString == switches::kTouchScrollingModeAsyncTouchmove)
125 return TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE;
126 if (modeString == switches::kTouchScrollingModeSyncTouchmove)
127 return TouchEventQueue::TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE;
128 if (modeString == switches::kTouchScrollingModeTouchcancel)
129 return TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL;
130 if (modeString != "")
131 LOG(ERROR) << "Invalid --touch-scrolling-mode option: " << modeString;
132 return TouchEventQueue::TOUCH_SCROLLING_MODE_DEFAULT;
133 }
134
135 } // namespace
136
137 InputRouterImpl::Config GetInputRouterConfigForPlatform() {
138 InputRouterImpl::Config config;
139 config.gesture_config = GetGestureEventQueueConfig();
140 config.touch_config = GetTouchEventQueueConfig();
141 config.touch_config.touch_scrolling_mode = GetTouchScrollingMode();
142 return config;
143 }
144
145 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698