Chromium Code Reviews| 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. | |
|
kylix_rd
2016/09/29 18:12:19
I noticed this comment and had a couple of cycles
| |
| 26 if (event->IsKeyEvent()) | 24 if (event->IsKeyEvent()) |
| 27 OnKeyEvent(static_cast<KeyEvent*>(event)); | 25 OnKeyEvent(event->AsKeyEvent()); |
| 28 else if (event->IsMouseEvent()) | 26 else if (event->IsMouseEvent()) |
| 29 OnMouseEvent(static_cast<MouseEvent*>(event)); | 27 OnMouseEvent(event->AsMouseEvent()); |
| 30 else if (event->IsScrollEvent()) | 28 else if (event->IsScrollEvent()) |
| 31 OnScrollEvent(static_cast<ScrollEvent*>(event)); | 29 OnScrollEvent(event->AsScrollEvent()); |
| 32 else if (event->IsTouchEvent()) | 30 else if (event->IsTouchEvent()) |
| 33 OnTouchEvent(static_cast<TouchEvent*>(event)); | 31 OnTouchEvent(event->AsTouchEvent()); |
| 34 else if (event->IsGestureEvent()) | 32 else if (event->IsGestureEvent()) |
| 35 OnGestureEvent(event->AsGestureEvent()); | 33 OnGestureEvent(event->AsGestureEvent()); |
| 36 else if (event->type() == ET_CANCEL_MODE) | 34 else if (event->type() == ET_CANCEL_MODE) |
| 37 OnCancelMode(static_cast<CancelModeEvent*>(event)); | 35 OnCancelMode(static_cast<CancelModeEvent*>(event)); |
|
kylix_rd
2016/09/29 18:12:19
Should there be an AsCancelMode() method on Event?
rjkroege
2016/10/03 17:42:45
my sense of implementation "rightness" is that the
kylix_rd
2016/10/03 18:29:04
Done.
| |
| 38 } | 36 } |
| 39 | 37 |
| 40 void EventHandler::OnKeyEvent(KeyEvent* event) { | 38 void EventHandler::OnKeyEvent(KeyEvent* event) { |
| 41 } | 39 } |
| 42 | 40 |
| 43 void EventHandler::OnMouseEvent(MouseEvent* event) { | 41 void EventHandler::OnMouseEvent(MouseEvent* event) { |
| 44 } | 42 } |
| 45 | 43 |
| 46 void EventHandler::OnScrollEvent(ScrollEvent* event) { | 44 void EventHandler::OnScrollEvent(ScrollEvent* event) { |
| 47 } | 45 } |
| 48 | 46 |
| 49 void EventHandler::OnTouchEvent(TouchEvent* event) { | 47 void EventHandler::OnTouchEvent(TouchEvent* event) { |
| 50 } | 48 } |
| 51 | 49 |
| 52 void EventHandler::OnGestureEvent(GestureEvent* event) { | 50 void EventHandler::OnGestureEvent(GestureEvent* event) { |
| 53 } | 51 } |
| 54 | 52 |
| 55 void EventHandler::OnCancelMode(CancelModeEvent* event) { | 53 void EventHandler::OnCancelMode(CancelModeEvent* event) { |
| 56 } | 54 } |
| 57 | 55 |
| 58 } // namespace ui | 56 } // namespace ui |
| OLD | NEW |