| 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_( |
| 19 GetGestureProviderConfig(GestureProviderConfigType::CURRENT_PLATFORM), |
| 20 this), |
| 19 handling_event_(false) { | 21 handling_event_(false) { |
| 20 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); | 22 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); |
| 21 } | 23 } |
| 22 | 24 |
| 23 GestureProviderAura::~GestureProviderAura() {} | 25 GestureProviderAura::~GestureProviderAura() {} |
| 24 | 26 |
| 25 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { | 27 bool GestureProviderAura::OnTouchEvent(TouchEvent* event) { |
| 26 int index = pointer_state_.FindPointerIndexOfId(event.touch_id()); | 28 DCHECK(event); |
| 29 int index = pointer_state_.FindPointerIndexOfId(event->touch_id()); |
| 27 bool pointer_id_is_active = index != -1; | 30 bool pointer_id_is_active = index != -1; |
| 28 | 31 |
| 29 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { | 32 if (event->type() == ET_TOUCH_PRESSED && pointer_id_is_active) { |
| 30 // Ignore touch press events if we already believe the pointer is down. | 33 // Ignore touch press events if we already believe the pointer is down. |
| 31 return false; | 34 return false; |
| 32 } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { | 35 } 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 | 36 // 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 | 37 // move or touch up events without associated touch down events. Ignore |
| 35 // them. | 38 // them. |
| 36 return false; | 39 return false; |
| 37 } | 40 } |
| 38 | 41 |
| 39 // If this is a touchmove event, and it isn't different from the last | 42 // If this is a touchmove event, and it isn't different from the last |
| 40 // event, ignore it. | 43 // event, ignore it. |
| 41 if (event.type() == ET_TOUCH_MOVED && | 44 if (event->type() == ET_TOUCH_MOVED && |
| 42 event.x() == pointer_state_.GetX(index) && | 45 event->x() == pointer_state_.GetX(index) && |
| 43 event.y() == pointer_state_.GetY(index)) { | 46 event->y() == pointer_state_.GetY(index)) { |
| 44 return false; | 47 return false; |
| 45 } | 48 } |
| 46 | 49 |
| 47 last_touch_event_latency_info_ = *event.latency(); | 50 last_touch_event_latency_info_ = *event->latency(); |
| 48 pointer_state_.OnTouch(event); | 51 pointer_state_.OnTouch(*event); |
| 49 | 52 |
| 50 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); | 53 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); |
| 51 pointer_state_.CleanupRemovedTouchPoints(event); | 54 event->set_may_cause_scrolling( |
| 55 filtered_gesture_provider_.LastTouchEventDidGenerateScroll()); |
| 56 pointer_state_.CleanupRemovedTouchPoints(*event); |
| 52 return result; | 57 return result; |
| 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 } |
| (...skipping 68 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 |