| 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_configuration.h" | 10 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 11 #include "ui/events/gesture_detection/gesture_event_data.h" | 11 #include "ui/events/gesture_detection/gesture_event_data.h" |
| 12 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 12 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 | 15 |
| 16 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client) | 16 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client) |
| 17 : client_(client), | 17 : client_(client), |
| 18 filtered_gesture_provider_(DefaultGestureProviderConfig(), this), | 18 filtered_gesture_provider_(DefaultGestureProviderConfig(), this), |
| 19 handling_event_(false) { | 19 handling_event_(false) { |
| 20 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); | 20 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); |
| 21 } | 21 } |
| 22 | 22 |
| 23 GestureProviderAura::~GestureProviderAura() {} | 23 GestureProviderAura::~GestureProviderAura() {} |
| 24 | 24 |
| 25 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { | 25 bool GestureProviderAura::OnTouchEvent(TouchEvent* event) { |
| 26 int index = pointer_state_.FindPointerIndexOfId(event.touch_id()); | 26 DCHECK(event); |
| 27 int index = pointer_state_.FindPointerIndexOfId(event->touch_id()); |
| 27 bool pointer_id_is_active = index != -1; | 28 bool pointer_id_is_active = index != -1; |
| 28 | 29 |
| 29 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { | 30 if (event->type() == ET_TOUCH_PRESSED && pointer_id_is_active) { |
| 30 // Ignore touch press events if we already believe the pointer is down. | 31 // Ignore touch press events if we already believe the pointer is down. |
| 31 return false; | 32 return false; |
| 32 } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { | 33 } else if (event->type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { |
| 33 // We could have an active touch stream transfered to us, resulting in touch | 34 // We could have an active touch stream transfered to us, resulting in touch |
| 34 // move or touch up events without associated touch down events. Ignore | 35 // move or touch up events without associated touch down events. Ignore |
| 35 // them. | 36 // them. |
| 36 return false; | 37 return false; |
| 37 } | 38 } |
| 38 | 39 |
| 39 // If this is a touchmove event, and it isn't different from the last | 40 // If this is a touchmove event, and it isn't different from the last |
| 40 // event, ignore it. | 41 // event, ignore it. |
| 41 if (event.type() == ET_TOUCH_MOVED && | 42 if (event->type() == ET_TOUCH_MOVED && |
| 42 event.x() == pointer_state_.GetX(index) && | 43 event->x() == pointer_state_.GetX(index) && |
| 43 event.y() == pointer_state_.GetY(index)) { | 44 event->y() == pointer_state_.GetY(index)) { |
| 44 return false; | 45 return false; |
| 45 } | 46 } |
| 46 | 47 |
| 47 last_touch_event_latency_info_ = *event.latency(); | 48 last_touch_event_latency_info_ = *event->latency(); |
| 48 pointer_state_.OnTouch(event); | 49 pointer_state_.OnTouch(*event); |
| 49 | 50 |
| 50 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); | 51 auto result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); |
| 51 pointer_state_.CleanupRemovedTouchPoints(event); | 52 if (!result.succeeded) |
| 52 return result; | 53 return false; |
| 54 |
| 55 event->set_causes_scrolling(result.did_generate_scroll); |
| 56 pointer_state_.CleanupRemovedTouchPoints(*event); |
| 57 return true; |
| 53 } | 58 } |
| 54 | 59 |
| 55 void GestureProviderAura::OnTouchEventAck(bool event_consumed) { | 60 void GestureProviderAura::OnTouchEventAck(bool event_consumed) { |
| 56 DCHECK(pending_gestures_.empty()); | 61 DCHECK(pending_gestures_.empty()); |
| 57 DCHECK(!handling_event_); | 62 DCHECK(!handling_event_); |
| 58 base::AutoReset<bool> handling_event(&handling_event_, true); | 63 base::AutoReset<bool> handling_event(&handling_event_, true); |
| 59 filtered_gesture_provider_.OnTouchEventAck(event_consumed); | 64 filtered_gesture_provider_.OnTouchEventAck(event_consumed); |
| 60 last_touch_event_latency_info_.Clear(); | 65 last_touch_event_latency_info_.Clear(); |
| 61 } | 66 } |
| 62 | 67 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 float double_tap_slop_square = | 135 float double_tap_slop_square = |
| 131 GestureConfiguration::GetInstance() | 136 GestureConfiguration::GetInstance() |
| 132 ->max_distance_between_taps_for_double_tap(); | 137 ->max_distance_between_taps_for_double_tap(); |
| 133 double_tap_slop_square *= double_tap_slop_square; | 138 double_tap_slop_square *= double_tap_slop_square; |
| 134 const float delta_x = previous_tap.x - current_tap.x; | 139 const float delta_x = previous_tap.x - current_tap.x; |
| 135 const float delta_y = previous_tap.y - current_tap.y; | 140 const float delta_y = previous_tap.y - current_tap.y; |
| 136 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); | 141 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); |
| 137 } | 142 } |
| 138 | 143 |
| 139 } // namespace content | 144 } // namespace content |
| OLD | NEW |