diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-08 07:29:11 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-08 07:29:11 +0000 |
commit | 8e2378c7bf9d2dd7d8e3a93c31dcdb79869b1e0e (patch) | |
tree | 5c9aab0565d3196a71e6eb5aba1be871b768ebb3 | |
parent | 2d7c8c7d770fcf40b0fa0357126dca59ae7775d0 (diff) | |
download | chromium_src-8e2378c7bf9d2dd7d8e3a93c31dcdb79869b1e0e.zip chromium_src-8e2378c7bf9d2dd7d8e3a93c31dcdb79869b1e0e.tar.gz chromium_src-8e2378c7bf9d2dd7d8e3a93c31dcdb79869b1e0e.tar.bz2 |
[rAc] [OSX] Set a minimum height for the Autofill dialog's main contents.
BUG=318535
TEST=Shrink Chrome browser window to be as short as possible, ensure that the
rAc dialog is still usable.
R=groby@chromium.org
Review URL: https://codereview.chromium.org/109453002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239392 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 47 insertions, 18 deletions
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm index fea519f..c8f0e01 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm +++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm @@ -26,6 +26,7 @@ #include "ui/base/cocoa/window_size_constants.h" #include "ui/base/l10n/l10n_util.h" +// The minimum useful height of the contents area of the dialog. const CGFloat kMinimumContentsHeight = 101; #pragma mark AutofillDialogWindow @@ -221,11 +222,17 @@ const CGFloat kMinimumContentsHeight = 101; } - (void)updateSignInSizeConstraints { - // Adjust for the size of the header. + // For the minimum height, account for the size of the footer. Even though the + // footer will not be visible when the sign-in view is showing, this prevents + // the dialog's size from bouncing around. + CGFloat width = NSWidth([[[self window] contentView] frame]); + CGFloat minHeight = + kMinimumContentsHeight + + [mainContainer_ decorationSizeForWidth:width].height; + + // For the maximum size, factor in the size of the header. CGFloat headerHeight = [[header_ view] frame].size.height; - CGFloat minHeight = kMinimumContentsHeight - headerHeight; CGFloat maxHeight = std::max([self maxHeight] - headerHeight, minHeight); - CGFloat width = NSWidth([[[self window] contentView] frame]); [signInContainer_ constrainSizeToMinimum:NSMakeSize(width, minHeight) maximum:NSMakeSize(width, maxHeight)]; @@ -268,13 +275,23 @@ const CGFloat kMinimumContentsHeight = 101; size = [signInContainer_ preferredSize]; // Always make room for the header. - size.height += [header_ heightForWidth:size.width]; + CGFloat headerHeight = [header_ heightForWidth:size.width]; + size.height += headerHeight; + + // For the minimum height, account for both the header and the footer. Even + // though the footer will not be visible when the sign-in view is showing, + // this prevents the dialog's size from bouncing around. + CGFloat minHeight = kMinimumContentsHeight; + minHeight += [mainContainer_ decorationSizeForWidth:size.width].height; + minHeight += headerHeight; + + // Show as much of the main view as is possible without going past the + // bottom of the browser window, unless this would cause the dialog to be + // less tall than the minimum height. + size.height = std::min(size.height, [self maxHeight]); + size.height = std::max(size.height, minHeight); } - // Show as much of the main view as is possible without going past the - // bottom of the browser window. - size.height = std::min(size.height, [self maxHeight]); - return size; } diff --git a/chrome/browser/ui/cocoa/autofill/autofill_main_container.h b/chrome/browser/ui/cocoa/autofill/autofill_main_container.h index 2c40042..defeb23 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_main_container.h +++ b/chrome/browser/ui/cocoa/autofill/autofill_main_container.h @@ -53,6 +53,9 @@ namespace autofill { // Designated initializer. - (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate; +// Returns the preferred size for the footer at the specfied |width|. +- (NSSize)decorationSizeForWidth:(CGFloat)width; + // Sets the anchor point for the notificationView_. - (void)setAnchorView:(NSView*)anchorView; diff --git a/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm b/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm index 45d0ef0..ad0410f 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm +++ b/chrome/browser/ui/cocoa/autofill/autofill_main_container.mm @@ -132,8 +132,7 @@ const SkColor kLegalDocumentsTextColor = SkColorSetRGB(102, 102, 102); return YES; } -- (NSSize)preferredSize { - // Overall width is determined by |detailsContainer_|. +- (NSSize)decorationSizeForWidth:(CGFloat)width { NSSize buttonSize = [buttonContainer_ frame].size; NSSize buttonStripImageSize = [buttonStripImage_ frame].size; NSSize buttonStripSize = @@ -143,21 +142,31 @@ const SkColor kLegalDocumentsTextColor = SkColorSetRGB(102, 102, 102); buttonStripImageSize.height) + chrome_style::kClientBottomPadding); - NSSize detailsSize = [detailsContainer_ preferredSize]; - - NSSize size = NSMakeSize(std::max(buttonStripSize.width, detailsSize.width), - buttonStripSize.height + detailsSize.height); - size.height += 2 * autofill::kDetailVerticalPadding; - + NSSize size = NSMakeSize(std::max(buttonStripSize.width, width), + buttonStripSize.height); if (![legalDocumentsView_ isHidden]) { NSSize legalDocumentSize = - [self preferredLegalDocumentSizeForWidth:detailsSize.width]; + [self preferredLegalDocumentSizeForWidth:width]; size.height += legalDocumentSize.height + autofill::kVerticalSpacing; } + // TODO(isherman): Move notifications into the AutofillHeader class, and + // rename this method to -footerSizeForWidth:. NSSize notificationSize = - [notificationContainer_ preferredSizeForWidth:detailsSize.width]; + [notificationContainer_ preferredSizeForWidth:width]; size.height += notificationSize.height; + + return size; +} + +- (NSSize)preferredSize { + NSSize detailsSize = [detailsContainer_ preferredSize]; + NSSize decorationSize = [self decorationSizeForWidth:detailsSize.width]; + + NSSize size = NSMakeSize(std::max(decorationSize.width, detailsSize.width), + decorationSize.height + detailsSize.height); + size.height += 2 * autofill::kDetailVerticalPadding; + return size; } |