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/views/widget/root_view.h" | 5 #include "ui/views/widget/root_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 return child_count() > 0 ? child_at(0) : NULL; | 104 return child_count() > 0 ? child_at(0) : NULL; |
105 } | 105 } |
106 | 106 |
107 void RootView::NotifyNativeViewHierarchyChanged(bool attached, | 107 void RootView::NotifyNativeViewHierarchyChanged(bool attached, |
108 gfx::NativeView native_view) { | 108 gfx::NativeView native_view) { |
109 PropagateNativeViewHierarchyChanged(attached, native_view, this); | 109 PropagateNativeViewHierarchyChanged(attached, native_view, this); |
110 } | 110 } |
111 | 111 |
112 // Input ----------------------------------------------------------------------- | 112 // Input ----------------------------------------------------------------------- |
113 | 113 |
114 ui::EventResult RootView::DispatchKeyEvent(const ui::KeyEvent& event) { | 114 void RootView::DispatchKeyEvent(ui::KeyEvent* event) { |
115 bool consumed = false; | 115 bool consumed = false; |
116 | 116 |
117 View* v = NULL; | 117 View* v = NULL; |
118 if (GetFocusManager()) // NULL in unittests. | 118 if (GetFocusManager()) // NULL in unittests. |
119 v = GetFocusManager()->GetFocusedView(); | 119 v = GetFocusManager()->GetFocusedView(); |
120 // Special case to handle right-click context menus triggered by the | 120 // Special case to handle right-click context menus triggered by the |
121 // keyboard. | 121 // keyboard. |
122 if (v && v->enabled() && ((event.key_code() == ui::VKEY_APPS) || | 122 if (v && v->enabled() && ((event->key_code() == ui::VKEY_APPS) || |
123 (event.key_code() == ui::VKEY_F10 && event.IsShiftDown()))) { | 123 (event->key_code() == ui::VKEY_F10 && event->IsShiftDown()))) { |
124 v->ShowContextMenu(v->GetKeyboardContextMenuLocation(), false); | 124 v->ShowContextMenu(v->GetKeyboardContextMenuLocation(), false); |
125 return ui::ER_CONSUMED; | 125 event->StopPropagation(); |
| 126 return; |
126 } | 127 } |
127 for (; v && v != this && !consumed; v = v->parent()) { | 128 for (; v && v != this && !consumed; v = v->parent()) { |
128 consumed = (event.type() == ui::ET_KEY_PRESSED) ? | 129 consumed = (event->type() == ui::ET_KEY_PRESSED) ? |
129 v->OnKeyPressed(event) : v->OnKeyReleased(event); | 130 v->OnKeyPressed(*event) : v->OnKeyReleased(*event); |
130 } | 131 } |
131 | 132 |
132 return consumed ? ui::ER_CONSUMED : ui::ER_UNHANDLED; | 133 if (consumed) |
| 134 event->StopPropagation(); |
133 } | 135 } |
134 | 136 |
135 void RootView::DispatchScrollEvent(ui::ScrollEvent* event) { | 137 void RootView::DispatchScrollEvent(ui::ScrollEvent* event) { |
136 for (View* v = GetEventHandlerForPoint(event->location()); | 138 for (View* v = GetEventHandlerForPoint(event->location()); |
137 v && v != this && !event->stopped_propagation(); v = v->parent()) { | 139 v && v != this && !event->stopped_propagation(); v = v->parent()) { |
138 v->OnScrollEvent(event); | 140 v->OnScrollEvent(event); |
139 } | 141 } |
140 } | 142 } |
141 | 143 |
142 void RootView::DispatchTouchEvent(ui::TouchEvent* event) { | 144 void RootView::DispatchTouchEvent(ui::TouchEvent* event) { |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 } | 627 } |
626 | 628 |
627 void RootView::SetMouseLocationAndFlags(const ui::MouseEvent& event) { | 629 void RootView::SetMouseLocationAndFlags(const ui::MouseEvent& event) { |
628 last_mouse_event_flags_ = event.flags(); | 630 last_mouse_event_flags_ = event.flags(); |
629 last_mouse_event_x_ = event.x(); | 631 last_mouse_event_x_ = event.x(); |
630 last_mouse_event_y_ = event.y(); | 632 last_mouse_event_y_ = event.y(); |
631 } | 633 } |
632 | 634 |
633 } // namespace internal | 635 } // namespace internal |
634 } // namespace views | 636 } // namespace views |
OLD | NEW |