summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-13 18:33:58 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-13 18:33:58 +0000
commit4904fecc1c97870df095714b3edd02b78b748f56 (patch)
tree21794843ae46651c617d78935065f0f61ee04b0f /chrome
parent038ca2215c278f9cc2642e71347229676c9367ae (diff)
downloadchromium_src-4904fecc1c97870df095714b3edd02b78b748f56.zip
chromium_src-4904fecc1c97870df095714b3edd02b78b748f56.tar.gz
chromium_src-4904fecc1c97870df095714b3edd02b78b748f56.tar.bz2
Take 2 at fixing anchor links opening in background tabs on linux.
Also fix a code path that seems to be missing on Windows (maybe this regressed?). This time make sure RWHV is not NULL. BUG=619 TEST=http://code.google.com/p/chromium/issues/detail?id=619#c6 Review URL: http://codereview.chromium.org/165468 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23332 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser.cc12
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.cc12
2 files changed, 22 insertions, 2 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 160be20..5fae3c8 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1831,6 +1831,18 @@ void Browser::AddNewContents(TabContents* source,
initial_pos, user_gesture);
browser->window()->Show();
} else if (disposition != SUPPRESS_OPEN) {
+ // Ensure that the new TabContentsView begins at the same size as the
+ // previous TabContentsView if it existed. Otherwise, the initial WebKit
+ // layout will be performed based on a width of 0 pixels, causing a
+ // very long, narrow, inaccurate layout. Because some scripts on pages (as
+ // well as WebKit's anchor link location calculation) are run on the
+ // initial layout and not recalculated later, we need to ensure the first
+ // layout is performed with sane view dimensions even when we're opening a
+ // new background tab.
+ if (TabContents* old_contents = tabstrip_model_.GetSelectedTabContents()) {
+ new_contents->view()->SizeContents(
+ old_contents->view()->GetContainerSize());
+ }
tabstrip_model_.AddTabContents(new_contents, -1, false,
PageTransition::LINK,
disposition == NEW_FOREGROUND_TAB);
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
index 9bb7036..00c546d 100644
--- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
@@ -575,8 +575,16 @@ void TabContentsViewGtk::OnTabCrashed() {
}
void TabContentsViewGtk::SizeContents(const gfx::Size& size) {
- // This function is a hack and should go away. In any case we don't manually
- // control the size of the contents on linux, so do nothing.
+ // 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();
+ widget->allocation.width = size.width();
+ widget->allocation.height = size.height();
+ }
}
void TabContentsViewGtk::Focus() {