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/events/gesture_detection/scale_gesture_detector.h" | 5 #include "ui/events/gesture_detection/scale_gesture_detector.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
| 8 |
8 #include <cmath> | 9 #include <cmath> |
9 | 10 |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "ui/events/gesture_detection/motion_event.h" | 12 #include "ui/events/gesture_detection/motion_event.h" |
12 #include "ui/events/gesture_detection/scale_gesture_listeners.h" | 13 #include "ui/events/gesture_detection/scale_gesture_listeners.h" |
13 | 14 |
14 using base::TimeDelta; | 15 using base::TimeDelta; |
15 using base::TimeTicks; | 16 using base::TimeTicks; |
16 | 17 |
17 namespace ui { | 18 namespace ui { |
18 namespace { | 19 namespace { |
19 | 20 |
20 // Using a small epsilon when comparing slop distances allows pixel perfect | 21 // Using a small epsilon when comparing slop distances allows pixel perfect |
21 // slop determination when using fractional DPI coordinates (assuming the slop | 22 // slop determination when using fractional DPI coordinates (assuming the slop |
22 // region and DPI scale are reasonably proportioned). | 23 // region and DPI scale are reasonably proportioned). |
23 const float kSlopEpsilon = .05f; | 24 const float kSlopEpsilon = .05f; |
24 | 25 |
25 const int kTouchStabilizeTimeMs = 128; | 26 const int kTouchStabilizeTimeMs = 128; |
26 | 27 |
27 const float kScaleFactor = .5f; | 28 const float kScaleFactor = .5f; |
28 | 29 |
29 } // namespace | 30 } // namespace |
30 | 31 |
31 // Note: These constants were taken directly from the default (unscaled) | 32 // Note: These constants were taken directly from the default (unscaled) |
32 // versions found in Android's ViewConfiguration. | 33 // versions found in Android's ViewConfiguration. Do not change these default |
| 34 // values without explicitly consulting an OWNER. |
33 ScaleGestureDetector::Config::Config() | 35 ScaleGestureDetector::Config::Config() |
34 : span_slop(16), | 36 : span_slop(16), |
35 min_scaling_touch_major(48), | 37 min_scaling_touch_major(48), |
36 min_scaling_span(200), | 38 min_scaling_span(200), |
37 min_pinch_update_span_delta(0) { | 39 min_pinch_update_span_delta(0) { |
38 } | 40 } |
39 | 41 |
40 ScaleGestureDetector::Config::~Config() {} | 42 ScaleGestureDetector::Config::~Config() {} |
41 | 43 |
42 ScaleGestureDetector::ScaleGestureDetector(const Config& config, | 44 ScaleGestureDetector::ScaleGestureDetector(const Config& config, |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 touch_history_last_accepted_time_ = base::TimeTicks(); | 346 touch_history_last_accepted_time_ = base::TimeTicks(); |
345 } | 347 } |
346 | 348 |
347 void ScaleGestureDetector::ResetScaleWithSpan(float span) { | 349 void ScaleGestureDetector::ResetScaleWithSpan(float span) { |
348 in_progress_ = false; | 350 in_progress_ = false; |
349 initial_span_ = span; | 351 initial_span_ = span; |
350 double_tap_mode_ = DOUBLE_TAP_MODE_NONE; | 352 double_tap_mode_ = DOUBLE_TAP_MODE_NONE; |
351 } | 353 } |
352 | 354 |
353 } // namespace ui | 355 } // namespace ui |
OLD | NEW |