diff options
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 22 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 6 |
4 files changed, 27 insertions, 6 deletions
diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index 2b2d0c3..2b5fb44 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -30,7 +30,7 @@ class BrowserWindowCocoa : public BrowserWindow, // Overridden from BrowserWindow virtual void Show(); - virtual void SetBounds(const gfx::Rect& bounds); + virtual void SetBounds(const gfx::Rect& bounds, BoundsType bounds_type); virtual void Close(); virtual void Activate(); virtual bool IsActive() const; diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index b3dd1f4..2ebda45 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -64,13 +64,27 @@ void BrowserWindowCocoa::Show() { [window() makeKeyAndOrderFront:controller_]; } -void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { - NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0, bounds.width(), - bounds.height()); +void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds, + BoundsType bounds_type) { + gfx::Rect win_bounds = bounds; + if (bounds_type == BrowserWindow::CONTENT_BOUNDS) { + // Fetch the size of the content area in the NSWindow. + NSSize content_area_size = [controller_ tabContentsFrame].size; + int width_offset = bounds.width() - content_area_size.width; + int height_offset = bounds.height() - content_area_size.height; + + // Adjust the size relative to the current frame size. + NSSize current_frame = [window() frame].size; + win_bounds.set_width(current_frame.width + width_offset); + win_bounds.set_height(current_frame.height + height_offset); + } + + NSRect cocoa_bounds = NSMakeRect(win_bounds.x(), 0, win_bounds.width(), + win_bounds.height()); // Flip coordinates based on the primary screen. NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; cocoa_bounds.origin.y = - [screen frame].size.height - bounds.height() - bounds.y(); + [screen frame].size.height - win_bounds.height() - win_bounds.y(); [window() setFrame:cocoa_bounds display:YES]; } diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index f3207f3..72edd91 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -155,6 +155,9 @@ class TabStripModelObserverBridge; // Sets whether or not the current page in the frontmost tab is bookmarked. - (void)setStarredState:(BOOL)isStarred; +// Returns the current frame of the the content area. +- (NSRect)tabContentsFrame; + // Return the rect, in WebKit coordinates (flipped), of the window's grow box // in the coordinate system of the content area of the currently selected tab. - (NSRect)selectedTabGrowBoxRect; diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index f795ce9..3eb0300 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -215,7 +215,7 @@ windowRect.set_origin(WindowSizer::GetDefaultPopupOrigin(size)); } - windowShim_->SetBounds(windowRect); + windowShim_->SetBounds(windowRect, BrowserWindow::WINDOW_BOUNDS); // Puts the incognito badge on the window frame, if necessary. Do this // before creating the tab strip to avoid redundant tab layout. @@ -976,6 +976,10 @@ [toolbarController_ setStarredState:isStarred]; } +- (NSRect)tabContentsFrame { + return [[self tabContentArea] frame]; +} + // Return the rect, in WebKit coordinates (flipped), of the window's grow box // in the coordinate system of the content area of the currently selected tab. // |windowGrowBox| needs to be in the window's coordinate system. |