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 "ui/gfx/android/view_configuration.h" | 5 #include "ui/gfx/android/view_configuration.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/threading/non_thread_safe.h" | 9 #include "base/threading/non_thread_safe.h" |
10 #include "jni/ViewConfigurationHelper_jni.h" | 10 #include "jni/ViewConfigurationHelper_jni.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 j_view_configuration_helper_.Reset( | 32 j_view_configuration_helper_.Reset( |
33 Java_ViewConfigurationHelper_createWithListener( | 33 Java_ViewConfigurationHelper_createWithListener( |
34 env, base::android::GetApplicationContext())); | 34 env, base::android::GetApplicationContext())); |
35 | 35 |
36 double_tap_timeout_in_ms_ = | 36 double_tap_timeout_in_ms_ = |
37 Java_ViewConfigurationHelper_getDoubleTapTimeout(env); | 37 Java_ViewConfigurationHelper_getDoubleTapTimeout(env); |
38 long_press_timeout_in_ms_ = | 38 long_press_timeout_in_ms_ = |
39 Java_ViewConfigurationHelper_getLongPressTimeout(env); | 39 Java_ViewConfigurationHelper_getLongPressTimeout(env); |
40 tap_timeout_in_ms_ = Java_ViewConfigurationHelper_getTapTimeout(env); | 40 tap_timeout_in_ms_ = Java_ViewConfigurationHelper_getTapTimeout(env); |
41 scroll_friction_ = Java_ViewConfigurationHelper_getScrollFriction(env); | 41 scroll_friction_ = Java_ViewConfigurationHelper_getScrollFriction(env); |
| 42 should_use_touch_major_in_scaling_span_ = |
| 43 Java_ViewConfigurationHelper_shouldUseTouchMajorInScalingSpan(env); |
42 | 44 |
43 jobject obj = j_view_configuration_helper_.obj(); | 45 jobject obj = j_view_configuration_helper_.obj(); |
44 Update( | 46 Update( |
45 Java_ViewConfigurationHelper_getScaledMaximumFlingVelocity(env, obj), | 47 Java_ViewConfigurationHelper_getScaledMaximumFlingVelocity(env, obj), |
46 Java_ViewConfigurationHelper_getScaledMinimumFlingVelocity(env, obj), | 48 Java_ViewConfigurationHelper_getScaledMinimumFlingVelocity(env, obj), |
47 Java_ViewConfigurationHelper_getScaledTouchSlop(env, obj), | 49 Java_ViewConfigurationHelper_getScaledTouchSlop(env, obj), |
48 Java_ViewConfigurationHelper_getScaledDoubleTapSlop(env, obj), | 50 Java_ViewConfigurationHelper_getScaledDoubleTapSlop(env, obj), |
49 Java_ViewConfigurationHelper_getScaledMinScalingSpan(env, obj), | 51 Java_ViewConfigurationHelper_getScaledMinScalingSpan(env, obj), |
50 Java_ViewConfigurationHelper_getScaledMinScalingTouchMajor(env, obj)); | 52 Java_ViewConfigurationHelper_getScaledMinScalingTouchMajor(env, obj)); |
51 } | 53 } |
(...skipping 12 matching lines...) Expand all Loading... |
64 scaled_touch_slop, | 66 scaled_touch_slop, |
65 scaled_double_tap_slop, | 67 scaled_double_tap_slop, |
66 scaled_min_scaling_span, | 68 scaled_min_scaling_span, |
67 scaled_min_scaling_touch_major); | 69 scaled_min_scaling_touch_major); |
68 } | 70 } |
69 | 71 |
70 int double_tap_timeout_in_ms() const { return double_tap_timeout_in_ms_; } | 72 int double_tap_timeout_in_ms() const { return double_tap_timeout_in_ms_; } |
71 int long_press_timeout_in_ms() const { return long_press_timeout_in_ms_; } | 73 int long_press_timeout_in_ms() const { return long_press_timeout_in_ms_; } |
72 int tap_timeout_in_ms() const { return tap_timeout_in_ms_; } | 74 int tap_timeout_in_ms() const { return tap_timeout_in_ms_; } |
73 float scroll_friction() const { return scroll_friction_; } | 75 float scroll_friction() const { return scroll_friction_; } |
| 76 bool should_use_touch_major_in_scaling_span() const { |
| 77 return should_use_touch_major_in_scaling_span_; |
| 78 } |
74 | 79 |
75 int max_fling_velocity_in_pixels_s() { | 80 int max_fling_velocity_in_pixels_s() { |
76 base::AutoLock autolock(lock_); | 81 base::AutoLock autolock(lock_); |
77 return max_fling_velocity_in_pixels_s_; | 82 return max_fling_velocity_in_pixels_s_; |
78 } | 83 } |
79 | 84 |
80 int min_fling_velocity_in_pixels_s() { | 85 int min_fling_velocity_in_pixels_s() { |
81 base::AutoLock autolock(lock_); | 86 base::AutoLock autolock(lock_); |
82 return min_fling_velocity_in_pixels_s_; | 87 return min_fling_velocity_in_pixels_s_; |
83 } | 88 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 125 |
121 base::Lock lock_; | 126 base::Lock lock_; |
122 base::android::ScopedJavaGlobalRef<jobject> j_view_configuration_helper_; | 127 base::android::ScopedJavaGlobalRef<jobject> j_view_configuration_helper_; |
123 | 128 |
124 // These values will remain constant throughout the lifetime of the app, so | 129 // These values will remain constant throughout the lifetime of the app, so |
125 // read-access needn't be synchronized. | 130 // read-access needn't be synchronized. |
126 int double_tap_timeout_in_ms_; | 131 int double_tap_timeout_in_ms_; |
127 int long_press_timeout_in_ms_; | 132 int long_press_timeout_in_ms_; |
128 int tap_timeout_in_ms_; | 133 int tap_timeout_in_ms_; |
129 float scroll_friction_; | 134 float scroll_friction_; |
| 135 bool should_use_touch_major_in_scaling_span_; |
130 | 136 |
131 // These values may vary as view-specific parameters (DPI scale) are changed, | 137 // These values may vary as view-specific parameters (DPI scale) are changed, |
132 // so read/write access must be synchronized. | 138 // so read/write access must be synchronized. |
133 int max_fling_velocity_in_pixels_s_; | 139 int max_fling_velocity_in_pixels_s_; |
134 int min_fling_velocity_in_pixels_s_; | 140 int min_fling_velocity_in_pixels_s_; |
135 int touch_slop_in_pixels_; | 141 int touch_slop_in_pixels_; |
136 int double_tap_slop_in_pixels_; | 142 int double_tap_slop_in_pixels_; |
137 int min_scaling_span_in_pixels_; | 143 int min_scaling_span_in_pixels_; |
138 int min_scaling_touch_major_in_pixels_; | 144 int min_scaling_touch_major_in_pixels_; |
139 | 145 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 202 } |
197 | 203 |
198 int ViewConfiguration::GetMinScalingSpanInPixels() { | 204 int ViewConfiguration::GetMinScalingSpanInPixels() { |
199 return g_view_configuration.Get().min_scaling_span_in_pixels(); | 205 return g_view_configuration.Get().min_scaling_span_in_pixels(); |
200 } | 206 } |
201 | 207 |
202 int ViewConfiguration::GetMinScalingTouchMajorInPixels() { | 208 int ViewConfiguration::GetMinScalingTouchMajorInPixels() { |
203 return g_view_configuration.Get().min_scaling_touch_major_in_pixels(); | 209 return g_view_configuration.Get().min_scaling_touch_major_in_pixels(); |
204 } | 210 } |
205 | 211 |
| 212 bool ViewConfiguration::ShouldUseTouchMajorInScalingSpan() { |
| 213 return g_view_configuration.Get().should_use_touch_major_in_scaling_span(); |
| 214 } |
| 215 |
206 bool ViewConfiguration::RegisterViewConfiguration(JNIEnv* env) { | 216 bool ViewConfiguration::RegisterViewConfiguration(JNIEnv* env) { |
207 return RegisterNativesImpl(env); | 217 return RegisterNativesImpl(env); |
208 } | 218 } |
209 | 219 |
210 } // namespace gfx | 220 } // namespace gfx |
OLD | NEW |