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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 flip_canvas_on_paint_for_rtl_ui_(false), | 119 flip_canvas_on_paint_for_rtl_ui_(false), |
120 paint_to_layer_(false), | 120 paint_to_layer_(false), |
121 accelerator_registration_delayed_(false), | 121 accelerator_registration_delayed_(false), |
122 accelerator_focus_manager_(NULL), | 122 accelerator_focus_manager_(NULL), |
123 registered_accelerator_count_(0), | 123 registered_accelerator_count_(0), |
124 next_focusable_view_(NULL), | 124 next_focusable_view_(NULL), |
125 previous_focusable_view_(NULL), | 125 previous_focusable_view_(NULL), |
126 focusable_(false), | 126 focusable_(false), |
127 accessibility_focusable_(false), | 127 accessibility_focusable_(false), |
128 context_menu_controller_(NULL), | 128 context_menu_controller_(NULL), |
129 drag_controller_(NULL), | 129 drag_controller_(NULL) { |
130 in_on_focus_(false) { | |
131 } | 130 } |
132 | 131 |
133 View::~View() { | 132 View::~View() { |
134 if (parent_) | 133 if (parent_) |
135 parent_->RemoveChildView(this); | 134 parent_->RemoveChildView(this); |
136 | 135 |
137 for (Views::const_iterator i(children_.begin()); i != children_.end(); ++i) { | 136 for (Views::const_iterator i(children_.begin()); i != children_.end(); ++i) { |
138 (*i)->parent_ = NULL; | 137 (*i)->parent_ = NULL; |
139 if (!(*i)->owned_by_client_) | 138 if (!(*i)->owned_by_client_) |
140 delete *i; | 139 delete *i; |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 } | 1320 } |
1322 | 1321 |
1323 // Focus ----------------------------------------------------------------------- | 1322 // Focus ----------------------------------------------------------------------- |
1324 | 1323 |
1325 void View::OnFocus() { | 1324 void View::OnFocus() { |
1326 // TODO(beng): Investigate whether it's possible for us to move this to | 1325 // TODO(beng): Investigate whether it's possible for us to move this to |
1327 // Focus(). | 1326 // Focus(). |
1328 // By default, we clear the native focus. This ensures that no visible native | 1327 // By default, we clear the native focus. This ensures that no visible native |
1329 // view as the focus and that we still receive keyboard inputs. | 1328 // view as the focus and that we still receive keyboard inputs. |
1330 FocusManager* focus_manager = GetFocusManager(); | 1329 FocusManager* focus_manager = GetFocusManager(); |
1331 if (focus_manager) { | 1330 if (focus_manager) |
1332 in_on_focus_ = true; | |
1333 focus_manager->ClearNativeFocus(); | 1331 focus_manager->ClearNativeFocus(); |
1334 in_on_focus_ = false; | |
1335 } | |
1336 | 1332 |
1337 // TODO(beng): Investigate whether it's possible for us to move this to | 1333 // TODO(beng): Investigate whether it's possible for us to move this to |
1338 // Focus(). | 1334 // Focus(). |
1339 // Notify assistive technologies of the focus change. | 1335 // Notify assistive technologies of the focus change. |
1340 GetWidget()->NotifyAccessibilityEvent( | 1336 GetWidget()->NotifyAccessibilityEvent( |
1341 this, ui::AccessibilityTypes::EVENT_FOCUS, true); | 1337 this, ui::AccessibilityTypes::EVENT_FOCUS, true); |
1342 } | 1338 } |
1343 | 1339 |
1344 void View::OnBlur() { | 1340 void View::OnBlur() { |
1345 } | 1341 } |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 } | 1585 } |
1590 | 1586 |
1591 if (update_tool_tip) | 1587 if (update_tool_tip) |
1592 UpdateTooltip(); | 1588 UpdateTooltip(); |
1593 | 1589 |
1594 if (layout_manager_.get()) | 1590 if (layout_manager_.get()) |
1595 layout_manager_->ViewRemoved(this, view); | 1591 layout_manager_->ViewRemoved(this, view); |
1596 } | 1592 } |
1597 | 1593 |
1598 void View::PropagateRemoveNotifications(View* parent) { | 1594 void View::PropagateRemoveNotifications(View* parent) { |
1599 CHECK(!in_on_focus_); | |
1600 | |
1601 for (int i = 0, count = child_count(); i < count; ++i) | 1595 for (int i = 0, count = child_count(); i < count; ++i) |
1602 child_at(i)->PropagateRemoveNotifications(parent); | 1596 child_at(i)->PropagateRemoveNotifications(parent); |
1603 | 1597 |
1604 for (View* v = this; v; v = v->parent_) | 1598 for (View* v = this; v; v = v->parent_) |
1605 v->ViewHierarchyChangedImpl(true, false, parent, this); | 1599 v->ViewHierarchyChangedImpl(true, false, parent, this); |
1606 } | 1600 } |
1607 | 1601 |
1608 void View::PropagateAddNotifications(View* parent, View* child) { | 1602 void View::PropagateAddNotifications(View* parent, View* child) { |
1609 for (int i = 0, count = child_count(); i < count; ++i) | 1603 for (int i = 0, count = child_count(); i < count; ++i) |
1610 child_at(i)->PropagateAddNotifications(parent, child); | 1604 child_at(i)->PropagateAddNotifications(parent, child); |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 ConvertPointToWidget(this, &widget_location); | 2162 ConvertPointToWidget(this, &widget_location); |
2169 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, | 2163 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, |
2170 source); | 2164 source); |
2171 return true; | 2165 return true; |
2172 #else | 2166 #else |
2173 return false; | 2167 return false; |
2174 #endif // !defined(OS_MACOSX) | 2168 #endif // !defined(OS_MACOSX) |
2175 } | 2169 } |
2176 | 2170 |
2177 } // namespace views | 2171 } // namespace views |
OLD | NEW |