From 46d614ab071ce85f57c8099cf8157d104e7fc2fc Mon Sep 17 00:00:00 2001 From: "simonrad@chromium.org" Date: Wed, 11 Nov 2009 19:21:19 +0000 Subject: Fix jumping/resize/relayout of NTP/webpages when switching between NTP and another tab. (This really fixes 3 issues) 1. When the bookmarks bar is not docked, it toggles on and off when switching between the NTP and another tab. Since it is part of the UI, this causes the TabContents to be resized. This causes ugly re-layout of some webpages and also causes the NTP to jump when you switch to it, if themed. The solution is to toggle the floating bookmarks bar at a time when no TabContents is attached - that is, after detaching the first one but before attaching the second one. 2. Changing the info-bar can also cause a resize, so we also want to do this when no TabContents is attached. 3. Finally, when the NTP is displayed and another, floating tab is dragged and inserted to the left of the NTP, the selected tab index will not be set correctly. As a result, the NTP will be resized incorrectly before the tabs are even switched. R=beng BUG=23925 TEST=1. Apply Ratchet and Clank theme. Open NTP and Google Calendar in tabs. Switch back and forth between them. The NTP background should not jump or flicker, and Calendar should not re-layout. 2. Try switching between the NTP (or Calendar) and a tab that has an info-bar. 3. Open NTP and another tab. Drag the other tab until it detaches from the windows and floats. Re-attach and detach the tab repeatedly, so that the window switches between displaying the two tabs, and make sure you insert the other tab to the *left* of the NTP. The NTP should never jump. Review URL: http://codereview.chromium.org/376018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31687 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/views/frame/browser_view.cc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'chrome/browser/views/frame') diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 23d7bd3..f50e6a1 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -1259,8 +1259,8 @@ void BrowserView::TabDetachedAt(TabContents* contents, int index) { // We need to reset the current tab contents to NULL before it gets // freed. This is because the focus manager performs some operations // on the selected TabContents when it is removed. - infobar_container_->ChangeTabContents(NULL); contents_container_->ChangeTabContents(NULL); + infobar_container_->ChangeTabContents(NULL); UpdateDevToolsForContents(NULL); } } @@ -1281,8 +1281,22 @@ void BrowserView::TabSelectedAt(TabContents* old_contents, // Update various elements that are interested in knowing the current // TabContents. + + // When we toggle the NTP floating bookmarks bar, + // we don't want any TabContents to be attached, so that we + // avoid an unnecessary resize and re-layout of a TabContents. + contents_container_->ChangeTabContents(NULL); + infobar_container_->ChangeTabContents(new_contents); + + // Update all the UI bits. + UpdateTitleBar(); + toolbar_->SetProfile(new_contents->profile()); + UpdateToolbar(new_contents, true); + UpdateUIForContents(new_contents); + contents_container_->ChangeTabContents(new_contents); + UpdateDevToolsForContents(new_contents); // TODO(beng): This should be called automatically by ChangeTabContents, but I // am striving for parity now rather than cleanliness. This is @@ -1295,12 +1309,6 @@ void BrowserView::TabSelectedAt(TabContents* old_contents, // handlers when we are eventually shown. new_contents->view()->RestoreFocus(); } - - // Update all the UI bits. - UpdateTitleBar(); - toolbar_->SetProfile(new_contents->profile()); - UpdateToolbar(new_contents, true); - UpdateUIForContents(new_contents); } void BrowserView::TabStripEmpty() { -- cgit v1.1