diff --git a/shell/browser/ui/views/win_caption_button.cc b/shell/browser/ui/views/win_caption_button.cc index 63b69f42e7..9db1e70b0c 100644 --- a/shell/browser/ui/views/win_caption_button.cc +++ b/shell/browser/ui/views/win_caption_button.cc @@ -11,6 +11,7 @@ #include "base/i18n/rtl.h" #include "base/numerics/safe_conversions.h" #include "base/win/windows_version.h" +#include "chrome/browser/ui/color/chrome_color_id.h" #include "chrome/grit/theme_resources.h" #include "shell/browser/native_window_views.h" #include "shell/browser/ui/views/win_frame_view.h" @@ -47,6 +48,13 @@ std::unique_ptr WinCaptionButton::CreateIconPainter() { return std::make_unique(); } +SkColor WinCaptionButton::GetBaseForegroundColor() const { + return GetColorProvider()->GetColor( + frame_view_->GetShouldPaintAsActive() + ? kColorCaptionButtonForegroundActive + : kColorCaptionButtonForegroundInactive); +} + gfx::Size WinCaptionButton::CalculatePreferredSize( const views::SizeBounds& available_size) const { // TODO(bsep): The sizes in this function are for 1x device scale and don't @@ -76,7 +84,7 @@ void WinCaptionButton::OnPaintBackground(gfx::Canvas* canvas) { pressed_alpha = 0x98; } else { // Match the native buttons. - base_color = frame_view_->GetReadableFeatureColor(bg_color); + base_color = GetBaseForegroundColor(); hovered_alpha = 0x1A; pressed_alpha = 0x33; diff --git a/shell/browser/ui/views/win_caption_button.h b/shell/browser/ui/views/win_caption_button.h index ff96851c84..4534f87107 100644 --- a/shell/browser/ui/views/win_caption_button.h +++ b/shell/browser/ui/views/win_caption_button.h @@ -49,6 +49,10 @@ class WinCaptionButton : public views::Button { private: std::unique_ptr CreateIconPainter(); + + // The base color to use for the button symbols and background blending. Uses + // the more readable of black and white. + SkColor GetBaseForegroundColor() const; // Returns the amount we should visually reserve on the left (right in RTL) // for spacing between buttons. We do this instead of repositioning the // buttons to avoid the sliver of deadspace that would result. @@ -59,10 +63,6 @@ class WinCaptionButton : public views::Button { // smaller indices). int GetButtonDisplayOrderIndex() const; - // The base color to use for the button symbols and background blending. Uses - // the more readable of black and white. - SkColor GetBaseColor() const; - // Paints the minimize/maximize/restore/close icon for the button. void PaintSymbol(gfx::Canvas* canvas); diff --git a/shell/browser/ui/views/win_frame_view.cc b/shell/browser/ui/views/win_frame_view.cc index 1c158529db..697243c4ad 100644 --- a/shell/browser/ui/views/win_frame_view.cc +++ b/shell/browser/ui/views/win_frame_view.cc @@ -39,18 +39,6 @@ void WinFrameView::Init(NativeWindowViews* window, views::Widget* frame) { } } -SkColor WinFrameView::GetReadableFeatureColor(SkColor background_color) { - // color_utils::GetColorWithMaxContrast()/IsDark() aren't used here because - // they switch based on the Chrome light/dark endpoints, while we want to use - // the system native behavior below. - const auto windows_luma = [](SkColor c) { - return 0.25f * SkColorGetR(c) + 0.625f * SkColorGetG(c) + - 0.125f * SkColorGetB(c); - }; - return windows_luma(background_color) <= 128.0f ? SK_ColorWHITE - : SK_ColorBLACK; -} - void WinFrameView::InvalidateCaptionButtons() { if (!caption_button_container_) return; @@ -282,6 +270,10 @@ void WinFrameView::LayoutWindowControlsOverlay() { window()->NotifyLayoutWindowControlsOverlay(); } +bool WinFrameView::GetShouldPaintAsActive() { + return ShouldPaintAsActive(); +} + BEGIN_METADATA(WinFrameView) END_METADATA diff --git a/shell/browser/ui/views/win_frame_view.h b/shell/browser/ui/views/win_frame_view.h index 679e24ba27..c47550aef0 100644 --- a/shell/browser/ui/views/win_frame_view.h +++ b/shell/browser/ui/views/win_frame_view.h @@ -46,6 +46,9 @@ class WinFrameView : public FramelessView { // the area above the top of the screen). int TitlebarMaximizedVisualHeight() const; + // Returns true if the frame should be painted as active. + bool GetShouldPaintAsActive(); + protected: // views::View: void Layout(PassKey) override;