summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-18 17:40:10 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-18 17:40:10 +0000
commit95c9bbd7141891389a00c3334df22be97ff37598 (patch)
tree32676d6677482a254be0c60b7588099aeaf7c3db
parent6f1ebb153210c5f77133b2a97596d07aabd9d675 (diff)
downloadchromium_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
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_gtk.cc32
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_gtk.h4
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.cc23
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.h4
4 files changed, 34 insertions, 29 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_
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
index 1eaaf4e..6326ae1 100644
--- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
@@ -476,7 +476,7 @@ void TabContentsViewGtk::GetContainerBounds(gfx::Rect* out) const {
if (fixed_->window)
gdk_window_get_origin(fixed_->window, &x, &y);
out->SetRect(x + fixed_->allocation.x, y + fixed_->allocation.y,
- fixed_->allocation.width, fixed_->allocation.height);
+ requested_size_.width(), requested_size_.height());
}
void TabContentsViewGtk::OnContentsDestroy() {
@@ -501,19 +501,12 @@ void TabContentsViewGtk::OnTabCrashed() {
}
void TabContentsViewGtk::SizeContents(const gfx::Size& size) {
- // We don't normally need to manually set the size of of widgets in GTK+,
- // but this is used when creating background tabs. When a tab is created in
- // the background, we need to set the size so WebKit can properly compute
- // the scrolling offset if a #ref is provided.
- if (tab_contents()->render_widget_host_view()) {
- GtkWidget* widget =
- tab_contents()->render_widget_host_view()->GetNativeView();
- // During unit tests, |widget| can be NULL.
- if (widget) {
- widget->allocation.width = size.width();
- widget->allocation.height = size.height();
- }
- }
+ // We don't need to manually set the size of of widgets in GTK+, but we do
+ // need to pass the sizing information on to the RWHV which will pass the
+ // sizing information on to the renderer.
+ requested_size_ = size;
+ if (tab_contents()->render_widget_host_view())
+ tab_contents()->render_widget_host_view()->SetSize(size);
}
void TabContentsViewGtk::Focus() {
@@ -635,6 +628,8 @@ gboolean TabContentsViewGtk::OnSizeAllocate(GtkWidget* widget,
TabContentsViewGtk* view) {
int width = allocation->width;
int height = allocation->height;
+ view->requested_size_.set_width(width);
+ view->requested_size_.set_height(height);
// |delegate()| can be NULL here during browser teardown.
if (view->tab_contents()->delegate())
height += view->tab_contents()->delegate()->GetExtraRenderViewHeight();
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.h b/chrome/browser/tab_contents/tab_contents_view_gtk.h
index 8e3fcf6..12bc936 100644
--- a/chrome/browser/tab_contents/tab_contents_view_gtk.h
+++ b/chrome/browser/tab_contents/tab_contents_view_gtk.h
@@ -139,6 +139,10 @@ class TabContentsViewGtk : public TabContentsView,
// Object responsible for handling drags from the page for us.
scoped_ptr<TabContentsDragSource> drag_source_;
+ // The size we want the tab contents view to be. We keep this in a separate
+ // variable because resizing in GTK+ is async.
+ gfx::Size requested_size_;
+
DISALLOW_COPY_AND_ASSIGN(TabContentsViewGtk);
};