Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / events / event_handler.cc
blob0f79c3556fb477e3cffda4d75920fe9cc767101b
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
3 // found in the LICENSE file.
5 #include "ui/events/event_handler.h"
7 #include "ui/events/event.h"
8 #include "ui/events/event_dispatcher.h"
10 namespace ui {
12 EventHandler::EventHandler() {
15 EventHandler::~EventHandler() {
16 while (!dispatchers_.empty()) {
17 EventDispatcher* dispatcher = dispatchers_.top();
18 dispatchers_.pop();
19 dispatcher->OnHandlerDestroyed(this);
23 void EventHandler::OnEvent(Event* event) {
24 // TODO(tdanderson): Encapsulate static_casts in ui::Event for all
25 // event types.
26 if (event->IsKeyEvent())
27 OnKeyEvent(static_cast<KeyEvent*>(event));
28 else if (event->IsMouseEvent())
29 OnMouseEvent(static_cast<MouseEvent*>(event));
30 else if (event->IsScrollEvent())
31 OnScrollEvent(static_cast<ScrollEvent*>(event));
32 else if (event->IsTouchEvent())
33 OnTouchEvent(static_cast<TouchEvent*>(event));
34 else if (event->IsGestureEvent())
35 OnGestureEvent(event->AsGestureEvent());
36 else if (event->type() == ET_CANCEL_MODE)
37 OnCancelMode(static_cast<CancelModeEvent*>(event));
40 void EventHandler::OnKeyEvent(KeyEvent* event) {
43 void EventHandler::OnMouseEvent(MouseEvent* event) {
46 void EventHandler::OnScrollEvent(ScrollEvent* event) {
49 void EventHandler::OnTouchEvent(TouchEvent* event) {
52 void EventHandler::OnGestureEvent(GestureEvent* event) {
55 void EventHandler::OnCancelMode(CancelModeEvent* event) {
58 } // namespace ui