OLD | NEW |
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/controls/native/native_view_host_mac.h" | 5 #include "ui/views/controls/native/native_view_host_mac.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
11 #import "ui/views/cocoa/bridged_content_view.h" | 11 #import "ui/views/cocoa/bridged_content_view.h" |
12 #include "ui/views/controls/native/native_view_host.h" | 12 #include "ui/views/controls/native/native_view_host.h" |
13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
14 | 14 |
15 namespace views { | 15 namespace views { |
16 namespace { | 16 namespace { |
17 | 17 |
18 // Reparents |native_view| to be a child of the native content view of | 18 // Reparents |native_view| to be a child of the native content view of |
19 // |new_parent|. | 19 // |new_parent|. |
20 void ReparentNSView(NSView* native_view, Widget* new_parent) { | 20 void ReparentNSView(NSView* native_view, Widget* new_parent) { |
21 DCHECK(native_view); | 21 DCHECK(native_view); |
22 // Mac's NativeViewHost has no support for hosting its own child widgets. | 22 // Mac's NativeViewHost has no support for hosting its own child widgets. |
23 // This check is probably overly restrictive, since the Widget containing the | 23 // This check is probably overly restrictive, since the Widget containing the |
24 // NativeViewHost _is_ allowed child Widgets. However, we don't know yet | 24 // NativeViewHost _is_ allowed child Widgets. However, we don't know yet |
25 // whether those child Widgets need to be distinguished from Widgets that code | 25 // whether those child Widgets need to be distinguished from Widgets that code |
26 // might want to associate with the hosted NSView instead. | 26 // might want to associate with the hosted NSView instead. |
27 { | 27 { |
28 Widget::Widgets child_widgets; | 28 Widget::Widgets child_widgets; |
29 Widget::GetAllChildWidgets(native_view, &child_widgets); | 29 Widget::GetAllChildAndOwnedWidgets(native_view, &child_widgets); |
30 CHECK_GE(1u, child_widgets.size()); // 1 (itself) or 0 if detached. | 30 CHECK_GE(1u, child_widgets.size()); // 1 (itself) or 0 if detached. |
31 } | 31 } |
32 | 32 |
33 if (!new_parent) { | 33 if (!new_parent) { |
34 [native_view removeFromSuperview]; | 34 [native_view removeFromSuperview]; |
35 return; | 35 return; |
36 } | 36 } |
37 | 37 |
38 BridgedContentView* new_superview = | 38 BridgedContentView* new_superview = |
39 base::mac::ObjCCastStrict<BridgedContentView>( | 39 base::mac::ObjCCastStrict<BridgedContentView>( |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return gfx::kNullCursor; | 133 return gfx::kNullCursor; |
134 } | 134 } |
135 | 135 |
136 // static | 136 // static |
137 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( | 137 NativeViewHostWrapper* NativeViewHostWrapper::CreateWrapper( |
138 NativeViewHost* host) { | 138 NativeViewHost* host) { |
139 return new NativeViewHostMac(host); | 139 return new NativeViewHostMac(host); |
140 } | 140 } |
141 | 141 |
142 } // namespace views | 142 } // namespace views |
OLD | NEW |