diff options
author | groby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-16 20:35:18 +0000 |
---|---|---|
committer | groby@chromium.org <groby@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-16 20:35:18 +0000 |
commit | d28775d2e8c2538a0bbea0fcb6f341a8ae861026 (patch) | |
tree | 71012f85de71daa0f70f21dc52d84382b3f6d2c7 | |
parent | e1ff4a4ae373958c2e964e57d9b07a76c20065e6 (diff) | |
download | chromium_src-d28775d2e8c2538a0bbea0fcb6f341a8ae861026.zip chromium_src-d28775d2e8c2538a0bbea0fcb6f341a8ae861026.tar.gz chromium_src-d28775d2e8c2538a0bbea0fcb6f341a8ae861026.tar.bz2 |
[rAC, OSX] Force better initial size for sign-in (2nd try)
This is a re-land of http://crrev.com/103853004 (r240566), which was
reverted in http://crrev.com/113913008 (r240603)
The revert was due to a test failure with the root cause that
AutofillDialogBrowserTest shows the dialog, but never runs the
NSRunLoop - which means the visual display is not fully updated. And
showing the sign-in dialog requires the main dialog's size to be non-
zero.
Fixes added:
* AutofillSignInDelegate DCHECKs for invalid sizes (better callstacks)
* AutofillDialogBrowserTest cycles run loops whenever dialog is shown
---- original description ----
Open the sign-in dialog with an initial size equal to the current
dialog. This avoids one unnecessary resize until the content is loaded
and makes the visual experience less jarring.
---- end original description ----
TBR=jochen@chromium.org
R=isherman@chromium.org
BUG=325518
Review URL: https://codereview.chromium.org/97993006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241009 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 31 insertions, 6 deletions
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc index 044f827..d72093f2 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_browsertest.cc @@ -57,6 +57,12 @@ #include "ui/base/window_open_disposition.h" #include "url/gurl.h" +#if defined(OS_MACOSX) +#include "base/mac/mac_util.h" +#include "base/mac/scoped_nsautorelease_pool.h" +#include "chrome/browser/ui/cocoa/run_loop_testing.h" +#endif + namespace autofill { namespace { @@ -284,6 +290,16 @@ class AutofillDialogControllerTest : public InProcessBrowserTest { InitializeController(); } + // A helper function that cycles the MessageLoop, and on Mac, the Cocoa run + // loop. It also drains the NSAutoreleasePool. + void CycleRunLoops() { + content::RunAllPendingInMessageLoop(); +#if defined(OS_MACOSX) + chrome::testing::NSRunLoopRunAllPending(); + AutoreleasePool()->Recycle(); +#endif + } + void InitializeController() { FormData form; form.name = ASCIIToUTF16("TestForm"); @@ -308,6 +324,7 @@ class AutofillDialogControllerTest : public InProcessBrowserTest { metric_logger_, message_loop_runner_); controller_->Show(); + CycleRunLoops(); // Ensures dialog is fully visible. } content::WebContents* GetActiveWebContents() { diff --git a/chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.cc b/chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.cc index 8bc6809..19ac03f 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.cc @@ -79,6 +79,8 @@ void AutofillDialogSignInDelegate::UpdateLimitsAndEnableAutoResize( } void AutofillDialogSignInDelegate::EnableAutoResize() { + DCHECK(!minimum_size_.IsEmpty()); + DCHECK(!maximum_size_.IsEmpty()); content::RenderViewHost* host = web_contents()->GetRenderViewHost(); if (host) host->EnableAutoResize(minimum_size_, maximum_size_); 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 ea09f2c..7086c60 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm +++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_window_controller.mm @@ -409,7 +409,12 @@ const CGFloat kMinimumContentsHeight = 101; - (content::NavigationController*)showSignIn { [self updateSignInSizeConstraints]; + // Ensure |signInContainer_| is set to the same size as |mainContainer_|, to + // force its minimum size so that there will not be a resize until the + // contents are loaded. + [[signInContainer_ view] setFrameSize:[[mainContainer_ view] frame].size]; [signInContainer_ loadSignInPage]; + [[signInContainer_ view] setHidden:NO]; [self updateMainContainerVisibility]; [self requestRelayout]; diff --git a/chrome/browser/ui/cocoa/autofill/autofill_sign_in_container.mm b/chrome/browser/ui/cocoa/autofill/autofill_sign_in_container.mm index 6ed7e29..ea26ca9 100644 --- a/chrome/browser/ui/cocoa/autofill/autofill_sign_in_container.mm +++ b/chrome/browser/ui/cocoa/autofill/autofill_sign_in_container.mm @@ -37,17 +37,18 @@ - (void)loadSignInPage { DCHECK(webContents_.get()); - // Prevent accidentaly empty |maxSize_|. - if (NSEqualSizes(NSMakeSize(0, 0), maxSize_)) { - maxSize_ = [[[self view] window] frame].size; - maxSize_.height -= chrome_style::kClientBottomPadding; - } + // Ensure initial minimum size doesn't cause resize. + NSSize initialMinSize = [[self view] frame].size; + + // Ensure |maxSize_| is bigger than |initialMinSize|. + maxSize_.height = std::max(maxSize_.height, initialMinSize.height); + maxSize_.width = std::max(maxSize_.width, initialMinSize.width); signInDelegate_.reset( new autofill::AutofillDialogSignInDelegate( dialog_, webContents_.get(), dialog_->delegate()->GetWebContents()->GetDelegate(), - gfx::Size(NSSizeToCGSize(minSize_)), + gfx::Size(NSSizeToCGSize(initialMinSize)), gfx::Size(NSSizeToCGSize(maxSize_)))); webContents_->GetController().LoadURL( dialog_->delegate()->SignInUrl(), |