Bug 1379266 - Tweak -moz-win-accentcolortext formula to better match native title bars. r?jimm draft
authorDão Gottwald <dao@mozilla.com>
Tue, 18 Jul 2017 13:23:25 +0200
changeset 610507 0a83ece8021d2444a77f2a7d116d0549d213f0ec
parent 610234 5e73b9798464c3f7106f0161dc9a49b234f42f9c
child 637881 9154ac86ab6baaa85bbccc2f4e740c15b9fcb32e
push id68914
push userdgottwald@mozilla.com
push dateTue, 18 Jul 2017 11:25:29 +0000
reviewersjimm
bugs1379266
milestone56.0a1
Bug 1379266 - Tweak -moz-win-accentcolortext formula to better match native title bars. r?jimm MozReview-Commit-ID: 9unrhFI3sWh
widget/windows/nsLookAndFeel.cpp
--- a/widget/windows/nsLookAndFeel.cpp
+++ b/widget/windows/nsLookAndFeel.cpp
@@ -821,16 +821,16 @@ nsLookAndFeel::GetAccentColorText(nscolo
 
   // We want the color that we return for text that will be drawn over
   // a background that has the accent color to have good contrast with
   // the accent color.  Windows itself uses either white or black text
   // depending on how light or dark the accent color is.  We do the same
   // here based on the luminance of the accent color with a threshhold
   // value that seem consistent with what Windows does.
 
-  float luminance = 0.2125f * NS_GET_R(accentColor) +
-                    0.7154f * NS_GET_G(accentColor) +
-                    0.0721f * NS_GET_B(accentColor);
+  float luminance = (NS_GET_R(accentColor) * 2 +
+                     NS_GET_G(accentColor) * 5 +
+                     NS_GET_B(accentColor)) / 8;
 
-  aColor = (luminance <= 110) ? NS_RGB(255, 255, 255) : NS_RGB(0, 0, 0);
+  aColor = (luminance <= 128) ? NS_RGB(255, 255, 255) : NS_RGB(0, 0, 0);
 
   return NS_OK;
 }