diff --git a/atom/browser/api/atom_api_browser_window_mac.mm b/atom/browser/api/atom_api_browser_window_mac.mm index 47f6488f4298..829a07eb57ff 100644 --- a/atom/browser/api/atom_api_browser_window_mac.mm +++ b/atom/browser/api/atom_api_browser_window_mac.mm @@ -59,8 +59,9 @@ void BrowserWindow::OverrideNSWindowContentView(InspectableWebContents* iwc) { // Make NativeWindow use a NSView as content view. static_cast(window())->OverrideNSWindowContentView(); // Add webview to contentView. - NSView* webView = iwc->GetView()->GetNativeView(); - NSView* contentView = [window()->GetNativeWindow() contentView]; + NSView* webView = iwc->GetView()->GetNativeView().GetNativeNSView(); + NSView* contentView = + [window()->GetNativeWindow().GetNativeNSWindow() contentView]; [webView setFrame:[contentView bounds]]; // ensure that buttons view is floated to top of view hierarchy @@ -80,7 +81,7 @@ void BrowserWindow::UpdateDraggableRegions( // All ControlRegionViews should be added as children of the WebContentsView, // because WebContentsView will be removed and re-added when entering and // leaving fullscreen mode. - NSView* webView = web_contents()->GetNativeView(); + NSView* webView = web_contents()->GetNativeView().GetNativeNSView(); NSInteger webViewWidth = NSWidth([webView bounds]); NSInteger webViewHeight = NSHeight([webView bounds]); diff --git a/atom/browser/api/atom_api_menu_mac.mm b/atom/browser/api/atom_api_menu_mac.mm index 2f647a8b67fb..a4ca8b51c71f 100644 --- a/atom/browser/api/atom_api_menu_mac.mm +++ b/atom/browser/api/atom_api_menu_mac.mm @@ -56,7 +56,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr& native_window, base::Closure callback) { if (!native_window) return; - NSWindow* nswindow = native_window->GetNativeWindow(); + NSWindow* nswindow = native_window->GetNativeWindow().GetNativeNSWindow(); auto close_callback = base::Bind( &MenuMac::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback); diff --git a/atom/browser/api/atom_api_web_contents_mac.mm b/atom/browser/api/atom_api_web_contents_mac.mm index dcf461e4f30c..86d78c3e3db2 100644 --- a/atom/browser/api/atom_api_web_contents_mac.mm +++ b/atom/browser/api/atom_api_web_contents_mac.mm @@ -17,7 +17,7 @@ bool WebContents::IsFocused() const { return false; if (GetType() != BACKGROUND_PAGE) { - auto window = [web_contents()->GetNativeView() window]; + auto window = [web_contents()->GetNativeView().GetNativeNSView() window]; // On Mac the render widget host view does not lose focus when the window // loses focus so check if the top level window is the key window. if (window && ![window isKeyWindow]) diff --git a/atom/browser/browser_mac.mm b/atom/browser/browser_mac.mm index 415f2217dfba..2d64a9b52585 100644 --- a/atom/browser/browser_mac.mm +++ b/atom/browser/browser_mac.mm @@ -325,7 +325,7 @@ std::string Browser::DockGetBadgeText() { void Browser::DockHide() { for (auto* const& window : WindowList::GetWindows()) - [window->GetNativeWindow() setCanHide:NO]; + [window->GetNativeWindow().GetNativeNSWindow() setCanHide:NO]; ProcessSerialNumber psn = {0, kCurrentProcess}; TransformProcessType(&psn, kProcessTransformToUIElementApplication); diff --git a/atom/browser/native_browser_view_mac.mm b/atom/browser/native_browser_view_mac.mm index b8a822ca4d1c..c0a1f64113e3 100644 --- a/atom/browser/native_browser_view_mac.mm +++ b/atom/browser/native_browser_view_mac.mm @@ -160,7 +160,8 @@ namespace atom { NativeBrowserViewMac::NativeBrowserViewMac( InspectableWebContents* inspectable_web_contents) : NativeBrowserView(inspectable_web_contents) { - auto* view = GetInspectableWebContentsView()->GetNativeView(); + auto* view = + GetInspectableWebContentsView()->GetNativeView().GetNativeNSView(); view.autoresizingMask = kDefaultAutoResizingMask; } @@ -175,12 +176,14 @@ void NativeBrowserViewMac::SetAutoResizeFlags(uint8_t flags) { autoresizing_mask |= NSViewHeightSizable; } - auto* view = GetInspectableWebContentsView()->GetNativeView(); + auto* view = + GetInspectableWebContentsView()->GetNativeView().GetNativeNSView(); view.autoresizingMask = autoresizing_mask; } void NativeBrowserViewMac::SetBounds(const gfx::Rect& bounds) { - auto* view = GetInspectableWebContentsView()->GetNativeView(); + auto* view = + GetInspectableWebContentsView()->GetNativeView().GetNativeNSView(); auto* superview = view.superview; const auto superview_height = superview ? superview.frame.size.height : 0; view.frame = @@ -189,15 +192,17 @@ void NativeBrowserViewMac::SetBounds(const gfx::Rect& bounds) { } void NativeBrowserViewMac::SetBackgroundColor(SkColor color) { - auto* view = GetInspectableWebContentsView()->GetNativeView(); + auto* view = + GetInspectableWebContentsView()->GetNativeView().GetNativeNSView(); view.wantsLayer = YES; view.layer.backgroundColor = skia::CGColorCreateFromSkColor(color); } void NativeBrowserViewMac::UpdateDraggableRegions( const std::vector& drag_exclude_rects) { - NSView* web_view = GetWebContents()->GetNativeView(); - NSView* inspectable_view = GetInspectableWebContentsView()->GetNativeView(); + NSView* web_view = GetWebContents()->GetNativeView().GetNativeNSView(); + NSView* inspectable_view = + GetInspectableWebContentsView()->GetNativeView().GetNativeNSView(); NSView* window_content_view = inspectable_view.superview; const auto window_content_view_height = NSHeight(window_content_view.bounds); diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index db1d61b568da..2600d9b201cb 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -347,7 +347,8 @@ NativeWindowMac::NativeWindowMac(const mate::Dictionary& options, params.type = views::Widget::InitParams::TYPE_WINDOW; params.native_widget = new AtomNativeWidgetMac(this, styleMask, widget()); widget()->Init(params); - window_ = static_cast(widget()->GetNativeWindow()); + window_ = static_cast( + widget()->GetNativeWindow().GetNativeNSWindow()); [window_ setEnableLargerThanScreen:enable_larger_than_screen()]; @@ -497,7 +498,7 @@ void NativeWindowMac::SetContentView(views::View* view) { void NativeWindowMac::Close() { // When this is a sheet showing, performClose won't work. if (is_modal() && parent() && IsVisible()) { - [parent()->GetNativeWindow() endSheet:window_]; + [parent()->GetNativeWindow().GetNativeNSWindow() endSheet:window_]; CloseImmediately(); return; } @@ -545,9 +546,10 @@ bool NativeWindowMac::IsFocused() { void NativeWindowMac::Show() { if (is_modal() && parent()) { if ([window_ sheetParent] == nil) - [parent()->GetNativeWindow() beginSheet:window_ - completionHandler:^(NSModalResponse){ - }]; + [parent()->GetNativeWindow().GetNativeNSWindow() + beginSheet:window_ + completionHandler:^(NSModalResponse){ + }]; return; } @@ -573,7 +575,7 @@ void NativeWindowMac::ShowInactive() { void NativeWindowMac::Hide() { if (is_modal() && parent()) { [window_ orderOut:nil]; - [parent()->GetNativeWindow() endSheet:window_]; + [parent()->GetNativeWindow().GetNativeNSWindow() endSheet:window_]; return; } @@ -897,7 +899,7 @@ void NativeWindowMac::FlashFrame(bool flash) { void NativeWindowMac::SetSkipTaskbar(bool skip) {} void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) { - NSWindow* window = GetNativeWindow(); + NSWindow* window = GetNativeWindow().GetNativeNSWindow(); if (simple_fullscreen && !is_simple_fullscreen_) { is_simple_fullscreen_ = true; @@ -1079,7 +1081,8 @@ void NativeWindowMac::AddBrowserView(NativeBrowserView* view) { } add_browser_view(view); - auto* native_view = view->GetInspectableWebContentsView()->GetNativeView(); + auto* native_view = + view->GetInspectableWebContentsView()->GetNativeView().GetNativeNSView(); [[window_ contentView] addSubview:native_view positioned:NSWindowAbove relativeTo:nil]; @@ -1097,7 +1100,8 @@ void NativeWindowMac::RemoveBrowserView(NativeBrowserView* view) { return; } - [view->GetInspectableWebContentsView()->GetNativeView() removeFromSuperview]; + [view->GetInspectableWebContentsView()->GetNativeView().GetNativeNSView() + removeFromSuperview]; remove_browser_view(view); [CATransaction commit]; @@ -1212,11 +1216,12 @@ void NativeWindowMac::ToggleTabBar() { } bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) { - if (window_ == window->GetNativeWindow()) { + if (window_ == window->GetNativeWindow().GetNativeNSWindow()) { return false; } else { if (@available(macOS 10.12, *)) - [window_ addTabbedWindow:window->GetNativeWindow() ordered:NSWindowAbove]; + [window_ addTabbedWindow:window->GetNativeWindow().GetNativeNSWindow() + ordered:NSWindowAbove]; } return true; } @@ -1441,7 +1446,8 @@ void NativeWindowMac::InternalSetParentWindow(NativeWindow* parent, NativeWindow::SetParentWindow(parent); // Do not remove/add if we are already properly attached. - if (attach && parent && [window_ parentWindow] == parent->GetNativeWindow()) + if (attach && parent && + [window_ parentWindow] == parent->GetNativeWindow().GetNativeNSWindow()) return; // Remove current parent window. @@ -1451,7 +1457,9 @@ void NativeWindowMac::InternalSetParentWindow(NativeWindow* parent, // Set new parent window. // Note that this method will force the window to become visible. if (parent && attach) - [parent->GetNativeWindow() addChildWindow:window_ ordered:NSWindowAbove]; + [parent->GetNativeWindow().GetNativeNSWindow() + addChildWindow:window_ + ordered:NSWindowAbove]; } void NativeWindowMac::ShowWindowButton(NSWindowButton button) { diff --git a/atom/browser/ui/certificate_trust_mac.mm b/atom/browser/ui/certificate_trust_mac.mm index db0ebd6c17fe..929eb559a69d 100644 --- a/atom/browser/ui/certificate_trust_mac.mm +++ b/atom/browser/ui/certificate_trust_mac.mm @@ -92,7 +92,9 @@ void ShowCertificateTrust(atom::NativeWindow* parent_window, SecTrustRef trust = nullptr; SecTrustCreateWithCertificates(cert_chain, sec_policy, &trust); - NSWindow* window = parent_window ? parent_window->GetNativeWindow() : nil; + NSWindow* window = parent_window + ? parent_window->GetNativeWindow().GetNativeNSWindow() + : nil; auto msg = base::SysUTF8ToNSString(message); auto panel = [[SFCertificateTrustPanel alloc] init]; diff --git a/atom/browser/ui/cocoa/atom_inspectable_web_contents_view.mm b/atom/browser/ui/cocoa/atom_inspectable_web_contents_view.mm index f61eb2bdafd9..9189470d8936 100644 --- a/atom/browser/ui/cocoa/atom_inspectable_web_contents_view.mm +++ b/atom/browser/ui/cocoa/atom_inspectable_web_contents_view.mm @@ -43,7 +43,7 @@ } else { auto* contents = inspectableWebContentsView_->inspectable_web_contents() ->GetWebContents(); - auto contentsView = contents->GetNativeView(); + auto* contentsView = contents->GetNativeView().GetNativeNSView(); [contentsView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; [self addSubview:contentsView]; } @@ -79,7 +79,7 @@ inspectableWebContentsView_->inspectable_web_contents(); auto* devToolsWebContents = inspectable_web_contents->GetDevToolsWebContents(); - auto devToolsView = devToolsWebContents->GetNativeView(); + auto* devToolsView = devToolsWebContents->GetNativeView().GetNativeNSView(); devtools_visible_ = visible; if (devtools_docked_) { @@ -134,7 +134,7 @@ inspectableWebContentsView_->inspectable_web_contents(); auto* devToolsWebContents = inspectable_web_contents->GetDevToolsWebContents(); - auto devToolsView = devToolsWebContents->GetNativeView(); + auto devToolsView = devToolsWebContents->GetNativeView().GetNativeNSView(); auto styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSMiniaturizableWindowMask | NSWindowStyleMaskResizable | @@ -203,7 +203,7 @@ if (!inspectable_web_contents || inspectable_web_contents->IsGuest()) return; auto* webContents = inspectable_web_contents->GetWebContents(); - auto webContentsView = webContents->GetNativeView(); + auto* webContentsView = webContents->GetNativeView().GetNativeNSView(); NSView* view = [notification object]; if ([[webContentsView subviews] containsObject:view]) { @@ -215,7 +215,7 @@ inspectable_web_contents->GetDevToolsWebContents(); if (!devToolsWebContents) return; - auto devToolsView = devToolsWebContents->GetNativeView(); + auto devToolsView = devToolsWebContents->GetNativeView().GetNativeNSView(); if ([[devToolsView subviews] containsObject:view]) { devtools_is_first_responder_ = YES; diff --git a/atom/browser/ui/cocoa/atom_ns_window_delegate.mm b/atom/browser/ui/cocoa/atom_ns_window_delegate.mm index dce3e6f81b89..7f1038ca3b62 100644 --- a/atom/browser/ui/cocoa/atom_ns_window_delegate.mm +++ b/atom/browser/ui/cocoa/atom_ns_window_delegate.mm @@ -9,6 +9,7 @@ #include "atom/browser/ui/cocoa/atom_preview_item.h" #include "atom/browser/ui/cocoa/atom_touch_bar.h" #include "base/mac/mac_util.h" +#include "ui/views/cocoa/bridged_native_widget_host_impl.h" #include "ui/views/widget/native_widget_mac.h" #include "ui/views_bridge_mac/bridged_native_widget_impl.h" @@ -21,12 +22,13 @@ // on the fly. // TODO(zcbenz): Add interface in NativeWidgetMac to allow overriding creating // window delegate. - auto* bridged_view = views::BridgedNativeWidgetImpl::GetFromNativeWindow( + auto* bridge_host = views::BridgedNativeWidgetHostImpl::GetFromNativeWindow( shell->GetNativeWindow()); + auto* bridged_view = bridge_host->bridge_impl(); if ((self = [super initWithBridgedNativeWidget:bridged_view])) { shell_ = shell; is_zooming_ = false; - level_ = [shell_->GetNativeWindow() level]; + level_ = [shell_->GetNativeWindow().GetNativeNSWindow() level]; } return self; } @@ -138,7 +140,7 @@ } - (void)windowWillMiniaturize:(NSNotification*)notification { - NSWindow* window = shell_->GetNativeWindow(); + NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow(); // store the current status window level to be restored in // windowDidDeminiaturize level_ = [window level]; @@ -152,7 +154,7 @@ - (void)windowDidDeminiaturize:(NSNotification*)notification { [super windowDidDeminiaturize:notification]; - [shell_->GetNativeWindow() setLevel:level_]; + [shell_->GetNativeWindow().GetNativeNSWindow() setLevel:level_]; shell_->NotifyWindowRestore(); } @@ -179,7 +181,7 @@ // artifacts. if (@available(macOS 10.10, *)) { if (shell_->title_bar_style() == atom::NativeWindowMac::HIDDEN_INSET) { - NSWindow* window = shell_->GetNativeWindow(); + NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow(); [window setToolbar:nil]; } } @@ -192,7 +194,7 @@ // For frameless window we don't show set title for normal mode since the // titlebar is expected to be empty, but after entering fullscreen mode we // have to set one, because title bar is visible here. - NSWindow* window = shell_->GetNativeWindow(); + NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow(); if ((shell_->transparent() || !shell_->has_frame()) && // FIXME(zcbenz): Showing titlebar for hiddenInset window is weird under // fullscreen mode. @@ -221,7 +223,7 @@ - (void)windowWillExitFullScreen:(NSNotification*)notification { if (@available(macOS 10.10, *)) { // Restore the titlebar visibility. - NSWindow* window = shell_->GetNativeWindow(); + NSWindow* window = shell_->GetNativeWindow().GetNativeNSWindow(); if ((shell_->transparent() || !shell_->has_frame()) && (shell_->title_bar_style() != atom::NativeWindowMac::HIDDEN_INSET || shell_->fullscreen_window_title())) { @@ -247,8 +249,9 @@ // Clears the delegate when window is going to be closed, since EL Capitan it // is possible that the methods of delegate would get called after the window // has been closed. - auto* bridged_view = views::BridgedNativeWidgetImpl::GetFromNativeWindow( + auto* bridge_host = views::BridgedNativeWidgetHostImpl::GetFromNativeWindow( shell_->GetNativeWindow()); + auto* bridged_view = bridge_host->bridge_impl(); bridged_view->OnWindowWillClose(); } diff --git a/atom/browser/ui/drag_util_mac.mm b/atom/browser/ui/drag_util_mac.mm index 7197e79af68c..a1306d035f50 100644 --- a/atom/browser/ui/drag_util_mac.mm +++ b/atom/browser/ui/drag_util_mac.mm @@ -33,26 +33,27 @@ void DragFileItems(const std::vector& files, // Synthesize a drag event, since we don't have access to the actual event // that initiated a drag (possibly consumed by the Web UI, for example). - NSPoint position = [[view window] mouseLocationOutsideOfEventStream]; + NSWindow* window = [view.GetNativeNSView() window]; + NSPoint position = [window mouseLocationOutsideOfEventStream]; NSTimeInterval eventTime = [[NSApp currentEvent] timestamp]; NSEvent* dragEvent = [NSEvent mouseEventWithType:NSLeftMouseDragged location:position modifierFlags:NSLeftMouseDraggedMask timestamp:eventTime - windowNumber:[[view window] windowNumber] + windowNumber:[window windowNumber] context:nil eventNumber:0 clickCount:1 pressure:1.0]; // Run the drag operation. - [[view window] dragImage:icon.ToNSImage() - at:position - offset:NSZeroSize - event:dragEvent - pasteboard:pasteboard - source:view - slideBack:YES]; + [window dragImage:icon.ToNSImage() + at:position + offset:NSZeroSize + event:dragEvent + pasteboard:pasteboard + source:view.GetNativeNSView() + slideBack:YES]; } } // namespace atom diff --git a/atom/browser/ui/file_dialog_mac.mm b/atom/browser/ui/file_dialog_mac.mm index 231c006d346e..5248441fe7f7 100644 --- a/atom/browser/ui/file_dialog_mac.mm +++ b/atom/browser/ui/file_dialog_mac.mm @@ -210,7 +210,8 @@ int RunModalDialog(NSSavePanel* dialog, const DialogSettings& settings) { settings.force_detached) { chosen = [dialog runModal]; } else { - NSWindow* window = settings.parent_window->GetNativeWindow(); + NSWindow* window = + settings.parent_window->GetNativeWindow().GetNativeNSWindow(); [dialog beginSheetModalForWindow:window completionHandler:^(NSInteger c) { @@ -328,7 +329,8 @@ void ShowOpenDialog(const DialogSettings& settings, OpenDialogCompletion(chosen, dialog, settings, callback); }]; } else { - NSWindow* window = settings.parent_window->GetNativeWindow(); + NSWindow* window = + settings.parent_window->GetNativeWindow().GetNativeNSWindow(); [dialog beginSheetModalForWindow:window completionHandler:^(NSInteger chosen) { OpenDialogCompletion(chosen, dialog, settings, callback); @@ -389,7 +391,8 @@ void ShowSaveDialog(const DialogSettings& settings, SaveDialogCompletion(chosen, dialog, settings, callback); }]; } else { - NSWindow* window = settings.parent_window->GetNativeWindow(); + NSWindow* window = + settings.parent_window->GetNativeWindow().GetNativeNSWindow(); [dialog beginSheetModalForWindow:window completionHandler:^(NSInteger chosen) { SaveDialogCompletion(chosen, dialog, settings, callback); diff --git a/atom/browser/ui/message_box_mac.mm b/atom/browser/ui/message_box_mac.mm index ee2f59dc8c84..94c243a81056 100644 --- a/atom/browser/ui/message_box_mac.mm +++ b/atom/browser/ui/message_box_mac.mm @@ -156,7 +156,7 @@ int ShowMessageBox(NativeWindow* parent_window, andAlert:alert callEndModal:true]; - NSWindow* window = parent_window->GetNativeWindow(); + NSWindow* window = parent_window->GetNativeWindow().GetNativeNSWindow(); [alert beginSheetModalForWindow:window modalDelegate:delegate didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) @@ -193,7 +193,9 @@ void ShowMessageBox(NativeWindow* parent_window, andAlert:alert callEndModal:false]; - NSWindow* window = parent_window ? parent_window->GetNativeWindow() : nil; + NSWindow* window = + parent_window ? parent_window->GetNativeWindow().GetNativeNSWindow() + : nil; [alert beginSheetModalForWindow:window modalDelegate:delegate