diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-13 23:32:13 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-13 23:32:13 +0000 |
commit | b4bdce24eea17d1ae5a262235122cbc2985ea011 (patch) | |
tree | 1e526a8cde10f35b8f87db4aade4f5c23261cb7c /chrome/browser/tabs/tab_strip_model.cc | |
parent | d347b1ef7c061dd2405144acc795474484d511be (diff) | |
download | chromium_src-b4bdce24eea17d1ae5a262235122cbc2985ea011.zip chromium_src-b4bdce24eea17d1ae5a262235122cbc2985ea011.tar.gz chromium_src-b4bdce24eea17d1ae5a262235122cbc2985ea011.tar.bz2 |
Reland r23358 with a fix for linux unit_tests:
Better location for setting the size of tab contents. This should
catch all code paths. I noticed that middle clicking a bookmark
wasn't working, so I found a single place to do this.
This code is always run when a tab is added and it sizes the
contents when it's loading in the background.
BUG=619
TBR=japhet
Review URL: http://codereview.chromium.org/164526
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23384 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tabs/tab_strip_model.cc')
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 6712ec1..2883cd0 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -16,6 +16,7 @@ #include "chrome/browser/tabs/tab_strip_model_order_controller.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" #include "chrome/common/url_constants.h" @@ -387,6 +388,19 @@ void TabStripModel::AddTabContents(TabContents* contents, InsertTabContentsAt(index, contents, foreground, inherit_group); if (inherit_group && transition == PageTransition::TYPED) contents_data_.at(index)->reset_group_on_select = true; + + // 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 = GetSelectedTabContents()) { + if (!foreground) + contents->view()->SizeContents(old_contents->view()->GetContainerSize()); + } } void TabStripModel::CloseSelectedTab() { |