Skip to content

Commit

Permalink
[QT] Ensure background tab text color has sufficient contrast
Browse files Browse the repository at this point in the history
Since the frame color depends on `use_custom_frame`, the background tab
text color needs to be computed based on the frame color.  For this,
BlendForMinContrast with default settings (formerly GetReadableColor)
is used.

R=thestig

Change-Id: I5178ffb44f4c3de9015b7cb973fddfb9a430411e
Bug: 1317782
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4113991
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1084746}
  • Loading branch information
tanderson-google authored and Chromium LUCI CQ committed Dec 18, 2022
1 parent 53a9f7f commit d5c3355
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ui/qt/qt_ui.cc
Expand Up @@ -24,6 +24,7 @@
#include "ui/color/color_mixer.h"
#include "ui/color/color_provider.h"
#include "ui/color/color_recipe.h"
#include "ui/color/color_transform.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/font.h"
Expand Down Expand Up @@ -438,9 +439,6 @@ void QtUi::AddNativeColorMixer(ui::ColorProvider* provider,
{ui::kColorNativeHeaderSeparatorBorderInactive, ColorType::kMidground,
ColorState::kInactive},
{ui::kColorNativeLabelForeground, ColorType::kWindowFg},
{ui::kColorNativeTabForegroundInactiveFrameActive, ColorType::kButtonFg},
{ui::kColorNativeTabForegroundInactiveFrameInactive, ColorType::kButtonFg,
ColorState::kInactive},
{ui::kColorNativeTextfieldBorderUnfocused, ColorType::kMidground,
ColorState::kInactive},
{ui::kColorNativeToolbarBackground, ColorType::kButtonBg},
Expand All @@ -454,6 +452,13 @@ void QtUi::AddNativeColorMixer(ui::ColorProvider* provider,
shim_->GetFrameColor(ColorState::kNormal, use_custom_frame)};
mixer[ui::kColorFrameInactive] = {
shim_->GetFrameColor(ColorState::kInactive, use_custom_frame)};

const SkColor button_fg =
shim_->GetColor(ColorType::kButtonFg, ColorState::kNormal);
mixer[ui::kColorNativeTabForegroundInactiveFrameActive] =
ui::BlendForMinContrast({button_fg}, {ui::kColorFrameActive});
mixer[ui::kColorNativeTabForegroundInactiveFrameInactive] =
ui::BlendForMinContrast({button_fg}, {ui::kColorFrameInactive});
}

DISABLE_CFI_VCALL
Expand Down

0 comments on commit d5c3355

Please sign in to comment.