summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-13 17:04:10 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-13 17:04:10 +0000
commitd94ccedd108876d5be652dfa8129df54cab555e9 (patch)
tree5afccd9515a80996d7a45badb43fc70bf445d812 /chrome/browser
parent253b7154b231a8c46ed74eaef03b87bd2e642517 (diff)
downloadchromium_src-d94ccedd108876d5be652dfa8129df54cab555e9.zip
chromium_src-d94ccedd108876d5be652dfa8129df54cab555e9.tar.gz
chromium_src-d94ccedd108876d5be652dfa8129df54cab555e9.tar.bz2
Fix native dialog size regression
A few sub options dialog has wrong size because OnCheckResize always applys Gtk's default size regardless of what we set. Fix the problem by only do auto resize when we are asked to (i.e. requested size_'s height is 0). Also make sure that auto resize repects the given minimum size. BUG=none TEST=Verify sub options dialogs such as autofill, search engine manager etc has the right size. Review URL: http://codereview.chromium.org/2053006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47154 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/native_dialog_window.cc63
1 files changed, 38 insertions, 25 deletions
diff --git a/chrome/browser/chromeos/native_dialog_window.cc b/chrome/browser/chromeos/native_dialog_window.cc
index 485b917..07693ec 100644
--- a/chrome/browser/chromeos/native_dialog_window.cc
+++ b/chrome/browser/chromeos/native_dialog_window.cc
@@ -53,6 +53,9 @@ class NativeDialogHost : public views::View,
// Init and attach to native dialog.
void Init();
+ // Check and apply minimum size restriction.
+ void CheckSize();
+
// The GtkDialog whose vbox will be displayed in this view.
gfx::NativeView dialog_;
@@ -62,6 +65,7 @@ class NativeDialogHost : public views::View,
std::wstring title_;
int flags_;
gfx::Size size_;
+ gfx::Size preferred_size_;
gfx::Size min_size_;
int destroy_signal_id_;
@@ -80,6 +84,7 @@ NativeDialogHost::NativeDialogHost(gfx::NativeView native_dialog,
contents_view_(NULL),
flags_(flags),
size_(size),
+ preferred_size_(size),
min_size_(min_size),
destroy_signal_id_(0) {
const char* title = gtk_window_get_title(GTK_WINDOW(dialog_));
@@ -94,24 +99,28 @@ NativeDialogHost::~NativeDialogHost() {
}
void NativeDialogHost::OnCheckResize(GtkWidget* widget) {
- gfx::NativeView contents = contents_view_->native_view();
-
- // Check whether preferred height has changed. We keep the current width
- // unchanged and pass "-1" as height to let gtk calculate a proper height.
- gtk_widget_set_size_request(contents, width(), -1);
- GtkRequisition requsition = { 0 };
- gtk_widget_size_request(contents, &requsition);
-
- if (size_.height() != requsition.height) {
- size_.set_width(requsition.width);
- size_.set_height(requsition.height);
- SizeToPreferredSize();
-
- gfx::Size window_size = window()->GetNonClientView()->GetPreferredSize();
- gfx::Rect window_bounds = window()->GetBounds();
- window_bounds.set_width(window_size.width());
- window_bounds.set_height(window_size.height());
- window()->SetBounds(window_bounds, NULL);
+ // Do auto height resize only when we are asked to do so.
+ if (size_.height() == 0) {
+ gfx::NativeView contents = contents_view_->native_view();
+
+ // Check whether preferred height has changed. We keep the current width
+ // unchanged and pass "-1" as height to let gtk calculate a proper height.
+ gtk_widget_set_size_request(contents, width(), -1);
+ GtkRequisition requsition = { 0 };
+ gtk_widget_size_request(contents, &requsition);
+
+ if (preferred_size_.height() != requsition.height) {
+ preferred_size_.set_width(requsition.width);
+ preferred_size_.set_height(requsition.height);
+ CheckSize();
+ SizeToPreferredSize();
+
+ gfx::Size window_size = window()->GetNonClientView()->GetPreferredSize();
+ gfx::Rect window_bounds = window()->GetBounds();
+ window_bounds.set_width(window_size.width());
+ window_bounds.set_height(window_size.height());
+ window()->SetBounds(window_bounds, NULL);
+ }
}
}
@@ -136,7 +145,7 @@ void NativeDialogHost::WindowClosing() {
// NativeDialogHost, views::View implementation:
gfx::Size NativeDialogHost::GetPreferredSize() {
- return size_;
+ return preferred_size_;
}
void NativeDialogHost::Layout() {
@@ -193,15 +202,19 @@ void NativeDialogHost::Init() {
GtkRequisition requsition = { 0 };
gtk_widget_size_request(contents, &requsition);
- size_.set_width(requsition.width);
- size_.set_height(requsition.height);
+ preferred_size_.set_width(requsition.width);
+ preferred_size_.set_height(requsition.height);
}
+ CheckSize();
+}
+
+void NativeDialogHost::CheckSize() {
// Apply the minimum size.
- if (size_.width() < min_size_.width())
- size_.set_width(min_size_.width());
- if (size_.height() < min_size_.height())
- size_.set_height(min_size_.height());
+ if (preferred_size_.width() < min_size_.width())
+ preferred_size_.set_width(min_size_.width());
+ if (preferred_size_.height() < min_size_.height())
+ preferred_size_.set_height(min_size_.height());
}
void ShowNativeDialog(gfx::NativeWindow parent,