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.
4
5#include "ui/events/event_handler.h"
6
7#include "ui/events/event.h"
8#include "ui/events/event_dispatcher.h"
9
10namespace ui {
11
12EventHandler::EventHandler() {
13}
14
15EventHandler::~EventHandler() {
16  while (!dispatchers_.empty()) {
17    EventDispatcher* dispatcher = dispatchers_.top();
18    dispatchers_.pop();
19    dispatcher->OnHandlerDestroyed(this);
20  }
21}
22
23void 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));
38}
39
40void EventHandler::OnKeyEvent(KeyEvent* event) {
41}
42
43void EventHandler::OnMouseEvent(MouseEvent* event) {
44}
45
46void EventHandler::OnScrollEvent(ScrollEvent* event) {
47}
48
49void EventHandler::OnTouchEvent(TouchEvent* event) {
50}
51
52void EventHandler::OnGestureEvent(GestureEvent* event) {
53}
54
55void EventHandler::OnCancelMode(CancelModeEvent* event) {
56}
57
58}  // namespace ui
59