From 01d7e75ba8fa1cd37abdef9b6f2467b275ba36b9 Mon Sep 17 00:00:00 2001 From: Pale Moon Date: Sat, 8 Jul 2017 22:37:54 +0200 Subject: [PATCH] Add a '-moz-windows-accent-color-applies' media query. The '-moz-windows-accent-color-applies' media query matches when the Windows 10 accent color should be used as the background of the title bar. --- dom/base/nsGkAtomList.h | 2 ++ layout/style/nsCSSRuleProcessor.cpp | 5 +++++ layout/style/nsMediaFeatures.cpp | 7 +++++++ widget/LookAndFeel.h | 9 +++++++++ widget/windows/nsLookAndFeel.cpp | 6 ++++++ 5 files changed, 29 insertions(+) diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index 78a005a0e0..903343d289 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -2139,6 +2139,7 @@ GK_ATOM(scrollbar_thumb_proportional, "scrollbar-thumb-proportional") GK_ATOM(images_in_menus, "images-in-menus") GK_ATOM(images_in_buttons, "images-in-buttons") GK_ATOM(overlay_scrollbars, "overlay-scrollbars") +GK_ATOM(windows_accent_color_applies, "windows-accent-color-applies") GK_ATOM(windows_default_theme, "windows-default-theme") GK_ATOM(mac_graphite_theme, "mac-graphite-theme") GK_ATOM(mac_lion_theme, "mac-lion-theme") @@ -2166,6 +2167,7 @@ GK_ATOM(_moz_scrollbar_thumb_proportional, "-moz-scrollbar-thumb-proportional") GK_ATOM(_moz_images_in_menus, "-moz-images-in-menus") GK_ATOM(_moz_images_in_buttons, "-moz-images-in-buttons") GK_ATOM(_moz_overlay_scrollbars, "-moz-overlay-scrollbars") +GK_ATOM(_moz_windows_accent_color_applies, "-moz-windows-accent-color-applies") GK_ATOM(_moz_windows_default_theme, "-moz-windows-default-theme") GK_ATOM(_moz_mac_graphite_theme, "-moz-mac-graphite-theme") GK_ATOM(_moz_mac_lion_theme, "-moz-mac-lion-theme") diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index a25d39d5e9..0429a9875f 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -1187,6 +1187,11 @@ InitSystemMetrics() sSystemMetrics->AppendElement(nsGkAtoms::mac_yosemite_theme); } + rv = LookAndFeel::GetInt(LookAndFeel::eIntID_WindowsAccentColorApplies, &metricResult); + if (NS_SUCCEEDED(rv) && metricResult) { + sSystemMetrics->AppendElement(nsGkAtoms::windows_accent_color_applies); + } + 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 1d1d9956b6..d9073e653c 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -582,6 +582,13 @@ nsMediaFeatures::features[] = { { &nsGkAtoms::mac_yosemite_theme }, GetSystemMetric }, + { + &nsGkAtoms::_moz_windows_accent_color_applies, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + { &nsGkAtoms::windows_accent_color_applies }, + GetSystemMetric + }, { &nsGkAtoms::_moz_windows_compositor, nsMediaFeature::eMinMaxNotAllowed, diff --git a/widget/LookAndFeel.h b/widget/LookAndFeel.h index 5ecb9aea8a..0ea405b6ae 100644 --- a/widget/LookAndFeel.h +++ b/widget/LookAndFeel.h @@ -232,6 +232,15 @@ public: // Should menu items blink when they're chosen? eIntID_ChosenMenuItemsShouldBlink, + /* + * A Boolean value to determine whether the Windows accent color + * should be applied to the title bar. + * + * 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_WindowsAccentColorApplies, + /* * A Boolean value to determine whether the Windows default theme is * being used. diff --git a/widget/windows/nsLookAndFeel.cpp b/widget/windows/nsLookAndFeel.cpp index 4534e53376..d2ab192827 100644 --- a/widget/windows/nsLookAndFeel.cpp +++ b/widget/windows/nsLookAndFeel.cpp @@ -438,6 +438,12 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult) case eIntID_DWMCompositor: aResult = nsUXThemeData::CheckForCompositor(); break; + case eIntID_WindowsAccentColorApplies: + { + nscolor unused; + aResult = NS_SUCCEEDED(GetAccentColor(unused)) ? 1 : 0; + } + break; case eIntID_WindowsGlass: // Aero Glass is only available prior to Windows 8 when DWM is used. aResult = (nsUXThemeData::CheckForCompositor() && !IsWin8OrLater());