Chromium Code Reviews| Index: ui/aura/root_window.cc |
| =================================================================== |
| --- ui/aura/root_window.cc (revision 218517) |
| +++ ui/aura/root_window.cc (working copy) |
| @@ -216,6 +216,11 @@ |
| } |
| void RootWindow::RepostEvent(const ui::LocatedEvent& event) { |
| + if (event.type() != ui::ET_MOUSE_PRESSED && |
|
sky
2013/08/22 22:07:16
I think this should just be a DCHECK. Also, docume
ananta
2013/08/22 22:48:15
Done.
|
| + event.type() != ui::ET_GESTURE_TAP_DOWN) { |
| + NOTREACHED() << "Invalid event type: " << event.type(); |
| + return; |
| + } |
| // We allow for only one outstanding repostable event. This is used |
| // in exiting context menus. A dropped repost request is allowed. |
| if (event.type() == ui::ET_MOUSE_PRESSED) { |
| @@ -224,15 +229,22 @@ |
| static_cast<const ui::MouseEvent&>(event), |
| static_cast<aura::Window*>(event.target()), |
| static_cast<aura::Window*>(this))); |
| - base::MessageLoop::current()->PostTask( |
| - FROM_HERE, |
| - base::Bind(&RootWindow::DispatchHeldEvents, |
| - repostable_event_factory_.GetWeakPtr())); |
| } else { |
| - DCHECK(event.type() == ui::ET_GESTURE_TAP_DOWN); |
| - held_repostable_event_.reset(); |
| - // TODO(sschmitz): add similar code for gesture events. |
| + const ui::GestureEvent* gesture_event = |
| + static_cast<const ui::GestureEvent*>(&event); |
| + held_repostable_event_.reset(new ui::GestureEvent( |
| + gesture_event->type(), |
| + gesture_event->root_location().x(), |
| + gesture_event->root_location().y(), |
| + gesture_event->flags(), |
| + gesture_event->time_stamp(), |
| + gesture_event->details(), |
| + gesture_event->touch_ids_bitfield())); |
| } |
| + base::MessageLoop::current()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&RootWindow::DispatchHeldEvents, |
| + repostable_event_factory_.GetWeakPtr())); |
| } |
| RootWindowHostDelegate* RootWindow::AsRootWindowHostDelegate() { |
| @@ -1017,6 +1029,24 @@ |
| return DispatchMouseEventToTarget(event, target); |
| } |
| +bool RootWindow::DispatchGestureEventRepost(ui::GestureEvent* event) { |
| + if (event->type() != ui::ET_GESTURE_TAP_DOWN) |
| + return false; |
| + |
| + // Cleanup stale gesture events for the old gesture target. |
| + GestureConsumer* old_consumer = GetGestureTarget(event); |
| + if (old_consumer) { |
|
sky
2013/08/22 22:07:16
nit: no {}
ananta
2013/08/22 22:48:15
Done.
|
| + CleanupGestureRecognizerState(static_cast<aura::Window*>(old_consumer)); |
| + } |
| + |
| + Window* new_consumer = GetEventHandlerForPoint(event->root_location()); |
| + if (new_consumer) { |
| + ProcessEvent(new_consumer, event); |
| + return event->handled(); |
| + } |
| + return false; |
| +} |
| + |
| bool RootWindow::DispatchMouseEventToTarget(ui::MouseEvent* event, |
| Window* target) { |
| client::CursorClient* cursor_client = client::GetCursorClient(this); |
| @@ -1144,11 +1174,14 @@ |
| if (held_repostable_event_->type() == ui::ET_MOUSE_PRESSED) { |
| ui::MouseEvent mouse_event( |
| static_cast<const ui::MouseEvent&>(*held_repostable_event_.get())); |
| - held_repostable_event_.reset(); // must be reset before dispatch |
| + held_repostable_event_.reset(); // must be reset before dispatch |
| DispatchMouseEventRepost(&mouse_event); |
| } else { |
| DCHECK(held_repostable_event_->type() == ui::ET_GESTURE_TAP_DOWN); |
| - // TODO(sschmitz): add similar code for gesture events |
| + ui::GestureEvent gesture_event( |
| + static_cast<const ui::GestureEvent&>(*held_repostable_event_.get())); |
| + held_repostable_event_.reset(); // must be reset before dispatch |
| + DispatchGestureEventRepost(&gesture_event); |
| } |
| held_repostable_event_.reset(); |
| } |