diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 21:41:43 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 21:41:43 +0000 |
commit | 9cea0d120a21c80f812be19cc7eb6e3fffdd6913 (patch) | |
tree | f68ea8358ccfc1b52cbb9a4edd84139e34a70b8d | |
parent | 6e4f53e62df44c9a91a0d7d127771c4bbabf850d (diff) | |
download | chromium_src-9cea0d120a21c80f812be19cc7eb6e3fffdd6913.zip chromium_src-9cea0d120a21c80f812be19cc7eb6e3fffdd6913.tar.gz chromium_src-9cea0d120a21c80f812be19cc7eb6e3fffdd6913.tar.bz2 |
Move RemoveTabAt to the TabStrip interface from RemoveTabAnimation.
* This change is needed to allow a clean refactoring of TabStrip. The animation classes should be as cross-platform as possible.
* RemoveTabStrip animation now requests the TabStrip to remove a tab for it.
Review URL: http://codereview.chromium.org/27366
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10830 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.cc | 40 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.h | 4 |
2 files changed, 21 insertions, 23 deletions
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index e3ec025..c256a82 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -316,34 +316,12 @@ class RemoveTabAnimation : public TabStrip::TabAnimation { } virtual void AnimationEnded(const Animation* animation) { - RemoveTabAt(index_); + tabstrip_->RemoveTabAt(index_); HighlightCloseButton(); TabStrip::TabAnimation::AnimationEnded(animation); } private: - // Cleans up the Tab from the TabStrip at the specified |index| once its - // animated removal is complete. - void RemoveTabAt(int index) const { - // Save a pointer to the Tab before we remove the TabData, we'll need this - // later. - Tab* removed = tabstrip_->tab_data_.at(index).tab; - - // Remove the Tab from the TabStrip's list... - tabstrip_->tab_data_.erase(tabstrip_->tab_data_.begin() + index); - - // If the TabContents being detached was removed as a result of a drag - // gesture from its corresponding Tab, we don't want to remove the Tab from - // the child list, because if we do so it'll stop receiving events and the - // drag will stall. So we only remove if a drag isn't active, or the Tab - // was for some other TabContents. - if (!tabstrip_->IsDragSessionActive() || - !tabstrip_->drag_controller_->IsDragSourceTab(removed)) { - tabstrip_->RemoveChildView(removed); - delete removed; - } - } - // When the animation completes, we send the Container a message to simulate // a mouse moved event at the current mouse position. This tickles the Tab // the mouse is currently over to show the "hot" state of the close button. @@ -1535,3 +1513,19 @@ bool TabStrip::IsPointInTab(Tab* tab, return tab->HitTest(point_in_tab_coords); } +void TabStrip::RemoveTabAt(int index) { + Tab* removed = tab_data_.at(index).tab; + + // Remove the Tab from the TabStrip's list... + tab_data_.erase(tab_data_.begin() + index); + + // If the TabContents being detached was removed as a result of a drag + // gesture from its corresponding Tab, we don't want to remove the Tab from + // the child list, because if we do so it'll stop receiving events and the + // drag will stall. So we only remove if a drag isn't active, or the Tab + // was for some other TabContents. + if (!IsDragSessionActive() || !drag_controller_->IsDragSourceTab(removed)) { + removed->GetParent()->RemoveChildView(removed); + delete removed; + } +} diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index e2e322fc..1cffb945 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -267,6 +267,10 @@ class TabStrip : public views::View, // hit-test region of the specified Tab. bool IsPointInTab(Tab* tab, const gfx::Point& point_in_tabstrip_coords); + // Cleans up the Tab from the TabStrip at the specified |index|. This is + // called from the tab animation code and is not a general-purpose method. + void RemoveTabAt(int index); + // -- Member Variables ------------------------------------------------------ // Our model. |