diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 02:53:53 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 02:53:53 +0000 |
commit | b4cd02bb4488b1bc9dc7e0be22e136c9bb1c70c9 (patch) | |
tree | 9b820a0c9ff7c31e2491196606aa7be380ae9ad5 | |
parent | c858763b98fc6d59984a2c611a865355656826ca (diff) | |
download | chromium_src-b4cd02bb4488b1bc9dc7e0be22e136c9bb1c70c9.zip chromium_src-b4cd02bb4488b1bc9dc7e0be22e136c9bb1c70c9.tar.gz chromium_src-b4cd02bb4488b1bc9dc7e0be22e136c9bb1c70c9.tar.bz2 |
Revert "Removes TabStrip::CanUpdateDisplay as it ..."
This reverts commit r31736 due to valgrind errors.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31761 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.cc | 47 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.h | 6 |
2 files changed, 37 insertions, 16 deletions
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index 67f9020..7b85532 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -964,12 +964,14 @@ void TabStripGtk::TabInsertedAt(TabContents* contents, } void TabStripGtk::TabDetachedAt(TabContents* contents, int index) { - GenerateIdealBounds(); - StartRemoveTabAnimation(index, contents); - // Have to do this _after_ calling StartRemoveTabAnimation, so that any - // previous remove is completed fully and index is valid in sync with the - // model index. - GetTabAt(index)->set_closing(true); + if (CanUpdateDisplay()) { + GenerateIdealBounds(); + StartRemoveTabAnimation(index, contents); + // Have to do this _after_ calling StartRemoveTabAnimation, so that any + // previous remove is completed fully and index is valid in sync with the + // model index. + GetTabAt(index)->set_closing(true); + } } void TabStripGtk::TabSelectedAt(TabContents* old_contents, @@ -978,18 +980,20 @@ void TabStripGtk::TabSelectedAt(TabContents* old_contents, bool user_gesture) { DCHECK(index >= 0 && index < static_cast<int>(GetTabCount())); - // We have "tiny tabs" if the tabs are so tiny that the unselected ones are - // a different size to the selected ones. - bool tiny_tabs = current_unselected_width_ != current_selected_width_; - if (!IsAnimating() && (!resize_layout_scheduled_ || tiny_tabs)) - Layout(); + if (CanUpdateDisplay()) { + // We have "tiny tabs" if the tabs are so tiny that the unselected ones are + // a different size to the selected ones. + bool tiny_tabs = current_unselected_width_ != current_selected_width_; + if (!IsAnimating() && (!resize_layout_scheduled_ || tiny_tabs)) + Layout(); - GetTabAt(index)->SchedulePaint(); + GetTabAt(index)->SchedulePaint(); - int old_index = model_->GetIndexOfTabContents(old_contents); - if (old_index >= 0) { - GetTabAt(old_index)->SchedulePaint(); - GetTabAt(old_index)->StopPinnedTabTitleAnimation(); + int old_index = model_->GetIndexOfTabContents(old_contents); + if (old_index >= 0) { + GetTabAt(old_index)->SchedulePaint(); + GetTabAt(old_index)->StopPinnedTabTitleAnimation(); + } } } @@ -1774,6 +1778,17 @@ void TabStripGtk::StartPinAndMoveTabAnimation(int from_index, active_animation_->Start(); } +bool TabStripGtk::CanUpdateDisplay() { + // Don't bother laying out/painting when we're closing all tabs. + if (model_->closing_all()) { + // Make sure any active animation is ended, too. + if (active_animation_.get()) + active_animation_->Stop(); + return false; + } + return true; +} + void TabStripGtk::FinishAnimation(TabStripGtk::TabAnimation* animation, bool layout) { active_animation_.reset(NULL); diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.h b/chrome/browser/gtk/tabs/tab_strip_gtk.h index 3204433..c13ceca 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.h +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.h @@ -380,6 +380,12 @@ class TabStripGtk : public TabStripModelObserver, void StartPinAndMoveTabAnimation(int from_index, int to_index, const gfx::Rect& start_bounds); + // Returns true if detach or select changes in the model should be reflected + // in the TabStrip. This returns false if we're closing all tabs in the + // TabStrip and so we should prevent updating. This is not const because we + // use this as a signal to cancel any active animations. + bool CanUpdateDisplay(); + // Notifies the TabStrip that the specified TabAnimation has completed. // Optionally a full Layout will be performed, specified by |layout|. void FinishAnimation(TabAnimation* animation, bool layout); |