Chromium Code Reviews| Index: chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm |
| 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 b8db59a2e5b157b3a0b51c3cc1bd57a8810fa2a0..c36ddecfbfebf945b41bce58a2a54dc3b8706bf3 100644 |
| --- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm |
| +++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm |
| @@ -32,6 +32,54 @@ const CGFloat kMinimumContentsHeight = 101; |
| } // namespace |
| +#pragma mark AutofillDialogWindow |
| + |
| +// Window class for the AutofillDialog. Its main purpose is the proper handling |
| +// of layout requests - i.e. ensuring that layout is fully done before any |
| +// updates of the display happen. |
| +@interface AutofillDialogWindow : ConstrainedWindowCustomWindow { |
| + @private |
| + BOOL needsLayout; // Indicates that the subviews need to be laid out. |
|
Nico
2013/11/27 01:03:06
don't we name instance variables with a trailing _
groby-ooo-7-16
2013/11/27 01:34:04
Yes, we do. My brain is already eating turkey, it
|
| +} |
| + |
| +// Request a new layout for all subviews. Layout occurs right before -display |
| +// or -displayIfNeeded are invoked. |
| +- (void)requestRelayout; |
| + |
| +// Layout the window's subviews. Delegates to the controller. |
| +- (void)performLayout; |
| + |
| +@end |
| + |
| + |
| +@implementation AutofillDialogWindow |
| + |
| +- (void)requestRelayout { |
| + needsLayout = YES; |
| +} |
| + |
| +- (void)performLayout { |
| + if (needsLayout) { |
| + needsLayout = NO; |
| + AutofillDialogWindowController* controller = |
| + base::mac::ObjCCastStrict<AutofillDialogWindowController>( |
| + [self windowController]); |
| + [controller performLayout]; |
| + } |
| +} |
| + |
| +- (void)display { |
| + [self performLayout]; |
| + [super display]; |
| +} |
| + |
| +- (void)displayIfNeeded { |
| + [self performLayout]; |
| + [super displayIfNeeded]; |
| +} |
| + |
| +@end |
| + |
| #pragma mark Field Editor |
| @interface AutofillDialogFieldEditor : NSTextView |
| @@ -81,6 +129,8 @@ const CGFloat kMinimumContentsHeight = 101; |
| // Update whether or not the main container is hidden. |
| - (void)updateMainContainerVisibility; |
| +- (AutofillDialogWindow*)autofillWindow; |
| + |
| @end |
| @@ -108,7 +158,7 @@ const CGFloat kMinimumContentsHeight = 101; |
| DCHECK(webContents); |
| base::scoped_nsobject<ConstrainedWindowCustomWindow> window( |
| - [[ConstrainedWindowCustomWindow alloc] |
| + [[AutofillDialogWindow alloc] |
| initWithContentRect:ui::kWindowSizeDeterminedLater]); |
| if ((self = [super initWithWindow:window])) { |
| @@ -196,15 +246,12 @@ const CGFloat kMinimumContentsHeight = 101; |
| [[mainContainer_ view] setHidden:!visible]; |
| } |
| -- (void)cancelRelayout { |
| - [NSObject cancelPreviousPerformRequestsWithTarget:self |
| - selector:@selector(performLayout) |
| - object:nil]; |
| +- (AutofillDialogWindow*)autofillWindow { |
| + return base::mac::ObjCCastStrict<AutofillDialogWindow>([self window]); |
| } |
| - (void)requestRelayout { |
| - [self cancelRelayout]; |
| - [self performSelector:@selector(performLayout) withObject:nil afterDelay:0.0]; |
| + [[self autofillWindow] requestRelayout]; |
| } |
| - (NSSize)preferredSize { |