Commit c04d6f47 authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Update tab strip foreground colors on activation and color changes.

The previous CL (https://crrev.com/c/1089723) only focused on getting the tab
colors from the browser frame. This CL focuses on ensuring the tab strip is
notified of activation and color changes so those colors can be recalculated.

Bug: 852388
Change-Id: Ib66c43038e1e8ea823fe991e55239754e5fce097
Reviewed-on: https://chromium-review.googlesource.com/1099048Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567617}
parent b7532ee3
...@@ -355,11 +355,14 @@ void BrowserNonClientFrameView::ActivationChanged(bool active) { ...@@ -355,11 +355,14 @@ void BrowserNonClientFrameView::ActivationChanged(bool active) {
// "correct" state as an override. // "correct" state as an override.
set_active_state_override(&active); set_active_state_override(&active);
UpdateProfileIcons(); UpdateProfileIcons();
set_active_state_override(nullptr);
// Changing the activation state may change the toolbar top separator color // Changing the activation state may change the toolbar top separator color
// that's used as the stroke around tabs/the new tab button. // that's used as the stroke around tabs/the new tab button. Under Refresh,
browser_view_->tabstrip()->SchedulePaint(); // the inactive tabs' backgrounds may match the frame accent color so the text
// color needs to be recalculated.
browser_view_->tabstrip()->FrameColorsChanged();
set_active_state_override(nullptr);
// Changing the activation state may change the visible frame color. // Changing the activation state may change the visible frame color.
SchedulePaint(); SchedulePaint();
......
...@@ -159,6 +159,13 @@ void NewTabButton::CloseBubble() { ...@@ -159,6 +159,13 @@ void NewTabButton::CloseBubble() {
new_tab_promo_->CloseBubble(); new_tab_promo_->CloseBubble();
} }
void NewTabButton::FrameColorsChanged() {
if (MD::IsRefreshUi()) {
InitButtonIcons();
UpdateInkDropBaseColor();
}
}
void NewTabButton::AnimateInkDropToStateForTesting(views::InkDropState state) { void NewTabButton::AnimateInkDropToStateForTesting(views::InkDropState state) {
GetInkDrop()->AnimateToState(state); GetInkDrop()->AnimateToState(state);
} }
...@@ -499,20 +506,12 @@ SkColor NewTabButton::GetButtonFillColor() const { ...@@ -499,20 +506,12 @@ SkColor NewTabButton::GetButtonFillColor() const {
ui::NativeTheme::kColorId_ProminentButtonColor); ui::NativeTheme::kColorId_ProminentButtonColor);
} }
const ui::ThemeProvider* theme_provider = GetThemeProvider(); return tab_strip_->GetTabBackgroundColor(TAB_INACTIVE);
DCHECK(theme_provider);
return theme_provider->GetColor(MD::GetMode() == MD::MATERIAL_TOUCH_OPTIMIZED
? ThemeProperties::COLOR_TOOLBAR
: ThemeProperties::COLOR_BACKGROUND_TAB);
} }
void NewTabButton::InitButtonIcons() { void NewTabButton::InitButtonIcons() {
DCHECK(MD::IsNewerMaterialUi()); DCHECK(MD::IsNewerMaterialUi());
const SkColor icon_color = tab_strip_->GetTabForegroundColor(TAB_INACTIVE);
const ui::ThemeProvider* theme_provider = GetThemeProvider();
DCHECK(theme_provider);
const SkColor icon_color =
theme_provider->GetColor(ThemeProperties::COLOR_TAB_TEXT);
plus_icon_ = gfx::CreateVectorIcon(kNewTabButtonPlusIcon, icon_color); plus_icon_ = gfx::CreateVectorIcon(kNewTabButtonPlusIcon, icon_color);
if (ShouldDrawIncognitoIcon()) { if (ShouldDrawIncognitoIcon()) {
incognito_icon_ = incognito_icon_ =
......
...@@ -53,6 +53,11 @@ class NewTabButton : public views::ImageButton, ...@@ -53,6 +53,11 @@ class NewTabButton : public views::ImageButton,
// when it exists. // when it exists.
void CloseBubble(); void CloseBubble();
// Called when the tab strip transitions to/from single tab mode, the frame
// state changes or the accent color changes. Under Refresh this function will
// update the glyph colors for the best contrast on the background.
void FrameColorsChanged();
void AnimateInkDropToStateForTesting(views::InkDropState state); void AnimateInkDropToStateForTesting(views::InkDropState state);
NewTabPromoBubbleView* new_tab_promo() { return new_tab_promo_; } NewTabPromoBubbleView* new_tab_promo() { return new_tab_promo_; }
......
...@@ -1061,6 +1061,11 @@ int Tab::GetWidthOfLargestSelectableRegion() const { ...@@ -1061,6 +1061,11 @@ int Tab::GetWidthOfLargestSelectableRegion() const {
return std::min(indicator_left, close_button_left); return std::min(indicator_left, close_button_left);
} }
void Tab::FrameColorsChanged() {
OnButtonColorMaybeChanged();
SchedulePaint();
}
// static // static
gfx::Size Tab::GetMinimumInactiveSize() { gfx::Size Tab::GetMinimumInactiveSize() {
return gfx::Size(GetLayoutInsets(TAB).width(), GetLayoutConstant(TAB_HEIGHT)); return gfx::Size(GetLayoutInsets(TAB).width(), GetLayoutConstant(TAB_HEIGHT));
......
...@@ -168,6 +168,9 @@ class Tab : public gfx::AnimationDelegate, ...@@ -168,6 +168,9 @@ class Tab : public gfx::AnimationDelegate,
// user to click to select/activate the tab. // user to click to select/activate the tab.
int GetWidthOfLargestSelectableRegion() const; int GetWidthOfLargestSelectableRegion() const;
// Called when the frame state color changes.
void FrameColorsChanged();
// Returns the minimum possible size of a single unselected Tab. // Returns the minimum possible size of a single unselected Tab.
static gfx::Size GetMinimumInactiveSize(); static gfx::Size GetMinimumInactiveSize();
......
...@@ -313,6 +313,13 @@ void TabStrip::RemoveObserver(TabStripObserver* observer) { ...@@ -313,6 +313,13 @@ void TabStrip::RemoveObserver(TabStripObserver* observer) {
observers_.RemoveObserver(observer); observers_.RemoveObserver(observer);
} }
void TabStrip::FrameColorsChanged() {
for (int i = 0; i < tab_count(); ++i)
tab_at(i)->FrameColorsChanged();
new_tab_button_->FrameColorsChanged();
SchedulePaint();
}
int TabStrip::GetTabsMaxX() const { int TabStrip::GetTabsMaxX() const {
// There might be no tabs yet during startup. // There might be no tabs yet during startup.
return tab_count() ? ideal_bounds(tab_count() - 1).right() : 0; return tab_count() ? ideal_bounds(tab_count() - 1).right() : 0;
...@@ -2365,6 +2372,7 @@ void TabStrip::SingleTabModeChanged() { ...@@ -2365,6 +2372,7 @@ void TabStrip::SingleTabModeChanged() {
const int active_tab_index = controller_->GetActiveIndex(); const int active_tab_index = controller_->GetActiveIndex();
if (IsValidModelIndex(active_tab_index)) if (IsValidModelIndex(active_tab_index))
tab_at(active_tab_index)->Layout(); tab_at(active_tab_index)->Layout();
new_tab_button_->FrameColorsChanged();
} }
void TabStrip::ButtonPressed(views::Button* sender, const ui::Event& event) { void TabStrip::ButtonPressed(views::Button* sender, const ui::Event& event) {
......
...@@ -77,6 +77,9 @@ class TabStrip : public views::View, ...@@ -77,6 +77,9 @@ class TabStrip : public views::View,
void AddObserver(TabStripObserver* observer); void AddObserver(TabStripObserver* observer);
void RemoveObserver(TabStripObserver* observer); void RemoveObserver(TabStripObserver* observer);
// Called when the colors of the frame change.
void FrameColorsChanged();
// Returns the trailing edge of the last tab. // Returns the trailing edge of the last tab.
int GetTabsMaxX() const; int GetTabsMaxX() const;
......
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