Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: chrome/browser/tabs/tab_strip_model.cc

Issue 165473: Better location for setting the size of tab contents. This should (Closed)
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« chrome/browser/browser.cc ('K') | « chrome/browser/browser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tabs/tab_strip_model.cc
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index 6712ec15ed3afa7ec03e594e8117dfe2e9c26050..2883cd00b595a9d14635342d05a8621bf481ac6e 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() {
« chrome/browser/browser.cc ('K') | « chrome/browser/browser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698