From 9af7038ba77d004b22397c43218fba458e504e1b Mon Sep 17 00:00:00 2001 From: "ben@chromium.org" Date: Thu, 15 Jan 2009 19:34:28 +0000 Subject: Fix for Issue 3258: Tabs created when tabstrip is compressed pending resize relayout should not force resize relayout. This is proposed solution one from the comment#5 which is to create new tabs without resizing existing tabs unless there is no room for the new tab. BUG=3258 Change from Itai Danan (idanan@google.com) Code review: http://codereview.chromium.org/14050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8109 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/tabs/tab_strip_model.cc | 2 +- chrome/browser/views/tabs/tab_strip.cc | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 2e42a64..3b0c4bb 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -533,7 +533,7 @@ bool TabStripModel::InternalCloseTabContentsAt(int index, // them. Once they have fired, we'll get a message back saying whether // to proceed closing the page or not, which sends us back to this method // with the HasUnloadListener bit cleared. - WebContents* web_contents = GetContentsAt(index)->AsWebContents(); + WebContents* web_contents = detached_contents->AsWebContents(); // If we hit this code path, the tab had better be a WebContents tab. DCHECK(web_contents); web_contents->render_view_host()->FirePageBeforeUnload(); diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index 3232ec4..7791289 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -1470,8 +1470,17 @@ void TabStrip::StartResizeLayoutAnimation() { } void TabStrip::StartInsertTabAnimation(int index) { - // The TabStrip can now use its entire width to lay out Tabs. - available_width_for_tabs_ = -1; + // Don't shock users by letting all tabs move when they are focused + // on the tab-strip. Wait for later, when they aren't looking. + int last_tab_index = GetTabCount() - 2; + if (last_tab_index > 0) { + Tab* last_tab = GetTabAt(last_tab_index); + available_width_for_tabs_ = std::min( + GetAvailableWidthForTabs(last_tab) + last_tab->width(), + width() - (kNewTabButtonHOffset + newtab_button_size_.width())); + } else { + available_width_for_tabs_ = -1; + } if (active_animation_.get()) active_animation_->Stop(); active_animation_.reset(new InsertTabAnimation(this, index)); -- cgit v1.1