Chromium Code Reviews| Index: chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm |
| diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm |
| index f7f2cc922623b4e4829949973e196f80c2cc99c3..91a72f81b77312bfab4f94ed6b839d5ca872c45f 100644 |
| --- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm |
| +++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm |
| @@ -19,6 +19,13 @@ |
| #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_window.h" |
| #include "ui/base/cocoa/window_size_constants.h" |
| +namespace { |
| + |
| +const CGFloat kAccountChooserHeight = 20.0; |
| +const CGFloat kRelatedControlVerticalSpacing = 8.0; |
| + |
| +} // namespace; |
| + |
| namespace autofill { |
| // static |
| @@ -139,7 +146,6 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
| [[mainContainer_ view] setFrame:clientRect]; |
| [[signInContainer_ view] setFrame:clientRect]; |
| - const CGFloat kAccountChooserHeight = 20.0; |
| NSRect headerRect = clientRect; |
| headerRect.size.height = kAccountChooserHeight; |
| headerRect.origin.y = NSMaxY(clientRect); |
| @@ -155,16 +161,61 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
| contentRect.size.height += NSHeight(headerRect) + |
| chrome_style::kClientBottomPadding + |
| chrome_style::kTitleTopPadding; |
| - [[[self window] contentView] setFrame:contentRect]; |
| - NSRect frame = [[self window] frameRectForContentRect:contentRect]; |
| - [[self window] setFrame:frame display:YES]; |
| - |
| - [accountChooser_ |
| - setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; |
| + [self performLayout]; |
| } |
| return self; |
| } |
| +- (void)requestRelayout { |
| + [self performLayout]; |
| +} |
| + |
| +- (NSSize)preferredSize { |
| + NSSize contentSize; |
| + if ([[signInContainer_ view] isHidden]) |
| + contentSize = [mainContainer_ preferredSize]; |
| + else { |
|
Robert Sesek
2013/05/23 15:30:16
If any branch has braces, all branches need braces
groby-ooo-7-16
2013/05/24 20:36:14
Done.
|
| + // TODO(groby): SignInContainer needs preferredSize, too. |
| + NOTREACHED(); |
| + } |
| + |
| + NSSize headerSize = NSMakeSize(contentSize.width, kAccountChooserHeight); |
| + NSSize size = NSMakeSize( |
| + std::max(contentSize.width, headerSize.width), |
| + contentSize.height + headerSize.height + kRelatedControlVerticalSpacing); |
| + size.width += 2 * chrome_style::kHorizontalPadding; |
| + size.height += chrome_style::kClientBottomPadding + |
| + chrome_style::kTitleTopPadding; |
| + return size; |
| +} |
| + |
| +- (void)performLayout { |
| + // Don't animate when we first show the window. |
| + BOOL shouldAnimate = |
| + !NSEqualRects(ui::kWindowSizeDeterminedLater, [[self window] frame]); |
| + |
| + NSRect contentRect = NSZeroRect; |
| + contentRect.size = [self preferredSize]; |
| + NSRect clientRect = NSInsetRect( |
| + contentRect, chrome_style::kHorizontalPadding, 0); |
| + clientRect.origin.y += chrome_style::kClientBottomPadding; |
| + clientRect.size.height -= chrome_style::kTitleTopPadding + |
| + chrome_style::kClientBottomPadding; |
| + |
| + NSRect headerRect, mainRect; |
| + NSDivideRect(clientRect, &headerRect, &mainRect, |
| + kAccountChooserHeight, NSMaxYEdge); |
| + |
| + [accountChooser_ setFrame:headerRect]; |
| + [[mainContainer_ view] setFrame:mainRect]; |
| + [mainContainer_ performLayout]; |
| + [[signInContainer_ view] setFrame:mainRect]; |
| + // TODO(groby): Perform layout for signInContainer. |
| + |
| + NSRect frameRect = [[self window] frameRectForContentRect:contentRect]; |
| + [[self window] setFrame:frameRect display:YES animate:shouldAnimate]; |
| +} |
| + |
| - (IBAction)accept:(id)sender { |
| // TODO(groby): Validation goes here. |
| autofillDialog_->controller()->OnAccept(); |