Bug 1673055 - Remove now-unused MenuBackground widget drawing. r=haik,spohl
authorMarkus Stange <mstange.moz@gmail.com>
Mon, 26 Oct 2020 23:17:24 +0000
changeset 554699 fc9d24f6ffbdfdeb213e97e9fa3d276b21dbf687
parent 554698 8d7ff75d700a8e3d81afe4a68c66fbcd4be9171a
child 554700 673508a5981eb2f6b5f80f7acacef8d295cb6917
push id37898
push userabutkovits@mozilla.com
push dateWed, 28 Oct 2020 09:24:21 +0000
treeherdermozilla-central@83bf4fd3b1fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershaik, spohl
bugs1673055
milestone84.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 1673055 - Remove now-unused MenuBackground widget drawing. r=haik,spohl Differential Revision: https://phabricator.services.mozilla.com/D94633
widget/cocoa/nsNativeThemeCocoa.h
widget/cocoa/nsNativeThemeCocoa.mm
--- a/widget/cocoa/nsNativeThemeCocoa.h
+++ b/widget/cocoa/nsNativeThemeCocoa.h
@@ -86,21 +86,16 @@ class nsNativeThemeCocoa : private nsNat
 
     bool disabled : 1;
     bool insideActiveWindow : 1;
     bool pressed : 1;
     bool focused : 1;
     bool rtl : 1;
   };
 
-  struct MenuBackgroundParams {
-    bool disabled = false;
-    bool submenuRightOfParent = false;
-  };
-
   struct MenuIconParams {
     MenuIcon icon = MenuIcon::eCheckmark;
     bool disabled = false;
     bool insideActiveMenuItem = false;
     bool centerHorizontally = false;
     bool rtl = false;
   };
 
@@ -201,21 +196,20 @@ class nsNativeThemeCocoa : private nsNat
     bool focused = false;
     bool horizontal = true;
     bool reverse = false;
   };
 
   using ScrollbarParams = mozilla::widget::ScrollbarParams;
 
   enum Widget : uint8_t {
-    eColorFill,       // mozilla::gfx::sRGBColor
-    eMenuBackground,  // MenuBackgroundParams
-    eMenuIcon,        // MenuIconParams
-    eMenuItem,        // MenuItemParams
-    eMenuSeparator,   // MenuItemParams
+    eColorFill,      // mozilla::gfx::sRGBColor
+    eMenuIcon,       // MenuIconParams
+    eMenuItem,       // MenuItemParams
+    eMenuSeparator,  // MenuItemParams
     eTooltip,
     eCheckbox,  // CheckboxOrRadioParams
     eRadio,     // CheckboxOrRadioParams
     eButton,    // ButtonParams
     eDropdown,  // DropdownParams
     eFocusOutline,
     eSpinButtons,     // SpinButtonParams
     eSpinButtonUp,    // SpinButtonParams
@@ -244,19 +238,16 @@ class nsNativeThemeCocoa : private nsNat
     eTabPanel,
     eResizer
   };
 
   struct WidgetInfo {
     static WidgetInfo ColorFill(const mozilla::gfx::sRGBColor& aParams) {
       return WidgetInfo(Widget::eColorFill, aParams);
     }
-    static WidgetInfo MenuBackground(const MenuBackgroundParams& aParams) {
-      return WidgetInfo(Widget::eMenuBackground, aParams);
-    }
     static WidgetInfo MenuIcon(const MenuIconParams& aParams) {
       return WidgetInfo(Widget::eMenuIcon, aParams);
     }
     static WidgetInfo MenuItem(const MenuItemParams& aParams) {
       return WidgetInfo(Widget::eMenuItem, aParams);
     }
     static WidgetInfo MenuSeparator(const MenuItemParams& aParams) {
       return WidgetInfo(Widget::eMenuSeparator, aParams);
@@ -345,21 +336,20 @@ class nsNativeThemeCocoa : private nsNat
     }
 
     enum Widget Widget() const { return mWidget; }
 
    private:
     template <typename T>
     WidgetInfo(enum Widget aWidget, const T& aParams) : mVariant(aParams), mWidget(aWidget) {}
 
-    mozilla::Variant<mozilla::gfx::sRGBColor, MenuBackgroundParams, MenuIconParams, MenuItemParams,
-                     CheckboxOrRadioParams, ButtonParams, DropdownParams, SpinButtonParams,
-                     SegmentParams, UnifiedToolbarParams, TextBoxParams, SearchFieldParams,
-                     ProgressParams, MeterParams, TreeHeaderCellParams, ScaleParams,
-                     ScrollbarParams, bool>
+    mozilla::Variant<mozilla::gfx::sRGBColor, MenuIconParams, MenuItemParams, CheckboxOrRadioParams,
+                     ButtonParams, DropdownParams, SpinButtonParams, SegmentParams,
+                     UnifiedToolbarParams, TextBoxParams, SearchFieldParams, ProgressParams,
+                     MeterParams, TreeHeaderCellParams, ScaleParams, ScrollbarParams, bool>
         mVariant;
 
     enum Widget mWidget;
   };
 
   using ScrollbarDrawingMac = mozilla::widget::ScrollbarDrawingMac;
 
   nsNativeThemeCocoa();
