| 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/gesture_provider.h" | 5 #include "ui/events/gesture_detection/gesture_provider.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 274 |
| 275 virtual bool OnScroll(const MotionEvent& e1, | 275 virtual bool OnScroll(const MotionEvent& e1, |
| 276 const MotionEvent& e2, | 276 const MotionEvent& e2, |
| 277 float raw_distance_x, | 277 float raw_distance_x, |
| 278 float raw_distance_y) override { | 278 float raw_distance_y) override { |
| 279 float distance_x = raw_distance_x; | 279 float distance_x = raw_distance_x; |
| 280 float distance_y = raw_distance_y; | 280 float distance_y = raw_distance_y; |
| 281 if (!scroll_event_sent_) { | 281 if (!scroll_event_sent_) { |
| 282 // Remove the touch slop region from the first scroll event to avoid a | 282 // Remove the touch slop region from the first scroll event to avoid a |
| 283 // jump. | 283 // jump. |
| 284 double distance = | 284 float distance = |
| 285 std::sqrt(distance_x * distance_x + distance_y * distance_y); | 285 std::sqrt(distance_x * distance_x + distance_y * distance_y); |
| 286 double epsilon = 1e-3; | 286 float epsilon = 1e-3f; |
| 287 if (distance > epsilon) { | 287 if (distance > epsilon) { |
| 288 double ratio = | 288 float ratio = |
| 289 std::max(0., | 289 std::max(0.f, |
| 290 distance - config_.gesture_detector_config.touch_slop) / | 290 distance - config_.gesture_detector_config.touch_slop) / |
| 291 distance; | 291 distance; |
| 292 distance_x *= ratio; | 292 distance_x *= ratio; |
| 293 distance_y *= ratio; | 293 distance_y *= ratio; |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Note that scroll start hints are in distance traveled, where | 296 // Note that scroll start hints are in distance traveled, where |
| 297 // scroll deltas are in the opposite direction. | 297 // scroll deltas are in the opposite direction. |
| 298 GestureEventDetails scroll_details( | 298 GestureEventDetails scroll_details( |
| 299 ET_GESTURE_SCROLL_BEGIN, -raw_distance_x, -raw_distance_y); | 299 ET_GESTURE_SCROLL_BEGIN, -raw_distance_x, -raw_distance_y); |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 // null'ing of the listener until the sequence has ended. | 813 // null'ing of the listener until the sequence has ended. |
| 814 if (current_down_event_) | 814 if (current_down_event_) |
| 815 return; | 815 return; |
| 816 | 816 |
| 817 const bool double_tap_enabled = | 817 const bool double_tap_enabled = |
| 818 double_tap_support_for_page_ && double_tap_support_for_platform_; | 818 double_tap_support_for_page_ && double_tap_support_for_platform_; |
| 819 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); | 819 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); |
| 820 } | 820 } |
| 821 | 821 |
| 822 } // namespace ui | 822 } // namespace ui |
| OLD | NEW |