summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 01:22:12 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-05 01:22:12 +0000
commit7cb25c28530dcd7739c1441588ad1deade53b5ee (patch)
tree12f44596c42049bbddd352108e5b46259fa45304 /webkit
parent4075c937997772e26dac372f6fbdec6100b95c99 (diff)
downloadchromium_src-7cb25c28530dcd7739c1441588ad1deade53b5ee.zip
chromium_src-7cb25c28530dcd7739c1441588ad1deade53b5ee.tar.gz
chromium_src-7cb25c28530dcd7739c1441588ad1deade53b5ee.tar.bz2
linux: SizeTo() must synchronously size webkit's content area.
The old code was wrong and racy and the new message loop really exposed the bug. It would be preferable to just wait until the content area was properly sized, but I kept running into corner cases trying to get that to work. BUG=13364 TEST=more layout tests should pass Review URL: http://codereview.chromium.org/119197 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/tools/test_shell/test_shell.h5
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc30
2 files changed, 23 insertions, 12 deletions
diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h
index d6ac049..1de2a9f 100644
--- a/webkit/tools/test_shell/test_shell.h
+++ b/webkit/tools/test_shell/test_shell.h
@@ -344,11 +344,6 @@ private:
// Dump the stats table counters on exit.
bool dump_stats_table_on_exit_;
-
-#if defined(OS_LINUX)
- // The height of the non-rendering area of the main window, in pixels.
- int top_chrome_height_;
-#endif
};
#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index 6971a57..efae470 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -314,7 +314,6 @@ GtkWidget* CreateMenuBar(TestShell* shell) {
bool TestShell::Initialize(const std::wstring& startingURL) {
m_mainWnd = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
gtk_window_set_title(m_mainWnd, "Test Shell");
- gtk_window_set_default_size(m_mainWnd, 640, 480);
g_signal_connect(G_OBJECT(m_mainWnd), "destroy",
G_CALLBACK(MainWindowDestroyed), this);
g_signal_connect(G_OBJECT(m_mainWnd), "focus-out-event",
@@ -370,11 +369,9 @@ bool TestShell::Initialize(const std::wstring& startingURL) {
gtk_container_add(GTK_CONTAINER(m_mainWnd), vbox);
gtk_widget_show_all(GTK_WIDGET(m_mainWnd));
- top_chrome_height_ = toolbar->allocation.height +
- menu_bar->allocation.height + 2 * gtk_box_get_spacing(GTK_BOX(vbox));
- // LoadURL will do a resize (which uses top_chrome_height_), so make
- // sure we don't call LoadURL until we've completed all of our GTK setup.
+ // LoadURL will do a resize, so make sure we don't call LoadURL
+ // until we've completed all of our GTK setup.
if (!startingURL.empty())
LoadURL(startingURL.c_str());
@@ -400,8 +397,27 @@ void TestShell::TestFinished() {
}
void TestShell::SizeTo(int width, int height) {
- gtk_window_resize(GTK_WINDOW(m_mainWnd), width,
- height + top_chrome_height_);
+ GtkWidget* widget = m_webViewHost->view_handle();
+ if (widget->allocation.width == width &&
+ widget->allocation.height == height) {
+ // Nothing to do.
+ return;
+ }
+
+ gtk_widget_set_size_request(widget, width, height);
+ if (widget->allocation.width > width ||
+ widget->allocation.height > height) {
+ // We've been sized smaller. Shrink the window so it snaps back to the
+ // appropriate size.
+ gtk_window_resize(GTK_WINDOW(m_mainWnd), 1, 1);
+ }
+
+ // We've been asked to size the content area to a particular size.
+ // GTK works asynchronously: you request a size and then it
+ // eventually becomes that size. But layout tests need to be sure
+ // the resize has gone into WebKit by the time SizeTo() returns.
+ // Force the webkit resize to happen now.
+ m_webViewHost->Resize(gfx::Size(width, height));
}
static void AlarmHandler(int signatl) {