| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/event_handler.h" | 5 #include "ui/events/event_handler.h" |
| 6 | 6 |
| 7 #include "ui/base/accelerators/accelerator_history.h" |
| 7 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 8 #include "ui/events/event_dispatcher.h" | 9 #include "ui/events/event_dispatcher.h" |
| 9 | 10 |
| 10 namespace ui { | 11 namespace ui { |
| 11 | 12 |
| 12 EventHandler::EventHandler() { | 13 EventHandler::EventHandler() { |
| 13 } | 14 } |
| 14 | 15 |
| 15 EventHandler::~EventHandler() { | 16 EventHandler::~EventHandler() { |
| 16 while (!dispatchers_.empty()) { | 17 while (!dispatchers_.empty()) { |
| 17 EventDispatcher* dispatcher = dispatchers_.top(); | 18 EventDispatcher* dispatcher = dispatchers_.top(); |
| 18 dispatchers_.pop(); | 19 dispatchers_.pop(); |
| 19 dispatcher->OnHandlerDestroyed(this); | 20 dispatcher->OnHandlerDestroyed(this); |
| 20 } | 21 } |
| 21 } | 22 } |
| 22 | 23 |
| 23 void EventHandler::OnEvent(Event* event) { | 24 void EventHandler::OnEvent(Event* event) { |
| 24 // TODO(tdanderson): Encapsulate static_casts in ui::Event for all | 25 // TODO(tdanderson): Encapsulate static_casts in ui::Event for all |
| 25 // event types. | 26 // event types. |
| 26 if (event->IsKeyEvent()) | 27 if (event->IsKeyEvent()) { |
| 28 AcceleratorHistory::GetInstance()->BuildCurrentAccelerator( |
| 29 static_cast<const KeyEvent&>(*event)); |
| 27 OnKeyEvent(static_cast<KeyEvent*>(event)); | 30 OnKeyEvent(static_cast<KeyEvent*>(event)); |
| 28 else if (event->IsMouseEvent()) | 31 } else if (event->IsMouseEvent()) |
| 29 OnMouseEvent(static_cast<MouseEvent*>(event)); | 32 OnMouseEvent(static_cast<MouseEvent*>(event)); |
| 30 else if (event->IsScrollEvent()) | 33 else if (event->IsScrollEvent()) |
| 31 OnScrollEvent(static_cast<ScrollEvent*>(event)); | 34 OnScrollEvent(static_cast<ScrollEvent*>(event)); |
| 32 else if (event->IsTouchEvent()) | 35 else if (event->IsTouchEvent()) |
| 33 OnTouchEvent(static_cast<TouchEvent*>(event)); | 36 OnTouchEvent(static_cast<TouchEvent*>(event)); |
| 34 else if (event->IsGestureEvent()) | 37 else if (event->IsGestureEvent()) |
| 35 OnGestureEvent(event->AsGestureEvent()); | 38 OnGestureEvent(event->AsGestureEvent()); |
| 36 else if (event->type() == ET_CANCEL_MODE) | 39 else if (event->type() == ET_CANCEL_MODE) |
| 37 OnCancelMode(static_cast<CancelModeEvent*>(event)); | 40 OnCancelMode(static_cast<CancelModeEvent*>(event)); |
| 38 } | 41 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 49 void EventHandler::OnTouchEvent(TouchEvent* event) { | 52 void EventHandler::OnTouchEvent(TouchEvent* event) { |
| 50 } | 53 } |
| 51 | 54 |
| 52 void EventHandler::OnGestureEvent(GestureEvent* event) { | 55 void EventHandler::OnGestureEvent(GestureEvent* event) { |
| 53 } | 56 } |
| 54 | 57 |
| 55 void EventHandler::OnCancelMode(CancelModeEvent* event) { | 58 void EventHandler::OnCancelMode(CancelModeEvent* event) { |
| 56 } | 59 } |
| 57 | 60 |
| 58 } // namespace ui | 61 } // namespace ui |
| OLD | NEW |