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/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.h" |
10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 while (window) { | 1080 while (window) { |
1081 NativeWidgetPrivate* native_widget = GetNativeWidgetForNativeView(window); | 1081 NativeWidgetPrivate* native_widget = GetNativeWidgetForNativeView(window); |
1082 if (native_widget) | 1082 if (native_widget) |
1083 top_level_native_widget = native_widget; | 1083 top_level_native_widget = native_widget; |
1084 window = window->parent(); | 1084 window = window->parent(); |
1085 } | 1085 } |
1086 return top_level_native_widget; | 1086 return top_level_native_widget; |
1087 } | 1087 } |
1088 | 1088 |
1089 // static | 1089 // static |
1090 void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view, | 1090 void NativeWidgetPrivate::GetAllChildAndOwnedWidgets( |
1091 Widget::Widgets* children) { | 1091 gfx::NativeView native_view, |
| 1092 Widget::Widgets* widgets) { |
1092 { | 1093 { |
1093 // Code expects widget for |native_view| to be added to |children|. | 1094 // Code expects widget for |native_view| to be added to |widgets|. |
1094 NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>( | 1095 NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>( |
1095 GetNativeWidgetForNativeView(native_view)); | 1096 GetNativeWidgetForNativeView(native_view)); |
1096 if (native_widget && native_widget->GetWidget()) | 1097 if (native_widget && native_widget->GetWidget()) |
1097 children->insert(native_widget->GetWidget()); | 1098 widgets->insert(native_widget->GetWidget()); |
1098 } | 1099 } |
1099 | 1100 |
1100 const aura::Window::Windows& child_windows = native_view->children(); | 1101 // Add all owned widgets. |
1101 for (aura::Window::Windows::const_iterator i = child_windows.begin(); | 1102 for (aura::Window* transient_child : wm::GetTransientChildren(native_view)) { |
1102 i != child_windows.end(); ++i) { | 1103 NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>( |
1103 GetAllChildWidgets((*i), children); | 1104 GetNativeWidgetForNativeView(transient_child)); |
| 1105 if (native_widget && native_widget->GetWidget()) |
| 1106 widgets->insert(native_widget->GetWidget()); |
| 1107 GetAllChildAndOwnedWidgets(transient_child, widgets); |
1104 } | 1108 } |
| 1109 |
| 1110 // Add all child windows. |
| 1111 for (aura::Window* child : native_view->children()) |
| 1112 GetAllChildAndOwnedWidgets(child, widgets); |
1105 } | 1113 } |
1106 | 1114 |
1107 // static | 1115 // static |
1108 void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view, | |
1109 Widget::Widgets* owned) { | |
1110 const aura::Window::Windows& transient_children = | |
1111 wm::GetTransientChildren(native_view); | |
1112 for (aura::Window::Windows::const_iterator i = transient_children.begin(); | |
1113 i != transient_children.end(); ++i) { | |
1114 NativeWidgetPrivate* native_widget = static_cast<NativeWidgetPrivate*>( | |
1115 GetNativeWidgetForNativeView(*i)); | |
1116 if (native_widget && native_widget->GetWidget()) | |
1117 owned->insert(native_widget->GetWidget()); | |
1118 GetAllOwnedWidgets((*i), owned); | |
1119 } | |
1120 } | |
1121 | |
1122 // static | |
1123 void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, | 1116 void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view, |
1124 gfx::NativeView new_parent) { | 1117 gfx::NativeView new_parent) { |
1125 DCHECK(native_view != new_parent); | 1118 DCHECK(native_view != new_parent); |
1126 | 1119 |
1127 gfx::NativeView previous_parent = native_view->parent(); | 1120 gfx::NativeView previous_parent = native_view->parent(); |
1128 if (previous_parent == new_parent) | 1121 if (previous_parent == new_parent) |
1129 return; | 1122 return; |
1130 | 1123 |
1131 Widget::Widgets widgets; | 1124 Widget::Widgets widgets; |
1132 GetAllChildWidgets(native_view, &widgets); | 1125 GetAllChildAndOwnedWidgets(native_view, &widgets); |
1133 | 1126 |
1134 // First notify all the widgets that they are being disassociated | 1127 // First notify all the widgets that they are being disassociated |
1135 // from their previous parent. | 1128 // from their previous parent. |
1136 for (Widget::Widgets::iterator it = widgets.begin(); | 1129 for (Widget::Widgets::iterator it = widgets.begin(); |
1137 it != widgets.end(); ++it) { | 1130 it != widgets.end(); ++it) { |
1138 (*it)->NotifyNativeViewHierarchyWillChange(); | 1131 (*it)->NotifyNativeViewHierarchyWillChange(); |
1139 } | 1132 } |
1140 | 1133 |
1141 if (new_parent) { | 1134 if (new_parent) { |
1142 new_parent->AddChild(native_view); | 1135 new_parent->AddChild(native_view); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); | 1170 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); |
1178 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 1171 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
1179 return gfx::FontList(gfx::Font(caption_font)); | 1172 return gfx::FontList(gfx::Font(caption_font)); |
1180 #else | 1173 #else |
1181 return gfx::FontList(); | 1174 return gfx::FontList(); |
1182 #endif | 1175 #endif |
1183 } | 1176 } |
1184 | 1177 |
1185 } // namespace internal | 1178 } // namespace internal |
1186 } // namespace views | 1179 } // namespace views |
OLD | NEW |