| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 void GestureProviderAura::OnGestureEvent(const GestureEventData& gesture) { | 54 void GestureProviderAura::OnGestureEvent(const GestureEventData& gesture) { |
| 55 std::unique_ptr<ui::GestureEvent> event( | 55 std::unique_ptr<ui::GestureEvent> event( |
| 56 new ui::GestureEvent(gesture.x, gesture.y, gesture.flags, | 56 new ui::GestureEvent(gesture.x, gesture.y, gesture.flags, |
| 57 gesture.time, gesture.details, | 57 gesture.time, gesture.details, |
| 58 gesture.unique_touch_event_id)); | 58 gesture.unique_touch_event_id)); |
| 59 | 59 |
| 60 if (!handling_event_) { | 60 if (!handling_event_) { |
| 61 // Dispatching event caused by timer. | 61 // Dispatching event caused by timer. |
| 62 client_->OnGestureEvent(gesture_consumer_, event.get()); | 62 client_->OnGestureEvent(gesture_consumer_, event.get()); |
| 63 } else { | 63 } else { |
| 64 // Memory managed by ScopedVector pending_gestures_. | |
| 65 pending_gestures_.push_back(std::move(event)); | 64 pending_gestures_.push_back(std::move(event)); |
| 66 } | 65 } |
| 67 } | 66 } |
| 68 | 67 |
| 69 ScopedVector<GestureEvent>* GestureProviderAura::GetAndResetPendingGestures() { | 68 std::vector<std::unique_ptr<GestureEvent>> |
| 70 if (pending_gestures_.empty()) | 69 GestureProviderAura::GetAndResetPendingGestures() { |
| 71 return NULL; | 70 std::vector<std::unique_ptr<GestureEvent>> result; |
| 72 // Caller is responsible for deleting old_pending_gestures. | 71 result.swap(pending_gestures_); |
| 73 ScopedVector<GestureEvent>* old_pending_gestures = | 72 return result; |
| 74 new ScopedVector<GestureEvent>(); | |
| 75 old_pending_gestures->swap(pending_gestures_); | |
| 76 return old_pending_gestures; | |
| 77 } | 73 } |
| 78 | 74 |
| 79 void GestureProviderAura::OnTouchEnter(int pointer_id, float x, float y) { | 75 void GestureProviderAura::OnTouchEnter(int pointer_id, float x, float y) { |
| 80 std::unique_ptr<TouchEvent> touch_event(new TouchEvent( | 76 std::unique_ptr<TouchEvent> touch_event(new TouchEvent( |
| 81 ET_TOUCH_PRESSED, gfx::Point(), EF_IS_SYNTHESIZED, pointer_id, | 77 ET_TOUCH_PRESSED, gfx::Point(), EF_IS_SYNTHESIZED, pointer_id, |
| 82 ui::EventTimeForNow(), 0.0f, 0.0f, 0.0f, 0.0f)); | 78 ui::EventTimeForNow(), 0.0f, 0.0f, 0.0f, 0.0f)); |
| 83 gfx::PointF point(x, y); | 79 gfx::PointF point(x, y); |
| 84 touch_event->set_location_f(point); | 80 touch_event->set_location_f(point); |
| 85 touch_event->set_root_location_f(point); | 81 touch_event->set_root_location_f(point); |
| 86 | 82 |
| 87 OnTouchEvent(touch_event.get()); | 83 OnTouchEvent(touch_event.get()); |
| 88 OnTouchEventAck(touch_event->unique_event_id(), true); | 84 OnTouchEventAck(touch_event->unique_event_id(), true); |
| 89 } | 85 } |
| 90 | 86 |
| 91 } // namespace content | 87 } // namespace content |
| OLD | NEW |