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 510093 f6a85c2b0dffda801e097f6efea14b46a35626e2
parent 510092 2a7dce7a42ea0527694c978e98d9af1687aecb36
child 510094 632ce013755e9616ffb69d73959fb7bebab5a9c7
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [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;
 }