1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/modules/Windows8WindowFrameColor.jsm Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,43 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 +const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; 1.10 + 1.11 +this.EXPORTED_SYMBOLS = ["Windows8WindowFrameColor"]; 1.12 + 1.13 +Cu.import("resource://gre/modules/Services.jsm"); 1.14 +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 1.15 +let Registry = Cu.import("resource://gre/modules/WindowsRegistry.jsm").WindowsRegistry; 1.16 + 1.17 +const Windows8WindowFrameColor = { 1.18 + _windowFrameColor: null, 1.19 + 1.20 + get: function() { 1.21 + if (this._windowFrameColor) 1.22 + return this._windowFrameColor; 1.23 + 1.24 + const HKCU = Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER; 1.25 + const dwmKey = "Software\\Microsoft\\Windows\\DWM"; 1.26 + let customizationColor = Registry.readRegKey(HKCU, dwmKey, 1.27 + "ColorizationColor"); 1.28 + // The color returned from the Registry is in decimal form. 1.29 + let customizationColorHex = customizationColor.toString(16); 1.30 + // Zero-pad the number just to make sure that it is 8 digits. 1.31 + customizationColorHex = ("00000000" + customizationColorHex).substr(-8); 1.32 + let customizationColorArray = customizationColorHex.match(/../g); 1.33 + let [unused, fgR, fgG, fgB] = customizationColorArray.map(function(val) parseInt(val, 16)); 1.34 + let colorizationColorBalance = Registry.readRegKey(HKCU, dwmKey, 1.35 + "ColorizationColorBalance"); 1.36 + // Window frame base color when Color Intensity is at 0, see bug 1004576. 1.37 + let frameBaseColor = 217; 1.38 + let alpha = colorizationColorBalance / 100; 1.39 + 1.40 + // Alpha-blend the foreground color with the frame base color. 1.41 + let r = Math.round(fgR * alpha + frameBaseColor * (1 - alpha)); 1.42 + let g = Math.round(fgG * alpha + frameBaseColor * (1 - alpha)); 1.43 + let b = Math.round(fgB * alpha + frameBaseColor * (1 - alpha)); 1.44 + return this._windowFrameColor = [r, g, b]; 1.45 + }, 1.46 +};