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/events/event.h" | 7 #include "ui/events/event.h" |
8 #include "ui/events/event_dispatcher.h" | 8 #include "ui/events/event_dispatcher.h" |
9 | 9 |
10 namespace ui { | 10 namespace ui { |
11 | 11 |
12 EventHandler::EventHandler() { | 12 EventHandler::EventHandler() { |
13 } | 13 } |
14 | 14 |
15 EventHandler::~EventHandler() { | 15 EventHandler::~EventHandler() { |
16 while (!dispatchers_.empty()) { | 16 while (!dispatchers_.empty()) { |
17 EventDispatcher* dispatcher = dispatchers_.top(); | 17 EventDispatcher* dispatcher = dispatchers_.top(); |
18 dispatchers_.pop(); | 18 dispatchers_.pop(); |
19 dispatcher->OnHandlerDestroyed(this); | 19 dispatcher->OnHandlerDestroyed(this); |
20 } | 20 } |
21 } | 21 } |
22 | 22 |
23 void EventHandler::OnEvent(Event* event) { | 23 void EventHandler::OnEvent(Event* event) { |
| 24 // TODO(tdanderson): Encapsulate static_casts in ui::Event for all |
| 25 // event types. |
24 if (event->IsKeyEvent()) | 26 if (event->IsKeyEvent()) |
25 OnKeyEvent(static_cast<KeyEvent*>(event)); | 27 OnKeyEvent(static_cast<KeyEvent*>(event)); |
26 else if (event->IsMouseEvent()) | 28 else if (event->IsMouseEvent()) |
27 OnMouseEvent(static_cast<MouseEvent*>(event)); | 29 OnMouseEvent(static_cast<MouseEvent*>(event)); |
28 else if (event->IsScrollEvent()) | 30 else if (event->IsScrollEvent()) |
29 OnScrollEvent(static_cast<ScrollEvent*>(event)); | 31 OnScrollEvent(static_cast<ScrollEvent*>(event)); |
30 else if (event->IsTouchEvent()) | 32 else if (event->IsTouchEvent()) |
31 OnTouchEvent(static_cast<TouchEvent*>(event)); | 33 OnTouchEvent(static_cast<TouchEvent*>(event)); |
32 else if (event->IsGestureEvent()) | 34 else if (event->IsGestureEvent()) |
33 OnGestureEvent(static_cast<GestureEvent*>(event)); | 35 OnGestureEvent(event->AsGestureEvent()); |
34 else if (event->type() == ET_CANCEL_MODE) | 36 else if (event->type() == ET_CANCEL_MODE) |
35 OnCancelMode(static_cast<CancelModeEvent*>(event)); | 37 OnCancelMode(static_cast<CancelModeEvent*>(event)); |
36 } | 38 } |
37 | 39 |
38 void EventHandler::OnKeyEvent(KeyEvent* event) { | 40 void EventHandler::OnKeyEvent(KeyEvent* event) { |
39 } | 41 } |
40 | 42 |
41 void EventHandler::OnMouseEvent(MouseEvent* event) { | 43 void EventHandler::OnMouseEvent(MouseEvent* event) { |
42 } | 44 } |
43 | 45 |
44 void EventHandler::OnScrollEvent(ScrollEvent* event) { | 46 void EventHandler::OnScrollEvent(ScrollEvent* event) { |
45 } | 47 } |
46 | 48 |
47 void EventHandler::OnTouchEvent(TouchEvent* event) { | 49 void EventHandler::OnTouchEvent(TouchEvent* event) { |
48 } | 50 } |
49 | 51 |
50 void EventHandler::OnGestureEvent(GestureEvent* event) { | 52 void EventHandler::OnGestureEvent(GestureEvent* event) { |
51 } | 53 } |
52 | 54 |
53 void EventHandler::OnCancelMode(CancelModeEvent* event) { | 55 void EventHandler::OnCancelMode(CancelModeEvent* event) { |
54 } | 56 } |
55 | 57 |
56 } // namespace ui | 58 } // namespace ui |
OLD | NEW |