diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 7864ac48f48aa..58939680b6e31 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1308,10 +1308,9 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { } void NativeWindowMac::UpdateVibrancyRadii(bool fullscreen) { - NSView* vibrant_view = [window_ vibrantView]; - NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view; + NSVisualEffectView* vibrantView = [window_ vibrantView]; - if (effect_view != nil && !vibrancy_type_.empty()) { + if (vibrantView != nil && !vibrancy_type_.empty()) { const bool no_rounded_corner = [window_ styleMask] & NSWindowStyleMaskFullSizeContentView; if (!has_frame() && !is_modal() && !no_rounded_corner) { @@ -1341,43 +1340,42 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { [maskImage setCapInsets:NSEdgeInsetsMake(radius, radius, radius, radius)]; [maskImage setResizingMode:NSImageResizingModeStretch]; - [effect_view setMaskImage:maskImage]; + [vibrantView setMaskImage:maskImage]; [window_ setCornerMask:maskImage]; } } } void NativeWindowMac::SetVibrancy(const std::string& type) { - NSView* vibrant_view = [window_ vibrantView]; + NSVisualEffectView* vibrantView = [window_ vibrantView]; if (type.empty()) { - if (vibrant_view == nil) + if (vibrantView == nil) return; - [vibrant_view removeFromSuperview]; + [vibrantView removeFromSuperview]; [window_ setVibrantView:nil]; return; } - NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view; - if (effect_view == nil) { - effect_view = [[[NSVisualEffectView alloc] + if (vibrantView == nil) { + vibrantView = [[[NSVisualEffectView alloc] initWithFrame:[[window_ contentView] bounds]] autorelease]; - [window_ setVibrantView:(NSView*)effect_view]; + [window_ setVibrantView:vibrantView]; - [effect_view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; - [effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow]; + [vibrantView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + [vibrantView setBlendingMode:NSVisualEffectBlendingModeBehindWindow]; if (visual_effect_state_ == VisualEffectState::kActive) { - [effect_view setState:NSVisualEffectStateActive]; + [vibrantView setState:NSVisualEffectStateActive]; } else if (visual_effect_state_ == VisualEffectState::kInactive) { - [effect_view setState:NSVisualEffectStateInactive]; + [vibrantView setState:NSVisualEffectStateInactive]; } else { - [effect_view setState:NSVisualEffectStateFollowsWindowActiveState]; + [vibrantView setState:NSVisualEffectStateFollowsWindowActiveState]; } - [[window_ contentView] addSubview:effect_view + [[window_ contentView] addSubview:vibrantView positioned:NSWindowBelow relativeTo:nil]; @@ -1447,7 +1445,7 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { if (vibrancyType) { vibrancy_type_ = type; - [effect_view setMaterial:vibrancyType]; + [vibrantView setMaterial:vibrancyType]; } } diff --git a/shell/browser/ui/cocoa/electron_ns_window.h b/shell/browser/ui/cocoa/electron_ns_window.h index 48e32def1ea42..c5adf86469e95 100644 --- a/shell/browser/ui/cocoa/electron_ns_window.h +++ b/shell/browser/ui/cocoa/electron_ns_window.h @@ -35,7 +35,7 @@ class ScopedDisableResize { @property BOOL enableLargerThanScreen; @property BOOL disableAutoHideCursor; @property BOOL disableKeyOrMainWindow; -@property(nonatomic, retain) NSView* vibrantView; +@property(nonatomic, retain) NSVisualEffectView* vibrantView; @property(nonatomic, retain) NSImage* cornerMask; - (id)initWithShell:(electron::NativeWindowMac*)shell styleMask:(NSUInteger)styleMask;