diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-11 23:34:04 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-11 23:34:04 +0000 |
commit | 099e3eb41df072bbc3dd5dd0b007595cb2a0c634 (patch) | |
tree | 248424058d1486080fa0d43a49549be10833160d /chrome/browser/gtk | |
parent | af9bebd7772e8b11bc6b2f7e908242993540cc5b (diff) | |
download | chromium_src-099e3eb41df072bbc3dd5dd0b007595cb2a0c634.zip chromium_src-099e3eb41df072bbc3dd5dd0b007595cb2a0c634.tar.gz chromium_src-099e3eb41df072bbc3dd5dd0b007595cb2a0c634.tar.bz2 |
Size popups by their contents, not the window's outer bounds.
(This problem was most annoying when a popup was meant to be exactly large enough to show a certain image.)
This fixes a BlockedPopupContainer interactive ui test.
Review URL: http://codereview.chromium.org/192058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26050 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 44 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 5 |
2 files changed, 41 insertions, 8 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 2a8d81e..15f4d9c 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -573,12 +573,21 @@ BrowserWindowGtk::BrowserWindowGtk(Browser* browser) gtk_window_group_add_window(gtk_window_group_new(), window_); g_object_unref(gtk_window_get_group(window_)); - SetGeometryHints(); + // For popups, we initialize widgets then set the window geometry, because + // popups need the widgets inited before they can set the window size + // properly. For other windows, we set the geometry first to prevent resize + // flicker. + if (browser_->type() & Browser::TYPE_POPUP) { + InitWidgets(); + SetGeometryHints(); + } else { + SetGeometryHints(); + InitWidgets(); + } + ConnectHandlersToSignals(); ConnectAccelerators(); - bounds_ = GetInitialWindowBounds(window_); - InitWidgets(); // Set the initial background color of widgets. SetBackgroundColor(); HideUnsupportedWindowFeatures(); @@ -814,16 +823,31 @@ void BrowserWindowGtk::Show() { gtk_window_maximize(window_); maximize_after_show_ = false; } + + // If we have sized the window by setting a size request for the render + // area, then undo it so that the render view can later adjust its own + // size. + gtk_widget_set_size_request(contents_container_->widget(), -1, -1); } -void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds) { +void BrowserWindowGtk::SetBoundsImpl(const gfx::Rect& bounds, bool exterior) { gint x = static_cast<gint>(bounds.x()); gint y = static_cast<gint>(bounds.y()); gint width = static_cast<gint>(bounds.width()); gint height = static_cast<gint>(bounds.height()); gtk_window_move(window_, x, y); - SetWindowSize(window_, width, height); + + if (exterior) { + SetWindowSize(window_, width, height); + } else { + gtk_widget_set_size_request(contents_container_->widget(), + width, height); + } +} + +void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds) { + SetBoundsImpl(bounds, true); } void BrowserWindowGtk::Close() { @@ -1462,7 +1486,9 @@ void BrowserWindowGtk::SetGeometryHints() { // However, in cases like dropping a tab where the bounds are // specifically set, we do want to position explicitly. if (browser_->bounds_overridden()) { - SetBounds(bounds); + // For popups, bounds are set in terms of the client area rather than the + // entire window. + SetBoundsImpl(bounds, !(browser_->type() & Browser::TYPE_POPUP)); } else { // Ignore the position but obey the size. SetWindowSize(window_, bounds.width(), bounds.height()); @@ -1495,6 +1521,8 @@ void BrowserWindowGtk::ConnectHandlersToSignals() { } void BrowserWindowGtk::InitWidgets() { + bounds_ = GetInitialWindowBounds(window_); + // This vbox encompasses all of the widgets within the browser, including the // tabstrip and the content vbox. The vbox is put in a floating container // (see gtk_floating_container.h) so we can position the @@ -1637,9 +1665,9 @@ void BrowserWindowGtk::InitWidgets() { gtk_widget_hide(devtools_container_->widget()); #if defined(OS_CHROMEOS) - if (browser_->type() == Browser::TYPE_POPUP) { + if (browser_->type() & Browser::TYPE_POPUP) { toolbar_->Hide(); - // The window manager needs the min size for popups + // The window manager needs the min size for popups. gtk_widget_set_size_request( GTK_WIDGET(window_), bounds_.width(), bounds_.height()); } diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index d83b46b..4fb84e1 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -247,6 +247,11 @@ class BrowserWindowGtk : public BrowserWindow, // Save the window position in the prefs. void SaveWindowPosition(); + // Set the bounds of the current window. If |exterior| is true, set the size + // of the window itself, otherwise set the bounds of the web contents. In + // either case, set the position of the window. + void SetBoundsImpl(const gfx::Rect& bounds, bool exterior); + // Callback for when the custom frame alignment needs to be redrawn. // The content area includes the toolbar and web page but not the tab strip. static gboolean OnCustomFrameExpose(GtkWidget* widget, GdkEventExpose* event, |