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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
6 | 6 |
7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 notify_enter_exit_on_child_(false), | 108 notify_enter_exit_on_child_(false), |
109 registered_for_visible_bounds_notification_(false), | 109 registered_for_visible_bounds_notification_(false), |
110 needs_layout_(true), | 110 needs_layout_(true), |
111 snap_layer_to_pixel_boundary_(false), | 111 snap_layer_to_pixel_boundary_(false), |
112 flip_canvas_on_paint_for_rtl_ui_(false), | 112 flip_canvas_on_paint_for_rtl_ui_(false), |
113 paint_to_layer_(false), | 113 paint_to_layer_(false), |
114 accelerator_focus_manager_(NULL), | 114 accelerator_focus_manager_(NULL), |
115 registered_accelerator_count_(0), | 115 registered_accelerator_count_(0), |
116 next_focusable_view_(NULL), | 116 next_focusable_view_(NULL), |
117 previous_focusable_view_(NULL), | 117 previous_focusable_view_(NULL), |
118 focusable_(false), | 118 focus_behavior_(FocusBehavior::NEVER), |
119 accessibility_focusable_(false), | |
120 context_menu_controller_(NULL), | 119 context_menu_controller_(NULL), |
121 drag_controller_(NULL), | 120 drag_controller_(NULL), |
122 native_view_accessibility_(NULL) { | 121 native_view_accessibility_(NULL) { |
123 SetTargetHandler(this); | 122 SetTargetHandler(this); |
124 } | 123 } |
125 | 124 |
126 View::~View() { | 125 View::~View() { |
127 if (parent_) | 126 if (parent_) |
128 parent_->RemoveChildView(this); | 127 parent_->RemoveChildView(this); |
129 | 128 |
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 View* View::GetPreviousFocusableView() { | 1191 View* View::GetPreviousFocusableView() { |
1193 return previous_focusable_view_; | 1192 return previous_focusable_view_; |
1194 } | 1193 } |
1195 | 1194 |
1196 void View::SetNextFocusableView(View* view) { | 1195 void View::SetNextFocusableView(View* view) { |
1197 if (view) | 1196 if (view) |
1198 view->previous_focusable_view_ = this; | 1197 view->previous_focusable_view_ = this; |
1199 next_focusable_view_ = view; | 1198 next_focusable_view_ = view; |
1200 } | 1199 } |
1201 | 1200 |
1202 void View::SetFocusable(bool focusable) { | 1201 void View::SetFocusBehavior(FocusBehavior focus_behavior) { |
1203 if (focusable_ == focusable) | 1202 if (focus_behavior_ == focus_behavior) |
1204 return; | 1203 return; |
1205 | 1204 |
1206 focusable_ = focusable; | 1205 focus_behavior_ = focus_behavior; |
1207 AdvanceFocusIfNecessary(); | 1206 AdvanceFocusIfNecessary(); |
1208 } | 1207 } |
1209 | 1208 |
1210 bool View::IsFocusable() const { | 1209 bool View::IsFocusable() const { |
1211 return focusable_ && enabled_ && IsDrawn(); | 1210 return focus_behavior_ == FocusBehavior::ALWAYS && enabled_ && IsDrawn(); |
1212 } | 1211 } |
1213 | 1212 |
1214 bool View::IsAccessibilityFocusable() const { | 1213 bool View::IsAccessibilityFocusable() const { |
1215 return (focusable_ || accessibility_focusable_) && enabled_ && IsDrawn(); | 1214 return focus_behavior_ != FocusBehavior::NEVER && enabled_ && IsDrawn(); |
1216 } | |
1217 | |
1218 void View::SetAccessibilityFocusable(bool accessibility_focusable) { | |
1219 if (accessibility_focusable_ == accessibility_focusable) | |
1220 return; | |
1221 | |
1222 accessibility_focusable_ = accessibility_focusable; | |
1223 AdvanceFocusIfNecessary(); | |
1224 } | 1215 } |
1225 | 1216 |
1226 FocusManager* View::GetFocusManager() { | 1217 FocusManager* View::GetFocusManager() { |
1227 Widget* widget = GetWidget(); | 1218 Widget* widget = GetWidget(); |
1228 return widget ? widget->GetFocusManager() : NULL; | 1219 return widget ? widget->GetFocusManager() : NULL; |
1229 } | 1220 } |
1230 | 1221 |
1231 const FocusManager* View::GetFocusManager() const { | 1222 const FocusManager* View::GetFocusManager() const { |
1232 const Widget* widget = GetWidget(); | 1223 const Widget* widget = GetWidget(); |
1233 return widget ? widget->GetFocusManager() : NULL; | 1224 return widget ? widget->GetFocusManager() : NULL; |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2424 // Message the RootView to do the drag and drop. That way if we're removed | 2415 // Message the RootView to do the drag and drop. That way if we're removed |
2425 // the RootView can detect it and avoid calling us back. | 2416 // the RootView can detect it and avoid calling us back. |
2426 gfx::Point widget_location(event.location()); | 2417 gfx::Point widget_location(event.location()); |
2427 ConvertPointToWidget(this, &widget_location); | 2418 ConvertPointToWidget(this, &widget_location); |
2428 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2419 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2429 // WARNING: we may have been deleted. | 2420 // WARNING: we may have been deleted. |
2430 return true; | 2421 return true; |
2431 } | 2422 } |
2432 | 2423 |
2433 } // namespace views | 2424 } // namespace views |
OLD | NEW |