From 0f285318cdf3336aabda0cfa6bc306b2274f14e8 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 19 Jul 2017 16:34:50 +0200 Subject: Add -moz-windows-accent-color-is-dark #31 point 4 --- dom/base/nsGkAtomList.h | 2 ++ layout/style/nsCSSRuleProcessor.cpp | 5 +++++ layout/style/nsMediaFeatures.cpp | 8 ++++++++ widget/LookAndFeel.h | 9 +++++++++ widget/windows/nsLookAndFeel.cpp | 8 ++++++++ widget/windows/nsWindow.cpp | 5 +++++ 6 files changed, 37 insertions(+) diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index f6b097a73..0b76b2bea 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -2231,6 +2231,7 @@ GK_ATOM(scrollbar_end_forward, "scrollbar-end-forward") GK_ATOM(scrollbar_thumb_proportional, "scrollbar-thumb-proportional") GK_ATOM(overlay_scrollbars, "overlay-scrollbars") GK_ATOM(windows_accent_color_applies, "windows-accent-color-applies") +GK_ATOM(windows_accent_color_is_dark, "windows-accent-color-is-dark") GK_ATOM(windows_default_theme, "windows-default-theme") GK_ATOM(mac_graphite_theme, "mac-graphite-theme") GK_ATOM(mac_yosemite_theme, "mac-yosemite-theme") @@ -2261,6 +2262,7 @@ GK_ATOM(_moz_scrollbar_end_forward, "-moz-scrollbar-end-forward") GK_ATOM(_moz_scrollbar_thumb_proportional, "-moz-scrollbar-thumb-proportional") GK_ATOM(_moz_overlay_scrollbars, "-moz-overlay-scrollbars") GK_ATOM(_moz_windows_accent_color_applies, "-moz-windows-accent-color-applies") +GK_ATOM(_moz_windows_accent_color_is_dark, "-moz-windows-accent-color-is-dark") GK_ATOM(_moz_windows_default_theme, "-moz-windows-default-theme") GK_ATOM(_moz_mac_graphite_theme, "-moz-mac-graphite-theme") GK_ATOM(_moz_mac_yosemite_theme, "-moz-mac-yosemite-theme") diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 4dc7ea1c8..8760a330e 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -1132,6 +1132,11 @@ InitSystemMetrics() sSystemMetrics->AppendElement(nsGkAtoms::windows_accent_color_applies); } + rv = LookAndFeel::GetInt(LookAndFeel::eIntID_WindowsAccentColorIsDark, &metricResult); + if (NS_SUCCEEDED(rv) && metricResult) { + sSystemMetrics->AppendElement(nsGkAtoms::windows_accent_color_is_dark); + } + rv = LookAndFeel::GetInt(LookAndFeel::eIntID_DWMCompositor, &metricResult); if (NS_SUCCEEDED(rv) && metricResult) { sSystemMetrics->AppendElement(nsGkAtoms::windows_compositor); diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp index f314835a4..052ce58e8 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -723,6 +723,14 @@ nsMediaFeatures::features[] = { { &nsGkAtoms::windows_accent_color_applies }, GetSystemMetric }, + { + &nsGkAtoms::_moz_windows_accent_color_is_dark, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::windows_accent_color_is_dark }, + GetSystemMetric + }, { &nsGkAtoms::_moz_windows_compositor, nsMediaFeature::eMinMaxNotAllowed, diff --git a/widget/LookAndFeel.h b/widget/LookAndFeel.h index 8d510f69f..e2502c559 100644 --- a/widget/LookAndFeel.h +++ b/widget/LookAndFeel.h @@ -250,6 +250,15 @@ public: * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric. */ eIntID_WindowsAccentColorApplies, + + /* + * A Boolean value to determine whether the Windows accent color + * is considered dark and should get bright text/controls. + * + * The value of this metric is not used on other platforms. These platforms + * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric. + */ + eIntID_WindowsAccentColorIsDark, /* * A Boolean value to determine whether the Windows default theme is diff --git a/widget/windows/nsLookAndFeel.cpp b/widget/windows/nsLookAndFeel.cpp index 5c0358bd9..e649802b1 100644 --- a/widget/windows/nsLookAndFeel.cpp +++ b/widget/windows/nsLookAndFeel.cpp @@ -442,6 +442,14 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult) aResult = NS_SUCCEEDED(GetAccentColor(unused)) ? 1 : 0; } break; + case eIntID_WindowsAccentColorIsDark: + { + nscolor accentColor; + if (NS_SUCCEEDED(GetAccentColor(accentColor))) { + aResult = AccentColorIsDark(accentColor) ? 1 : 0; + } + } + break; case eIntID_WindowsGlass: // Aero Glass is only available prior to Windows 8 when DWM is used. aResult = (nsUXThemeData::CheckForCompositor() && !IsWin8OrLater()); diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index dd4f359f7..85321a189 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -7138,6 +7138,11 @@ nsWindow::OnSysColorChanged() // so all presentations get notified properly. // See nsWindow::GlobalMsgWindowProc. NotifySysColorChanged(); + // On Windows 10 only, we trigger a theme change to pick up changed media + // queries that are needed for accent color changes. + if (IsWin10OrLater()) { + NotifyThemeChanged(); + } } } -- cgit v1.2.3