From cfd8ea8eb02dd1a8b1457e660cf2c4c8a54e3e95 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 10 Apr 2018 16:49:22 +0900 Subject: [PATCH] mac: Correctly unload previous content view --- atom/browser/native_window_mac.mm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 878ec507ea..e57d9c5b00 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -986,9 +986,15 @@ NativeWindowMac::~NativeWindowMac() { void NativeWindowMac::SetContentView( brightray::InspectableWebContents* web_contents) { - // TODO(zcbenz): Uninstall view first. - // TODO(zcbenz): Handle vibrancy. - // TODO(zcbenz): Handle draggable regions. + // We might have vibrantView added to the contentView. + NSArray* subviews = [[window_ contentView] subviews]; + if ([subviews count] == ([window_ vibrantView] != nil ? 2 : 1)) { + // The vibrantView is always bellow the web view. + NSView* content_view = static_cast( + [subviews objectAtIndex:([subviews count] - 1)]); + [content_view removeFromSuperview]; + } + NSView* view = web_contents->GetView()->GetNativeView(); [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; InstallView(web_contents->GetView()->GetNativeView());