From 42a63522f3f83af5a2bfa126be5d02bfb27c617c Mon Sep 17 00:00:00 2001 From: Leonard Grey Date: Mon, 22 Oct 2018 20:26:50 +0000 Subject: [PATCH] Mac: dark backgrounds in dark mode for secondary UI/menus. Bug: 850098 Change-Id: If6de5922311ba501c5a746d9228993b42eff0b60 Reviewed-on: https://chromium-review.googlesource.com/c/1291569 Commit-Queue: Leonard Grey Reviewed-by: Peter Kasting Reviewed-by: Michael Wasserman Reviewed-by: Elly Fong-Jones Cr-Commit-Position: refs/heads/master@{#601709} --- ui/native_theme/native_theme_mac.mm | 10 ++++++++-- ui/views/bubble/footnote_container_view.cc | 7 ++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ui/native_theme/native_theme_mac.mm b/ui/native_theme/native_theme_mac.mm index 70c2aa2432da3d..4f48f0c417802e 100644 --- a/ui/native_theme/native_theme_mac.mm +++ b/ui/native_theme/native_theme_mac.mm @@ -25,6 +25,9 @@ @interface NSWorkspace (Redeclarations) namespace { const SkColor kMenuPopupBackgroundColor = SK_ColorWHITE; +// TODO(crbug.com/893598): Finalize dark mode color. +const SkColor kMenuPopupBackgroundColorDarkMode = + SkColorSetRGB(0x2B, 0x2B, 0x2B); // Helper to make indexing an array by an enum class easier. template @@ -123,7 +126,10 @@ SkColor ColorToGrayscale(SkColor color) { case kColorId_FocusedMenuItemBackgroundColor: return UsesHighContrastColors() ? SK_ColorDKGRAY : gfx::kGoogleGrey200; case kColorId_MenuBackgroundColor: - return kMenuPopupBackgroundColor; + case kColorId_BubbleBackground: + case kColorId_DialogBackground: + return SystemDarkModeEnabled() ? kMenuPopupBackgroundColorDarkMode + : kMenuPopupBackgroundColor; case kColorId_MenuSeparatorColor: return UsesHighContrastColors() ? SK_ColorBLACK : SkColorSetA(SK_ColorBLACK, 0x26); @@ -160,7 +166,7 @@ SkColor ColorToGrayscale(SkColor color) { const MenuBackgroundExtraParams& menu_background) const { cc::PaintFlags flags; flags.setAntiAlias(true); - flags.setColor(kMenuPopupBackgroundColor); + flags.setColor(GetSystemColor(kColorId_MenuBackgroundColor)); const SkScalar radius = SkIntToScalar(menu_background.corner_radius); SkRect rect = gfx::RectToSkRect(gfx::Rect(size)); canvas->drawRoundRect(rect, radius, radius, flags); diff --git a/ui/views/bubble/footnote_container_view.cc b/ui/views/bubble/footnote_container_view.cc index 4e0d62ec9a71c2..e8a28b3b0354c0 100644 --- a/ui/views/bubble/footnote_container_view.cc +++ b/ui/views/bubble/footnote_container_view.cc @@ -8,6 +8,7 @@ #include "ui/gfx/canvas.h" #include "ui/gfx/color_palette.h" #include "ui/gfx/geometry/rect_f.h" +#include "ui/native_theme/native_theme.h" #include "ui/views/background.h" #include "ui/views/border.h" #include "ui/views/layout/box_layout.h" @@ -61,7 +62,11 @@ FootnoteContainerView::FootnoteContainerView(const gfx::Insets& margins, FootnoteContainerView::~FootnoteContainerView() = default; void FootnoteContainerView::SetCornerRadius(float corner_radius) { - SetBackground(std::make_unique(gfx::kGoogleGrey050, + // TODO(crbug.com/893598): Finalize dark mode color. + SkColor background_color = GetNativeTheme()->SystemDarkModeEnabled() + ? gfx::kGoogleGrey800 + : gfx::kGoogleGrey050; + SetBackground(std::make_unique(background_color, corner_radius)); }