Commit 1fb00d5b authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Use tab foreground color blended with the background color for separator.

Bug: 866689
Change-Id: I33ba303ddad0bec0de0624f98444c252ff5251ba
Reviewed-on: https://chromium-review.googlesource.com/1173752Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582922}
parent 13cb35b1
...@@ -155,19 +155,6 @@ SkColor BrowserNonClientFrameView::GetToolbarTopSeparatorColor() const { ...@@ -155,19 +155,6 @@ SkColor BrowserNonClientFrameView::GetToolbarTopSeparatorColor() const {
: paint_color; : paint_color;
} }
SkColor BrowserNonClientFrameView::GetTabSeparatorColor() const {
DCHECK(MD::IsRefreshUi());
// TODO(pkasting): https://crbug.com/866689 Replace this with "blend
// background tab text color toward background tab background color at 46% or
// 1.84 contrast ratio, whichever is larger" (and make sure the blend is large
// enough in the default theme to not need adjusting).
constexpr SkAlpha kTabSeparatorAlpha = 0x4D; // 30%
const SkColor tab_color = GetTabBackgroundColor(TAB_INACTIVE, true);
const SkColor base_color =
color_utils::BlendTowardOppositeLuma(tab_color, SK_AlphaOPAQUE);
return color_utils::AlphaBlend(base_color, tab_color, kTabSeparatorAlpha);
}
SkColor BrowserNonClientFrameView::GetTabBackgroundColor(TabState state, SkColor BrowserNonClientFrameView::GetTabBackgroundColor(TabState state,
bool opaque) const { bool opaque) const {
if (state == TAB_ACTIVE) if (state == TAB_ACTIVE)
......
...@@ -93,9 +93,6 @@ class BrowserNonClientFrameView : public views::NonClientFrameView, ...@@ -93,9 +93,6 @@ class BrowserNonClientFrameView : public views::NonClientFrameView,
// state of the window. // state of the window.
SkColor GetToolbarTopSeparatorColor() const; SkColor GetToolbarTopSeparatorColor() const;
// Under Refresh, returns the color of the separator between the tabs.
SkColor GetTabSeparatorColor() const;
// Returns the tab background color based on both the |state| of the tab and // Returns the tab background color based on both the |state| of the tab and
// the activation state of the window. If |opaque| is true, the resulting // the activation state of the window. If |opaque| is true, the resulting
// color after drawing the tab background on the frame will be returned. // color after drawing the tab background on the frame will be returned.
......
...@@ -398,10 +398,6 @@ SkColor BrowserTabStripController::GetToolbarTopSeparatorColor() const { ...@@ -398,10 +398,6 @@ SkColor BrowserTabStripController::GetToolbarTopSeparatorColor() const {
return GetFrameView()->GetToolbarTopSeparatorColor(); return GetFrameView()->GetToolbarTopSeparatorColor();
} }
SkColor BrowserTabStripController::GetTabSeparatorColor() const {
return GetFrameView()->GetTabSeparatorColor();
}
SkColor BrowserTabStripController::GetTabBackgroundColor(TabState state, SkColor BrowserTabStripController::GetTabBackgroundColor(TabState state,
bool opaque) const { bool opaque) const {
return GetFrameView()->GetTabBackgroundColor(state, opaque); return GetFrameView()->GetTabBackgroundColor(state, opaque);
......
...@@ -79,7 +79,6 @@ class BrowserTabStripController : public TabStripController, ...@@ -79,7 +79,6 @@ class BrowserTabStripController : public TabStripController,
bool HasVisibleBackgroundTabShapes() const override; bool HasVisibleBackgroundTabShapes() const override;
SkColor GetFrameColor() const override; SkColor GetFrameColor() const override;
SkColor GetToolbarTopSeparatorColor() const override; SkColor GetToolbarTopSeparatorColor() const override;
SkColor GetTabSeparatorColor() const override;
SkColor GetTabBackgroundColor(TabState active, bool opaque) const override; SkColor GetTabBackgroundColor(TabState active, bool opaque) const override;
SkColor GetTabForegroundColor(TabState state) const override; SkColor GetTabForegroundColor(TabState state) const override;
int GetTabBackgroundResourceId(bool* has_custom_image) const override; int GetTabBackgroundResourceId(bool* has_custom_image) const override;
......
...@@ -162,10 +162,6 @@ SkColor FakeBaseTabStripController::GetToolbarTopSeparatorColor() const { ...@@ -162,10 +162,6 @@ SkColor FakeBaseTabStripController::GetToolbarTopSeparatorColor() const {
return gfx::kPlaceholderColor; return gfx::kPlaceholderColor;
} }
SkColor FakeBaseTabStripController::GetTabSeparatorColor() const {
return gfx::kPlaceholderColor;
}
SkColor FakeBaseTabStripController::GetTabBackgroundColor(TabState state, SkColor FakeBaseTabStripController::GetTabBackgroundColor(TabState state,
bool opaque) const { bool opaque) const {
return gfx::kPlaceholderColor; return gfx::kPlaceholderColor;
......
...@@ -55,7 +55,6 @@ class FakeBaseTabStripController : public TabStripController { ...@@ -55,7 +55,6 @@ class FakeBaseTabStripController : public TabStripController {
bool HasVisibleBackgroundTabShapes() const override; bool HasVisibleBackgroundTabShapes() const override;
SkColor GetFrameColor() const override; SkColor GetFrameColor() const override;
SkColor GetToolbarTopSeparatorColor() const override; SkColor GetToolbarTopSeparatorColor() const override;
SkColor GetTabSeparatorColor() const override;
SkColor GetTabBackgroundColor(TabState state, bool opaque) const override; SkColor GetTabBackgroundColor(TabState state, bool opaque) const override;
SkColor GetTabForegroundColor(TabState state) const override; SkColor GetTabForegroundColor(TabState state) const override;
int GetTabBackgroundResourceId(bool* has_custom_image) const override; int GetTabBackgroundResourceId(bool* has_custom_image) const override;
......
...@@ -319,7 +319,7 @@ void TabStrip::FrameColorsChanged() { ...@@ -319,7 +319,7 @@ void TabStrip::FrameColorsChanged() {
for (int i = 0; i < tab_count(); ++i) for (int i = 0; i < tab_count(); ++i)
tab_at(i)->FrameColorsChanged(); tab_at(i)->FrameColorsChanged();
new_tab_button_->FrameColorsChanged(); new_tab_button_->FrameColorsChanged();
UpdateOpacities(); UpdateContrastRatioValues();
SchedulePaint(); SchedulePaint();
} }
...@@ -1144,7 +1144,7 @@ SkColor TabStrip::GetToolbarTopSeparatorColor() const { ...@@ -1144,7 +1144,7 @@ SkColor TabStrip::GetToolbarTopSeparatorColor() const {
} }
SkColor TabStrip::GetTabSeparatorColor() const { SkColor TabStrip::GetTabSeparatorColor() const {
return controller_->GetTabSeparatorColor(); return separator_color_;
} }
SkColor TabStrip::GetTabBackgroundColor(TabState state, bool opaque) const { SkColor TabStrip::GetTabBackgroundColor(TabState state, bool opaque) const {
...@@ -1440,6 +1440,8 @@ void TabStrip::OnThemeChanged() { ...@@ -1440,6 +1440,8 @@ void TabStrip::OnThemeChanged() {
// available. // available.
if (MD::IsRefreshUi()) if (MD::IsRefreshUi())
SingleTabModeChanged(); SingleTabModeChanged();
else
FrameColorsChanged();
} }
BrowserRootView::DropIndex TabStrip::GetDropIndex( BrowserRootView::DropIndex TabStrip::GetDropIndex(
...@@ -1507,7 +1509,7 @@ void TabStrip::Init() { ...@@ -1507,7 +1509,7 @@ void TabStrip::Init() {
drop_indicator_height = drop_image->height(); drop_indicator_height = drop_image->height();
} }
UpdateOpacities(); UpdateContrastRatioValues();
} }
void TabStrip::StartInsertTabAnimation(int model_index) { void TabStrip::StartInsertTabAnimation(int model_index) {
...@@ -2060,47 +2062,56 @@ void TabStrip::UpdateStackedLayoutFromMouseEvent(views::View* source, ...@@ -2060,47 +2062,56 @@ void TabStrip::UpdateStackedLayoutFromMouseEvent(views::View* source,
} }
} }
void TabStrip::UpdateOpacities() { void TabStrip::UpdateContrastRatioValues() {
// There may be no controller in unit tests, and call to GetTabBackgroundColor // There may be no controller in unit tests, and the call to
// below requires one, so bail early if it is absent. // GetTabBackgroundColor() below requires one, so bail early if it is absent.
if (!controller_) if (!controller_)
return; return;
const SkColor active_tab_bg_color = GetTabBackgroundColor(TAB_ACTIVE, true);
const SkColor inactive_tab_bg_color =
GetTabBackgroundColor(TAB_INACTIVE, true);
// The contrast ratio for the hover effect on standard-width tabs. // The contrast ratio for the hover effect on standard-width tabs.
// In the default Refresh color scheme, this corresponds to a hover // In the default Refresh color scheme, this corresponds to a hover
// opacity of 0.4. // opacity of 0.4.
constexpr float kDesiredContrastHoveredStandardWidthTab = 1.11f; constexpr float kDesiredContrastHoveredStandardWidthTab = 1.11f;
const SkAlpha hover_base_alpha_wide =
color_utils::GetBlendValueWithMinimumContrast(
inactive_tab_bg_color, active_tab_bg_color, inactive_tab_bg_color,
kDesiredContrastHoveredStandardWidthTab);
hover_opacity_min_ = hover_base_alpha_wide / 255.0f;
// The contrast ratio for the hover effect on min-width tabs. // The contrast ratio for the hover effect on min-width tabs.
// In the default Refresh color scheme, this corresponds to a hover // In the default Refresh color scheme, this corresponds to a hover
// opacity of 0.65. // opacity of 0.65.
constexpr float kDesiredContrastHoveredMinWidthTab = 1.19f; constexpr float kDesiredContrastHoveredMinWidthTab = 1.19f;
const SkAlpha hover_base_alpha_narrow =
color_utils::GetBlendValueWithMinimumContrast(
inactive_tab_bg_color, active_tab_bg_color, inactive_tab_bg_color,
kDesiredContrastHoveredMinWidthTab);
hover_opacity_max_ = hover_base_alpha_narrow / 255.0f;
// The contrast ratio for the radial gradient effect on hovered tabs. // The contrast ratio for the radial gradient effect on hovered tabs.
// In the default Refresh color scheme, this corresponds to a hover // In the default Refresh color scheme, this corresponds to a hover
// opacity of 0.45. // opacity of 0.45.
constexpr float kDesiredContrastRadialGradient = 1.13728f; constexpr float kDesiredContrastRadialGradient = 1.13728f;
const SkColor active_tab_bg_color = GetTabBackgroundColor(TAB_ACTIVE, true);
const SkColor inactive_tab_bg_color =
GetTabBackgroundColor(TAB_INACTIVE, true);
const SkAlpha hover_base_alpha_wide =
color_utils::GetBlendValueWithMinimumContrast(
inactive_tab_bg_color, active_tab_bg_color, inactive_tab_bg_color,
kDesiredContrastHoveredStandardWidthTab);
const SkAlpha hover_base_alpha_narrow =
color_utils::GetBlendValueWithMinimumContrast(
inactive_tab_bg_color, active_tab_bg_color, inactive_tab_bg_color,
kDesiredContrastHoveredMinWidthTab);
const SkAlpha radial_highlight_alpha = const SkAlpha radial_highlight_alpha =
color_utils::GetBlendValueWithMinimumContrast( color_utils::GetBlendValueWithMinimumContrast(
inactive_tab_bg_color, active_tab_bg_color, inactive_tab_bg_color, inactive_tab_bg_color, active_tab_bg_color, inactive_tab_bg_color,
kDesiredContrastRadialGradient); kDesiredContrastRadialGradient);
hover_opacity_min_ = hover_base_alpha_wide / 255.0f;
hover_opacity_max_ = hover_base_alpha_narrow / 255.0f;
radial_highlight_opacity_ = radial_highlight_alpha / 255.0f; radial_highlight_opacity_ = radial_highlight_alpha / 255.0f;
// The contrast ratio for the separator between inactive tabs.
// In the default Refresh color scheme, this corresponds to a tab text opacity
// of 0.46.
const SkColor text_color = GetTabForegroundColor(TAB_INACTIVE);
constexpr float kTabSeparatorRatio = 1.84f;
const SkAlpha separator_alpha = color_utils::GetBlendValueWithMinimumContrast(
inactive_tab_bg_color, text_color, inactive_tab_bg_color,
kTabSeparatorRatio);
separator_color_ = color_utils::AlphaBlend(text_color, inactive_tab_bg_color,
separator_alpha);
} }
void TabStrip::ResizeLayoutTabs() { void TabStrip::ResizeLayoutTabs() {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "chrome/browser/ui/views/tabs/tab_controller.h" #include "chrome/browser/ui/views/tabs/tab_controller.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h" #include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "ui/gfx/animation/animation_container.h" #include "ui/gfx/animation/animation_container.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/views/animation/bounds_animator.h" #include "ui/views/animation/bounds_animator.h"
...@@ -456,8 +457,8 @@ class TabStrip : public views::View, ...@@ -456,8 +457,8 @@ class TabStrip : public views::View,
void UpdateStackedLayoutFromMouseEvent(views::View* source, void UpdateStackedLayoutFromMouseEvent(views::View* source,
const ui::MouseEvent& event); const ui::MouseEvent& event);
// Computes and stores tab hover opacities derived from contrast ratios. // Computes and stores values derived from contrast ratios.
void UpdateOpacities(); void UpdateContrastRatioValues();
// -- Tab Resize Layout ----------------------------------------------------- // -- Tab Resize Layout -----------------------------------------------------
...@@ -690,6 +691,8 @@ class TabStrip : public views::View, ...@@ -690,6 +691,8 @@ class TabStrip : public views::View,
float hover_opacity_max_ = 1.0f; float hover_opacity_max_ = 1.0f;
float radial_highlight_opacity_ = 1.0f; float radial_highlight_opacity_ = 1.0f;
SkColor separator_color_ = gfx::kPlaceholderColor;
DISALLOW_COPY_AND_ASSIGN(TabStrip); DISALLOW_COPY_AND_ASSIGN(TabStrip);
}; };
......
...@@ -131,9 +131,6 @@ class TabStripController { ...@@ -131,9 +131,6 @@ class TabStripController {
// state of the window. // state of the window.
virtual SkColor GetToolbarTopSeparatorColor() const = 0; virtual SkColor GetToolbarTopSeparatorColor() const = 0;
// Under Refresh, returns the color of the separator between the tabs.
virtual SkColor GetTabSeparatorColor() const = 0;
// Returns the tab background color based on both the |state| of the tab and // Returns the tab background color based on both the |state| of the tab and
// the activation state of the window. If |opaque| is true, the resulting // the activation state of the window. If |opaque| is true, the resulting
// color after drawing the tab background on the frame will be returned. // color after drawing the tab background on the frame will be returned.
......
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