From ac663083950b2e00573395d68348302df94e3ac1 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 19 Jul 2017 13:11:28 +0200 Subject: Add `@media(-moz-windows-accent-color-applies)` #31 point 3 --- dom/base/nsGkAtomList.h | 2 ++ layout/style/nsCSSRuleProcessor.cpp | 5 +++++ layout/style/nsMediaFeatures.cpp | 8 ++++++++ layout/style/test/test_media_queries.html | 5 +++++ widget/LookAndFeel.h | 9 +++++++++ widget/windows/nsLookAndFeel.cpp | 6 ++++++ 6 files changed, 35 insertions(+) diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index 7827ad66b6..f6b097a73e 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -2230,6 +2230,7 @@ GK_ATOM(scrollbar_end_backward, "scrollbar-end-backward") 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_default_theme, "windows-default-theme") GK_ATOM(mac_graphite_theme, "mac-graphite-theme") GK_ATOM(mac_yosemite_theme, "mac-yosemite-theme") @@ -2259,6 +2260,7 @@ GK_ATOM(_moz_scrollbar_end_backward, "-moz-scrollbar-end-backward") 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_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 07a4ef57b3..4dc7ea1c88 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -1127,6 +1127,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 c07a4123ef..f314835a40 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -715,6 +715,14 @@ nsMediaFeatures::features[] = { { &nsGkAtoms::mac_yosemite_theme }, GetSystemMetric }, + { + &nsGkAtoms::_moz_windows_accent_color_applies, + nsMediaFeature::eMinMaxNotAllowed, + nsMediaFeature::eBoolInteger, + nsMediaFeature::eNoRequirements, + { &nsGkAtoms::windows_accent_color_applies }, + GetSystemMetric + }, { &nsGkAtoms::_moz_windows_compositor, nsMediaFeature::eMinMaxNotAllowed, diff --git a/layout/style/test/test_media_queries.html b/layout/style/test/test_media_queries.html index 1edac15ae2..479306a55a 100644 --- a/layout/style/test/test_media_queries.html +++ b/layout/style/test/test_media_queries.html @@ -628,6 +628,7 @@ function run() { expression_should_be_parseable("-moz-windows-default-theme"); expression_should_be_parseable("-moz-mac-graphite-theme"); expression_should_be_parseable("-moz-mac-yosemite-theme"); + expression_should_be_parseable("-moz-windows-accent-color-applies"); expression_should_be_parseable("-moz-windows-compositor"); expression_should_be_parseable("-moz-windows-classic"); expression_should_be_parseable("-moz-windows-glass"); @@ -643,6 +644,7 @@ function run() { expression_should_be_parseable("-moz-windows-default-theme: 0"); expression_should_be_parseable("-moz-mac-graphite-theme: 0"); expression_should_be_parseable("-moz-mac-yosemite-theme: 0"); + expression_should_be_parseable("-moz-windows-accent-color-applies: 0"); expression_should_be_parseable("-moz-windows-compositor: 0"); expression_should_be_parseable("-moz-windows-classic: 0"); expression_should_be_parseable("-moz-windows-glass: 0"); @@ -658,6 +660,7 @@ function run() { expression_should_be_parseable("-moz-windows-default-theme: 1"); expression_should_be_parseable("-moz-mac-graphite-theme: 1"); expression_should_be_parseable("-moz-mac-yosemite-theme: 1"); + expression_should_be_parseable("-moz-windows-accent-color-applies: 1"); expression_should_be_parseable("-moz-windows-compositor: 1"); expression_should_be_parseable("-moz-windows-classic: 1"); expression_should_be_parseable("-moz-windows-glass: 1"); @@ -673,6 +676,7 @@ function run() { expression_should_not_be_parseable("-moz-windows-default-theme: -1"); expression_should_not_be_parseable("-moz-mac-graphite-theme: -1"); expression_should_not_be_parseable("-moz-mac-yosemite-theme: -1"); + expression_should_not_be_parseable("-moz-windows-accent-color-applies: -1"); expression_should_not_be_parseable("-moz-windows-compositor: -1"); expression_should_not_be_parseable("-moz-windows-classic: -1"); expression_should_not_be_parseable("-moz-windows-glass: -1"); @@ -688,6 +692,7 @@ function run() { expression_should_not_be_parseable("-moz-windows-default-theme: true"); expression_should_not_be_parseable("-moz-mac-graphite-theme: true"); expression_should_not_be_parseable("-moz-mac-yosemite-theme: true"); + expression_should_not_be_parseable("-moz-windows-accent-color-applies: true"); expression_should_not_be_parseable("-moz-windows-compositor: true"); expression_should_not_be_parseable("-moz-windows-classic: true"); expression_should_not_be_parseable("-moz-windows-glass: true"); diff --git a/widget/LookAndFeel.h b/widget/LookAndFeel.h index 3a4929c9f3..b7a05748ed 100644 --- a/widget/LookAndFeel.h +++ b/widget/LookAndFeel.h @@ -238,6 +238,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 7c427ac9fe..60e351323d 100644 --- a/widget/windows/nsLookAndFeel.cpp +++ b/widget/windows/nsLookAndFeel.cpp @@ -419,6 +419,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()); -- cgit v1.2.3