| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/views/widget/root_view.h" | 5 #include "chrome/views/widget/root_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include "base/base_drag_source.h" | 10 #include "base/base_drag_source.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 mouse_move_handler_(NULL), | 61 mouse_move_handler_(NULL), |
| 62 last_click_handler_(NULL), | 62 last_click_handler_(NULL), |
| 63 widget_(widget), | 63 widget_(widget), |
| 64 invalid_rect_urgent_(false), | 64 invalid_rect_urgent_(false), |
| 65 pending_paint_task_(NULL), | 65 pending_paint_task_(NULL), |
| 66 paint_task_needed_(false), | 66 paint_task_needed_(false), |
| 67 explicit_mouse_handler_(false), | 67 explicit_mouse_handler_(false), |
| 68 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
| 69 previous_cursor_(NULL), | 69 previous_cursor_(NULL), |
| 70 #endif | 70 #endif |
| 71 default_keyboard_hander_(NULL), | 71 default_keyboard_handler_(NULL), |
| 72 focus_listener_(NULL), | 72 focus_listener_(NULL), |
| 73 focus_on_mouse_pressed_(false), | 73 focus_on_mouse_pressed_(false), |
| 74 ignore_set_focus_calls_(false), | 74 ignore_set_focus_calls_(false), |
| 75 focus_traversable_parent_(NULL), | 75 focus_traversable_parent_(NULL), |
| 76 focus_traversable_parent_view_(NULL), | 76 focus_traversable_parent_view_(NULL), |
| 77 drag_view_(NULL) | 77 drag_view_(NULL) |
| 78 #ifndef NDEBUG | 78 #ifndef NDEBUG |
| 79 , | 79 , |
| 80 is_processing_paint_(false) | 80 is_processing_paint_(false) |
| 81 #endif | 81 #endif |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 mouse_move_handler_ = NULL; | 251 mouse_move_handler_ = NULL; |
| 252 } | 252 } |
| 253 | 253 |
| 254 if (GetFocusedView() == child) { | 254 if (GetFocusedView() == child) { |
| 255 FocusView(NULL); | 255 FocusView(NULL); |
| 256 } | 256 } |
| 257 | 257 |
| 258 if (child == drag_view_) | 258 if (child == drag_view_) |
| 259 drag_view_ = NULL; | 259 drag_view_ = NULL; |
| 260 | 260 |
| 261 if (default_keyboard_hander_ == child) { | 261 if (default_keyboard_handler_ == child) { |
| 262 default_keyboard_hander_ = NULL; | 262 default_keyboard_handler_ = NULL; |
| 263 } | 263 } |
| 264 NotificationService::current()->Notify( | 264 NotificationService::current()->Notify( |
| 265 NotificationType::VIEW_REMOVED, | 265 NotificationType::VIEW_REMOVED, |
| 266 Source<View>(child), | 266 Source<View>(child), |
| 267 Details<View>(parent)); | 267 Details<View>(parent)); |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| 271 void RootView::SetFocusOnMousePressed(bool f) { | 271 void RootView::SetFocusOnMousePressed(bool f) { |
| 272 focus_on_mouse_pressed_ = f; | 272 focus_on_mouse_pressed_ = f; |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 #else | 864 #else |
| 865 // TODO(port): The above block needs the VK_* refactored out. | 865 // TODO(port): The above block needs the VK_* refactored out. |
| 866 NOTIMPLEMENTED(); | 866 NOTIMPLEMENTED(); |
| 867 #endif | 867 #endif |
| 868 | 868 |
| 869 for (; v && v != this && !consumed; v = v->GetParent()) { | 869 for (; v && v != this && !consumed; v = v->GetParent()) { |
| 870 consumed = (event.GetType() == Event::ET_KEY_PRESSED) ? | 870 consumed = (event.GetType() == Event::ET_KEY_PRESSED) ? |
| 871 v->OnKeyPressed(event) : v->OnKeyReleased(event); | 871 v->OnKeyPressed(event) : v->OnKeyReleased(event); |
| 872 } | 872 } |
| 873 | 873 |
| 874 if (!consumed && default_keyboard_hander_) { | 874 if (!consumed && default_keyboard_handler_) { |
| 875 consumed = (event.GetType() == Event::ET_KEY_PRESSED) ? | 875 consumed = (event.GetType() == Event::ET_KEY_PRESSED) ? |
| 876 default_keyboard_hander_->OnKeyPressed(event) : | 876 default_keyboard_handler_->OnKeyPressed(event) : |
| 877 default_keyboard_hander_->OnKeyReleased(event); | 877 default_keyboard_handler_->OnKeyReleased(event); |
| 878 } | 878 } |
| 879 | 879 |
| 880 return consumed; | 880 return consumed; |
| 881 } | 881 } |
| 882 | 882 |
| 883 bool RootView::ProcessMouseWheelEvent(const MouseWheelEvent& e) { | 883 bool RootView::ProcessMouseWheelEvent(const MouseWheelEvent& e) { |
| 884 View* v; | 884 View* v; |
| 885 bool consumed = false; | 885 bool consumed = false; |
| 886 if (GetFocusedView()) { | 886 if (GetFocusedView()) { |
| 887 for (v = GetFocusedView(); | 887 for (v = GetFocusedView(); |
| 888 v && v != this && !consumed; v = v->GetParent()) { | 888 v && v != this && !consumed; v = v->GetParent()) { |
| 889 consumed = v->OnMouseWheel(e); | 889 consumed = v->OnMouseWheel(e); |
| 890 } | 890 } |
| 891 } | 891 } |
| 892 | 892 |
| 893 if (!consumed && default_keyboard_hander_) { | 893 if (!consumed && default_keyboard_handler_) { |
| 894 consumed = default_keyboard_hander_->OnMouseWheel(e); | 894 consumed = default_keyboard_handler_->OnMouseWheel(e); |
| 895 } | 895 } |
| 896 return consumed; | 896 return consumed; |
| 897 } | 897 } |
| 898 | 898 |
| 899 void RootView::SetDefaultKeyboardHandler(View* v) { | 899 void RootView::SetDefaultKeyboardHandler(View* v) { |
| 900 default_keyboard_hander_ = v; | 900 default_keyboard_handler_ = v; |
| 901 } | 901 } |
| 902 | 902 |
| 903 bool RootView::IsVisibleInRootView() const { | 903 bool RootView::IsVisibleInRootView() const { |
| 904 return IsVisible(); | 904 return IsVisible(); |
| 905 } | 905 } |
| 906 | 906 |
| 907 void RootView::ViewBoundsChanged(View* view, bool size_changed, | 907 void RootView::ViewBoundsChanged(View* view, bool size_changed, |
| 908 bool position_changed) { | 908 bool position_changed) { |
| 909 DCHECK(view && (size_changed || position_changed)); | 909 DCHECK(view && (size_changed || position_changed)); |
| 910 if (!view->descendants_to_notify_.get()) | 910 if (!view->descendants_to_notify_.get()) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 | 976 |
| 977 void RootView::SetAccessibleName(const std::wstring& name) { | 977 void RootView::SetAccessibleName(const std::wstring& name) { |
| 978 accessible_name_.assign(name); | 978 accessible_name_.assign(name); |
| 979 } | 979 } |
| 980 | 980 |
| 981 View* RootView::GetDragView() { | 981 View* RootView::GetDragView() { |
| 982 return drag_view_; | 982 return drag_view_; |
| 983 } | 983 } |
| 984 | 984 |
| 985 } // namespace views | 985 } // namespace views |
| OLD | NEW |