Bug 1722833 - Make MozButtonactivetext use NSColor.controlTextColor on macOS 12+. r=mac-reviewers,spohl
authorMarkus Stange <mstange.moz@gmail.com>
Mon, 18 Oct 2021 21:29:42 +0000
changeset 596249 40fe290c760459430ae64aca0df18477f1aff466
parent 596248 f718eaf8816e2fabd319aab507691fa829a2df88
child 596250 4e5cf61ceab6549e835b236e66ebc7d60b361b91
push id38892
push userctuns@mozilla.com
push dateTue, 19 Oct 2021 04:21:59 +0000
treeherdermozilla-central@1e37fc4a7f53 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmac-reviewers, spohl
bugs1722833
milestone95.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 1722833 - Make MozButtonactivetext use NSColor.controlTextColor on macOS 12+. r=mac-reviewers,spohl Depends on D128785 Differential Revision: https://phabricator.services.mozilla.com/D128786
widget/cocoa/nsLookAndFeel.mm
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -196,24 +196,30 @@ nsresult nsLookAndFeel::NativeGetColor(C
       // It's really hard to effectively map these to the Appearance Manager properly,
       // since they are modeled word for word after the win32 system colors and don't have any
       // real counterparts in the Mac world. I'm sure we'll be tweaking these for
       // years to come.
       //
       // Thanks to mpt26@student.canterbury.ac.nz for the hardcoded values that form the defaults
       //  if querying the Appearance Manager fails ;)
       //
-    case ColorID::MozButtonactivetext:
     case ColorID::MozMacDefaultbuttontext:
       color = NS_RGB(0xFF, 0xFF, 0xFF);
       break;
     case ColorID::Buttontext:
     case ColorID::MozButtonhovertext:
       color = GetColorFromNSColor(NSColor.controlTextColor);
       break;
+    case ColorID::MozButtonactivetext:
+      // Pre-macOS 12, pressed buttons were filled with the highlight color and the text was white.
+      // Starting with macOS 12, pressed (non-default) buttons are filled with medium gray and the
+      // text color is the same as in the non-pressed state.
+      color = nsCocoaFeatures::OnMontereyOrLater() ? GetColorFromNSColor(NSColor.controlTextColor)
+                                                   : NS_RGB(0xFF, 0xFF, 0xFF);
+      break;
     case ColorID::Captiontext:
     case ColorID::Menutext:
     case ColorID::Infotext:
     case ColorID::MozMenubartext:
       color = GetColorFromNSColor(NSColor.textColor);
       break;
     case ColorID::Windowtext:
       color = GetColorFromNSColor(NSColor.windowFrameTextColor);