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

Side by Side Diff: ui/views/widget/native_widget_mac.mm

Issue 2535163002: MacViews: Fix Widget::GetAllChildWidgets(gfx::NativeView) for non-Widgets. (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/widget/native_widget_mac_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_mac.h" 5 #include "ui/views/widget/native_widget_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 [bridge->parent()->GetNSWindow() contentView]) 682 [bridge->parent()->GetNSWindow() contentView])
683 : nullptr; 683 : nullptr;
684 return ancestor ? ancestor : bridge->native_widget_mac(); 684 return ancestor ? ancestor : bridge->native_widget_mac();
685 } 685 }
686 686
687 // static 687 // static
688 void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view, 688 void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view,
689 Widget::Widgets* children) { 689 Widget::Widgets* children) {
690 BridgedNativeWidget* bridge = 690 BridgedNativeWidget* bridge =
691 NativeWidgetMac::GetBridgeForNativeWindow([native_view window]); 691 NativeWidgetMac::GetBridgeForNativeWindow([native_view window]);
692 if (!bridge) 692 if (!bridge) {
693 // The NSWindow is not itself a views::Widget, but it may have children that
694 // are. Note we assume we don't care about children of Widgets that are not
695 // themselves a Widget (those are skipped by this logic).
karandeepb 2016/11/29 05:28:42 It's not clear to me what this comment means- "Not
tapted 2016/11/29 05:51:42 Moved it down to the other for loop and reworded.
karandeepb 2016/11/29 06:00:20 Acknowledged.
696 for (NSWindow* native_child in [[native_view window] childWindows])
697 GetAllChildWidgets([native_child contentView], children);
693 return; 698 return;
699 }
694 700
695 // If |native_view| is a subview of the contentView, it will share an 701 // If |native_view| is a subview of the contentView, it will share an
696 // NSWindow, but will itself be a native child of the Widget. That is, adding 702 // NSWindow, but will itself be a native child of the Widget. That is, adding
697 // bridge->..->GetWidget() to |children| would be adding the _parent_ of 703 // bridge->..->GetWidget() to |children| would be adding the _parent_ of
698 // |native_view|, not the Widget for |native_view|. |native_view| doesn't have 704 // |native_view|, not the Widget for |native_view|. |native_view| doesn't have
699 // a corresponding Widget of its own in this case (and so can't have Widget 705 // a corresponding Widget of its own in this case (and so can't have Widget
700 // children of its own on Mac). 706 // children of its own on Mac).
karandeepb 2016/11/29 05:28:42 Should we not do the same for this case?
tapted 2016/11/29 05:51:42 Done.
karandeepb 2016/11/29 06:00:20 Actually I meant iterating over the child windows
tapted 2016/11/29 06:06:11 Ah, yep. GetBridgeForNativeWindow uses the NSWindo
701 if (bridge->ns_view() != native_view) 707 if (bridge->ns_view() != native_view)
702 return; 708 return;
703 709
704 // Code expects widget for |native_view| to be added to |children|. 710 // Code expects widget for |native_view| to be added to |children|.
705 if (bridge->native_widget_mac()->GetWidget()) 711 if (bridge->native_widget_mac()->GetWidget())
706 children->insert(bridge->native_widget_mac()->GetWidget()); 712 children->insert(bridge->native_widget_mac()->GetWidget());
707 713
708 for (BridgedNativeWidget* child : bridge->child_windows()) 714 for (BridgedNativeWidget* child : bridge->child_windows())
709 GetAllChildWidgets(child->ns_view(), children); 715 GetAllChildWidgets(child->ns_view(), children);
710 } 716 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window]; 772 [[ViewsNSWindowCloseAnimator alloc] initWithWindow:window];
767 } 773 }
768 774
769 - (void)animationDidEnd:(NSAnimation*)animation { 775 - (void)animationDidEnd:(NSAnimation*)animation {
770 [window_ close]; 776 [window_ close];
771 [animation_ setDelegate:nil]; 777 [animation_ setDelegate:nil];
772 [self release]; 778 [self release];
773 } 779 }
774 780
775 @end 781 @end
OLDNEW
« 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