diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-13 14:55:47 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-13 14:55:47 +0000 |
commit | 56a4355f80e324bd8f7aa439fb6424f86475c94d (patch) | |
tree | f5b3ae2aba635af6fe45c3417beb18e7231b9622 /chrome/browser/cocoa/browser_window_controller.mm | |
parent | c9b0cbdfe3a92f8e7413fb89fa67d25864eebc0f (diff) | |
download | chromium_src-56a4355f80e324bd8f7aa439fb6424f86475c94d.zip chromium_src-56a4355f80e324bd8f7aa439fb6424f86475c94d.tar.gz chromium_src-56a4355f80e324bd8f7aa439fb6424f86475c94d.tar.bz2 |
Disable Leopard's automatic window title gradient height detection, as it gets
confused by our tabs. Patch from rohitrao@google.com.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13591 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/browser_window_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 91 |
1 files changed, 69 insertions, 22 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index b092e07..5be49d9 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -17,10 +17,27 @@ #import "chrome/browser/cocoa/tab_view.h" #import "chrome/browser/cocoa/toolbar_controller.h" +namespace { + +// Size of the gradient. Empirically determined so that the gradient looks +// like what the heuristic does when there are just a few tabs. +const int kWindowGradientHeight = 24; + +} + @interface BrowserWindowController(Private) + - (void)positionToolbar; + +// Leopard's gradient heuristic gets confused by our tabs and makes the title +// gradient jump when creating a tab that is less than a tab width from the +// right side of the screen. This function disables Leopard's gradient +// heuristic. +- (void)fixWindowGradient; + @end + @implementation BrowserWindowController // Load the browser window nib and do any Cocoa-specific initialization. @@ -61,6 +78,7 @@ initWithModel:browser->toolbar_model() commands:browser->command_updater()]); [self positionToolbar]; + [self fixWindowGradient]; // Create the bridge for the status bubble. statusBubble_.reset(new StatusBubbleMac([self window])); @@ -78,28 +96,6 @@ return windowShim_.get(); } -// Position |toolbarView_| below the tab strip, but not as a sibling. The -// toolbar is part of the window's contentView, mainly because we want the -// opacity during drags to be the same as the web content. -- (void)positionToolbar { - NSView* contentView = [self tabContentArea]; - NSRect contentFrame = [contentView frame]; - NSView* toolbarView = [toolbarController_ view]; - NSRect toolbarFrame = [toolbarView frame]; - - // Shrink the content area by the height of the toolbar. - contentFrame.size.height -= toolbarFrame.size.height; - [contentView setFrame:contentFrame]; - - // Move the toolbar above the content area, within the window's content view - // (as opposed to the tab strip, which is a sibling). - toolbarFrame.origin.y = NSMaxY(contentFrame); - toolbarFrame.origin.x = 0; - toolbarFrame.size.width = contentFrame.size.width; - [toolbarView setFrame:toolbarFrame]; - [[[self window] contentView] addSubview:toolbarView]; -} - - (void)destroyBrowser { // We need the window to go away now. [self autorelease]; @@ -357,3 +353,54 @@ } @end + + +@interface NSWindow (NSPrivateApis) +// Note: These functions are private, use -[NSObject respondsToSelector:] +// before calling them. + +- (void)setAutorecalculatesContentBorderThickness:(BOOL)b + forEdge:(NSRectEdge)e; +- (void)setContentBorderThickness:(CGFloat)b forEdge:(NSRectEdge)e; +@end + + +@implementation BrowserWindowController (Private) + +// Position |toolbarView_| below the tab strip, but not as a sibling. The +// toolbar is part of the window's contentView, mainly because we want the +// opacity during drags to be the same as the web content. +- (void)positionToolbar { + NSView* contentView = [self tabContentArea]; + NSRect contentFrame = [contentView frame]; + NSView* toolbarView = [toolbarController_ view]; + NSRect toolbarFrame = [toolbarView frame]; + + // Shrink the content area by the height of the toolbar. + contentFrame.size.height -= toolbarFrame.size.height; + [contentView setFrame:contentFrame]; + + // Move the toolbar above the content area, within the window's content view + // (as opposed to the tab strip, which is a sibling). + toolbarFrame.origin.y = NSMaxY(contentFrame); + toolbarFrame.origin.x = 0; + toolbarFrame.size.width = contentFrame.size.width; + [toolbarView setFrame:toolbarFrame]; + [[[self window] contentView] addSubview:toolbarView]; +} + +- (void)fixWindowGradient { + NSWindow* win = [self window]; + if ([win respondsToSelector:@selector( + setAutorecalculatesContentBorderThickness:forEdge:)] && + [win respondsToSelector:@selector( + setContentBorderThickness:forEdge:)]) { + [win setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge]; + [win setContentBorderThickness:kWindowGradientHeight forEdge:NSMaxYEdge]; + + [win setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge]; + [win setContentBorderThickness:kWindowGradientHeight forEdge:NSMinYEdge]; + } +} + +@end |