diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-18 17:40:10 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-18 17:40:10 +0000 |
commit | 95c9bbd7141891389a00c3334df22be97ff37598 (patch) | |
tree | 32676d6677482a254be0c60b7588099aeaf7c3db /chrome/browser/renderer_host | |
parent | 6f1ebb153210c5f77133b2a97596d07aabd9d675 (diff) | |
download | chromium_src-95c9bbd7141891389a00c3334df22be97ff37598.zip chromium_src-95c9bbd7141891389a00c3334df22be97ff37598.tar.gz chromium_src-95c9bbd7141891389a00c3334df22be97ff37598.tar.bz2 |
Size the render widget host view when the browser tries to set it to a particular size.
BUG=21942
TEST=On Linux chrome, load a #anchor page in the background. After
the page loads, view the tab. It should be scrolled to the right
place.
Review URL: http://codereview.chromium.org/214002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_gtk.cc | 32 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_gtk.h | 4 |
2 files changed, 21 insertions, 15 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index e4c460c..56b64ad 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -94,6 +94,8 @@ class RenderWidgetHostViewGtkWidget { private: static gboolean SizeAllocate(GtkWidget* widget, GtkAllocation* allocation, RenderWidgetHostViewGtk* host_view) { + host_view->requested_size_ = gfx::Size(allocation->width, + allocation->height); host_view->GetRenderWidgetHost()->WasResized(); return FALSE; } @@ -386,23 +388,21 @@ void RenderWidgetHostViewGtk::WasHidden() { void RenderWidgetHostViewGtk::SetSize(const gfx::Size& size) { // This is called when webkit has sent us a Move message. - // If we are a popup, we want to handle this. - // TODO(estade): are there other situations where we want to respect the - // request? -#if !defined(TOOLKIT_VIEWS) + int width = std::min(size.width(), kMaxWindowWidth); + int height = std::min(size.height(), kMaxWindowHeight); if (parent_) { -#else - // TOOLKIT_VIEWS' resize logic flow matches windows. When the container widget - // is resized, it calls RWH::WasSized, which sizes this widget using SetSize. - // TODO(estade): figure out if the logic flow here can be normalized across - // platforms + // We're a popup, honor the size request. + gtk_widget_set_size_request(view_.get(), width, height); + } else { +#if defined(TOOLKIT_VIEWS) + // TOOLKIT_VIEWS' resize logic flow matches windows. so we go ahead and + // size the widget. In GTK+, the size of the widget is determined by it's + // children. + gtk_widget_set_size_request(view_.get(), width, height); #endif - gtk_widget_set_size_request(view_.get(), - std::min(size.width(), kMaxWindowWidth), - std::min(size.height(), kMaxWindowHeight)); -#if !defined(TOOLKIT_VIEWS) + requested_size_ = gfx::Size(width, height); + host_->WasResized(); } -#endif } gfx::NativeView RenderWidgetHostViewGtk::GetNativeView() { @@ -444,7 +444,9 @@ void RenderWidgetHostViewGtk::Hide() { gfx::Rect RenderWidgetHostViewGtk::GetViewBounds() const { GtkAllocation* alloc = &view_.get()->allocation; - return gfx::Rect(alloc->x, alloc->y, alloc->width, alloc->height); + return gfx::Rect(alloc->x, alloc->y, + requested_size_.width(), + requested_size_.height()); } void RenderWidgetHostViewGtk::UpdateCursor(const WebCursor& cursor) { diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h index e0b3d64..102eb09 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h @@ -136,6 +136,10 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView { // Helper class that lets us allocate plugin containers and move them. GtkPluginContainerManager plugin_container_manager_; + + // The size that we want the renderer to be. We keep this in a separate + // variable because resizing in GTK+ is async. + gfx::Size requested_size_; }; #endif // CHROME_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_VIEW_GTK_H_ |