browser/modules/Windows8WindowFrameColor.jsm

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 "use strict";
     6 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
     8 this.EXPORTED_SYMBOLS = ["Windows8WindowFrameColor"];
    10 Cu.import("resource://gre/modules/Services.jsm");
    11 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
    12 let Registry = Cu.import("resource://gre/modules/WindowsRegistry.jsm").WindowsRegistry;
    14 const Windows8WindowFrameColor = {
    15   _windowFrameColor: null,
    17   get: function() {
    18     if (this._windowFrameColor)
    19       return this._windowFrameColor;
    21     const HKCU = Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER;
    22     const dwmKey = "Software\\Microsoft\\Windows\\DWM";
    23     let customizationColor = Registry.readRegKey(HKCU, dwmKey,
    24                                                  "ColorizationColor");
    25     // The color returned from the Registry is in decimal form.
    26     let customizationColorHex = customizationColor.toString(16);
    27     // Zero-pad the number just to make sure that it is 8 digits.
    28     customizationColorHex = ("00000000" + customizationColorHex).substr(-8);
    29     let customizationColorArray = customizationColorHex.match(/../g);
    30     let [unused, fgR, fgG, fgB] = customizationColorArray.map(function(val) parseInt(val, 16));
    31     let colorizationColorBalance = Registry.readRegKey(HKCU, dwmKey,
    32                                                        "ColorizationColorBalance");
    33      // Window frame base color when Color Intensity is at 0, see bug 1004576.
    34     let frameBaseColor = 217;
    35     let alpha = colorizationColorBalance / 100;
    37     // Alpha-blend the foreground color with the frame base color.
    38     let r = Math.round(fgR * alpha + frameBaseColor * (1 - alpha));
    39     let g = Math.round(fgG * alpha + frameBaseColor * (1 - alpha));
    40     let b = Math.round(fgB * alpha + frameBaseColor * (1 - alpha));
    41     return this._windowFrameColor = [r, g, b];
    42   },
    43 };

mercurial