Bug 1516867 - Clamp selection color saturation between 0 and 255 in nsLookAndFeel.mm. r=mstange
authorTim Nguyen <ntim.bugs@gmail.com>
Sun, 30 Dec 2018 13:58:10 +0100
changeset 452990 f6a85c2b0dffda801e097f6efea14b46a35626e2
parent 452989 2a7dce7a42ea0527694c978e98d9af1687aecb36
child 452991 632ce013755e9616ffb69d73959fb7bebab5a9c7
push id35337
push userrmaries@mozilla.com
push dateWed, 09 Jan 2019 03:50:08 +0000
treeherdermozilla-central@3b629ad2475f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1516867
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 1516867 - Clamp selection color saturation between 0 and 255 in nsLookAndFeel.mm. r=mstange Differential Revision: https://phabricator.services.mozilla.com/D15500
widget/cocoa/nsLookAndFeel.mm
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -152,17 +152,17 @@ nsLookAndFeel::ProcessSelectionBackgroun
   uint8_t alpha;
   nscolor resultColor = aColor;
   NS_RGB2HSV(resultColor, hue, sat, value, alpha);
   int factor = 2;
   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;
+    sat = mozilla::clamped(sat * factor, 0, 255);
   } else {
     // The color is a shade of grey, find the value that looks equivalent
     // on a white background with the given opacity.
     value = mozilla::clamped(255 - (255 - value) * factor, 0, 255);
   }
   NS_HSV2RGB(resultColor, hue, sat, value, alpha);
   return resultColor;
 }