Bug 1514464 - Clamp selection color value between 0 and 255 in nsLookAndFeel.mm. r=mstange
authorTim Nguyen <ntim.bugs@gmail.com>
Sat, 15 Dec 2018 22:46:31 +0000
changeset 450872 655c49c71be0b2f973ffffb168825aa1c0401552
parent 450871 b7e8997927b9dd441be11adb6544abb7f8387929
child 450873 d70fba3550b4f487e64eaa4f4068df5fbfe90403
push id74786
push userntim.bugs@gmail.com
push dateSat, 15 Dec 2018 23:14:12 +0000
treeherderautoland@655c49c71be0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1514464
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1514464 - Clamp selection color value between 0 and 255 in nsLookAndFeel.mm. r=mstange Differential Revision: https://phabricator.services.mozilla.com/D14676
widget/cocoa/nsLookAndFeel.mm
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -156,17 +156,17 @@ nsLookAndFeel::ProcessSelectionBackgroun
   alpha = alpha / factor;
   if (sat > 0) {
     // The color is not a shade of grey, restore the saturation taken away by
     // the transparency.
     sat = sat * factor;
   } else {
     // The color is a shade of grey, find the value that looks equivalent
     // on a white background with the given opacity.
-    value = 255 - (255 - value) * factor;
+    value = mozilla::clamped(255 - (255 - value) * factor, 0, 255);
   }
   NS_HSV2RGB(resultColor, hue, sat, value, alpha);
   return resultColor;
 }
 
 nsresult
 nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor)
 {