summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
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 /chrome/browser/tab_contents
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
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.cc23
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.h4
2 files changed, 13 insertions, 14 deletions
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);
};