@@ -412,18 +402,16 @@ class nsNativeThemeCocoa : private nsNat
  protected:
   virtual ~nsNativeThemeCocoa();
 
   LayoutDeviceIntMargin DirectionAwareMargin(const LayoutDeviceIntMargin& aMargin,
                                              nsIFrame* aFrame);
   nsIFrame* SeparatorResponsibility(nsIFrame* aBefore, nsIFrame* aAfter);
   bool IsWindowSheet(nsIFrame* aFrame);
   ControlParams ComputeControlParams(nsIFrame* aFrame, mozilla::EventStates aEventState);
-  MenuBackgroundParams ComputeMenuBackgroundParams(nsIFrame* aFrame,
-                                                   mozilla::EventStates aEventState);
   MenuIconParams ComputeMenuIconParams(nsIFrame* aParams, mozilla::EventStates aEventState,
                                        MenuIcon aIcon);
   MenuItemParams ComputeMenuItemParams(nsIFrame* aFrame, mozilla::EventStates aEventState,
                                        bool aIsChecked);
   SegmentParams ComputeSegmentParams(nsIFrame* aFrame, mozilla::EventStates aEventState,
                                      SegmentType aSegmentType);
   SearchFieldParams ComputeSearchFieldParams(nsIFrame* aFrame, mozilla::EventStates aEventState);
   ProgressParams ComputeProgressParams(nsIFrame* aFrame, mozilla::EventStates aEventState,
@@ -449,18 +437,16 @@ class nsNativeThemeCocoa : private nsNat
   void DrawRoundedBezelPushButton(CGContextRef cgContext, const HIRect& inBoxRect,
                                   ControlParams aControlParams);
   void DrawSquareBezelPushButton(CGContextRef cgContext, const HIRect& inBoxRect,
                                  ControlParams aControlParams);
   void DrawHelpButton(CGContextRef cgContext, const HIRect& inBoxRect,
                       ControlParams aControlParams);
   void DrawDisclosureButton(CGContextRef cgContext, const HIRect& inBoxRect,
                             ControlParams aControlParams, NSCellStateValue aState);
-  void DrawMenuBackground(CGContextRef cgContext, const CGRect& inBoxRect,
-                          const MenuBackgroundParams& aParams);
   NSString* GetMenuIconName(const MenuIconParams& aParams);
   NSSize GetMenuIconSize(MenuIcon aIcon);
   void DrawMenuIcon(CGContextRef cgContext, const CGRect& aRect, const MenuIconParams& aParams);
   void DrawMenuItem(CGContextRef cgContext, const CGRect& inBoxRect, const MenuItemParams& aParams);
   void DrawMenuSeparator(CGContextRef cgContext, const CGRect& inBoxRect,
                          const MenuItemParams& aParams);
   void DrawHIThemeButton(CGContextRef cgContext, const HIRect& aRect, ThemeButtonKind aKind,
                          ThemeButtonValue aValue, ThemeDrawState aState,
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -1031,43 +1031,16 @@ void nsNativeThemeCocoa::DrawSearchField
   [cell setPlaceholderString:@""];
 
   DrawCellWithSnapping(cell, cgContext, inBoxRect, searchFieldSettings, aParams.verticalAlignFactor,
                        mCellDrawView, aParams.rtl);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
-nsNativeThemeCocoa::MenuBackgroundParams nsNativeThemeCocoa::ComputeMenuBackgroundParams(
-    nsIFrame* aFrame, EventStates aEventState) {
-  MenuBackgroundParams params;
-  params.disabled = IsDisabled(aFrame, aEventState);
-  bool isLeftOfParent = false;
-  params.submenuRightOfParent = IsSubmenu(aFrame, &isLeftOfParent) && !isLeftOfParent;
-  return params;
-}
-
-void nsNativeThemeCocoa::DrawMenuBackground(CGContextRef cgContext, const CGRect& inBoxRect,
-                                            const MenuBackgroundParams& aParams) {
-  HIThemeMenuDrawInfo mdi;
-  memset(&mdi, 0, sizeof(mdi));
-  mdi.version = 0;
-  mdi.menuType = aParams.disabled ? static_cast<ThemeMenuType>(kThemeMenuTypeInactive)
-                                  : static_cast<ThemeMenuType>(kThemeMenuTypePopUp);
-
-  if (aParams.submenuRightOfParent) {
-    mdi.menuType = kThemeMenuTypeHierarchical;
-  }
-
-  // The rounded corners draw outside the frame.
-  CGRect deflatedRect = CGRectMake(inBoxRect.origin.x, inBoxRect.origin.y + 4, inBoxRect.size.width,
-                                   inBoxRect.size.height - 8);
-  HIThemeDrawMenuBackground(&deflatedRect, &mdi, cgContext, HITHEME_ORIENTATION);
-}
-
 static const NSSize kCheckmarkSize = NSMakeSize(11, 11);
 static const NSSize kMenuarrowSize = NSMakeSize(9, 10);
 static const NSSize kMenuScrollArrowSize = NSMakeSize(10, 8);
 static NSString* kCheckmarkImage = @"MenuOnState";
 static NSString* kMenuarrowRightImage = @"MenuSubmenu";
 static NSString* kMenuarrowLeftImage = @"MenuSubmenuLeft";
 static NSString* kMenuDownScrollArrowImage = @"MenuScrollDown";
 static NSString* kMenuUpScrollArrowImage = @"MenuScrollUp";
@@ -2926,21 +2899,16 @@ void nsNativeThemeCocoa::RenderWidget(co
       switch (widget) {
         case Widget::eColorFill:
         case Widget::eScrollbarThumb:
         case Widget::eScrollbarTrack:
         case Widget::eScrollCorner: {
           MOZ_CRASH("already handled in outer switch");
           break;
         }
-        case Widget::eMenuBackground: {
-          MenuBackgroundParams params = aWidgetInfo.Params<MenuBackgroundParams>();
-          DrawMenuBackground(cgContext, macRect, params);
-          break;
-        }
         case Widget::eMenuIcon: {
           MenuIconParams params = aWidgetInfo.Params<MenuIconParams>();
           DrawMenuIcon(cgContext, macRect, params);
           break;
         }
         case Widget::eMenuItem: {
           MenuItemParams params = aWidgetInfo.Params<MenuItemParams>();
           DrawMenuItem(cgContext, macRect, params);