Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove c-style conversion for vibrantView #29724

Merged
merged 1 commit into from Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 16 additions & 18 deletions shell/browser/native_window_mac.mm
Expand Up @@ -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) {
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -1447,7 +1445,7 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {

if (vibrancyType) {
vibrancy_type_ = type;
[effect_view setMaterial:vibrancyType];
[vibrantView setMaterial:vibrancyType];
}
}

Expand Down
2 changes: 1 addition & 1 deletion shell/browser/ui/cocoa/electron_ns_window.h
Expand Up @@ -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;
Expand Down