Commit d425b35d authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Simplified GetTabBackgroundColor()

Pushed color calculation logic in GetTabBackgroundColor() down into
ThemeHelper.

Bug: 1056916
Change-Id: I6c6b5a204554b825887b1c306b766e4403609279
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2092199
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748889}
parent c4fe601d
......@@ -244,7 +244,19 @@ SkColor ThemeHelper::GetDefaultColor(
const CustomThemeSupplier* theme_supplier) const {
// For backward compat with older themes, some newer colors are generated from
// older ones if they are missing.
const auto get_frame_color = [this, incognito, theme_supplier](bool active) {
return this->GetColor(active ? TP::COLOR_FRAME : TP::COLOR_FRAME_INACTIVE,
incognito, theme_supplier);
};
switch (id) {
case TP::COLOR_BACKGROUND_TAB:
return color_utils::HSLShift(get_frame_color(/*active=*/true),
GetTint(ThemeProperties::TINT_BACKGROUND_TAB,
incognito, theme_supplier));
case TP::COLOR_BACKGROUND_TAB_INACTIVE:
return color_utils::HSLShift(get_frame_color(/*active=*/false),
GetTint(ThemeProperties::TINT_BACKGROUND_TAB,
incognito, theme_supplier));
case TP::COLOR_TOOLBAR_BUTTON_ICON:
case TP::COLOR_TOOLBAR_BUTTON_ICON_HOVERED:
case TP::COLOR_TOOLBAR_BUTTON_ICON_PRESSED:
......@@ -262,10 +274,8 @@ SkColor ThemeHelper::GetDefaultColor(
case TP::COLOR_TOOLBAR_TOP_SEPARATOR_INACTIVE: {
const SkColor tab_color =
GetColor(TP::COLOR_TOOLBAR, incognito, theme_supplier);
const int frame_id = (id == TP::COLOR_TOOLBAR_TOP_SEPARATOR)
? TP::COLOR_FRAME
: TP::COLOR_FRAME_INACTIVE;
const SkColor frame_color = GetColor(frame_id, incognito, theme_supplier);
const SkColor frame_color =
get_frame_color(/*active=*/id == TP::COLOR_TOOLBAR_TOP_SEPARATOR);
const SeparatorColorKey key(tab_color, frame_color);
auto i = GetSeparatorColorCache().find(key);
if (i != GetSeparatorColorCache().end())
......
......@@ -1908,25 +1908,13 @@ SkColor TabStrip::GetTabBackgroundColor(
if (active == TabActive::kActive)
return tp->GetColor(ThemeProperties::COLOR_TOOLBAR);
bool is_active_frame;
if (active_state == BrowserFrameActiveState::kUseCurrent)
is_active_frame = ShouldPaintAsActiveFrame();
else
is_active_frame = active_state == BrowserFrameActiveState::kActive;
const int color_id = is_active_frame
? ThemeProperties::COLOR_BACKGROUND_TAB
: ThemeProperties::COLOR_BACKGROUND_TAB_INACTIVE;
// When the background tab color has not been customized, use the actual frame
// color instead of COLOR_BACKGROUND_TAB.
const SkColor frame = controller_->GetFrameColor(active_state);
const SkColor background =
tp->HasCustomColor(color_id)
? tp->GetColor(color_id)
: color_utils::HSLShift(
frame, tp->GetTint(ThemeProperties::TINT_BACKGROUND_TAB));
return background;
using State = BrowserFrameActiveState;
const bool is_active_frame =
(active_state == State::kActive) ||
((active_state == State::kUseCurrent) && ShouldPaintAsActiveFrame());
return tp->GetColor(is_active_frame
? ThemeProperties::COLOR_BACKGROUND_TAB
: ThemeProperties::COLOR_BACKGROUND_TAB_INACTIVE);
}
SkColor TabStrip::GetTabForegroundColor(TabActive active,
......
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