Chromium Code Reviews| 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; |
|
Evan Stade
2014/04/22 00:25:41
this change makes it so that OnNativeThemeChanged
sky
2014/04/22 15:30:21
Why do you need to do these changes?
Evan Stade
2014/04/22 17:12:32
The changes on L239-241 just seem more correct to
| |
| 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 |
| 228 ViewHierarchyChangedDetails details(true, this, view, parent); | 229 ViewHierarchyChangedDetails details(true, this, view, parent); |
| 229 | 230 |
| 230 for (View* v = this; v; v = v->parent_) | 231 for (View* v = this; v; v = v->parent_) |
| 231 v->ViewHierarchyChangedImpl(false, details); | 232 v->ViewHierarchyChangedImpl(false, details); |
| 232 | 233 |
| 233 view->PropagateAddNotifications(details); | 234 view->PropagateAddNotifications(details); |
| 234 UpdateTooltip(); | 235 UpdateTooltip(); |
| 235 views::Widget* widget = GetWidget(); | 236 views::Widget* widget = GetWidget(); |
| 236 if (widget) { | 237 if (widget) { |
| 237 RegisterChildrenForVisibleBoundsNotification(view); | 238 RegisterChildrenForVisibleBoundsNotification(view); |
| 238 const ui::NativeTheme* new_theme = widget->GetNativeTheme(); | 239 const ui::NativeTheme* new_theme = view->GetNativeTheme(); |
| 239 if (new_theme != old_theme) | 240 if (new_theme != old_theme) |
| 240 PropagateNativeThemeChanged(new_theme); | 241 view->PropagateNativeThemeChanged(new_theme); |
| 241 if (view->visible()) | 242 if (view->visible()) |
| 242 view->SchedulePaint(); | 243 view->SchedulePaint(); |
| 243 } | 244 } |
| 244 | 245 |
| 245 if (layout_manager_.get()) | 246 if (layout_manager_.get()) |
| 246 layout_manager_->ViewAdded(this, view); | 247 layout_manager_->ViewAdded(this, view); |
| 247 | 248 |
| 248 ReorderLayers(); | 249 ReorderLayers(); |
| 249 | 250 |
| 250 // Make sure the visibility of the child layers are correct. | 251 // Make sure the visibility of the child layers are correct. |
| (...skipping 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2354 // Message the RootView to do the drag and drop. That way if we're removed | 2355 // Message the RootView to do the drag and drop. That way if we're removed |
| 2355 // the RootView can detect it and avoid calling us back. | 2356 // the RootView can detect it and avoid calling us back. |
| 2356 gfx::Point widget_location(event.location()); | 2357 gfx::Point widget_location(event.location()); |
| 2357 ConvertPointToWidget(this, &widget_location); | 2358 ConvertPointToWidget(this, &widget_location); |
| 2358 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2359 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2359 // WARNING: we may have been deleted. | 2360 // WARNING: we may have been deleted. |
| 2360 return true; | 2361 return true; |
| 2361 } | 2362 } |
| 2362 | 2363 |
| 2363 } // namespace views | 2364 } // namespace views |
| OLD | NEW |