diff options
-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. |