Bug 1421088 - Route more button types through DrawButton. r=spohl
authorMarkus Stange <mstange@themasta.com>
Thu, 30 Nov 2017 16:47:59 -0500
changeset 466934 d7a371dd00626d6aef9db1a3eba52dbcae6264fc
parent 466933 f91c55d12fccb4582ada303e1ffb0ee76772cdca
child 466935 7d5825e533547ce882c3a132b430211bb0b99359
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1421088
milestone61.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 1421088 - Route more button types through DrawButton. r=spohl MozReview-Commit-ID: 8AhEnEi5UCZ
widget/cocoa/nsNativeThemeCocoa.h
widget/cocoa/nsNativeThemeCocoa.mm
--- a/widget/cocoa/nsNativeThemeCocoa.h
+++ b/widget/cocoa/nsNativeThemeCocoa.h
@@ -46,19 +46,24 @@ public:
     eThemeGeometryTypeActiveSourceListSelection
   };
 
   enum class ButtonType : uint8_t {
     eRegularPushButton,
     eDefaultPushButton,
     eRegularBevelButton,
     eDefaultBevelButton,
+    eRoundedBezelPushButton,
+    eSquareBezelPushButton,
     eArrowButton,
+    eHelpButton,
     eTreeTwistyPointingRight,
-    eTreeTwistyPointingDown
+    eTreeTwistyPointingDown,
+    eDisclosureButtonClosed,
+    eDisclosureButtonOpen
   };
 
   struct ControlParams {
     ControlParams()
       : disabled(false)
       , insideActiveWindow(false)
       , pressed(false)
       , focused(false)
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -1465,29 +1465,44 @@ nsNativeThemeCocoa::DrawButton(CGContext
     case ButtonType::eDefaultBevelButton: {
       ThemeButtonAdornment adornment =
         aParams.button == ButtonType::eDefaultBevelButton ? kThemeAdornmentDefault
                                                           : kThemeAdornmentNone;
       DrawHIThemeButton(cgContext, inBoxRect, kThemeMediumBevelButton, kThemeButtonOff,
                         ToThemeDrawState(controlParams), adornment, controlParams);
       return;
     }
+    case ButtonType::eRoundedBezelPushButton:
+      DrawRoundedBezelPushButton(cgContext, inBoxRect, controlParams);
+      return;
+    case ButtonType::eSquareBezelPushButton:
+      DrawSquareBezelPushButton(cgContext, inBoxRect, controlParams);
+      return;
     case ButtonType::eArrowButton:
       DrawHIThemeButton(cgContext, inBoxRect, kThemeArrowButton, kThemeButtonOn,
                         kThemeStateUnavailable, kThemeAdornmentArrowDownArrow,
                         controlParams);
       return;
+    case ButtonType::eHelpButton:
+      DrawHelpButton(cgContext, inBoxRect, controlParams);
+      return;
     case ButtonType::eTreeTwistyPointingRight:
       DrawHIThemeButton(cgContext, inBoxRect, kThemeDisclosureButton, kThemeDisclosureRight,
                         ToThemeDrawState(controlParams), kThemeAdornmentNone, controlParams);
       return;
     case ButtonType::eTreeTwistyPointingDown:
       DrawHIThemeButton(cgContext, inBoxRect, kThemeDisclosureButton, kThemeDisclosureDown,
                         ToThemeDrawState(controlParams), kThemeAdornmentNone, controlParams);
       return;
+    case ButtonType::eDisclosureButtonClosed:
+      DrawDisclosureButton(cgContext, inBoxRect, controlParams, NSOffState);
+      return;
+    case ButtonType::eDisclosureButtonOpen:
+      DrawDisclosureButton(cgContext, inBoxRect, controlParams, NSOnState);
+      return;
   }
 }
 
 nsNativeThemeCocoa::TreeHeaderCellParams
 nsNativeThemeCocoa::ComputeTreeHeaderCellParams(nsIFrame* aFrame,
                                                 EventStates aEventState)
 {
   TreeHeaderCellParams params;
@@ -2623,39 +2638,43 @@ nsNativeThemeCocoa::DrawWidgetBackground
         DrawDropdown(cgContext, macRect, eventState, aWidgetType, aFrame);
       } else if (nativeWidgetHeight > DO_SQUARE_BUTTON_HEIGHT) {
         // If the button is tall enough, draw the square button style so that
         // buttons with non-standard content look good. Otherwise draw normal
         // rounded aqua buttons.
         // This comparison is done based on the height that is calculated without
         // the top, because the snapped height can be affected by the top of the
         // rect and that may result in different height depending on the top value.
-        DrawSquareBezelPushButton(cgContext, macRect,
-                                  ComputeControlParams(aFrame, eventState));
+        DrawButton(cgContext, macRect,
+                   ButtonParams{ComputeControlParams(aFrame, eventState),
+                                ButtonType::eSquareBezelPushButton});
       } else {
-        DrawRoundedBezelPushButton(cgContext, macRect,
-                                   ComputeControlParams(aFrame, eventState));
+        DrawButton(cgContext, macRect,
+                   ButtonParams{ComputeControlParams(aFrame, eventState),
+                                ButtonType::eRoundedBezelPushButton});
       }
       break;
 
     case NS_THEME_FOCUS_OUTLINE:
       DrawFocusOutline(cgContext, macRect, eventState, aWidgetType, aFrame);
       break;
 
     case NS_THEME_MAC_HELP_BUTTON:
-      DrawHelpButton(cgContext, macRect,
-                     ComputeControlParams(aFrame, eventState));
+      DrawButton(cgContext, macRect,
+                 ButtonParams{ComputeControlParams(aFrame, eventState),
+                              ButtonType::eHelpButton});
       break;
 
     case NS_THEME_MAC_DISCLOSURE_BUTTON_OPEN:
     case NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED: {
-      NSCellStateValue value = (aWidgetType == NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED)
-        ? NSOffState : NSOnState;
-      DrawDisclosureButton(cgContext, macRect,
-                           ComputeControlParams(aFrame, eventState), value);
+      ButtonType buttonType = (aWidgetType == NS_THEME_MAC_DISCLOSURE_BUTTON_CLOSED)
+        ? ButtonType::eDisclosureButtonClosed : ButtonType::eDisclosureButtonOpen;
+      DrawButton(cgContext, macRect,
+                 ButtonParams{ComputeControlParams(aFrame, eventState),
+                              buttonType});
     }
       break;
 
     case NS_THEME_BUTTON_BEVEL: {
       bool isDefaultButton = IsDefaultButton(aFrame);
       ButtonType buttonType =
         isDefaultButton ? ButtonType::eDefaultBevelButton
                         : ButtonType::eRegularBevelButton;