Bug 1344917, part 1 - Add a '-moz-windows-accent-color-applies' media query. r=heycam draft
authorJonathan Watt <jwatt@jwatt.org>
Thu, 08 Jun 2017 14:49:21 +0100
changeset 601084 ee8089ef876d0887e2c0d063015145d17eefa612
parent 601080 2a6d9c432453fc2854c85c45b2e357bb023abc4d
child 601085 ab2d2197ddf3528b6af212c00c8d3edb6ed1fc06
push id65952
push userjwatt@jwatt.org
push dateWed, 28 Jun 2017 00:28:40 +0000
reviewersheycam
bugs1344917
milestone56.0a1
Bug 1344917, part 1 - Add a '-moz-windows-accent-color-applies' media query. r=heycam 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. MozReview-Commit-ID: GM7nZij6MhQ
dom/base/nsGkAtomList.h
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsMediaFeatures.cpp
widget/LookAndFeel.h
widget/windows/nsLookAndFeel.cpp
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -2233,16 +2233,17 @@ GK_ATOM(forcemessagemanager, "forcemessa
 // Names for system metrics
 GK_ATOM(color_picker_available, "color-picker-available")
 GK_ATOM(scrollbar_start_backward, "scrollbar-start-backward")
 GK_ATOM(scrollbar_start_forward, "scrollbar-start-forward")
 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")
 GK_ATOM(windows_compositor, "windows-compositor")
 GK_ATOM(windows_glass, "windows-glass")
 GK_ATOM(touch_enabled, "touch-enabled")
 GK_ATOM(menubar_drag, "menubar-drag")
 GK_ATOM(swipe_animation_enabled, "swipe-animation-enabled")
@@ -2262,16 +2263,17 @@ GK_ATOM(windows_theme_generic, "windows-
 // And the same again, as media query keywords.
 GK_ATOM(_moz_color_picker_available, "-moz-color-picker-available")
 GK_ATOM(_moz_scrollbar_start_backward, "-moz-scrollbar-start-backward")
 GK_ATOM(_moz_scrollbar_start_forward, "-moz-scrollbar-start-forward")
 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")
 GK_ATOM(_moz_windows_compositor, "-moz-windows-compositor")
 GK_ATOM(_moz_windows_classic, "-moz-windows-classic")
 GK_ATOM(_moz_windows_glass, "-moz-windows-glass")
 GK_ATOM(_moz_windows_theme, "-moz-windows-theme")
 GK_ATOM(_moz_os_version, "-moz-os-version")
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1127,16 +1127,21 @@ nsCSSRuleProcessor::InitSystemMetrics()
     sSystemMetrics->AppendElement(nsGkAtoms::mac_graphite_theme);
   }
 
   rv = LookAndFeel::GetInt(LookAndFeel::eIntID_MacYosemiteTheme, &metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     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);
   }
 
   rv = LookAndFeel::GetInt(LookAndFeel::eIntID_WindowsGlass, &metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     sSystemMetrics->AppendElement(nsGkAtoms::windows_glass);
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -689,16 +689,24 @@ nsMediaFeatures::features[] = {
     &nsGkAtoms::_moz_mac_yosemite_theme,
     nsMediaFeature::eMinMaxNotAllowed,
     nsMediaFeature::eBoolInteger,
     nsMediaFeature::eNoRequirements,
     { &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,
     nsMediaFeature::eBoolInteger,
     nsMediaFeature::eNoRequirements,
     { &nsGkAtoms::windows_compositor },
     GetSystemMetric
   },
   {
--- a/widget/LookAndFeel.h
+++ b/widget/LookAndFeel.h
@@ -238,16 +238,25 @@ public:
     // the maximum number of lines to be scrolled at ones
     eIntID_TreeScrollLinesMax,
     // What type of tab-order to use
     eIntID_TabFocusModel,
     // 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.
      *
      * 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_WindowsDefaultTheme,
 
--- a/widget/windows/nsLookAndFeel.cpp
+++ b/widget/windows/nsLookAndFeel.cpp
@@ -435,16 +435,22 @@ nsLookAndFeel::GetIntImpl(IntID aID, int
 
     case eIntID_MacGraphiteTheme:
         aResult = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
         break;
     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());
         break;
     case eIntID_AlertNotificationOrigin:
         aResult = 0;
         {
           // Get task bar window handle