| 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 #include "ui/views/widget/root_view.h" | 5 #include "ui/views/widget/root_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 void RootView::SetContentsView(View* contents_view) { | 187 void RootView::SetContentsView(View* contents_view) { |
| 188 DCHECK(contents_view && GetWidget()->native_widget()) << | 188 DCHECK(contents_view && GetWidget()->native_widget()) << |
| 189 "Can't be called until after the native widget is created!"; | 189 "Can't be called until after the native widget is created!"; |
| 190 // The ContentsView must be set up _after_ the window is created so that its | 190 // The ContentsView must be set up _after_ the window is created so that its |
| 191 // Widget pointer is valid. | 191 // Widget pointer is valid. |
| 192 SetLayoutManager(new FillLayout); | 192 SetLayoutManager(new FillLayout); |
| 193 if (has_children()) | 193 if (has_children()) |
| 194 RemoveAllChildViews(true); | 194 RemoveAllChildViews(true); |
| 195 AddChildView(contents_view); | 195 AddChildView(contents_view); |
| 196 | |
| 197 // Force a layout now, since the attached hierarchy won't be ready for the | |
| 198 // containing window's bounds. Note that we call Layout directly rather than | |
| 199 // calling the widget's size changed handler, since the RootView's bounds may | |
| 200 // not have changed, which will cause the Layout not to be done otherwise. | |
| 201 Layout(); | |
| 202 } | 196 } |
| 203 | 197 |
| 204 View* RootView::GetContentsView() { | 198 View* RootView::GetContentsView() { |
| 205 return child_count() > 0 ? child_at(0) : NULL; | 199 return child_count() > 0 ? child_at(0) : NULL; |
| 206 } | 200 } |
| 207 | 201 |
| 208 void RootView::NotifyNativeViewHierarchyChanged() { | 202 void RootView::NotifyNativeViewHierarchyChanged() { |
| 209 PropagateNativeViewHierarchyChanged(); | 203 PropagateNativeViewHierarchyChanged(); |
| 210 } | 204 } |
| 211 | 205 |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 | 746 |
| 753 #ifndef NDEBUG | 747 #ifndef NDEBUG |
| 754 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); | 748 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); |
| 755 #endif | 749 #endif |
| 756 | 750 |
| 757 return details; | 751 return details; |
| 758 } | 752 } |
| 759 | 753 |
| 760 } // namespace internal | 754 } // namespace internal |
| 761 } // namespace views | 755 } // namespace views |
| OLD | NEW |