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

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

Issue 646703002: mac: Use a full-size content view (reland 1). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from avi. Created 6 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 b5069cb862f85d692f195ce06f9ca0fefd9026bd..33f7fc013b8dcc45dbf5dc5707a1778c9f329456 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm
@@ -15,8 +15,14 @@
#import "ui/base/cocoa/focus_tracker.h"
#include "ui/base/theme_provider.h"
-@interface TabWindowController(PRIVATE)
+@interface TabWindowController ()
- (void)setUseOverlay:(BOOL)useOverlay;
+
+// The tab strip background view should always be inserted as the back-most
+// subview of the root view. It cannot be a subview of the contentView, as that
+// would cause it to become layer backed, which would cause it to draw on top
+// of non-layer backed content like the window controls.
+- (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window;
@end
@interface TabWindowOverlayWindow : NSWindow
@@ -49,7 +55,10 @@
@implementation TabWindowController
- (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip {
- NSRect contentRect = NSMakeRect(60, 229, 750, 600);
+ const CGFloat kDefaultWidth = 750;
+ const CGFloat kDefaultHeight = 600;
+
+ NSRect contentRect = NSMakeRect(60, 229, kDefaultWidth, kDefaultHeight);
base::scoped_nsobject<FramedBrowserWindow> window(
[[FramedBrowserWindow alloc] initWithContentRect:contentRect
hasTabStrip:hasTabStrip]);
@@ -59,11 +68,18 @@
if ((self = [super initWithWindow:window])) {
[[self window] setDelegate:self];
- tabContentArea_.reset([[FastResizeView alloc] initWithFrame:
- NSMakeRect(0, 0, 750, 600)]);
+ chromeContentView_.reset([[NSView alloc]
+ initWithFrame:NSMakeRect(0, 0, kDefaultWidth, kDefaultHeight)]);
+ [chromeContentView_
+ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+ [chromeContentView_ setWantsLayer:YES];
+ [[[self window] contentView] addSubview:chromeContentView_];
+
+ tabContentArea_.reset(
+ [[FastResizeView alloc] initWithFrame:[chromeContentView_ bounds]]);
[tabContentArea_ setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
- [[[self window] contentView] addSubview:tabContentArea_];
+ [chromeContentView_ addSubview:tabContentArea_];
// tabStripBackgroundView_ draws the theme image behind the tab strip area.
// When making a tab dragging window (setUseOverlay:), this view stays in
@@ -78,14 +94,13 @@
kBrowserFrameViewPaintHeight)]);
[tabStripBackgroundView_
setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin];
- [windowView addSubview:tabStripBackgroundView_
- positioned:NSWindowBelow
- relativeTo:nil];
+ [self insertTabStripBackgroundViewIntoWindow:window];
[self moveContentViewToBack:[window contentView]];
tabStripView_.reset([[TabStripView alloc]
- initWithFrame:NSMakeRect(0, 0, 750, chrome::kTabStripHeight)]);
+ initWithFrame:NSMakeRect(
+ 0, 0, kDefaultWidth, chrome::kTabStripHeight)]);
[tabStripView_ setAutoresizingMask:NSViewWidthSizable |
NSViewMinYMargin];
if (hasTabStrip)
@@ -106,6 +121,10 @@
return tabContentArea_;
}
+- (NSView*)chromeContentView {
+ return chromeContentView_;
+}
+
- (void)removeOverlay {
[self setUseOverlay:NO];
if (closeDeferred_) {
@@ -141,8 +160,9 @@
[overlayWindow_ setBackgroundColor:[NSColor clearColor]];
[overlayWindow_ setOpaque:NO];
[overlayWindow_ setDelegate:self];
+ [[overlayWindow_ contentView] setWantsLayer:YES];
- originalContentView_ = [window contentView];
+ originalContentView_ = self.chromeContentView;
[window addChildWindow:overlayWindow_ ordered:NSWindowAbove];
// Explicitly set the responder to be nil here (for restoring later).
@@ -168,8 +188,10 @@
// places. The TabStripView always needs to be in front of the window's
// content view and therefore it should always be added after the content
// view is set.
- [window setContentView:originalContentView_];
- [self moveContentViewToBack:originalContentView_];
+ [[window contentView] addSubview:originalContentView_
+ positioned:NSWindowBelow
+ relativeTo:nil];
+ originalContentView_.frame = [[window contentView] bounds];
[self insertTabStripView:[self tabStripView] intoWindow:window];
[[window cr_windowView] updateTrackingAreas];
@@ -334,6 +356,14 @@
}
}
+- (void)insertTabStripBackgroundViewIntoWindow:(NSWindow*)window {
+ DCHECK(tabStripBackgroundView_);
+ NSView* rootView = [[window contentView] superview];
+ [rootView addSubview:tabStripBackgroundView_
+ positioned:NSWindowBelow
+ relativeTo:nil];
+}
+
// Called when the size of the window content area has changed. Override to
// position specific views. Base class implementation does nothing.
- (void)layoutSubviews {
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_window_controller.h ('k') | chrome/browser/ui/cocoa/version_independent_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698