Bug 1498592 - Port bug 1496322 to TB: Update window border colors for Windows 10 1809 update. r+a=jorgk
authorRichard Marti <richard.marti@gmail.com>
Fri, 12 Oct 2018 16:26:28 +0200
changeset 33062 74c68eb741b5
parent 33061 1af8d4fa7627
child 33063 a154f71f5005
push id386
push userclokep@gmail.com
push dateTue, 23 Oct 2018 00:48:12 +0000
bugs1498592, 1496322
Bug 1498592 - Port bug 1496322 to TB: Update window border colors for Windows 10 1809 update. r+a=jorgk
mail/base/content/msgMail3PaneWindow.js
mail/themes/windows/mail/mailWindow1.css
--- a/mail/base/content/msgMail3PaneWindow.js
+++ b/mail/base/content/msgMail3PaneWindow.js
@@ -19,16 +19,82 @@ ChromeUtils.import("resource:///modules/
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/Color.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
   LightweightThemeManager: "resource://gre/modules/LightweightThemeManager.jsm",
 });
 
+// Copied from M-C's TelemetryEnvironment.jsm
+ChromeUtils.defineModuleGetter(this, "ctypes",
+                               "resource://gre/modules/ctypes.jsm");
+/**
+ * Gets the service pack and build information on Windows platforms. The initial version
+ * was copied from nsUpdateService.js.
+ *
+ * @return An object containing the service pack major and minor versions, along with the
+ *         build number.
+ */
+function getWindowsVersionInfo() {
+  const UNKNOWN_VERSION_INFO = {servicePackMajor: null, servicePackMinor: null, buildNumber: null};
+
+  if (AppConstants.platform !== "win") {
+    return UNKNOWN_VERSION_INFO;
+  }
+
+  const BYTE = ctypes.uint8_t;
+  const WORD = ctypes.uint16_t;
+  const DWORD = ctypes.uint32_t;
+  const WCHAR = ctypes.char16_t;
+  const BOOL = ctypes.int;
+
+  // This structure is described at:
+  // http://msdn.microsoft.com/en-us/library/ms724833%28v=vs.85%29.aspx
+  const SZCSDVERSIONLENGTH = 128;
+  const OSVERSIONINFOEXW = new ctypes.StructType("OSVERSIONINFOEXW",
+      [
+      {dwOSVersionInfoSize: DWORD},
+      {dwMajorVersion: DWORD},
+      {dwMinorVersion: DWORD},
+      {dwBuildNumber: DWORD},
+      {dwPlatformId: DWORD},
+      {szCSDVersion: ctypes.ArrayType(WCHAR, SZCSDVERSIONLENGTH)},
+      {wServicePackMajor: WORD},
+      {wServicePackMinor: WORD},
+      {wSuiteMask: WORD},
+      {wProductType: BYTE},
+      {wReserved: BYTE},
+      ]);
+
+  let kernel32 = ctypes.open("kernel32");
+  try {
+    let GetVersionEx = kernel32.declare("GetVersionExW",
+                                        ctypes.winapi_abi,
+                                        BOOL,
+                                        OSVERSIONINFOEXW.ptr);
+    let winVer = OSVERSIONINFOEXW();
+    winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
+
+    if (0 === GetVersionEx(winVer.address())) {
+      throw ("Failure in GetVersionEx (returned 0)");
+    }
+
+    return {
+      servicePackMajor: winVer.wServicePackMajor,
+      servicePackMinor: winVer.wServicePackMinor,
+      buildNumber: winVer.dwBuildNumber,
+    };
+  } catch (e) {
+    return UNKNOWN_VERSION_INFO;
+  } finally {
+    kernel32.close();
+  }
+}
+
 /* This is where functions related to the 3 pane window are kept */
 
 // from MailNewsTypes.h
 var nsMsgKey_None = 0xFFFFFFFF;
 var nsMsgViewIndex_None = 0xFFFFFFFF;
 var kMailCheckOncePrefName = "mail.startup.enabledMailCheckOnce";
 
 var kStandardPaneConfig = 0;
@@ -350,16 +416,21 @@ function OnLoadMessenger()
     if (window.matchMedia("(-moz-os-version: windows-win8)").matches &&
         window.matchMedia("(-moz-windows-default-theme)").matches) {
       let windowFrameColor = new Color(...ChromeUtils.import("resource:///modules/Windows8WindowFrameColor.jsm", {})
                                             .Windows8WindowFrameColor.get());
       // Default to black for foreground text.
       if (!windowFrameColor.isContrastRatioAcceptable(new Color(0, 0, 0))) {
         document.documentElement.setAttribute("darkwindowframe", "true");
       }
+    } else if (AppConstants.isPlatformAndVersionAtLeast("win", "10")) {
+      // 17763 is the build number of Windows 10 version 1809
+      if (getWindowsVersionInfo().buildNumber < 17763) {
+        document.documentElement.setAttribute("always-use-accent-color-for-window-border", "");
+      }
     }
   }
 
   if (AppConstants.platform == "linux") {
     let { WindowDraggingElement } =
       ChromeUtils.import("resource://gre/modules/WindowDraggingUtils.jsm", {});
     new WindowDraggingElement(document.getElementById("titlebar"));
   }
--- a/mail/themes/windows/mail/mailWindow1.css
+++ b/mail/themes/windows/mail/mailWindow1.css
@@ -194,48 +194,53 @@ treechildren::-moz-tree-cell-text(dummy)
   }
 
   @media (-moz-os-version: windows-win10) {
     @media (-moz-windows-default-theme) {
       :root:not(:-moz-lwtheme) {
         background-color: #d1d1d1;
       }
 
-      :root[sizemode=normal][tabsintitlebar] {
-        border-top: 1px solid -moz-win-accentcolor;
-      }
-
-      :root[sizemode=normal][tabsintitlebar]:-moz-window-inactive {
-        border-top-color: rgba(0,0,0,.2);
-      }
-
       :root[tabsintitlebar] #navigation-toolbox {
         margin-top: -1px;
       }
 
       :root[tabsintitlebar] #mail-toolbar-menubar2 {
         margin-top: 1px;
       }
 
       @media (-moz-windows-accent-color-in-titlebar: 0) {
+        :root[sizemode=normal][tabsintitlebar] {
+          border-top: 1px solid rgba(0,0,0,.7);
+        }
+        :root[sizemode=normal][tabsintitlebar][always-use-accent-color-for-window-border]:not(:-moz-window-inactive) {
+          border-top-color: -moz-win-accentcolor;
+        }
         :root[tabsintitlebar]:not(:-moz-window-inactive):not(:-moz-lwtheme) {
           background-color: #a8cbdb;
         }
       }
 
       @media (-moz-windows-accent-color-in-titlebar) {
+        :root[sizemode=normal][tabsintitlebar] {
+          border-top: 1px solid -moz-win-accentcolor;
+        }
         :root[tabsintitlebar]:not(:-moz-window-inactive):not(:-moz-lwtheme) {
           background-color: -moz-win-accentcolor;
         }
 
         :root[tabsintitlebar] >
           #navigation-toolbox:not(:-moz-window-inactive):not(:-moz-lwtheme) {
           color: -moz-win-accentcolortext;
         }
       }
+
+      :root[sizemode=normal][tabsintitlebar]:-moz-window-inactive {
+        border-top-color: rgba(0,0,0,.3);
+      }
     }
 
     @media (-moz-windows-default-theme: 0) {
       :root {
         -moz-appearance: -moz-win-glass;
         background-color: transparent;
       }