From 4073599f59023360fbaff0a6e90f34dc26246338 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 14 May 2021 18:05:34 +0900 Subject: [PATCH] fix: remove background color hack in vibrancy (#29114) --- docs/api/browser-window.md | 2 +- shell/browser/native_window_mac.h | 2 -- shell/browser/native_window_mac.mm | 12 +----------- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index a1602e47ccf1..3dd9de0c2de4 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -238,7 +238,7 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. window shadow and window animations. Default is `true`. * `vibrancy` String (optional) - Add a type of vibrancy effect to the window, only on macOS. Can be `appearance-based`, `light`, `dark`, `titlebar`, `selection`, - `menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. Please note that using `frame: false` in combination with a vibrancy value requires that you use a non-default `titleBarStyle` as well. Also note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` are deprecated and have been removed in macOS Catalina (10.15). + `menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. Please note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` are deprecated and have been removed in macOS Catalina (10.15). * `zoomToPageWidth` Boolean (optional) - Controls the behavior on macOS when option-clicking the green stoplight button on the toolbar or by clicking the Window > Zoom menu item. If `true`, the window will grow to the preferred diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h index 4f66a2660173..65fe746a58e1 100644 --- a/shell/browser/native_window_mac.h +++ b/shell/browser/native_window_mac.h @@ -271,8 +271,6 @@ class NativeWindowMac : public NativeWindow, NSInteger original_level_; NSUInteger simple_fullscreen_mask_; - base::scoped_nsobject background_color_before_vibrancy_; - bool transparency_before_vibrancy_ = false; std::string vibrancy_type_; // The presentation options before entering simple fullscreen mode. diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 67b2ed06722e..f6867beb8797 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1338,6 +1338,7 @@ void NativeWindowMac::UpdateVibrancyRadii(bool fullscreen) { [maskImage setCapInsets:NSEdgeInsetsMake(radius, radius, radius, radius)]; [maskImage setResizingMode:NSImageResizingModeStretch]; [effect_view setMaskImage:maskImage]; + [window_ setCornerMask:maskImage]; } } } @@ -1346,10 +1347,6 @@ void NativeWindowMac::SetVibrancy(const std::string& type) { NSView* vibrant_view = [window_ vibrantView]; if (type.empty()) { - if (background_color_before_vibrancy_) { - [window_ setBackgroundColor:background_color_before_vibrancy_]; - [window_ setTitlebarAppearsTransparent:transparency_before_vibrancy_]; - } if (vibrant_view == nil) return; @@ -1360,13 +1357,6 @@ void NativeWindowMac::SetVibrancy(const std::string& type) { } vibrancy_type_ = type; - background_color_before_vibrancy_.reset([[window_ backgroundColor] retain]); - transparency_before_vibrancy_ = [window_ titlebarAppearsTransparent]; - - if (title_bar_style_ != TitleBarStyle::kNormal) { - [window_ setTitlebarAppearsTransparent:YES]; - [window_ setBackgroundColor:[NSColor clearColor]]; - } NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view; if (effect_view == nil) {