| 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 13 matching lines...) Expand all Loading... |
| 24 case MotionEvent::ACTION_POINTER_UP: return "ACTION_POINTER_UP"; | 24 case MotionEvent::ACTION_POINTER_UP: return "ACTION_POINTER_UP"; |
| 25 case MotionEvent::ACTION_DOWN: return "ACTION_DOWN"; | 25 case MotionEvent::ACTION_DOWN: return "ACTION_DOWN"; |
| 26 case MotionEvent::ACTION_UP: return "ACTION_UP"; | 26 case MotionEvent::ACTION_UP: return "ACTION_UP"; |
| 27 case MotionEvent::ACTION_CANCEL: return "ACTION_CANCEL"; | 27 case MotionEvent::ACTION_CANCEL: return "ACTION_CANCEL"; |
| 28 case MotionEvent::ACTION_MOVE: return "ACTION_MOVE"; | 28 case MotionEvent::ACTION_MOVE: return "ACTION_MOVE"; |
| 29 } | 29 } |
| 30 return ""; | 30 return ""; |
| 31 } | 31 } |
| 32 | 32 |
| 33 gfx::RectF GetBoundingBox(const MotionEvent& event) { | 33 gfx::RectF GetBoundingBox(const MotionEvent& event) { |
| 34 gfx::RectF bounds; | 34 // Can't use gfx::RectF::Union, as it ignores touches with a radius of 0. |
| 35 float left = std::numeric_limits<float>::max(); |
| 36 float top = std::numeric_limits<float>::max(); |
| 37 float right = -std::numeric_limits<float>::max(); |
| 38 float bottom = -std::numeric_limits<float>::max(); |
| 35 for (size_t i = 0; i < event.GetPointerCount(); ++i) { | 39 for (size_t i = 0; i < event.GetPointerCount(); ++i) { |
| 36 float diameter = event.GetTouchMajor(i); | 40 float diameter = event.GetTouchMajor(i); |
| 37 bounds.Union(gfx::RectF(event.GetX(i) - diameter / 2, | 41 float x = event.GetX(i) - diameter / 2; |
| 38 event.GetY(i) - diameter / 2, | 42 float y = event.GetY(i) - diameter / 2; |
| 39 diameter, | 43 left = std::min(left, x); |
| 40 diameter)); | 44 right = std::max(right, x + diameter); |
| 45 top = std::min(top, y); |
| 46 bottom = std::max(bottom, y + diameter); |
| 41 } | 47 } |
| 42 return bounds; | 48 return gfx::RectF(left, top, right - left, bottom - top); |
| 43 } | 49 } |
| 44 | 50 |
| 45 GestureEventData CreateGesture(const GestureEventDetails& details, | 51 GestureEventData CreateGesture(const GestureEventDetails& details, |
| 46 int motion_event_id, | 52 int motion_event_id, |
| 47 base::TimeTicks time, | 53 base::TimeTicks time, |
| 48 float x, | 54 float x, |
| 49 float y, | 55 float y, |
| 50 float raw_x, | 56 float raw_x, |
| 51 float raw_y, | 57 float raw_y, |
| 52 size_t touch_point_count, | 58 size_t touch_point_count, |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 if (current_down_event_) | 819 if (current_down_event_) |
| 814 return; | 820 return; |
| 815 | 821 |
| 816 const bool double_tap_enabled = double_tap_support_for_page_ && | 822 const bool double_tap_enabled = double_tap_support_for_page_ && |
| 817 double_tap_support_for_platform_; | 823 double_tap_support_for_platform_; |
| 818 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); | 824 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); |
| 819 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); | 825 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); |
| 820 } | 826 } |
| 821 | 827 |
| 822 } // namespace ui | 828 } // namespace ui |
| OLD | NEW |