Chromium Code Reviews| Index: ui/events/gestures/gesture_provider_aura.cc |
| diff --git a/ui/events/gestures/gesture_provider_aura.cc b/ui/events/gestures/gesture_provider_aura.cc |
| index 0db2e04f882d52dd017c8e31a33d5a6638eabea7..236d7be1de5fc540d246a07205244afa0308c69a 100644 |
| --- a/ui/events/gestures/gesture_provider_aura.cc |
| +++ b/ui/events/gestures/gesture_provider_aura.cc |
| @@ -4,6 +4,7 @@ |
| #include "ui/events/gestures/gesture_provider_aura.h" |
| +#include "base/auto_reset.h" |
| #include "base/logging.h" |
| #include "ui/events/event.h" |
| #include "ui/events/gesture_detection/gesture_config_helper.h" |
| @@ -14,7 +15,8 @@ namespace ui { |
| GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client) |
| : client_(client), |
| - filtered_gesture_provider_(ui::DefaultGestureProviderConfig(), this) { |
| + filtered_gesture_provider_(ui::DefaultGestureProviderConfig(), this), |
| + handling_event_(false) { |
| filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); |
| } |
| @@ -48,6 +50,9 @@ bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { |
| } |
| void GestureProviderAura::OnTouchEventAck(bool event_consumed) { |
| + DCHECK(pending_gestures_.empty()); |
| + DCHECK(!handling_event_); |
| + base::AutoReset<bool> handling_event(&handling_event_, true); |
| filtered_gesture_provider_.OnTouchEventAck(event_consumed); |
| } |
| @@ -69,18 +74,34 @@ void GestureProviderAura::OnGestureEvent( |
| previous_tap_.reset(); |
| } |
| - ui::GestureEvent event(gesture.type, |
| - gesture.x, |
| - gesture.y, |
| - last_touch_event_flags_, |
| - gesture.time - base::TimeTicks(), |
| - details, |
| - // ui::GestureEvent stores a bitfield indicating the |
| - // ids of active touch points. This is currently only |
| - // used when one finger is down, and will eventually |
| - // be cleaned up. See crbug.com/366707. |
| - 1 << gesture.motion_event_id); |
| - client_->OnGestureEvent(&event); |
| + scoped_ptr<ui::GestureEvent> event( |
| + new ui::GestureEvent(gesture.type, |
| + gesture.x, |
| + gesture.y, |
| + last_touch_event_flags_, |
| + gesture.time - base::TimeTicks(), |
| + details, |
| + // ui::GestureEvent stores a bitfield indicating the |
| + // ids of active touch points. This is currently only |
| + // used when one finger is down, and will eventually |
| + // be cleaned up. See crbug.com/366707. |
| + 1 << gesture.motion_event_id)); |
| + |
| + if (!handling_event_) { |
| + // Dispatching event caused by timer. |
| + client_->OnGestureEvent(event.get()); |
| + } else { |
| + // Memory managed by ScopedVector pending_gestures_. |
| + pending_gestures_.push_back(event.release()); |
| + } |
| +} |
| + |
| +ScopedVector<GestureEvent>* GestureProviderAura::GetAndResetPendingGestures() { |
| + // Caller is responsible for deleting old_pending_gestures. |
| + ScopedVector<GestureEvent>* old_pending_gestures = |
|
jdduke (slow)
2014/05/29 16:25:40
Returning NULL is OK, right? If so, please check f
tdresser
2014/05/30 14:05:37
Done.
|
| + new ScopedVector<GestureEvent>(); |
| + old_pending_gestures->swap(pending_gestures_); |
| + return old_pending_gestures; |
| } |
| bool GestureProviderAura::IsConsideredDoubleTap( |