Commit c799f6a7 authored by Ryan Meier's avatar Ryan Meier Committed by Commit Bot

Update tab's active state when removed from view model

TabStrip now calls ActiveStateChanged() on tabs when they are removed
from the view model, giving them a chance to update any relevant state
(such as background/text color, etc).

Bug: 859321
Change-Id: Iaad9d3dfa2d378c708a648315e5bdef9e2f2ff5f
Reviewed-on: https://chromium-review.googlesource.com/1162429
Commit-Queue: Ryan Meier <rameier@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581272}
parent ba33dbe6
......@@ -982,6 +982,11 @@ void Tab::OnThemeChanged() {
OnButtonColorMaybeChanged();
}
void Tab::SetClosing(bool closing) {
closing_ = closing;
ActiveStateChanged();
}
SkColor Tab::GetAlertIndicatorColor(TabAlertState state) const {
const bool is_touch_optimized = MD::IsTouchOptimizedUiEnabled();
// If theme provider is not yet available, return the default button
......
......@@ -108,7 +108,7 @@ class Tab : public gfx::AnimationDelegate,
TabController* controller() const { return controller_; }
// Used to set/check whether this Tab is being animated closed.
void set_closing(bool closing) { closing_ = closing; }
void SetClosing(bool closing);
bool closing() const { return closing_; }
// See description above field.
......
......@@ -572,7 +572,7 @@ void TabStrip::RemoveTabAt(content::WebContents* contents,
PrepareForAnimation();
Tab* tab = tab_at(model_index);
tab->set_closing(true);
tab->SetClosing(true);
int old_x = tabs_.ideal_bounds(model_index).x();
RemoveTabFromViewModel(model_index);
......@@ -1823,12 +1823,18 @@ const Tab* TabStrip::GetLastVisibleTab() const {
}
void TabStrip::RemoveTabFromViewModel(int index) {
Tab* closing_tab = tab_at(index);
bool closing_tab_was_active = closing_tab->IsActive();
// We still need to paint the tab until we actually remove it. Put it
// in tabs_closing_map_ so we can find it.
tabs_closing_map_[index].push_back(tab_at(index));
tabs_closing_map_[index].push_back(closing_tab);
UpdateTabsClosingMap(index + 1, -1);
tabs_.Remove(index);
selected_tabs_.DecrementFrom(index);
if (closing_tab_was_active)
closing_tab->ActiveStateChanged();
}
void TabStrip::RemoveAndDeleteTab(Tab* tab) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment