| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return const_cast<Widget*>(const_cast<const View*>(this)->GetWidget()); | 152 return const_cast<Widget*>(const_cast<const View*>(this)->GetWidget()); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void View::AddChildView(View* view) { | 155 void View::AddChildView(View* view) { |
| 156 if (view->parent_ == this) | 156 if (view->parent_ == this) |
| 157 return; | 157 return; |
| 158 AddChildViewAt(view, child_count()); | 158 AddChildViewAt(view, child_count()); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void View::AddChildViewAt(View* view, int index) { | 161 void View::AddChildViewAt(View* view, int index) { |
| 162 CHECK_NE(view, this) << "You cannot add a view as its own child"; | 162 // You cannot add a view as its own child |
| 163 CHECK_NE(view, this); |
| 163 DCHECK_GE(index, 0); | 164 DCHECK_GE(index, 0); |
| 164 DCHECK_LE(index, child_count()); | 165 DCHECK_LE(index, child_count()); |
| 165 | 166 |
| 166 // If |view| has a parent, remove it from its parent. | 167 // If |view| has a parent, remove it from its parent. |
| 167 View* parent = view->parent_; | 168 View* parent = view->parent_; |
| 168 ui::NativeTheme* old_theme = NULL; | 169 ui::NativeTheme* old_theme = NULL; |
| 169 if (parent) { | 170 if (parent) { |
| 170 old_theme = view->GetNativeTheme(); | 171 old_theme = view->GetNativeTheme(); |
| 171 if (parent == this) { | 172 if (parent == this) { |
| 172 ReorderChildView(view, index); | 173 ReorderChildView(view, index); |
| (...skipping 2275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2448 // Message the RootView to do the drag and drop. That way if we're removed | 2449 // Message the RootView to do the drag and drop. That way if we're removed |
| 2449 // the RootView can detect it and avoid calling us back. | 2450 // the RootView can detect it and avoid calling us back. |
| 2450 gfx::Point widget_location(event.location()); | 2451 gfx::Point widget_location(event.location()); |
| 2451 ConvertPointToWidget(this, &widget_location); | 2452 ConvertPointToWidget(this, &widget_location); |
| 2452 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2453 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2453 // WARNING: we may have been deleted. | 2454 // WARNING: we may have been deleted. |
| 2454 return true; | 2455 return true; |
| 2455 } | 2456 } |
| 2456 | 2457 |
| 2457 } // namespace views | 2458 } // namespace views |
| OLD | NEW |