Bug 1381833 - Port
bug 1279717 to TB [introduce a Color.jsm module that implements common color math operations in a single place]. r=jorgk
--- a/mail/base/content/msgMail3PaneWindow.js
+++ b/mail/base/content/msgMail3PaneWindow.js
@@ -12,16 +12,17 @@ Components.utils.import("resource:///mod
Components.utils.import("resource:///modules/mailInstrumentation.js");
Components.utils.import("resource:///modules/mailnewsMigrator.js");
Components.utils.import("resource:///modules/mailServices.js");
Components.utils.import("resource:///modules/msgDBCacheManager.js");
Components.utils.import("resource:///modules/sessionStoreManager.js");
Components.utils.import("resource:///modules/summaryFrameManager.js");
Components.utils.import("resource:///modules/MailUtils.js");
Components.utils.import("resource://gre/modules/Services.jsm");
+Components.utils.import("resource://gre/modules/Color.jsm");
/* 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";
@@ -352,33 +353,20 @@ function OnLoadMessenger()
// in delayedOnLoadMessenger...
UpdateMailPaneConfig(false);
document.loadBindingDocument('chrome://global/content/bindings/textbox.xml');
#ifdef XP_WIN
// On Win8 set an attribute when the window frame color is too dark for black text.
if (window.matchMedia("(-moz-os-version: windows-win8)").matches &&
window.matchMedia("(-moz-windows-default-theme)").matches) {
- let windows8WindowFrameColor = Cu.import("resource:///modules/Windows8WindowFrameColor.jsm", {}).Windows8WindowFrameColor;
- let windowFrameColor = windows8WindowFrameColor.get();
-
- // Formula from W3C's WCAG 2.0 spec's color ratio and relative luminance,
- // section 1.3.4, http://www.w3.org/TR/WCAG20/ .
- windowFrameColor = windowFrameColor.map((color) => {
- if (color <= 10) {
- return color / 255 / 12.92;
- }
- return Math.pow(((color / 255) + 0.055) / 1.055, 2.4);
- });
- let backgroundLuminance = windowFrameColor[0] * 0.2126 +
- windowFrameColor[1] * 0.7152 +
- windowFrameColor[2] * 0.0722;
- let foregroundLuminance = 0; // Default to black for foreground text.
- let contrastRatio = (backgroundLuminance + 0.05) / (foregroundLuminance + 0.05);
- if (contrastRatio < 3) {
+ let windowFrameColor = new Color(...Cu.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");
}
}
#endif
ToolbarIconColor.init();
// Set a sane starting width/height for all resolutions on new profiles.