summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 17:31:31 +0000
committerrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 17:31:31 +0000
commita1e9bf8abb33e2b6b840447993e2ff6821214669 (patch)
treee4189809235eebb0acc99c4d9ae2088fc0015b6e
parent9f16f9fb94d4f2a7963e759f3ca712df30d74fff (diff)
downloadchromium_src-a1e9bf8abb33e2b6b840447993e2ff6821214669.zip
chromium_src-a1e9bf8abb33e2b6b840447993e2ff6821214669.tar.gz
chromium_src-a1e9bf8abb33e2b6b840447993e2ff6821214669.tar.bz2
[Mac] Size popup windows correctly.
BUG=48428 TEST=Popup windows should open with the correct content size (while still respecting the 400x250 minimum window size). Review URL: http://codereview.chromium.org/3408003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59678 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm27
1 files changed, 26 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index b7bbe34..e2743c8 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -208,7 +208,8 @@
// offscreen, but there will always be enough window onscreen to
// drag the whole window back into view.
NSSize minSize = [[self window] minSize];
- gfx::Rect windowRect = browser_->GetSavedWindowBounds();
+ gfx::Rect desiredContentRect = browser_->GetSavedWindowBounds();
+ gfx::Rect windowRect = desiredContentRect;
if (windowRect.width() < minSize.width)
windowRect.set_width(minSize.width);
if (windowRect.height() < minSize.height)
@@ -222,6 +223,9 @@
windowRect.set_origin(WindowSizer::GetDefaultPopupOrigin(size));
}
+ // Size and position the window. Note that it is not yet onscreen. Popup
+ // windows may get resized later on in this function, once the actual size
+ // of the toolbar/tabstrip is known.
windowShim_->SetBounds(windowRect);
// Puts the incognito badge on the window frame, if necessary.
@@ -291,6 +295,27 @@
// Force a relayout of all the various bars.
[self layoutSubviews];
+ // For a popup window, |desiredContentRect| contains the desired height of
+ // the content, not of the whole window. Now that all the views are laid
+ // out, measure the current content area size and grow if needed. The
+ // window has not been placed onscreen yet, so this extra resize will not
+ // cause visible jank.
+ if (browser_->type() & Browser::TYPE_POPUP) {
+ CGFloat deltaH = desiredContentRect.height() -
+ NSHeight([[self tabContentArea] frame]);
+ // Do not shrink the window, as that may break minimum size invariants.
+ if (deltaH > 0) {
+ // Convert from tabContentArea coordinates to window coordinates.
+ NSSize convertedSize =
+ [[self tabContentArea] convertSize:NSMakeSize(0, deltaH)
+ toView:nil];
+ NSRect frame = [[self window] frame];
+ frame.size.height += convertedSize.height;
+ frame.origin.y -= convertedSize.height;
+ [[self window] setFrame:frame display:NO];
+ }
+ }
+
// Create the bridge for the status bubble.
statusBubble_ = new StatusBubbleMac([self window], self);