Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: ui/views/widget/native_widget_mac.mm

Issue 2535163002: MacViews: Fix Widget::GetAllChildWidgets(gfx::NativeView) for non-Widgets. (Closed)
Patch Set: respond to comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/widget/native_widget_mac_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/native_widget_mac.mm
diff --git a/ui/views/widget/native_widget_mac.mm b/ui/views/widget/native_widget_mac.mm
index 28bc1da2d126c3014da169c90542c73a5ee476d9..e81bba45df906f90e4c03351acf778f22318c7a0 100644
--- a/ui/views/widget/native_widget_mac.mm
+++ b/ui/views/widget/native_widget_mac.mm
@@ -689,8 +689,18 @@ void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view,
Widget::Widgets* children) {
BridgedNativeWidget* bridge =
NativeWidgetMac::GetBridgeForNativeWindow([native_view window]);
- if (!bridge)
+ if (!bridge) {
+ // The NSWindow is not itself a views::Widget, but it may have children that
+ // are. Support returning Widgets that are parented to the NSWindow, except:
+ // - Ignore requests for children of an NSView that is not a contentView.
+ // - We do not add a Widget for |native_view| to |children| (there is none).
+ if ([[native_view window] contentView] != native_view)
+ return;
+
+ for (NSWindow* native_child in [[native_view window] childWindows])
+ GetAllChildWidgets([native_child contentView], children);
return;
+ }
// If |native_view| is a subview of the contentView, it will share an
// NSWindow, but will itself be a native child of the Widget. That is, adding
@@ -705,6 +715,10 @@ void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view,
if (bridge->native_widget_mac()->GetWidget())
children->insert(bridge->native_widget_mac()->GetWidget());
+ // When the NSWindow *is* a Widget, only consider child_windows(). I.e. do not
+ // look through -[NSWindow childWindows] as done for the (!bridge) case above.
+ // -childWindows does not support hidden windows, and anything in there which
+ // is not in child_windows() would have been added by AppKit.
for (BridgedNativeWidget* child : bridge->child_windows())
GetAllChildWidgets(child->ns_view(), children);
}
« no previous file with comments | « no previous file | ui/views/widget/native_widget_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698