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) {
// "correct" state as an override.
set_active_state_override(&active);
UpdateProfileIcons();
set_active_state_override(nullptr);
// Changing the activation state may change the toolbar top separator color
// that's used as the stroke around tabs/the new tab button.
browser_view_->tabstrip()->SchedulePaint();
// that's used as the stroke around tabs/the new tab button. Under Refresh,
// 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.
SchedulePaint();
......
......@@ -159,6 +159,13 @@ void NewTabButton::CloseBubble() {
new_tab_promo_->CloseBubble();
}
void NewTabButton::FrameColorsChanged() {
if (MD::IsRefreshUi()) {
InitButtonIcons();
UpdateInkDropBaseColor();
}
}
void NewTabButton::AnimateInkDropToStateForTesting(views::InkDropState state) {
GetInkDrop()->AnimateToState(state);
}
......@@ -499,20 +506,12 @@ SkColor NewTabButton::GetButtonFillColor() const {
ui::NativeTheme::kColorId_ProminentButtonColor);
}
const ui::ThemeProvider* theme_provider = GetThemeProvider();
DCHECK(theme_provider);
return theme_provider->GetColor(MD::GetMode() == MD::MATERIAL_TOUCH_OPTIMIZED
? ThemeProperties::COLOR_TOOLBAR
: ThemeProperties::COLOR_BACKGROUND_TAB);
return tab_strip_->GetTabBackgroundColor(TAB_INACTIVE);
}
void NewTabButton::InitButtonIcons() {
DCHECK(MD::IsNewerMaterialUi());
const ui::ThemeProvider* theme_provider = GetThemeProvider();
DCHECK(theme_provider);
const SkColor icon_color =
theme_provider->GetColor(ThemeProperties::COLOR_TAB_TEXT);
const SkColor icon_color = tab_strip_->GetTabForegroundColor(TAB_INACTIVE);
plus_icon_ = gfx::CreateVectorIcon(kNewTabButtonPlusIcon, icon_color);
if (ShouldDrawIncognitoIcon()) {
incognito_icon_ =
......
......@@ -53,6 +53,11 @@ class NewTabButton : public views::ImageButton,
// when it exists.
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);
NewTabPromoBubbleView* new_tab_promo() { return new_tab_promo_; }
......
......@@ -1061,6 +1061,11 @@ int Tab::GetWidthOfLargestSelectableRegion() const {
return std::min(indicator_left, close_button_left);
}
void Tab::FrameColorsChanged() {
OnButtonColorMaybeChanged();
SchedulePaint();
}
// static
gfx::Size Tab::GetMinimumInactiveSize() {
return gfx::Size(GetLayoutInsets(TAB).width(), GetLayoutConstant(TAB_HEIGHT));
......
......@@ -168,6 +168,9 @@ class Tab : public gfx::AnimationDelegate,
// user to click to select/activate the tab.
int GetWidthOfLargestSelectableRegion() const;
// Called when the frame state color changes.
void FrameColorsChanged();
// Returns the minimum possible size of a single unselected Tab.
static gfx::Size GetMinimumInactiveSize();
......
......@@ -313,6 +313,13 @@ void TabStrip::RemoveObserver(TabStripObserver* 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 {
// There might be no tabs yet during startup.
return tab_count() ? ideal_bounds(tab_count() - 1).right() : 0;
......@@ -2365,6 +2372,7 @@ void TabStrip::SingleTabModeChanged() {
const int active_tab_index = controller_->GetActiveIndex();
if (IsValidModelIndex(active_tab_index))
tab_at(active_tab_index)->Layout();
new_tab_button_->FrameColorsChanged();
}
void TabStrip::ButtonPressed(views::Button* sender, const ui::Event& event) {
......
......@@ -77,6 +77,9 @@ class TabStrip : public views::View,
void AddObserver(TabStripObserver* observer);
void RemoveObserver(TabStripObserver* observer);
// Called when the colors of the frame change.
void FrameColorsChanged();
// Returns the trailing edge of the last tab.
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