Commit 4940aa0a authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Respect theme colors for new tab-loading animation

Uses 12% opacity of white / black for the placeholder depending on contrast
instead of hard-coding GoogleBlue100. For the bouncing pill, use theme colors
previously used for the spinner.

Bug: chromium:903457
Change-Id: I6dd46ac516a8fef874ecdf95bcaef3b57d7a5974
Reviewed-on: https://chromium-review.googlesource.com/c/1327422Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606620}
parent 002dfaef
...@@ -1006,7 +1006,7 @@ void Tab::UpdateForegroundColors() { ...@@ -1006,7 +1006,7 @@ void Tab::UpdateForegroundColors() {
} else if (mouse_hovered_) { } else if (mouse_hovered_) {
expected_opacity = GetHoverOpacity(); expected_opacity = GetHoverOpacity();
} }
SkColor tab_bg_color = color_utils::AlphaBlend( const SkColor tab_bg_color = color_utils::AlphaBlend(
controller_->GetTabBackgroundColor(TAB_ACTIVE), controller_->GetTabBackgroundColor(TAB_ACTIVE),
controller_->GetTabBackgroundColor(TAB_INACTIVE), controller_->GetTabBackgroundColor(TAB_INACTIVE),
gfx::ToRoundedInt(expected_opacity * SK_AlphaOPAQUE)); gfx::ToRoundedInt(expected_opacity * SK_AlphaOPAQUE));
...@@ -1015,6 +1015,8 @@ void Tab::UpdateForegroundColors() { ...@@ -1015,6 +1015,8 @@ void Tab::UpdateForegroundColors() {
tab_title_color = tab_title_color =
color_utils::GetColorWithMinimumContrast(tab_title_color, tab_bg_color); color_utils::GetColorWithMinimumContrast(tab_title_color, tab_bg_color);
icon_->SetBackgroundColor(tab_bg_color);
title_->SetEnabledColor(tab_title_color); title_->SetEnabledColor(tab_title_color);
const SkColor base_hovered_color = theme_provider->GetColor( const SkColor base_hovered_color = theme_provider->GetColor(
......
...@@ -161,6 +161,11 @@ void TabIcon::StepLoadingAnimation(const base::TimeDelta& elapsed_time) { ...@@ -161,6 +161,11 @@ void TabIcon::StepLoadingAnimation(const base::TimeDelta& elapsed_time) {
SchedulePaint(); SchedulePaint();
} }
void TabIcon::SetBackgroundColor(SkColor bg_color) {
bg_color_ = bg_color;
SchedulePaint();
}
void TabIcon::OnPaint(gfx::Canvas* canvas) { void TabIcon::OnPaint(gfx::Canvas* canvas) {
// Compute the bounds adjusted for the hiding fraction. // Compute the bounds adjusted for the hiding fraction.
gfx::Rect contents_bounds = GetContentsBounds(); gfx::Rect contents_bounds = GetContentsBounds();
...@@ -253,12 +258,15 @@ void TabIcon::PaintLoadingAnimation(gfx::Canvas* canvas, ...@@ -253,12 +258,15 @@ void TabIcon::PaintLoadingAnimation(gfx::Canvas* canvas,
const ui::ThemeProvider* tp = GetThemeProvider(); const ui::ThemeProvider* tp = GetThemeProvider();
if (UseNewLoadingAnimation()) { if (UseNewLoadingAnimation()) {
const gfx::RectF throbber_bounds = GetThrobberBounds(bounds); const gfx::RectF throbber_bounds = GetThrobberBounds(bounds);
constexpr SkColor kLoadingColor = gfx::kGoogleBlue500;
if (network_state_ == TabNetworkState::kWaiting) { if (network_state_ == TabNetworkState::kWaiting) {
gfx::PaintNewThrobberWaiting(canvas, throbber_bounds, kLoadingColor, gfx::PaintNewThrobberWaiting(
waiting_state_.elapsed_time); canvas, throbber_bounds,
tp->GetColor(ThemeProperties::COLOR_TAB_THROBBER_WAITING),
waiting_state_.elapsed_time);
} else { } else {
PaintLoadingProgressIndicator(canvas, throbber_bounds, kLoadingColor); PaintLoadingProgressIndicator(
canvas, throbber_bounds,
tp->GetColor(ThemeProperties::COLOR_TAB_THROBBER_SPINNING));
} }
} else { } else {
if (network_state_ == TabNetworkState::kWaiting) { if (network_state_ == TabNetworkState::kWaiting) {
...@@ -296,7 +304,8 @@ const gfx::ImageSkia& TabIcon::GetIconToPaint() { ...@@ -296,7 +304,8 @@ const gfx::ImageSkia& TabIcon::GetIconToPaint() {
void TabIcon::PaintFaviconPlaceholder(gfx::Canvas* canvas, void TabIcon::PaintFaviconPlaceholder(gfx::Canvas* canvas,
const gfx::Rect& bounds) { const gfx::Rect& bounds) {
cc::PaintFlags flags; cc::PaintFlags flags;
flags.setColor(gfx::kGoogleBlue100); flags.setColor(SkColorSetA(
color_utils::IsDark(bg_color_) ? SK_ColorWHITE : SK_ColorBLACK, 32));
flags.setStyle(cc::PaintFlags::kFill_Style); flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setAntiAlias(true); flags.setAntiAlias(true);
......
...@@ -60,6 +60,8 @@ class TabIcon : public views::View, public gfx::AnimationDelegate { ...@@ -60,6 +60,8 @@ class TabIcon : public views::View, public gfx::AnimationDelegate {
// strip in order to keep the throbbers in sync. // strip in order to keep the throbbers in sync.
void StepLoadingAnimation(const base::TimeDelta& elapsed_time); void StepLoadingAnimation(const base::TimeDelta& elapsed_time);
void SetBackgroundColor(SkColor color);
private: private:
class CrashAnimation; class CrashAnimation;
friend CrashAnimation; friend CrashAnimation;
...@@ -166,6 +168,8 @@ class TabIcon : public views::View, public gfx::AnimationDelegate { ...@@ -166,6 +168,8 @@ class TabIcon : public views::View, public gfx::AnimationDelegate {
bool can_paint_to_layer_ = false; bool can_paint_to_layer_ = false;
SkColor bg_color_ = SK_ColorBLACK;
DISALLOW_COPY_AND_ASSIGN(TabIcon); DISALLOW_COPY_AND_ASSIGN(TabIcon);
}; };
......
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