OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/input_router_config_helper.h" | 5 #include "content/browser/renderer_host/input/input_router_config_helper.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/public/common/content_switches.h" | 8 #include "content/public/common/content_switches.h" |
| 9 #include "ui/events/gesture_detection/gesture_configuration.h" |
9 #include "ui/events/gesture_detection/gesture_detector.h" | 10 #include "ui/events/gesture_detection/gesture_detector.h" |
10 | 11 |
11 #if defined(USE_AURA) | |
12 #include "ui/events/gesture_detection/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 { | 12 namespace content { |
19 namespace { | 13 namespace { |
20 | 14 |
21 #if defined(USE_AURA) | 15 // Default time allowance for the touch ack delay before the touch sequence is |
22 // TODO(jdduke): Consolidate router configuration paths using | 16 // cancelled, depending on whether the site has a mobile-friendly viewport. |
23 // ui::GestureConfiguration. | 17 // Note that these constants are effective only when the timeout is supported. |
| 18 const int kDesktopTouchAckTimeoutDelayMs = 200; |
| 19 const int kMobileTouchAckTimeoutDelayMs = 1000; |
| 20 |
| 21 TouchEventQueue::Config GetTouchEventQueueConfig() { |
| 22 TouchEventQueue::Config config; |
| 23 |
| 24 config.desktop_touch_ack_timeout_delay = |
| 25 base::TimeDelta::FromMilliseconds(kDesktopTouchAckTimeoutDelayMs); |
| 26 config.mobile_touch_ack_timeout_delay = |
| 27 base::TimeDelta::FromMilliseconds(kMobileTouchAckTimeoutDelayMs); |
| 28 |
| 29 #if defined(OS_ANDROID) |
| 30 // For historical reasons only Android enables the touch ack timeout. |
| 31 config.touch_ack_timeout_supported = true; |
| 32 #else |
| 33 config.touch_ack_timeout_supported = false; |
| 34 #endif |
| 35 |
| 36 return config; |
| 37 } |
| 38 |
24 GestureEventQueue::Config GetGestureEventQueueConfig() { | 39 GestureEventQueue::Config GetGestureEventQueueConfig() { |
25 GestureEventQueue::Config config; | 40 GestureEventQueue::Config config; |
26 ui::GestureConfiguration* gesture_config = | 41 ui::GestureConfiguration* gesture_config = |
27 ui::GestureConfiguration::GetInstance(); | 42 ui::GestureConfiguration::GetInstance(); |
28 config.debounce_interval = base::TimeDelta::FromMilliseconds( | 43 config.debounce_interval = base::TimeDelta::FromMilliseconds( |
29 gesture_config->scroll_debounce_interval_in_ms()); | 44 gesture_config->scroll_debounce_interval_in_ms()); |
30 | 45 |
31 config.touchscreen_tap_suppression_config.enabled = true; | 46 config.touchscreen_tap_suppression_config.enabled = |
| 47 gesture_config->fling_touchscreen_tap_suppression_enabled(); |
32 config.touchscreen_tap_suppression_config.max_cancel_to_down_time = | 48 config.touchscreen_tap_suppression_config.max_cancel_to_down_time = |
33 base::TimeDelta::FromMilliseconds( | 49 base::TimeDelta::FromMilliseconds( |
34 gesture_config->fling_max_cancel_to_down_time_in_ms()); | 50 gesture_config->fling_max_cancel_to_down_time_in_ms()); |
35 | |
36 config.touchscreen_tap_suppression_config.max_tap_gap_time = | 51 config.touchscreen_tap_suppression_config.max_tap_gap_time = |
37 base::TimeDelta::FromMilliseconds( | 52 base::TimeDelta::FromMilliseconds( |
38 gesture_config->semi_long_press_time_in_ms()); | 53 gesture_config->long_press_time_in_ms()); |
39 | 54 |
40 config.touchpad_tap_suppression_config.enabled = true; | 55 config.touchpad_tap_suppression_config.enabled = |
| 56 gesture_config->fling_touchpad_tap_suppression_enabled(); |
41 config.touchpad_tap_suppression_config.max_cancel_to_down_time = | 57 config.touchpad_tap_suppression_config.max_cancel_to_down_time = |
42 base::TimeDelta::FromMilliseconds( | 58 base::TimeDelta::FromMilliseconds( |
43 gesture_config->fling_max_cancel_to_down_time_in_ms()); | 59 gesture_config->fling_max_cancel_to_down_time_in_ms()); |
44 | |
45 config.touchpad_tap_suppression_config.max_tap_gap_time = | 60 config.touchpad_tap_suppression_config.max_tap_gap_time = |
46 base::TimeDelta::FromMilliseconds( | 61 base::TimeDelta::FromMilliseconds( |
47 gesture_config->fling_max_tap_gap_time_in_ms()); | 62 gesture_config->fling_max_tap_gap_time_in_ms()); |
48 | 63 |
49 return config; | 64 return config; |
50 } | 65 } |
51 | 66 |
52 TouchEventQueue::Config GetTouchEventQueueConfig() { | |
53 return TouchEventQueue::Config(); | |
54 } | |
55 | |
56 #elif defined(OS_ANDROID) | |
57 | |
58 // Default time allowance for the touch ack delay before the touch sequence is | |
59 // cancelled, depending on whether the site has a mobile-friendly viewport. | |
60 const int kDesktopTouchAckTimeoutDelayMs = 200; | |
61 const int kMobileTouchAckTimeoutDelayMs = 1000; | |
62 | |
63 GestureEventQueue::Config GetGestureEventQueueConfig() { | |
64 GestureEventQueue::Config config; | |
65 | |
66 config.touchscreen_tap_suppression_config.enabled = true; | |
67 config.touchscreen_tap_suppression_config.max_cancel_to_down_time = | |
68 base::TimeDelta::FromMilliseconds( | |
69 gfx::ViewConfiguration::GetTapTimeoutInMs()); | |
70 config.touchscreen_tap_suppression_config.max_tap_gap_time = | |
71 base::TimeDelta::FromMilliseconds( | |
72 gfx::ViewConfiguration::GetLongPressTimeoutInMs()); | |
73 | |
74 return config; | |
75 } | |
76 | |
77 TouchEventQueue::Config GetTouchEventQueueConfig() { | |
78 TouchEventQueue::Config config; | |
79 | |
80 config.desktop_touch_ack_timeout_delay = | |
81 base::TimeDelta::FromMilliseconds(kDesktopTouchAckTimeoutDelayMs); | |
82 config.mobile_touch_ack_timeout_delay = | |
83 base::TimeDelta::FromMilliseconds(kMobileTouchAckTimeoutDelayMs); | |
84 config.touch_ack_timeout_supported = true; | |
85 | |
86 return config; | |
87 } | |
88 | |
89 #else | |
90 | |
91 GestureEventQueue::Config GetGestureEventQueueConfig() { | |
92 return GestureEventQueue::Config(); | |
93 } | |
94 | |
95 TouchEventQueue::Config GetTouchEventQueueConfig() { | |
96 return TouchEventQueue::Config(); | |
97 } | |
98 | |
99 #endif | |
100 | |
101 } // namespace | 67 } // namespace |
102 | 68 |
103 InputRouterImpl::Config GetInputRouterConfigForPlatform() { | 69 InputRouterImpl::Config GetInputRouterConfigForPlatform() { |
104 InputRouterImpl::Config config; | 70 InputRouterImpl::Config config; |
105 config.gesture_config = GetGestureEventQueueConfig(); | 71 config.gesture_config = GetGestureEventQueueConfig(); |
106 config.touch_config = GetTouchEventQueueConfig(); | 72 config.touch_config = GetTouchEventQueueConfig(); |
107 return config; | 73 return config; |
108 } | 74 } |
109 | 75 |
110 } // namespace content | 76 } // namespace content |
OLD | NEW |