diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 19:54:32 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-14 19:54:32 +0000 |
commit | 26783d056f3639d6310c41d1f499d5a9b13bbf90 (patch) | |
tree | 35c754f8a0c06923695ecc73d27f775d375416d4 | |
parent | 9486c1fe61ac28f5a4cb0a371ee4409a1208a965 (diff) | |
download | chromium_src-26783d056f3639d6310c41d1f499d5a9b13bbf90.zip chromium_src-26783d056f3639d6310c41d1f499d5a9b13bbf90.tar.gz chromium_src-26783d056f3639d6310c41d1f499d5a9b13bbf90.tar.bz2 |
Changes tab strip to only cancel animations if layout is invoked and
the size actually changes. Layout was the wrong place for the check
before as Layout may be invoked even if the size hasn't changed.
BUG=59164
TEST=make sure tabstrip on windows still has animations.
Review URL: http://codereview.chromium.org/3782006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62625 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/views/tabs/base_tab_strip.cc | 29 | ||||
-rw-r--r-- | chrome/browser/views/tabs/base_tab_strip.h | 6 | ||||
-rw-r--r-- | chrome/browser/views/tabs/side_tab_strip.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/tabs/side_tab_strip.h | 2 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.cc | 18 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.h | 2 |
6 files changed, 38 insertions, 25 deletions
diff --git a/chrome/browser/views/tabs/base_tab_strip.cc b/chrome/browser/views/tabs/base_tab_strip.cc index c39f779..4f844ed 100644 --- a/chrome/browser/views/tabs/base_tab_strip.cc +++ b/chrome/browser/views/tabs/base_tab_strip.cc @@ -154,7 +154,7 @@ void BaseTabStrip::AddTabAt(int model_index, if (tab_count() > 1 && GetWindow() && GetWindow()->IsVisible()) StartInsertTabAnimation(model_index, foreground); else - Layout(); + DoLayout(); } void BaseTabStrip::MoveTab(int from_model_index, int to_model_index) { @@ -182,7 +182,7 @@ void BaseTabStrip::SetTabData(int model_index, const TabRendererData& data) { if (GetWindow() && GetWindow()->IsVisible()) StartMiniTabAnimation(); else - Layout(); + DoLayout(); } } @@ -332,14 +332,10 @@ BaseTab* BaseTabStrip::GetTabAt(BaseTab* tab, } void BaseTabStrip::Layout() { - StopAnimating(false); - - GenerateIdealBounds(); - - for (int i = 0; i < tab_count(); ++i) - tab_data_[i].tab->SetBounds(tab_data_[i].ideal_bounds); - - SchedulePaint(); + // Only do a layout if our size changed. + if (last_layout_size_ == size()) + return; + DoLayout(); } bool BaseTabStrip::OnMouseDragged(const views::MouseEvent& event) { @@ -462,3 +458,16 @@ void BaseTabStrip::PrepareForAnimation() { AnimationDelegate* BaseTabStrip::CreateRemoveTabDelegate(BaseTab* tab) { return new RemoveTabDelegate(this, tab); } + +void BaseTabStrip::DoLayout() { + last_layout_size_ = size(); + + StopAnimating(false); + + GenerateIdealBounds(); + + for (int i = 0; i < tab_count(); ++i) + tab_data_[i].tab->SetBounds(tab_data_[i].ideal_bounds); + + SchedulePaint(); +} diff --git a/chrome/browser/views/tabs/base_tab_strip.h b/chrome/browser/views/tabs/base_tab_strip.h index 91f5e6c..e3f5231 100644 --- a/chrome/browser/views/tabs/base_tab_strip.h +++ b/chrome/browser/views/tabs/base_tab_strip.h @@ -232,6 +232,9 @@ class BaseTabStrip : public views::View, // completes. The caller owns the returned object. AnimationDelegate* CreateRemoveTabDelegate(BaseTab* tab); + // Invoked from Layout if the size changes or layout is really needed. + virtual void DoLayout(); + private: class RemoveTabDelegate; @@ -255,6 +258,9 @@ class BaseTabStrip : public views::View, bool attaching_dragged_tab_; views::BoundsAnimator bounds_animator_; + + // Size we last layed out at. + gfx::Size last_layout_size_; }; #endif // CHROME_BROWSER_VIEWS_TABS_BASE_TAB_STRIP_H_ diff --git a/chrome/browser/views/tabs/side_tab_strip.cc b/chrome/browser/views/tabs/side_tab_strip.cc index 4b97b08..84e8082 100644 --- a/chrome/browser/views/tabs/side_tab_strip.cc +++ b/chrome/browser/views/tabs/side_tab_strip.cc @@ -236,7 +236,7 @@ void SideTabStrip::StopAnimating(bool layout) { bounds_animator().Cancel(); if (layout) - Layout(); + DoLayout(); } void SideTabStrip::AnimateToIdealBounds() { @@ -251,8 +251,8 @@ void SideTabStrip::AnimateToIdealBounds() { bounds_animator().AnimateViewTo(separator_, separator_bounds_); } -void SideTabStrip::Layout() { - BaseTabStrip::Layout(); +void SideTabStrip::DoLayout() { + BaseTabStrip::DoLayout(); newtab_button_->SetBounds(newtab_button_bounds_); diff --git a/chrome/browser/views/tabs/side_tab_strip.h b/chrome/browser/views/tabs/side_tab_strip.h index d5f0ffa..c847077 100644 --- a/chrome/browser/views/tabs/side_tab_strip.h +++ b/chrome/browser/views/tabs/side_tab_strip.h @@ -45,7 +45,7 @@ class SideTabStrip : public BaseTabStrip { virtual void StartMoveTabAnimation(); virtual void StopAnimating(bool layout); virtual void AnimateToIdealBounds(); - virtual void Layout(); + virtual void DoLayout(); private: // The "New Tab" button. diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index 1a1a99e..9b25dfa 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -235,7 +235,7 @@ void TabStrip::SelectTabAt(int old_model_index, int new_model_index) { // a different size to the selected ones. bool tiny_tabs = current_unselected_width_ != current_selected_width_; if (!IsAnimating() && (!in_tab_close_ || tiny_tabs)) { - Layout(); + DoLayout(); } else { SchedulePaint(); } @@ -332,14 +332,6 @@ views::View* TabStrip::GetViewByID(int view_id) const { return View::GetViewByID(view_id); } -void TabStrip::Layout() { - BaseTabStrip::Layout(); - - newtab_button_->SetBounds(newtab_button_bounds_); - - SchedulePaint(); -} - gfx::Size TabStrip::GetPreferredSize() { return gfx::Size(0, Tab::GetMinimumUnselectedSize().height()); } @@ -463,6 +455,12 @@ bool TabStrip::ShouldHighlightCloseButtonAfterRemove() { return in_tab_close_; } +void TabStrip::DoLayout() { + BaseTabStrip::DoLayout(); + + newtab_button_->SetBounds(newtab_button_bounds_); +} + void TabStrip::ViewHierarchyChanged(bool is_add, views::View* parent, views::View* child) { @@ -958,7 +956,7 @@ void TabStrip::StopAnimating(bool layout) { DCHECK(!IsAnimating()); if (layout) - Layout(); + DoLayout(); } int TabStrip::GetMiniTabCount() const { diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index 188868d..f7ec80fd 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -73,7 +73,6 @@ class TabStrip : public BaseTabStrip, // views::View overrides: virtual void PaintChildren(gfx::Canvas* canvas); virtual views::View* GetViewByID(int id) const; - virtual void Layout(); virtual gfx::Size GetPreferredSize(); // NOTE: the drag and drop methods are invoked from FrameView. This is done to // allow for a drop region that extends outside the bounds of the TabStrip. @@ -92,6 +91,7 @@ class TabStrip : public BaseTabStrip, virtual void StartMoveTabAnimation(); virtual void AnimateToIdealBounds(); virtual bool ShouldHighlightCloseButtonAfterRemove(); + virtual void DoLayout(); // views::View implementation: virtual void ViewHierarchyChanged(bool is_add, |