Chromium Code Reviews| Index: chrome/browser/ui/cocoa/tabs/tab_window_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm |
| index 0d1927f1bee471859e4aacc843fa6e9f524893ab..73d0f3e755b97af15cb87aef4bc07c9584dc3639 100644 |
| --- a/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm |
| +++ b/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm |
| @@ -25,6 +25,15 @@ |
| // of non-layer backed content like the window controls. |
| - (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window |
| titleBar:(BOOL)hasTitleBar; |
| + |
| +// Called when NSWindowWillEnterFullScreenNotification notification received. |
| +// Makes visual effects view hidden as it should not be displayed in fullscreen. |
| +- (void)windowWillEnterFullScreenNotification:(NSNotification*)notification; |
| + |
| +// Called when NSWindowWillExitFullScreenNotification notification received. |
| +// Makes visual effects view visible since it was hidden in fullscreen. |
| +- (void)windowWillExitFullScreenNotification:(NSNotification*)notification; |
| + |
| @end |
| @interface TabWindowOverlayWindow : NSWindow |
| @@ -89,12 +98,10 @@ |
| // the parent window so that it can be translucent, while the tab strip view |
| // moves to the child window and stays opaque. |
| NSView* windowView = [window contentView]; |
| + CGFloat paintHeight = [FramedBrowserWindow browserFrameViewPaintHeight]; |
| tabStripBackgroundView_.reset([[TabStripBackgroundView alloc] |
| - initWithFrame:NSMakeRect(0, |
| - NSMaxY([windowView bounds]) - |
| - kBrowserFrameViewPaintHeight, |
| - NSWidth([windowView bounds]), |
| - kBrowserFrameViewPaintHeight)]); |
| + initWithFrame:NSMakeRect(0, NSMaxY([windowView bounds]) - paintHeight, |
| + NSWidth([windowView bounds]), paintHeight)]); |
| [tabStripBackgroundView_ |
| setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; |
| [self insertTabStripBackgroundViewIntoWindow:window titleBar:hasTitleBar]; |
| @@ -106,10 +113,34 @@ |
| NSViewMinYMargin]; |
| if (hasTabStrip) |
| [windowView addSubview:tabStripView_]; |
| + |
| + if (chrome::ShouldUseFullSizeContentView()) { |
| + // |windowWillEnterFullScreen:| and |windowWillExitFullScreen:| are |
| + // already called because self is a delegate for the window. However this |
| + // class is designed for subclassing and can not implement |
| + // NSWindowDelegate methods (because subclasses can do so as well and they |
| + // should be able to). TODO(crbug.com/654656): Move |visualEffectView_| to |
| + // subclass. |
| + [[NSNotificationCenter defaultCenter] |
| + addObserver:self |
| + selector:@selector(windowWillEnterFullScreenNotification:) |
| + name:NSWindowWillEnterFullScreenNotification |
| + object:window]; |
| + [[NSNotificationCenter defaultCenter] |
| + addObserver:self |
| + selector:@selector(windowWillExitFullScreenNotification:) |
| + name:NSWindowWillExitFullScreenNotification |
| + object:window]; |
| + } |
| } |
| return self; |
| } |
| +- (void)dealloc { |
| + [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| + [super dealloc]; |
| +} |
| + |
| - (NSView*)tabStripBackgroundView { |
| return tabStripBackgroundView_; |
| } |
| @@ -360,6 +391,7 @@ |
| // blurred using an NSVisualEffectView. |
| Class nsVisualEffectViewClass = NSClassFromString(@"NSVisualEffectView"); |
| if (!nsVisualEffectViewClass) { |
| + DCHECK(!chrome::ShouldUseFullSizeContentView()); |
| [rootView addSubview:tabStripBackgroundView_ |
| positioned:NSWindowBelow |
| relativeTo:nil]; |
| @@ -372,12 +404,12 @@ |
| if (hasTitleBar) |
| return; |
| - base::scoped_nsobject<NSVisualEffectView> visualEffectView( |
| + visualEffectView_.reset( |
| [[nsVisualEffectViewClass alloc] |
| initWithFrame:[tabStripBackgroundView_ frame]]); |
| - DCHECK(visualEffectView); |
| + DCHECK(visualEffectView_); |
| - [visualEffectView setAutoresizingMask: |
| + [visualEffectView_ setAutoresizingMask: |
| [tabStripBackgroundView_ autoresizingMask]]; |
| [tabStripBackgroundView_ |
| setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
| @@ -388,19 +420,23 @@ |
| // before the |browser_| ivar has been set. Without a browser object we |
| // can't check the window's theme. The final setup happens in |
| // -[TabStripView setController:], at which point we have access to the theme. |
| - [visualEffectView setAppearance: |
| + [visualEffectView_ setAppearance: |
| [NSAppearance appearanceNamed:NSAppearanceNameVibrantLight]]; |
| - [visualEffectView setMaterial:NSVisualEffectMaterialLight]; |
| - [visualEffectView setBlendingMode:NSVisualEffectBlendingModeBehindWindow]; |
| - [visualEffectView setState:NSVisualEffectStateFollowsWindowActiveState]; |
| + [visualEffectView_ setMaterial:NSVisualEffectMaterialLight]; |
| + [visualEffectView_ setBlendingMode:NSVisualEffectBlendingModeBehindWindow]; |
| + [visualEffectView_ setState:NSVisualEffectStateFollowsWindowActiveState]; |
| - [rootView addSubview:visualEffectView |
| - positioned:NSWindowBelow |
| - relativeTo:nil]; |
| + if (chrome::ShouldUseFullSizeContentView()) { |
| + [[window contentView] addSubview:visualEffectView_]; |
| + } else { |
| + [rootView addSubview:visualEffectView_ |
| + positioned:NSWindowBelow |
| + relativeTo:nil]; |
| + } |
| // Make the |tabStripBackgroundView_| a child of the NSVisualEffectView. |
| - [tabStripBackgroundView_ setFrame:[visualEffectView bounds]]; |
| - [visualEffectView addSubview:tabStripBackgroundView_]; |
| + [tabStripBackgroundView_ setFrame:[visualEffectView_ bounds]]; |
| + [visualEffectView_ addSubview:tabStripBackgroundView_]; |
| } |
| // Called when the size of the window content area has changed. Override to |
| @@ -409,4 +445,12 @@ |
| NOTIMPLEMENTED(); |
| } |
| +- (void)windowWillEnterFullScreenNotification:(NSNotification*)notification { |
| + [[visualEffectView_ animator] setAlphaValue:0.0]; |
|
erikchen
2016/10/11 17:39:45
why is this necessary now but not before?
Eugene But (OOO till 7-30)
2016/10/11 21:06:16
With old view hierarchy NSVisualEffectVew was move
|
| +} |
| + |
| +- (void)windowWillExitFullScreenNotification:(NSNotification*)notification { |
| + [[visualEffectView_ animator] setAlphaValue:1.0]; |
| +} |
| + |
| @end |