Bug 1973157 - Fix cocoa native rendering regression from bug 1971369. r=mac-reviewers,spohl
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 20 Jun 2025 14:04:34 +0000 (3 weeks ago)
changeset 793072 de60bae5ab9b20a8ca574a3c28954c337f49804d
parent 793071 20aeb633b342dad7e49cf83358380dfddf576d9c
child 793073 36c907b1d8b76afc2e33e2986da8e8345bad4d2f
push id234476
push userealvarez@mozilla.com
push dateFri, 20 Jun 2025 14:07:41 +0000 (3 weeks ago)
treeherderautoland@5b8d03fdc83f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
git commitf6b73c87ee010a24632211a921dc6ea1f816e0d5
reviewersmac-reviewers, spohl
bugs1973157, 1971369
milestone141.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 1973157 - Fix cocoa native rendering regression from bug 1971369. r=mac-reviewers,spohl D253206 changed the margins to use an IntMargin. However I didn't realize the order was subtly different. The cocoa code was using left, top, right, bottom, while IntMargin uses the CSS order (top, right, bottom, left). So fix the order of the numbers to preserve previous behavior. Differential Revision: https://phabricator.services.mozilla.com/D254496
widget/cocoa/nsNativeThemeCocoa.mm
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -694,32 +694,32 @@ constexpr static CellRenderSettings radi
     {
         NSSize{11, 11},  // mini
         NSSize{13, 13},  // small
         NSSize{16, 16}   // regular
     },
     {NSSize{}, NSSize{}, NSSize{}},
     {
         IntMargin{0, 0, 0, 0},  // mini
-        IntMargin{1, 1, 1, 2},  // small
+        IntMargin{1, 1, 2, 1},  // small
         IntMargin{0, 0, 0, 0},  // regular
     },
 };
 
 constexpr static CellRenderSettings checkboxSettings = {
     {
         NSSize{11, 11},  // mini
         NSSize{13, 13},  // small
         NSSize{16, 16}   // regular
     },
     {NSSize{}, NSSize{}, NSSize{}},
     {
-        IntMargin{0, 1, 0, 0},  // mini
-        IntMargin{0, 1, 0, 1},  // small
-        IntMargin{0, 1, 0, 1}   // regular
+        IntMargin{1, 0, 0, 0},  // mini
+        IntMargin{1, 0, 1, 0},  // small
+        IntMargin{1, 0, 1, 0}   // regular
     }};
 
 static NSControlStateValue CellStateForCheckboxOrRadioState(
     nsNativeThemeCocoa::CheckboxOrRadioState aState) {
   switch (aState) {
     case nsNativeThemeCocoa::CheckboxOrRadioState::eOff:
       return NSControlStateValueOff;
     case nsNativeThemeCocoa::CheckboxOrRadioState::eOn:
@@ -869,18 +869,18 @@ constexpr static CellRenderSettings push
     },
     {
         NSSize{18, 0},  // mini
         NSSize{26, 0},  // small
         NSSize{30, 0}   // regular
     },
     {
         IntMargin{0, 0, 0, 0},  // mini
-        IntMargin{4, 0, 4, 1},  // small
-        IntMargin{5, 0, 5, 2}   // regular
+        IntMargin{0, 4, 1, 4},  // small
+        IntMargin{0, 5, 2, 5}   // regular
     }};
 
 // The height at which we start doing square buttons instead of rounded buttons
 // Rounded buttons look bad if drawn at a height greater than 26, so at that
 // point we switch over to doing square buttons which looks fine at any size.
 #define DO_SQUARE_BUTTON_HEIGHT 26
 
 void nsNativeThemeCocoa::DrawPushButton(CGContextRef cgContext,
@@ -1116,37 +1116,37 @@ constexpr static CellRenderSettings drop
         NSSize{0, 22}   // regular
     },
     {
         NSSize{18, 0},  // mini
         NSSize{38, 0},  // small
         NSSize{44, 0}   // regular
     },
     {
-        IntMargin{1, 1, 2, 1},  // mini
-        IntMargin{3, 0, 3, 1},  // small
-        IntMargin{3, 0, 3, 0}   // regular
+        IntMargin{1, 2, 1, 1},  // mini
+        IntMargin{0, 3, 1, 3},  // small
+        IntMargin{0, 3, 0, 3}   // regular
     },
 };
 
 constexpr static CellRenderSettings editableMenulistSettings = {
     {
         NSSize{0, 15},  // mini
         NSSize{0, 18},  // small
         NSSize{0, 21}   // regular
     },
     {
         NSSize{18, 0},  // mini
         NSSize{38, 0},  // small
         NSSize{44, 0}   // regular
     },
     {
-        IntMargin{0, 0, 2, 2},  // mini
-        IntMargin{0, 0, 3, 2},  // small
-        IntMargin{0, 1, 3, 3}   // regular
+        IntMargin{0, 2, 2, 0},  // mini
+        IntMargin{0, 3, 2, 0},  // small
+        IntMargin{1, 3, 3, 0}   // regular
     }};
 
 void nsNativeThemeCocoa::DrawDropdown(CGContextRef cgContext,
                                       const HIRect& inBoxRect,
                                       const DropdownParams& aParams) {
   NS_OBJC_BEGIN_TRY_IGNORE_BLOCK;
 
   [mDropdownCell setPullsDown:aParams.pullsDown];