summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.mm2
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_private.mm18
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_unittest.mm2
-rw-r--r--chrome/browser/ui/cocoa/tabs/tab_window_controller.h11
-rw-r--r--chrome/browser/ui/cocoa/tabs/tab_window_controller.mm32
-rw-r--r--chrome/browser/ui/cocoa/version_independent_window.mm8
6 files changed, 47 insertions, 26 deletions
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index f45fe95..bd0cae6 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -1556,7 +1556,7 @@ using content::WebContents;
if (!downloadShelfController_.get()) {
downloadShelfController_.reset([[DownloadShelfController alloc]
initWithBrowser:browser_.get() resizeDelegate:self]);
- [[[self window] contentView] addSubview:[downloadShelfController_ view]];
+ [self.chromeContentView addSubview:[downloadShelfController_ view]];
}
return downloadShelfController_;
}
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index e1b7885..f701c6f 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -566,13 +566,10 @@ willPositionSheet:(NSWindow*)sheet
[tabStripView removeFromSuperview];
}
- // Ditto for the content view.
- base::scoped_nsobject<NSView> contentView(
- [[sourceWindow contentView] retain]);
// Disable autoresizing of subviews while we move views around. This prevents
// spurious renderer resizes.
- [contentView setAutoresizesSubviews:NO];
- [contentView removeFromSuperview];
+ [self.chromeContentView setAutoresizesSubviews:NO];
+ [self.chromeContentView removeFromSuperview];
// Have to do this here, otherwise later calls can crash because the window
// has no delegate.
@@ -584,8 +581,11 @@ willPositionSheet:(NSWindow*)sheet
// drawOverlayRect:]. I'm pretty convinced this is an Apple bug, but there is
// no visual impact. I have been unable to tickle it away with other window
// or view manipulation Cocoa calls. Stack added to suppressions_mac.txt.
- [contentView setAutoresizesSubviews:YES];
- [destWindow setContentView:contentView];
+ [self.chromeContentView setAutoresizesSubviews:YES];
+ [[destWindow contentView] addSubview:self.chromeContentView
+ positioned:NSWindowBelow
+ relativeTo:nil];
+ self.chromeContentView.frame = [[destWindow contentView] bounds];
// Move the incognito badge if present.
if ([self shouldShowAvatar]) {
@@ -852,7 +852,7 @@ willPositionSheet:(NSWindow*)sheet
for (NSWindow* window in [[NSApplication sharedApplication] windows]) {
if ([window
isKindOfClass:NSClassFromString(@"NSToolbarFullScreenWindow")]) {
- [window.contentView setHidden:YES];
+ [[window contentView] setHidden:YES];
}
}
}
@@ -930,7 +930,7 @@ willPositionSheet:(NSWindow*)sheet
}
- (void)updateSubviewZOrder:(BOOL)inPresentationMode {
- NSView* contentView = [[self window] contentView];
+ NSView* contentView = self.chromeContentView;
NSView* toolbarView = [toolbarController_ view];
if (inPresentationMode) {
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
index 0823f2d..64faaf6 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
@@ -615,7 +615,7 @@ TEST_F(BrowserWindowControllerTest, TestFindBarOnTop) {
[controller_ addFindBar:bridge.find_bar_cocoa_controller()];
// Test that the Z-order of the find bar is on top of everything.
- NSArray* subviews = [[[controller_ window] contentView] subviews];
+ NSArray* subviews = [controller_.chromeContentView subviews];
NSUInteger findBar_index =
[subviews indexOfObject:[controller_ findBarView]];
EXPECT_NE(NSNotFound, findBar_index);
diff --git a/chrome/browser/ui/cocoa/tabs/tab_window_controller.h b/chrome/browser/ui/cocoa/tabs/tab_window_controller.h
index fd41a56..ef85470 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_window_controller.h
+++ b/chrome/browser/ui/cocoa/tabs/tab_window_controller.h
@@ -23,9 +23,19 @@
@interface TabWindowController : NSWindowController<NSWindowDelegate> {
@private
+ // Wrapper view around web content, and the developer tools view.
base::scoped_nsobject<FastResizeView> tabContentArea_;
+
+ // The tab strip overlaps the titlebar of the window.
base::scoped_nsobject<TabStripView> tabStripView_;
+ // In OSX 10.10+, all views must be added to the NSWindow's contentView. Some
+ // views (like the tab strip and the profile icon) are placed on top of the
+ // title bar and require special treatment. All other views should be added
+ // as subviews of chromeContentView_. This allows tab dragging and fullscreen
+ // logic to easily move the views that don't need special treatment.
+ base::scoped_nsobject<NSView> chromeContentView_;
+
// The child window used during dragging to achieve the opacity tricks.
NSWindow* overlayWindow_;
@@ -38,6 +48,7 @@
}
@property(readonly, nonatomic) TabStripView* tabStripView;
@property(readonly, nonatomic) FastResizeView* tabContentArea;
+@property(readonly, nonatomic) NSView* chromeContentView;
// This is the designated initializer for this class.
- (id)initTabWindowControllerWithTabStrip:(BOOL)hasTabStrip;
diff --git a/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm b/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm
index c6dfa62..17327c9 100644
--- a/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm
+++ b/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm
@@ -47,7 +47,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]);
@@ -57,14 +60,20 @@
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];
+ [[[self window] contentView] addSubview:chromeContentView_];
+
+ tabContentArea_.reset(
+ [[FastResizeView alloc] initWithFrame:[chromeContentView_ bounds]]);
[tabContentArea_ setAutoresizingMask:NSViewWidthSizable |
NSViewHeightSizable];
- [[[self window] contentView] addSubview:tabContentArea_];
+ [chromeContentView_ addSubview:tabContentArea_];
- tabStripView_.reset([[TabStripView alloc] initWithFrame:
- NSMakeRect(0, 0, 750, 37)]);
+ tabStripView_.reset([[TabStripView alloc]
+ initWithFrame:NSMakeRect(0, 0, kDefaultWidth, 37)]);
[tabStripView_ setAutoresizingMask:NSViewWidthSizable |
NSViewMinYMargin];
if (hasTabStrip)
@@ -81,6 +90,10 @@
return tabContentArea_;
}
+- (NSView*)chromeContentView {
+ return chromeContentView_;
+}
+
// Add the top tab strop to the window, above the content box and add it to the
// view hierarchy as a sibling of the content view so it can overlap with the
// window frame.
@@ -127,7 +140,7 @@
[overlayWindow_ setOpaque:NO];
[overlayWindow_ setDelegate:self];
- originalContentView_ = [window contentView];
+ originalContentView_ = self.chromeContentView;
[window addChildWindow:overlayWindow_ ordered:NSWindowAbove];
// Explicitly set the responder to be nil here (for restoring later).
@@ -153,7 +166,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_];
+ [[window contentView] addSubview:originalContentView_
+ positioned:NSWindowBelow
+ relativeTo:nil];
+ originalContentView_.frame = [[window contentView] bounds];
[[window cr_windowView] addSubview:[self tabStripView]];
[[window cr_windowView] updateTrackingAreas];
diff --git a/chrome/browser/ui/cocoa/version_independent_window.mm b/chrome/browser/ui/cocoa/version_independent_window.mm
index 24284a4..98dacb3 100644
--- a/chrome/browser/ui/cocoa/version_independent_window.mm
+++ b/chrome/browser/ui/cocoa/version_independent_window.mm
@@ -32,12 +32,6 @@
[super setFrameSize:size];
}
-// The contentView gets moved around during certain full-screen operations.
-// This is less than ideal, and should eventually be removed.
-- (void)viewDidMoveToSuperview {
- [self setFrame:[[self superview] bounds]];
-}
-
@end
@implementation NSWindow (VersionIndependentWindow)
@@ -79,8 +73,8 @@
chromeWindowView_.reset([[FullSizeContentView alloc] init]);
[chromeWindowView_
setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
- [chromeWindowView_ setFrame:[[[self contentView] superview] bounds]];
[self setContentView:chromeWindowView_];
+ [chromeWindowView_ setFrame:[[[self contentView] superview] bounds]];
}
}
return self;