Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1164)

Unified Diff: chrome/browser/ui/cocoa/tabs/tab_window_controller.mm

Issue 2404783002: [Mac] Avoid "adding unknown subview" warning. (Closed)
Patch Set: Merged with head Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..49bf202a705891f150af74a3a233dddafb75cc46 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm
@@ -25,6 +25,14 @@
// 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;
tapted 2016/10/10 23:38:06 nit: windowWillEnterFullScreen: (consistent with B
Eugene But (OOO till 7-30) 2016/10/11 00:33:10 |windowWillEnterFullScreen:| does not follow Codin
+// Called when NSWindowWillExitFullScreenNotification notification received.
tapted 2016/10/10 23:38:06 nit: blank line before [consistency]
Eugene But (OOO till 7-30) 2016/10/11 00:33:10 Done.
+// Makes visual effects view visible since it was hidden in fullscreen.
+- (void)windowWillExitFullScreenNotification:(NSNotification*)notification;
+
@end
@interface TabWindowOverlayWindow : NSWindow
@@ -89,12 +97,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 +112,28 @@
NSViewMinYMargin];
if (hasTabStrip)
[windowView addSubview:tabStripView_];
+
+ if (chrome::ShouldUseFullSizeContentView()) {
+ [[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_;
}
@@ -394,13 +418,18 @@
[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_];
+ visualEffectView_.reset([visualEffectView retain]);
tapted 2016/10/10 23:38:06 since visualEffectView is also scoped_nsobject, we
Eugene But (OOO till 7-30) 2016/10/11 00:33:10 Done.
}
// Called when the size of the window content area has changed. Override to
@@ -409,4 +438,12 @@
NOTIMPLEMENTED();
}
+- (void)windowWillEnterFullScreenNotification:(NSNotification*)notification {
+ [[visualEffectView_ animator] setAlphaValue:0.0];
tapted 2016/10/10 23:38:06 I wonder if there are implications for text render
Eugene But (OOO till 7-30) 2016/10/11 00:33:10 Visually looks the same before and after the chang
+}
+
+- (void)windowWillExitFullScreenNotification:(NSNotification*)notification {
+ [[visualEffectView_ animator] setAlphaValue:1.0];
tapted 2016/10/10 23:38:06 Maybe worth a note for these - visualEffectView_ w
Eugene But (OOO till 7-30) 2016/10/11 00:33:10 Done. Added comments to the header.
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698