diff options
-rw-r--r-- | chrome/browser/browser.cc | 11 | ||||
-rw-r--r-- | chrome/browser/views/tab_contents/tab_contents_view_win.cc | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 6c9c787..9b42d01 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1465,6 +1465,17 @@ TabContents* Browser::CreateTabContentsForURL( TabContents* contents = new TabContents(profile, instance, MSG_ROUTING_NONE, NULL); + // 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()) + contents->view()->SizeContents(old_contents->view()->GetContainerSize()); + if (!defer_load) { // Load the initial URL before adding the new tab contents to the tab strip // so that the tab contents has navigation state. diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc index 6febbdd..570df67 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc +++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc @@ -630,6 +630,8 @@ void TabContentsViewWin::WasShown() { } void TabContentsViewWin::WasSized(const gfx::Size& size) { + UINT swp_flags = SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE; + SetWindowPos(NULL, 0, 0, size.width(), size.height(), swp_flags); if (tab_contents()->interstitial_page()) tab_contents()->interstitial_page()->SetSize(size); if (tab_contents()->render_widget_host_view()) |