| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 AddChildViewAt(view, child_count()); | 202 AddChildViewAt(view, child_count()); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void View::AddChildViewAt(View* view, int index) { | 205 void View::AddChildViewAt(View* view, int index) { |
| 206 CHECK_NE(view, this) << "You cannot add a view as its own child"; | 206 CHECK_NE(view, this) << "You cannot add a view as its own child"; |
| 207 DCHECK_GE(index, 0); | 207 DCHECK_GE(index, 0); |
| 208 DCHECK_LE(index, child_count()); | 208 DCHECK_LE(index, child_count()); |
| 209 | 209 |
| 210 // If |view| has a parent, remove it from its parent. | 210 // If |view| has a parent, remove it from its parent. |
| 211 View* parent = view->parent_; | 211 View* parent = view->parent_; |
| 212 const ui::NativeTheme* old_theme = view->GetNativeTheme(); | 212 ui::NativeTheme* old_theme = NULL; |
| 213 if (parent) { | 213 if (parent) { |
| 214 old_theme = view->GetNativeTheme(); |
| 214 if (parent == this) { | 215 if (parent == this) { |
| 215 ReorderChildView(view, index); | 216 ReorderChildView(view, index); |
| 216 return; | 217 return; |
| 217 } | 218 } |
| 218 parent->DoRemoveChildView(view, true, true, false, this); | 219 parent->DoRemoveChildView(view, true, true, false, this); |
| 219 } | 220 } |
| 220 | 221 |
| 221 // Sets the prev/next focus views. | 222 // Sets the prev/next focus views. |
| 222 InitFocusSiblings(view, index); | 223 InitFocusSiblings(view, index); |
| 223 | 224 |
| 224 // Let's insert the view. | 225 // Let's insert the view. |
| 225 view->parent_ = this; | 226 view->parent_ = this; |
| 226 children_.insert(children_.begin() + index, view); | 227 children_.insert(children_.begin() + index, view); |
| 227 | 228 |
| 229 views::Widget* widget = GetWidget(); |
| 230 if (widget) { |
| 231 const ui::NativeTheme* new_theme = view->GetNativeTheme(); |
| 232 if (new_theme != old_theme) |
| 233 view->PropagateNativeThemeChanged(new_theme); |
| 234 } |
| 235 |
| 228 ViewHierarchyChangedDetails details(true, this, view, parent); | 236 ViewHierarchyChangedDetails details(true, this, view, parent); |
| 229 | 237 |
| 230 for (View* v = this; v; v = v->parent_) | 238 for (View* v = this; v; v = v->parent_) |
| 231 v->ViewHierarchyChangedImpl(false, details); | 239 v->ViewHierarchyChangedImpl(false, details); |
| 232 | 240 |
| 233 view->PropagateAddNotifications(details); | 241 view->PropagateAddNotifications(details); |
| 234 UpdateTooltip(); | 242 UpdateTooltip(); |
| 235 views::Widget* widget = GetWidget(); | |
| 236 if (widget) { | 243 if (widget) { |
| 237 RegisterChildrenForVisibleBoundsNotification(view); | 244 RegisterChildrenForVisibleBoundsNotification(view); |
| 238 const ui::NativeTheme* new_theme = widget->GetNativeTheme(); | 245 |
| 239 if (new_theme != old_theme) | |
| 240 PropagateNativeThemeChanged(new_theme); | |
| 241 if (view->visible()) | 246 if (view->visible()) |
| 242 view->SchedulePaint(); | 247 view->SchedulePaint(); |
| 243 } | 248 } |
| 244 | 249 |
| 245 if (layout_manager_.get()) | 250 if (layout_manager_.get()) |
| 246 layout_manager_->ViewAdded(this, view); | 251 layout_manager_->ViewAdded(this, view); |
| 247 | 252 |
| 248 ReorderLayers(); | 253 ReorderLayers(); |
| 249 | 254 |
| 250 // Make sure the visibility of the child layers are correct. | 255 // Make sure the visibility of the child layers are correct. |
| (...skipping 2114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2365 // Message the RootView to do the drag and drop. That way if we're removed | 2370 // Message the RootView to do the drag and drop. That way if we're removed |
| 2366 // the RootView can detect it and avoid calling us back. | 2371 // the RootView can detect it and avoid calling us back. |
| 2367 gfx::Point widget_location(event.location()); | 2372 gfx::Point widget_location(event.location()); |
| 2368 ConvertPointToWidget(this, &widget_location); | 2373 ConvertPointToWidget(this, &widget_location); |
| 2369 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2374 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2370 // WARNING: we may have been deleted. | 2375 // WARNING: we may have been deleted. |
| 2371 return true; | 2376 return true; |
| 2372 } | 2377 } |
| 2373 | 2378 |
| 2374 } // namespace views | 2379 } // namespace views |
| OLD | NEW |