diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-13 18:53:25 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-13 18:53:25 +0000 |
commit | b83fed38db16e462afa3051dcad21318c62b2357 (patch) | |
tree | fd5ae43f789d403c5993662bdd0b41f74765ae86 | |
parent | b93a61088c60744e95b385ca14e16c996abffc0d (diff) | |
download | chromium_src-b83fed38db16e462afa3051dcad21318c62b2357.zip chromium_src-b83fed38db16e462afa3051dcad21318c62b2357.tar.gz chromium_src-b83fed38db16e462afa3051dcad21318c62b2357.tar.bz2 |
The dialogs would size their width to their contents (and a minimum size).
In some cases, the dialog buttons can be wider than the contents and were clipped.
This CL size the dialog to its contents or buttons, whatever is wider.
BUG=11855
TEST=Visit pages with alerts/confirm dialogs, make sure dialog are shown properly. Test the case described in the bug.
Review URL: http://codereview.chromium.org/115314
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15981 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | views/window/dialog_client_view.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc index 17fc332..d5574fa 100644 --- a/views/window/dialog_client_view.cc +++ b/views/window/dialog_client_view.cc @@ -300,6 +300,26 @@ gfx::Size DialogClientView::GetPreferredSize() { button_height = ok_button_->height(); // Account for padding above and below the button. button_height += kDialogButtonContentSpacing + kButtonVEdgeMargin; + + // Make sure the view is sized to the buttons's width if they are wider than + // the contents. + int width = 0; + if (cancel_button_) + width += GetButtonWidth(MessageBoxFlags::DIALOGBUTTON_CANCEL); + if (ok_button_) { + width += GetButtonWidth(MessageBoxFlags::DIALOGBUTTON_OK); + if (cancel_button_) + width += kRelatedButtonHSpacing; + } + if (extra_view_) { + width += extra_view_->GetPreferredSize().width(); + if (cancel_button_ || ok_button_) + width += kRelatedButtonHSpacing; + } + if (width > 0) { + width += 2 * kButtonHEdgeMargin; + prefsize.set_width(std::max(prefsize.width(), width)); + } } prefsize.Enlarge(0, button_height); return prefsize; |