Bug 1698336 - Fix high contrast rendering of <meter>. r=mstange
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 15 Mar 2021 21:06:54 +0000
changeset 571327 62e31d29d198457d30a54f53f59ed8949be678e5
parent 571326 847ac239d883f37fad58b9742e1fb66603635ec7
child 571328 e6af362362a835be30bd356f17c3ecefb6fa5a49
push id38288
push usernbeleuzu@mozilla.com
push dateTue, 16 Mar 2021 05:27:46 +0000
treeherdermozilla-central@f2134bdaf09c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1698336
milestone88.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 1698336 - Fix high contrast rendering of <meter>. r=mstange Using the same color for the track and the meter chunk is not going to fly of course... In high contrast, make the colors consistent with <progress>, which seems like a reasonable thing to do. Differential Revision: https://phabricator.services.mozilla.com/D108347
widget/nsNativeBasicTheme.cpp
widget/nsNativeBasicTheme.h
--- a/widget/nsNativeBasicTheme.cpp
+++ b/widget/nsNativeBasicTheme.cpp
@@ -454,42 +454,32 @@ std::pair<sRGBColor, sRGBColor> nsNative
                            StyleSystemColor::Buttontext);
   }
   return std::make_pair(sColorGrey10, sColorGrey40);
 }
 
 std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeMeterchunkColors(
     const EventStates& aMeterState, UseSystemColors aUseSystemColors) {
   if (bool(aUseSystemColors)) {
-    return SystemColorPair(StyleSystemColor::TextBackground,
-                           StyleSystemColor::TextForeground);
+    return ComputeProgressColors(aUseSystemColors);
   }
   sRGBColor borderColor = sColorMeterGreen20;
   sRGBColor chunkColor = sColorMeterGreen10;
 
   if (aMeterState.HasState(NS_EVENT_STATE_SUB_OPTIMUM)) {
     borderColor = sColorMeterYellow20;
     chunkColor = sColorMeterYellow10;
   } else if (aMeterState.HasState(NS_EVENT_STATE_SUB_SUB_OPTIMUM)) {
     borderColor = sColorMeterRed20;
     chunkColor = sColorMeterRed10;
   }
 
   return std::make_pair(chunkColor, borderColor);
 }
 
-std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeMeterTrackColors(
-    UseSystemColors aUseSystemColors) {
-  if (bool(aUseSystemColors)) {
-    return SystemColorPair(StyleSystemColor::TextBackground,
-                           StyleSystemColor::TextForeground);
-  }
-  return std::make_pair(sColorGrey10, sColorGrey40);
-}
-
 sRGBColor nsNativeBasicTheme::ComputeMenulistArrowButtonColor(
     const EventStates& aState, UseSystemColors aUseSystemColors) {
   bool isDisabled = aState.HasState(NS_EVENT_STATE_DISABLED);
   if (bool(aUseSystemColors)) {
     return SystemColor(isDisabled ? StyleSystemColor::Graytext
                                   : StyleSystemColor::TextForeground);
   }
   return isDisabled ? sColorGrey60Alpha50 : sColorGrey60;
@@ -1317,18 +1307,17 @@ void nsNativeBasicTheme::PaintProgress(n
     // Center it horizontally.
     rect.x += (rect.width - thickness) / 2;
     rect.width = thickness;
   }
 
   {
     // Paint the track, unclipped.
     auto [backgroundColor, borderColor] =
-        aIsMeter ? ComputeMeterTrackColors(aUseSystemColors)
-                 : ComputeProgressTrackColors(aUseSystemColors);
+        ComputeProgressTrackColors(aUseSystemColors);
     PaintRoundedRectWithRadius(aPaintData, rect, rect, backgroundColor,
                                borderColor, borderWidth, radius, aDpiRatio);
   }
 
   // Now paint the chunk, clipped as needed.
   LayoutDeviceRect clipRect = rect;
   if (aState.HasState(NS_EVENT_STATE_INDETERMINATE)) {
     // For indeterminate progress, we paint an animated chunk of 1/3 of the
--- a/widget/nsNativeBasicTheme.h
+++ b/widget/nsNativeBasicTheme.h
@@ -202,17 +202,16 @@ class nsNativeBasicTheme : protected nsN
   std::pair<sRGBColor, sRGBColor> ComputeRangeTrackColors(const EventStates&,
                                                           UseSystemColors);
   std::pair<sRGBColor, sRGBColor> ComputeRangeThumbColors(const EventStates&,
                                                           UseSystemColors);
   std::pair<sRGBColor, sRGBColor> ComputeProgressColors(UseSystemColors);
   std::pair<sRGBColor, sRGBColor> ComputeProgressTrackColors(UseSystemColors);
   std::pair<sRGBColor, sRGBColor> ComputeMeterchunkColors(
       const EventStates& aMeterState, UseSystemColors);
-  std::pair<sRGBColor, sRGBColor> ComputeMeterTrackColors(UseSystemColors);
   sRGBColor ComputeMenulistArrowButtonColor(const EventStates&,
                                             UseSystemColors);
   std::array<sRGBColor, 3> ComputeFocusRectColors(UseSystemColors);
 
   static bool ShouldUseDarkScrollbar(nsIFrame*, const ComputedStyle&);
   virtual sRGBColor ComputeScrollbarColor(nsIFrame*, const ComputedStyle&,
                                           const EventStates& aDocumentState,
                                           UseSystemColors);