| 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/gestures/gesture_provider_aura.h" | 5 #include "ui/events/gestures/gesture_provider_aura.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 #include "ui/events/gesture_detection/gesture_config_helper.h" | 10 #include "ui/events/gesture_detection/gesture_config_helper.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 DCHECK(!handling_event_); | 55 DCHECK(!handling_event_); |
| 56 base::AutoReset<bool> handling_event(&handling_event_, true); | 56 base::AutoReset<bool> handling_event(&handling_event_, true); |
| 57 filtered_gesture_provider_.OnTouchEventAck(event_consumed); | 57 filtered_gesture_provider_.OnTouchEventAck(event_consumed); |
| 58 last_touch_event_latency_info_.Clear(); | 58 last_touch_event_latency_info_.Clear(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void GestureProviderAura::OnGestureEvent( | 61 void GestureProviderAura::OnGestureEvent( |
| 62 const GestureEventData& gesture) { | 62 const GestureEventData& gesture) { |
| 63 GestureEventDetails details = gesture.details; | 63 GestureEventDetails details = gesture.details; |
| 64 | 64 |
| 65 if (gesture.type == ET_GESTURE_TAP) { | 65 if (gesture.type() == ET_GESTURE_TAP) { |
| 66 int tap_count = 1; | 66 int tap_count = 1; |
| 67 if (previous_tap_ && IsConsideredDoubleTap(*previous_tap_, gesture)) | 67 if (previous_tap_ && IsConsideredDoubleTap(*previous_tap_, gesture)) |
| 68 tap_count = 1 + (previous_tap_->details.tap_count() % 3); | 68 tap_count = 1 + (previous_tap_->details.tap_count() % 3); |
| 69 details.set_tap_count(tap_count); | 69 details.set_tap_count(tap_count); |
| 70 if (!previous_tap_) | 70 if (!previous_tap_) |
| 71 previous_tap_.reset(new GestureEventData(gesture)); | 71 previous_tap_.reset(new GestureEventData(gesture)); |
| 72 else | 72 else |
| 73 *previous_tap_ = gesture; | 73 *previous_tap_ = gesture; |
| 74 previous_tap_->details = details; | 74 previous_tap_->details = details; |
| 75 } else if (gesture.type == ET_GESTURE_TAP_CANCEL) { | 75 } else if (gesture.type() == ET_GESTURE_TAP_CANCEL) { |
| 76 previous_tap_.reset(); | 76 previous_tap_.reset(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 scoped_ptr<ui::GestureEvent> event( | 79 scoped_ptr<ui::GestureEvent> event( |
| 80 new ui::GestureEvent(gesture.type, | 80 new ui::GestureEvent(gesture.type(), |
| 81 gesture.x, | 81 gesture.x, |
| 82 gesture.y, | 82 gesture.y, |
| 83 last_touch_event_flags_, | 83 last_touch_event_flags_, |
| 84 gesture.time - base::TimeTicks(), | 84 gesture.time - base::TimeTicks(), |
| 85 details, | 85 details, |
| 86 // ui::GestureEvent stores a bitfield indicating the | 86 // ui::GestureEvent stores a bitfield indicating the |
| 87 // ids of active touch points. This is currently only | 87 // ids of active touch points. This is currently only |
| 88 // used when one finger is down, and will eventually | 88 // used when one finger is down, and will eventually |
| 89 // be cleaned up. See crbug.com/366707. | 89 // be cleaned up. See crbug.com/366707. |
| 90 1 << gesture.motion_event_id)); | 90 1 << gesture.motion_event_id)); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 double double_tap_slop_square = | 134 double double_tap_slop_square = |
| 135 GestureConfiguration::max_distance_between_taps_for_double_tap(); | 135 GestureConfiguration::max_distance_between_taps_for_double_tap(); |
| 136 double_tap_slop_square *= double_tap_slop_square; | 136 double_tap_slop_square *= double_tap_slop_square; |
| 137 const float delta_x = previous_tap.x - current_tap.x; | 137 const float delta_x = previous_tap.x - current_tap.x; |
| 138 const float delta_y = previous_tap.y - current_tap.y; | 138 const float delta_y = previous_tap.y - current_tap.y; |
| 139 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); | 139 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace content | 142 } // namespace content |
| OLD | NEW |