Bug 1466330 - Make nsITheme::GetWidgetBorder return the border directly instead of using an out-param (idempotent patch). r=emilio
authorMats Palmgren <mats@mozilla.com>
Sat, 02 Jun 2018 19:10:48 +0200
changeset 420987 1f62ecdf59b6ecaa3c0fdda39bb296ec092a156b
parent 420986 703b0fc17e49383be3a3151e48599f5ed147beb1
child 420988 08753da56e121ff186ce5895e6b93a41dc99baf6
child 421098 15b13a9f6e9126bacbb28b626561eb7558c86ec7
push id34083
push userapavel@mozilla.com
push dateSat, 02 Jun 2018 23:03:25 +0000
treeherdermozilla-central@1f62ecdf59b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1466330
milestone62.0a1
first release with
nightly linux32
1f62ecdf59b6 / 62.0a1 / 20180602233306 / files
nightly linux64
1f62ecdf59b6 / 62.0a1 / 20180602233306 / files
nightly mac
1f62ecdf59b6 / 62.0a1 / 20180602233306 / files
nightly win32
1f62ecdf59b6 / 62.0a1 / 20180602233306 / files
nightly win64
1f62ecdf59b6 / 62.0a1 / 20180602233306 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1466330 - Make nsITheme::GetWidgetBorder return the border directly instead of using an out-param (idempotent patch). r=emilio
gfx/src/nsITheme.h
layout/generic/ReflowInput.cpp
layout/generic/nsFrame.cpp
layout/xul/nsBox.cpp
widget/android/nsNativeThemeAndroid.cpp
widget/android/nsNativeThemeAndroid.h
widget/cocoa/nsNativeThemeCocoa.h
widget/cocoa/nsNativeThemeCocoa.mm
widget/gtk/nsNativeThemeGTK.cpp
widget/gtk/nsNativeThemeGTK.h
widget/headless/HeadlessThemeGTK.cpp
widget/headless/HeadlessThemeGTK.h
widget/windows/nsNativeThemeWin.cpp
widget/windows/nsNativeThemeWin.h
--- a/gfx/src/nsITheme.h
+++ b/gfx/src/nsITheme.h
@@ -51,16 +51,19 @@ class IpcResourceUpdateQueue;
  * operations to draw a rendering object (an nsIFrame) as a native
  * widget.
  *
  * All the methods on nsITheme take a rendering context or device
  * context, a frame (the rendering object), and a widget type (one of
  * the constants in nsThemeConstants.h).
  */
 class nsITheme: public nsISupports {
+protected:
+  using LayoutDeviceIntMargin = mozilla::LayoutDeviceIntMargin;
+
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITHEME_IID)
 
   /**
    * Draw the actual theme background.
    * @param aContext the context to draw into
    * @param aFrame the frame for the widget that we're drawing
    * @param aWidgetType the -moz-appearance value to draw
@@ -91,36 +94,35 @@ public:
                                                 mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                 const mozilla::layers::StackingContextHelper& aSc,
                                                 mozilla::layers::WebRenderLayerManager* aManager,
                                                 nsIFrame* aFrame,
                                                 uint8_t aWidgetType,
                                                 const nsRect& aRect) { return false; }
 
   /**
-   * Get the border for the widget, in device pixels.
+   * Return the border for the widget, in device pixels.
    */
-  NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, 
-                             nsIFrame* aFrame,
-                             uint8_t aWidgetType,
-                             mozilla::LayoutDeviceIntMargin* aResult) = 0;
+  virtual MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext,
+                                                             nsIFrame* aFrame,
+                                                             uint8_t aWidgetType) = 0;
 
   /**
    * This method can return false to indicate that the CSS padding
    * value should be used.  Otherwise, it will fill in aResult with the
    * computed padding, in pixels, and return true.
    *
    * XXXldb This ought to be required to return true for non-containers
    * so that we don't let specified padding that has no effect change
    * the computed padding and potentially the size.
    */
   virtual bool GetWidgetPadding(nsDeviceContext* aContext,
                                   nsIFrame* aFrame,
                                   uint8_t aWidgetType,
-                                  mozilla::LayoutDeviceIntMargin* aResult) = 0;
+                                  LayoutDeviceIntMargin* aResult) = 0;
 
   /**
    * On entry, *aResult is positioned at 0,0 and sized to the new size
    * of aFrame (aFrame->GetSize() may be stale and should not be used).
    * This method can return false to indicate that no special
    * overflow area is required by the native widget. Otherwise it will
    * fill in aResult with the desired overflow area, in appunits, relative
    * to the frame origin, and return true.
--- a/layout/generic/ReflowInput.cpp
+++ b/layout/generic/ReflowInput.cpp
@@ -2593,20 +2593,19 @@ SizeComputationInput::InitOffsets(Writin
   if (!aFlags.mUseAutoBSize) {
     ApplyBaselinePadding(eLogicalAxisBlock, nsIFrame::BBaselinePadProperty());
   }
   if (!aFlags.mShrinkWrap) {
     ApplyBaselinePadding(eLogicalAxisInline, nsIFrame::IBaselinePadProperty());
   }
 
   if (isThemed) {
-    LayoutDeviceIntMargin border;
-    presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
-                                             mFrame, disp->mAppearance,
-                                             &border);
+    LayoutDeviceIntMargin border =
+      presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
+                                               mFrame, disp->mAppearance);
     ComputedPhysicalBorderPadding() =
       LayoutDevicePixel::ToAppUnits(border,
                                     presContext->AppUnitsPerDevPixel());
   }
   else if (nsSVGUtils::IsInSVGTextSubtree(mFrame)) {
     ComputedPhysicalBorderPadding().SizeTo(0, 0, 0, 0);
   }
   else if (aBorder) {  // border is an input arg
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -1376,20 +1376,20 @@ nsIFrame::GetUsedBorder() const
       nsSVGUtils::IsInSVGTextSubtree(this))
     return border;
 
   // Theme methods don't use const-ness.
   nsIFrame* mutable_this = const_cast<nsIFrame*>(this);
 
   const nsStyleDisplay* disp = StyleDisplay();
   if (mutable_this->IsThemed(disp)) {
-    LayoutDeviceIntMargin widgetBorder;
     nsPresContext* pc = PresContext();
-    pc->GetTheme()->GetWidgetBorder(pc->DeviceContext(), mutable_this,
-                                    disp->mAppearance, &widgetBorder);
+    LayoutDeviceIntMargin widgetBorder =
+      pc->GetTheme()->GetWidgetBorder(pc->DeviceContext(), mutable_this,
+                                      disp->mAppearance);
     border = LayoutDevicePixel::ToAppUnits(widgetBorder,
                                            pc->AppUnitsPerDevPixel());
     return border;
   }
 
   nsMargin* b = GetProperty(UsedBorderProperty());
   if (b) {
     border = *b;
@@ -5545,20 +5545,19 @@ IntrinsicSizeOffsets(nsIFrame* aFrame, n
     result.hBorder += styleBorder->GetComputedBorderWidth(eSideLeft);
     result.hBorder += styleBorder->GetComputedBorderWidth(eSideRight);
   }
 
   const nsStyleDisplay* disp = aFrame->StyleDisplay();
   if (aFrame->IsThemed(disp)) {
     nsPresContext* presContext = aFrame->PresContext();
 
-    LayoutDeviceIntMargin border;
-    presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
-                                             aFrame, disp->mAppearance,
-                                             &border);
+    LayoutDeviceIntMargin border =
+      presContext->GetTheme()->GetWidgetBorder(presContext->DeviceContext(),
+                                               aFrame, disp->mAppearance);
     result.hBorder =
       presContext->DevPixelsToAppUnits(verticalAxis ? border.TopBottom()
                                                     : border.LeftRight());
 
     LayoutDeviceIntMargin padding;
     if (presContext->GetTheme()->GetWidgetPadding(presContext->DeviceContext(),
                                                   aFrame, disp->mAppearance,
                                                   &padding)) {
--- a/layout/xul/nsBox.cpp
+++ b/layout/xul/nsBox.cpp
@@ -169,19 +169,19 @@ nsBox::GetXULBorder(nsMargin& aMargin)
 {
   aMargin.SizeTo(0,0,0,0);
 
   const nsStyleDisplay* disp = StyleDisplay();
   if (disp->mAppearance && gTheme) {
     // Go to the theme for the border.
     nsPresContext *context = PresContext();
     if (gTheme->ThemeSupportsWidget(context, this, disp->mAppearance)) {
-      LayoutDeviceIntMargin margin;
-      gTheme->GetWidgetBorder(context->DeviceContext(), this,
-                              disp->mAppearance, &margin);
+      LayoutDeviceIntMargin margin =
+        gTheme->GetWidgetBorder(context->DeviceContext(), this,
+                                disp->mAppearance);
       aMargin = LayoutDevicePixel::ToAppUnits(margin,
                                               context->AppUnitsPerDevPixel());
       return NS_OK;
     }
   }
 
   aMargin = StyleBorder()->GetComputedBorder();
 
--- a/widget/android/nsNativeThemeAndroid.cpp
+++ b/widget/android/nsNativeThemeAndroid.cpp
@@ -199,23 +199,21 @@ nsNativeThemeAndroid::DrawWidgetBackgrou
     default:
       MOZ_ASSERT_UNREACHABLE("Should not get here with a widget type we don't support.");
       return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
+LayoutDeviceIntMargin
 nsNativeThemeAndroid::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame,
-                                      uint8_t aWidgetType,
-                                      LayoutDeviceIntMargin* aResult)
+                                      uint8_t aWidgetType)
 {
-  *aResult = LayoutDeviceIntMargin();
-  return NS_OK;
+  return LayoutDeviceIntMargin();
 }
 
 bool
 nsNativeThemeAndroid::GetWidgetPadding(nsDeviceContext* aContext,
                                        nsIFrame* aFrame, uint8_t aWidgetType,
                                        LayoutDeviceIntMargin* aResult)
 {
   switch (aWidgetType) {
--- a/widget/android/nsNativeThemeAndroid.h
+++ b/widget/android/nsNativeThemeAndroid.h
@@ -15,24 +15,24 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   // The nsITheme interface.
   NS_IMETHOD DrawWidgetBackground(gfxContext* aContext,
                                   nsIFrame* aFrame, uint8_t aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aDirtyRect) override;
 
-  NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame,
-                             uint8_t aWidgetType,
-                             mozilla::LayoutDeviceIntMargin* aResult) override;
+  MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext,
+                                                     nsIFrame* aFrame,
+                                                     uint8_t aWidgetType) override;
 
   bool GetWidgetPadding(nsDeviceContext* aContext,
                         nsIFrame* aFrame,
                         uint8_t aWidgetType,
-                        mozilla::LayoutDeviceIntMargin* aResult) override;
+                        LayoutDeviceIntMargin* aResult) override;
 
   bool GetWidgetOverflow(nsDeviceContext* aContext,
                          nsIFrame* aFrame,
                          uint8_t aWidgetType,
                          nsRect* aOverflowRect) override;
 
   NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext,
                                   nsIFrame* aFrame, uint8_t aWidgetType,
--- a/widget/cocoa/nsNativeThemeCocoa.h
+++ b/widget/cocoa/nsNativeThemeCocoa.h
@@ -374,25 +374,24 @@ public:
                                   const nsRect& aDirtyRect) override;
   bool CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBuilder& aBuilder,
                                         mozilla::wr::IpcResourceUpdateQueue& aResources,
                                         const mozilla::layers::StackingContextHelper& aSc,
                                         mozilla::layers::WebRenderLayerManager* aManager,
                                         nsIFrame* aFrame,
                                         uint8_t aWidgetType,
                                         const nsRect& aRect) override;
-  NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext,
-                             nsIFrame* aFrame,
-                             uint8_t aWidgetType,
-                             mozilla::LayoutDeviceIntMargin* aResult) override;
+  MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext,
+                                                     nsIFrame* aFrame,
+                                                     uint8_t aWidgetType) override;
 
    bool GetWidgetPadding(nsDeviceContext* aContext,
                          nsIFrame* aFrame,
                          uint8_t aWidgetType,
-                         mozilla::LayoutDeviceIntMargin* aResult) override;
+                         LayoutDeviceIntMargin* aResult) override;
 
   virtual bool GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame,
                                    uint8_t aWidgetType, nsRect* aOverflowRect) override;
 
   NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame,
                                   uint8_t aWidgetType,
                                   mozilla::LayoutDeviceIntSize* aResult, bool* aIsOverridable) override;
   NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType, 
@@ -416,18 +415,18 @@ public:
                     const ProgressParams& aParams);
 
   static void DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
                                  CGFloat aUnifiedHeight, BOOL aIsMain, BOOL aIsFlipped);
 
 protected:
   virtual ~nsNativeThemeCocoa();
 
-  mozilla::LayoutDeviceIntMargin
-  DirectionAwareMargin(const mozilla::LayoutDeviceIntMargin& aMargin,
+  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,
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -3759,134 +3759,131 @@ nsNativeThemeCocoa::DirectionAwareMargin
                              aMargin.left).GetPhysicalMargin(wm);
   return LayoutDeviceIntMargin(m.top, m.right, m.bottom, m.left);
 }
 
 static const LayoutDeviceIntMargin kAquaDropdownBorder(1, 22, 2, 5);
 static const LayoutDeviceIntMargin kAquaComboboxBorder(3, 20, 3, 4);
 static const LayoutDeviceIntMargin kAquaSearchfieldBorder(3, 5, 2, 19);
 
-NS_IMETHODIMP
+LayoutDeviceIntMargin
 nsNativeThemeCocoa::GetWidgetBorder(nsDeviceContext* aContext,
                                     nsIFrame* aFrame,
-                                    uint8_t aWidgetType,
-                                    LayoutDeviceIntMargin* aResult)
+                                    uint8_t aWidgetType)
 {
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
-
-  aResult->SizeTo(0, 0, 0, 0);
+  LayoutDeviceIntMargin result;
+
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   switch (aWidgetType) {
     case NS_THEME_BUTTON:
     {
       if (IsButtonTypeMenu(aFrame)) {
-        *aResult = DirectionAwareMargin(kAquaDropdownBorder, aFrame);
+        result = DirectionAwareMargin(kAquaDropdownBorder, aFrame);
       } else {
-        *aResult = DirectionAwareMargin(LayoutDeviceIntMargin(1, 7, 3, 7), aFrame);
+        result = DirectionAwareMargin(LayoutDeviceIntMargin(1, 7, 3, 7), aFrame);
       }
       break;
     }
 
     case NS_THEME_TOOLBARBUTTON:
     {
-      *aResult = DirectionAwareMargin(LayoutDeviceIntMargin(1, 4, 1, 4), aFrame);
+      result = DirectionAwareMargin(LayoutDeviceIntMargin(1, 4, 1, 4), aFrame);
       break;
     }
 
     case NS_THEME_CHECKBOX:
     case NS_THEME_RADIO:
     {
       // nsCheckboxRadioFrame::GetIntrinsicWidth and nsCheckboxRadioFrame::GetIntrinsicHeight
       // assume a border width of 2px.
-      aResult->SizeTo(2, 2, 2, 2);
+      result.SizeTo(2, 2, 2, 2);
       break;
     }
 
     case NS_THEME_MENULIST:
     case NS_THEME_MENULIST_BUTTON:
-      *aResult = DirectionAwareMargin(kAquaDropdownBorder, aFrame);
+      result = DirectionAwareMargin(kAquaDropdownBorder, aFrame);
       break;
 
     case NS_THEME_MENULIST_TEXTFIELD:
-      *aResult = DirectionAwareMargin(kAquaComboboxBorder, aFrame);
+      result = DirectionAwareMargin(kAquaComboboxBorder, aFrame);
       break;
 
     case NS_THEME_NUMBER_INPUT:
     case NS_THEME_TEXTFIELD:
     {
       SInt32 frameOutset = 0;
       ::GetThemeMetric(kThemeMetricEditTextFrameOutset, &frameOutset);
 
       SInt32 textPadding = 0;
       ::GetThemeMetric(kThemeMetricEditTextWhitespace, &textPadding);
 
       frameOutset += textPadding;
 
-      aResult->SizeTo(frameOutset, frameOutset, frameOutset, frameOutset);
+      result.SizeTo(frameOutset, frameOutset, frameOutset, frameOutset);
       break;
     }
 
     case NS_THEME_TEXTFIELD_MULTILINE:
-      aResult->SizeTo(1, 1, 1, 1);
+      result.SizeTo(1, 1, 1, 1);
       break;
 
     case NS_THEME_SEARCHFIELD:
-      *aResult = DirectionAwareMargin(kAquaSearchfieldBorder, aFrame);
+      result = DirectionAwareMargin(kAquaSearchfieldBorder, aFrame);
       break;
 
     case NS_THEME_LISTBOX:
     {
       SInt32 frameOutset = 0;
       ::GetThemeMetric(kThemeMetricListBoxFrameOutset, &frameOutset);
-      aResult->SizeTo(frameOutset, frameOutset, frameOutset, frameOutset);
+      result.SizeTo(frameOutset, frameOutset, frameOutset, frameOutset);
       break;
     }
 
     case NS_THEME_SCROLLBARTRACK_HORIZONTAL:
     case NS_THEME_SCROLLBARTRACK_VERTICAL:
     {
       bool isHorizontal = (aWidgetType == NS_THEME_SCROLLBARTRACK_HORIZONTAL);
       if (nsLookAndFeel::UseOverlayScrollbars()) {
         if (!nsCocoaFeatures::OnYosemiteOrLater()) {
           // Pre-10.10, we have to center the thumb rect in the middle of the
           // scrollbar. Starting with 10.10, the expected rect for thumb
           // rendering is the full width of the scrollbar.
           if (isHorizontal) {
-            aResult->top = 2;
-            aResult->bottom = 1;
+            result.top = 2;
+            result.bottom = 1;
           } else {
-            aResult->left = 2;
-            aResult->right = 1;
+            result.left = 2;
+            result.right = 1;
           }
         }
         // Leave a bit of space at the start and the end on all OS X versions.
         if (isHorizontal) {
-          aResult->left = 1;
-          aResult->right = 1;
+          result.left = 1;
+          result.right = 1;
         } else {
-          aResult->top = 1;
-          aResult->bottom = 1;
+          result.top = 1;
+          result.bottom = 1;
         }
       }
 
       break;
     }
 
     case NS_THEME_STATUSBAR:
-      aResult->SizeTo(1, 0, 0, 0);
+      result.SizeTo(1, 0, 0, 0);
       break;
   }
 
   if (IsHiDPIContext(aContext)) {
-    *aResult = *aResult + *aResult; // doubled
+    result = result + result; // doubled
   }
 
-  return NS_OK;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
+  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(result);
 }
 
 // Return false here to indicate that CSS padding values should be used. There is
 // no reason to make a distinction between padding and border values, just specify
 // whatever values you want in GetWidgetBorder and only use this to return true
 // if you want to override CSS padding values.
 bool
 nsNativeThemeCocoa::GetWidgetPadding(nsDeviceContext* aContext,
--- a/widget/gtk/nsNativeThemeGTK.cpp
+++ b/widget/gtk/nsNativeThemeGTK.cpp
@@ -1270,54 +1270,53 @@ nsNativeThemeGTK::GetCachedWidgetBorder(
       if (aWidgetType != MOZ_GTK_DROPDOWN) { // depends on aDirection
         mBorderCacheValid[cacheIndex] |= cacheBit;
         mBorderCache[gtkWidgetType] = *aResult;
       }
     }
   }
 }
 
-NS_IMETHODIMP
+LayoutDeviceIntMargin
 nsNativeThemeGTK::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame,
-                                  uint8_t aWidgetType,
-                                  LayoutDeviceIntMargin* aResult)
+                                  uint8_t aWidgetType)
 {
+  LayoutDeviceIntMargin result;
   GtkTextDirection direction = GetTextDirection(aFrame);
-  aResult->top = aResult->left = aResult->right = aResult->bottom = 0;
   switch (aWidgetType) {
   case NS_THEME_SCROLLBAR_HORIZONTAL:
   case NS_THEME_SCROLLBAR_VERTICAL:
     {
       GtkOrientation orientation =
         aWidgetType == NS_THEME_SCROLLBAR_HORIZONTAL ?
         GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
       const ScrollbarGTKMetrics* metrics =
         GetActiveScrollbarMetrics(orientation);
 
       const GtkBorder& border = metrics->border.scrollbar;
-      aResult->top = border.top;
-      aResult->right = border.right;
-      aResult->bottom = border.bottom;
-      aResult->left = border.left;
+      result.top = border.top;
+      result.right = border.right;
+      result.bottom = border.bottom;
+      result.left = border.left;
     }
     break;
   case NS_THEME_SCROLLBARTRACK_HORIZONTAL:
   case NS_THEME_SCROLLBARTRACK_VERTICAL:
     {
       GtkOrientation orientation =
         aWidgetType == NS_THEME_SCROLLBARTRACK_HORIZONTAL ?
         GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL;
       const ScrollbarGTKMetrics* metrics =
         GetActiveScrollbarMetrics(orientation);
 
       const GtkBorder& border = metrics->border.track;
-      aResult->top = border.top;
-      aResult->right = border.right;
-      aResult->bottom = border.bottom;
-      aResult->left = border.left;
+      result.top = border.top;
+      result.right = border.right;
+      result.bottom = border.bottom;
+      result.left = border.left;
     }
     break;
   case NS_THEME_TOOLBOX:
     // gtk has no toolbox equivalent.  So, although we map toolbox to
     // gtk's 'toolbar' for purposes of painting the widget background,
     // we don't use the toolbar border for toolbox.
     break;
   case NS_THEME_DUALBUTTON:
@@ -1329,45 +1328,45 @@ nsNativeThemeGTK::GetWidgetBorder(nsDevi
     // but don't reserve any space for it.
     break;
   case NS_THEME_TAB:
     {
       WidgetNodeType gtkWidgetType;
       gint flags;
 
       if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, nullptr,
-                                &flags))
-        return NS_OK;
-
-      moz_gtk_get_tab_border(&aResult->left, &aResult->top,
-                             &aResult->right, &aResult->bottom, direction,
+                                &flags)) {
+        return result;
+      }
+      moz_gtk_get_tab_border(&result.left, &result.top,
+                             &result.right, &result.bottom, direction,
                              (GtkTabFlags)flags, gtkWidgetType);
     }
     break;
   case NS_THEME_MENUITEM:
   case NS_THEME_CHECKMENUITEM:
   case NS_THEME_RADIOMENUITEM:
     // For regular menuitems, we will be using GetWidgetPadding instead of
     // GetWidgetBorder to pad up the widget's internals; other menuitems
     // will need to fall through and use the default case as before.
     if (IsRegularMenuItem(aFrame))
       break;
     MOZ_FALLTHROUGH;
   default:
     {
-      GetCachedWidgetBorder(aFrame, aWidgetType, direction, aResult);
+      GetCachedWidgetBorder(aFrame, aWidgetType, direction, &result);
     }
   }
 
   gint scale = GetMonitorScaleFactor(aFrame);
-  aResult->top *= scale;
-  aResult->right *= scale;
-  aResult->bottom *= scale;
-  aResult->left *= scale;
-  return NS_OK;
+  result.top *= scale;
+  result.right *= scale;
+  result.bottom *= scale;
+  result.left *= scale;
+  return result;
 }
 
 bool
 nsNativeThemeGTK::GetWidgetPadding(nsDeviceContext* aContext,
                                    nsIFrame* aFrame, uint8_t aWidgetType,
                                    LayoutDeviceIntMargin* aResult)
 {
   switch (aWidgetType) {
--- a/widget/gtk/nsNativeThemeGTK.h
+++ b/widget/gtk/nsNativeThemeGTK.h
@@ -33,24 +33,24 @@ public:
   bool CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBuilder& aBuilder,
                                         mozilla::wr::IpcResourceUpdateQueue& aResources,
                                         const mozilla::layers::StackingContextHelper& aSc,
                                         mozilla::layers::WebRenderLayerManager* aManager,
                                         nsIFrame* aFrame,
                                         uint8_t aWidgetType,
                                         const nsRect& aRect) override;
 
-  NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame,
-                             uint8_t aWidgetType,
-                             mozilla::LayoutDeviceIntMargin* aResult) override;
+  MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext,
+                                                     nsIFrame* aFrame,
+                                                     uint8_t aWidgetType) override;
 
   bool GetWidgetPadding(nsDeviceContext* aContext,
                         nsIFrame* aFrame,
                         uint8_t aWidgetType,
-                        mozilla::LayoutDeviceIntMargin* aResult) override;
+                        LayoutDeviceIntMargin* aResult) override;
 
   virtual bool GetWidgetOverflow(nsDeviceContext* aContext,
                                  nsIFrame* aFrame,
                                  uint8_t aWidgetType,
                                  nsRect* aOverflowRect) override;
 
   NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext,
                                   nsIFrame* aFrame, uint8_t aWidgetType,
@@ -97,14 +97,14 @@ private:
   uint8_t mSafeWidgetStates[ThemeWidgetType_COUNT * 4]; // 32 bits per widget
   static const char* sDisabledEngines[];
 
   // Because moz_gtk_get_widget_border can be slow, we cache its results
   // by widget type.  Each bit in mBorderCacheValid says whether the
   // corresponding entry in mBorderCache is valid.
   void GetCachedWidgetBorder(nsIFrame* aFrame, uint8_t aWidgetType,
                              GtkTextDirection aDirection,
-                             mozilla::LayoutDeviceIntMargin* aResult);
+                             LayoutDeviceIntMargin* aResult);
   uint8_t mBorderCacheValid[(MOZ_GTK_WIDGET_NODE_COUNT + 7) / 8];
-  mozilla::LayoutDeviceIntMargin mBorderCache[MOZ_GTK_WIDGET_NODE_COUNT];
+  LayoutDeviceIntMargin mBorderCache[MOZ_GTK_WIDGET_NODE_COUNT];
 };
 
 #endif
--- a/widget/headless/HeadlessThemeGTK.cpp
+++ b/widget/headless/HeadlessThemeGTK.cpp
@@ -18,106 +18,105 @@ HeadlessThemeGTK::DrawWidgetBackground(g
                                        nsIFrame* aFrame,
                                        uint8_t aWidgetType,
                                        const nsRect& aRect,
                                        const nsRect& aDirtyRect)
 {
   return NS_OK;
 }
 
-NS_IMETHODIMP
+LayoutDeviceIntMargin
 HeadlessThemeGTK::GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame,
-                                  uint8_t aWidgetType,
-                                  LayoutDeviceIntMargin* aResult)
+                                  uint8_t aWidgetType)
 {
-  aResult->top = aResult->right = aResult->bottom = aResult->left = 0;
+  LayoutDeviceIntMargin result;
   // The following values are generated from the Ubuntu GTK theme.
   switch (aWidgetType) {
     case NS_THEME_BUTTON:
     case NS_THEME_TOOLBARBUTTON:
-      aResult->top = 6;
-      aResult->right = 7;
-      aResult->bottom = 6;
-      aResult->left = 7;
+      result.top = 6;
+      result.right = 7;
+      result.bottom = 6;
+      result.left = 7;
       break;
     case NS_THEME_FOCUS_OUTLINE:
     case NS_THEME_NUMBER_INPUT:
     case NS_THEME_TEXTFIELD:
-      aResult->top = 5;
-      aResult->right = 7;
-      aResult->bottom = 5;
-      aResult->left = 7;
+      result.top = 5;
+      result.right = 7;
+      result.bottom = 5;
+      result.left = 7;
       break;
     case NS_THEME_STATUSBARPANEL:
     case NS_THEME_RESIZERPANEL:
     case NS_THEME_LISTBOX:
     case NS_THEME_TREEVIEW:
     case NS_THEME_TREEHEADERSORTARROW:
     case NS_THEME_PROGRESSBAR:
     case NS_THEME_PROGRESSBAR_VERTICAL:
     case NS_THEME_SPINNER_UPBUTTON:
     case NS_THEME_SPINNER_DOWNBUTTON:
     case NS_THEME_SPINNER_TEXTFIELD:
     case NS_THEME_TEXTFIELD_MULTILINE:
     case NS_THEME_MENUPOPUP:
     case NS_THEME_GTK_INFO_BAR:
-      aResult->top = 1;
-      aResult->right = 1;
-      aResult->bottom = 1;
-      aResult->left = 1;
+      result.top = 1;
+      result.right = 1;
+      result.bottom = 1;
+      result.left = 1;
       break;
     case NS_THEME_TREEHEADERCELL:
-      aResult->top = 5;
-      aResult->right = 7;
-      aResult->bottom = 6;
-      aResult->left = 6;
+      result.top = 5;
+      result.right = 7;
+      result.bottom = 6;
+      result.left = 6;
       break;
     case NS_THEME_TAB:
-      aResult->top = 4;
-      aResult->right = 7;
-      aResult->bottom = 2;
-      aResult->left = 7;
+      result.top = 4;
+      result.right = 7;
+      result.bottom = 2;
+      result.left = 7;
       break;
     case NS_THEME_TOOLTIP:
-      aResult->top = 6;
-      aResult->right = 6;
-      aResult->bottom = 6;
-      aResult->left = 6;
+      result.top = 6;
+      result.right = 6;
+      result.bottom = 6;
+      result.left = 6;
       break;
     case NS_THEME_MENULIST:
-      aResult->top = 6;
-      aResult->right = 22;
-      aResult->bottom = 6;
-      aResult->left = 7;
+      result.top = 6;
+      result.right = 22;
+      result.bottom = 6;
+      result.left = 7;
       break;
     case NS_THEME_MENULIST_BUTTON:
-      aResult->top = 1;
-      aResult->right = 1;
-      aResult->bottom = 1;
-      aResult->left = 0;
+      result.top = 1;
+      result.right = 1;
+      result.bottom = 1;
+      result.left = 0;
       break;
     case NS_THEME_MENULIST_TEXTFIELD:
-      aResult->top = 1;
-      aResult->right = 0;
-      aResult->bottom = 1;
-      aResult->left = 1;
+      result.top = 1;
+      result.right = 0;
+      result.bottom = 1;
+      result.left = 1;
       break;
     case NS_THEME_MENUITEM:
     case NS_THEME_CHECKMENUITEM:
     case NS_THEME_RADIOMENUITEM:
       if (IsRegularMenuItem(aFrame)) {
         break;
       }
-      aResult->top = 3;
-      aResult->right = 5;
-      aResult->bottom = 3;
-      aResult->left = 5;
+      result.top = 3;
+      result.right = 5;
+      result.bottom = 3;
+      result.left = 5;
       break;
   }
-  return NS_OK;
+  return result;
 }
 
 bool
 HeadlessThemeGTK::GetWidgetPadding(nsDeviceContext* aContext,
                                    nsIFrame* aFrame, uint8_t aWidgetType,
                                    LayoutDeviceIntMargin* aResult)
 {
   // The following values are generated from the Ubuntu GTK theme.
--- a/widget/headless/HeadlessThemeGTK.h
+++ b/widget/headless/HeadlessThemeGTK.h
@@ -18,24 +18,24 @@ public:
   NS_DECL_ISUPPORTS_INHERITED
 
   HeadlessThemeGTK() = default;
   NS_IMETHOD DrawWidgetBackground(gfxContext* aContext,
                                   nsIFrame* aFrame, uint8_t aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aDirtyRect) override;
 
-  NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, nsIFrame* aFrame,
-                             uint8_t aWidgetType,
-                             mozilla::LayoutDeviceIntMargin* aResult) override;
+  MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext,
+                                                     nsIFrame* aFrame,
+                                                     uint8_t aWidgetType) override;
 
   bool GetWidgetPadding(nsDeviceContext* aContext,
                         nsIFrame* aFrame,
                         uint8_t aWidgetType,
-                        mozilla::LayoutDeviceIntMargin* aResult) override;
+                        LayoutDeviceIntMargin* aResult) override;
   NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext,
                                   nsIFrame* aFrame, uint8_t aWidgetType,
                                   mozilla::LayoutDeviceIntSize* aResult,
                                   bool* aIsOverridable) override;
 
   NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, uint8_t aWidgetType,
                                 nsAtom* aAttribute,
                                 bool* aShouldRepaint,
--- a/widget/windows/nsNativeThemeWin.cpp
+++ b/widget/windows/nsNativeThemeWin.cpp
@@ -605,55 +605,54 @@ nsNativeThemeWin::DrawThemedProgressMete
                         &adjClipRect);
 
     if (!QueueAnimatedContentForRefresh(aFrame->GetContent(), 60)) {
       NS_WARNING("unable to animate progress widget!");
     }
   }
 }
 
-nsresult nsNativeThemeWin::GetCachedWidgetBorder(nsIFrame* aFrame,
-                                                 HTHEME aTheme,
-                                                 nsUXThemeClass aThemeClass,
-                                                 uint8_t aWidgetType,
-                                                 int32_t aPart,
-                                                 int32_t aState,
-                                                 LayoutDeviceIntMargin* aResult)
+LayoutDeviceIntMargin
+nsNativeThemeWin::GetCachedWidgetBorder(HTHEME aTheme,
+                                        nsUXThemeClass aThemeClass,
+                                        uint8_t aWidgetType,
+                                        int32_t aPart,
+                                        int32_t aState)
 {
   int32_t cacheIndex = aThemeClass * THEME_PART_DISTINCT_VALUE_COUNT + aPart;
   int32_t cacheBitIndex = cacheIndex / 8;
   uint8_t cacheBit = 1u << (cacheIndex % 8);
 
   if (mBorderCacheValid[cacheBitIndex] & cacheBit) {
-    *aResult = mBorderCache[cacheIndex];
-    return NS_OK;
+    return mBorderCache[cacheIndex];
   }
 
   // Get our info.
   RECT outerRect; // Create a fake outer rect.
   outerRect.top = outerRect.left = 100;
   outerRect.right = outerRect.bottom = 200;
   RECT contentRect(outerRect);
   HRESULT res = GetThemeBackgroundContentRect(aTheme, nullptr, aPart, aState, &outerRect, &contentRect);
 
   if (FAILED(res)) {
-    return NS_ERROR_FAILURE;
+    return LayoutDeviceIntMargin();
   }
 
   // Now compute the delta in each direction and place it in our
   // nsIntMargin struct.
-  aResult->top = contentRect.top - outerRect.top;
-  aResult->bottom = outerRect.bottom - contentRect.bottom;
-  aResult->left = contentRect.left - outerRect.left;
-  aResult->right = outerRect.right - contentRect.right;
+  LayoutDeviceIntMargin result;
+  result.top = contentRect.top - outerRect.top;
+  result.bottom = outerRect.bottom - contentRect.bottom;
+  result.left = contentRect.left - outerRect.left;
+  result.right = outerRect.right - contentRect.right;
 
   mBorderCacheValid[cacheBitIndex] |= cacheBit;
-  mBorderCache[cacheIndex] = *aResult;
-
-  return NS_OK;
+  mBorderCache[cacheIndex] = result;
+
+  return result;
 }
 
 nsresult nsNativeThemeWin::GetCachedMinimumWidgetSize(nsIFrame * aFrame, HANDLE aTheme,
                                                       nsUXThemeClass aThemeClass, uint8_t aWidgetType,
                                                       int32_t aPart, int32_t aState, THEMESIZE aSizeReq,
                                                       mozilla::LayoutDeviceIntSize * aResult)
 {
   int32_t cachePart = aPart;
@@ -1867,24 +1866,23 @@ RENDER_AGAIN:
   }
   else if (aWidgetType == NS_THEME_PROGRESSCHUNK ||
            aWidgetType == NS_THEME_PROGRESSCHUNK_VERTICAL) {
     DrawThemedProgressMeter(aFrame, aWidgetType, theme, hdc, part, state,
                             &widgetRect, &clipRect);
   }
   else if (aWidgetType == NS_THEME_FOCUS_OUTLINE) {
     // Inflate 'widgetRect' with the focus outline size.
-    LayoutDeviceIntMargin border;
-    if (NS_SUCCEEDED(GetWidgetBorder(aFrame->PresContext()->DeviceContext(),
-                                     aFrame, aWidgetType, &border))) {
-      widgetRect.left -= border.left;
-      widgetRect.right += border.right;
-      widgetRect.top -= border.top;
-      widgetRect.bottom += border.bottom;
-    }
+    LayoutDeviceIntMargin border =
+      GetWidgetBorder(aFrame->PresContext()->DeviceContext(),
+                      aFrame, aWidgetType);
+    widgetRect.left -= border.left;
+    widgetRect.right += border.right;
+    widgetRect.top -= border.top;
+    widgetRect.bottom += border.bottom;
 
     DTBGOPTS opts = {
       sizeof(DTBGOPTS),
       DTBG_OMITCONTENT | DTBG_CLIPRECT,
       clipRect
     };
     DrawThemeBackgroundEx(theme, hdc, part, state, &widgetRect, &opts);
   }
@@ -2027,95 +2025,91 @@ ScaleForFrameDPI(LayoutDeviceIntSize* aS
 {
   double themeScale = GetThemeDpiScaleFactor(aFrame);
   if (themeScale != 1.0) {
     aSize->width = NSToIntRound(aSize->width * themeScale);
     aSize->height = NSToIntRound(aSize->height * themeScale);
   }
 }
 
-NS_IMETHODIMP
+LayoutDeviceIntMargin
 nsNativeThemeWin::GetWidgetBorder(nsDeviceContext* aContext, 
                                   nsIFrame* aFrame,
-                                  uint8_t aWidgetType,
-                                  LayoutDeviceIntMargin* aResult)
+                                  uint8_t aWidgetType)
 {
+  LayoutDeviceIntMargin result;
   mozilla::Maybe<nsUXThemeClass> themeClass = GetThemeClass(aWidgetType);
   HTHEME theme = NULL;
   if (!themeClass.isNothing()) {
     theme = nsUXThemeData::GetTheme(themeClass.value());
   }
-  nsresult rv = NS_OK;
   if (!theme) {
-    rv = ClassicGetWidgetBorder(aContext, aFrame, aWidgetType, aResult);
-    ScaleForFrameDPI(aResult, aFrame);
-    return rv;
+    result = ClassicGetWidgetBorder(aContext, aFrame, aWidgetType);
+    ScaleForFrameDPI(&result, aFrame);
+    return result;
   }
 
-  aResult->top = aResult->bottom = aResult->left = aResult->right = 0;
-
   if (!WidgetIsContainer(aWidgetType) ||
       aWidgetType == NS_THEME_TOOLBOX || 
       aWidgetType == NS_THEME_WIN_MEDIA_TOOLBOX ||
       aWidgetType == NS_THEME_WIN_COMMUNICATIONS_TOOLBOX ||
       aWidgetType == NS_THEME_WIN_BROWSERTABBAR_TOOLBOX ||
       aWidgetType == NS_THEME_STATUSBAR || 
       aWidgetType == NS_THEME_RESIZER || aWidgetType == NS_THEME_TABPANEL ||
       aWidgetType == NS_THEME_SCROLLBAR_HORIZONTAL ||
       aWidgetType == NS_THEME_SCROLLBAR_VERTICAL ||
       aWidgetType == NS_THEME_MENUITEM || aWidgetType == NS_THEME_CHECKMENUITEM ||
       aWidgetType == NS_THEME_RADIOMENUITEM || aWidgetType == NS_THEME_MENUPOPUP ||
       aWidgetType == NS_THEME_MENUIMAGE || aWidgetType == NS_THEME_MENUITEMTEXT ||
       aWidgetType == NS_THEME_SEPARATOR ||
       aWidgetType == NS_THEME_WINDOW_TITLEBAR ||
       aWidgetType == NS_THEME_WINDOW_TITLEBAR_MAXIMIZED ||
       aWidgetType == NS_THEME_WIN_GLASS || aWidgetType == NS_THEME_WIN_BORDERLESS_GLASS)
-    return NS_OK; // Don't worry about it.
+    return result; // Don't worry about it.
 
   int32_t part, state;
-  rv = GetThemePartAndState(aFrame, aWidgetType, part, state);
+  nsresult rv = GetThemePartAndState(aFrame, aWidgetType, part, state);
   if (NS_FAILED(rv))
-    return rv;
+    return result;
 
   if (aWidgetType == NS_THEME_TOOLBAR) {
     // make space for the separator line above all toolbars but the first
     if (state == 0)
-      aResult->top = TB_SEPARATOR_HEIGHT;
-    return NS_OK;
+      result.top = TB_SEPARATOR_HEIGHT;
+    return result;
   }
 
-  rv = GetCachedWidgetBorder(aFrame, theme, themeClass.value(), aWidgetType, part, state, aResult);
-  NS_ENSURE_SUCCESS(rv, rv);
+  result = GetCachedWidgetBorder(theme, themeClass.value(), aWidgetType, part, state);
 
   // Remove the edges for tabs that are before or after the selected tab,
   if (aWidgetType == NS_THEME_TAB) {
     if (IsLeftToSelectedTab(aFrame))
       // Remove the right edge, since we won't be drawing it.
-      aResult->right = 0;
+      result.right = 0;
     else if (IsRightToSelectedTab(aFrame))
       // Remove the left edge, since we won't be drawing it.
-      aResult->left = 0;
+      result.left = 0;
   }
 
   if (aFrame && (aWidgetType == NS_THEME_NUMBER_INPUT ||
                  aWidgetType == NS_THEME_TEXTFIELD ||
                  aWidgetType == NS_THEME_TEXTFIELD_MULTILINE)) {
     nsIContent* content = aFrame->GetContent();
     if (content && content->IsHTMLElement()) {
       // We need to pad textfields by 1 pixel, since the caret will draw
       // flush against the edge by default if we don't.
-      aResult->top++;
-      aResult->left++;
-      aResult->bottom++;
-      aResult->right++;
+      result.top++;
+      result.left++;
+      result.bottom++;
+      result.right++;
     }
   }
 
-  ScaleForFrameDPI(aResult, aFrame);
-  return rv;
+  ScaleForFrameDPI(&result, aFrame);
+  return result;
 }
 
 bool
 nsNativeThemeWin::GetWidgetPadding(nsDeviceContext* aContext, 
                                    nsIFrame* aFrame,
                                    uint8_t aWidgetType,
                                    LayoutDeviceIntMargin* aResult)
 {
@@ -2288,27 +2282,25 @@ nsNativeThemeWin::GetWidgetOverflow(nsDe
     /* Note: no overflow on the left */
     nsMargin m(p2a, p2a, p2a, 0);
     aOverflowRect->Inflate (m);
     return true;
   }
 #endif
 
   if (aWidgetType == NS_THEME_FOCUS_OUTLINE) {
-    LayoutDeviceIntMargin border;
-    nsresult rv = GetWidgetBorder(aContext, aFrame, aWidgetType, &border);
-    if (NS_SUCCEEDED(rv)) {
-      int32_t p2a = aContext->AppUnitsPerDevPixel();
-      nsMargin m(NSIntPixelsToAppUnits(border.top, p2a),
-                 NSIntPixelsToAppUnits(border.right, p2a),
-                 NSIntPixelsToAppUnits(border.bottom, p2a),
-                 NSIntPixelsToAppUnits(border.left, p2a));
-      aOverflowRect->Inflate(m);
-      return true;
-    }
+    LayoutDeviceIntMargin border =
+      GetWidgetBorder(aContext, aFrame, aWidgetType);
+    int32_t p2a = aContext->AppUnitsPerDevPixel();
+    nsMargin m(NSIntPixelsToAppUnits(border.top, p2a),
+               NSIntPixelsToAppUnits(border.right, p2a),
+               NSIntPixelsToAppUnits(border.bottom, p2a),
+               NSIntPixelsToAppUnits(border.left, p2a));
+    aOverflowRect->Inflate(m);
+    return true;
   }
 
   return false;
 }
 
 NS_IMETHODIMP
 nsNativeThemeWin::GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame,
                                        uint8_t aWidgetType,
@@ -2838,68 +2830,68 @@ nsNativeThemeWin::ClassicThemeSupportsWi
     case NS_THEME_WINDOW_BUTTON_RESTORE:
     case NS_THEME_WINDOW_BUTTON_BOX:
     case NS_THEME_WINDOW_BUTTON_BOX_MAXIMIZED:
       return true;
   }
   return false;
 }
 
-nsresult
+LayoutDeviceIntMargin
 nsNativeThemeWin::ClassicGetWidgetBorder(nsDeviceContext* aContext, 
-                                  nsIFrame* aFrame,
-                                  uint8_t aWidgetType,
-                                  LayoutDeviceIntMargin* aResult)
+                                         nsIFrame* aFrame,
+                                         uint8_t aWidgetType)
 {
+  LayoutDeviceIntMargin result;
   switch (aWidgetType) {
     case NS_THEME_GROUPBOX:
     case NS_THEME_BUTTON:
-      (*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 2; 
+      result.top = result.left = result.bottom = result.right = 2;
       break;
     case NS_THEME_STATUSBAR:
-      (*aResult).bottom = (*aResult).left = (*aResult).right = 0;
-      (*aResult).top = 2;
+      result.bottom = result.left = result.right = 0;
+      result.top = 2;
       break;
     case NS_THEME_LISTBOX:
     case NS_THEME_TREEVIEW:
     case NS_THEME_MENULIST:
     case NS_THEME_MENULIST_TEXTFIELD:
     case NS_THEME_TAB:
     case NS_THEME_NUMBER_INPUT:
     case NS_THEME_TEXTFIELD:
     case NS_THEME_TEXTFIELD_MULTILINE:
     case NS_THEME_FOCUS_OUTLINE:
-      (*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 2;
+      result.top = result.left = result.bottom = result.right = 2;
       break;
     case NS_THEME_STATUSBARPANEL:
     case NS_THEME_RESIZERPANEL: {
-      (*aResult).top = 1;      
-      (*aResult).left = 1;
-      (*aResult).bottom = 1;
-      (*aResult).right = aFrame->GetNextSibling() ? 3 : 1;
+      result.top = 1;
+      result.left = 1;
+      result.bottom = 1;
+      result.right = aFrame->GetNextSibling() ? 3 : 1;
       break;
-    }    
+    }
     case NS_THEME_TOOLTIP:
-      (*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 1;
+      result.top = result.left = result.bottom = result.right = 1;
       break;
     case NS_THEME_PROGRESSBAR:
     case NS_THEME_PROGRESSBAR_VERTICAL:
-      (*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 1;
+      result.top = result.left = result.bottom = result.right = 1;
       break;
     case NS_THEME_MENUBAR:
-      (*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 0;
+      result.top = result.left = result.bottom = result.right = 0;
       break;
     case NS_THEME_MENUPOPUP:
-      (*aResult).top = (*aResult).left = (*aResult).bottom = (*aResult).right = 3;
+      result.top = result.left = result.bottom = result.right = 3;
       break;
     default:
-      (*aResult).top = (*aResult).bottom = (*aResult).left = (*aResult).right = 0;
+      result.top = result.bottom = result.left = result.right = 0;
       break;
   }
-  return NS_OK;
+  return result;
 }
 
 bool
 nsNativeThemeWin::ClassicGetWidgetPadding(nsDeviceContext* aContext,
                                    nsIFrame* aFrame,
                                    uint8_t aWidgetType,
                                    LayoutDeviceIntMargin* aResult)
 {
--- a/widget/windows/nsNativeThemeWin.h
+++ b/widget/windows/nsNativeThemeWin.h
@@ -35,25 +35,24 @@ public:
                                   nsIFrame* aFrame,
                                   uint8_t aWidgetType,
                                   const nsRect& aRect,
                                   const nsRect& aDirtyRect) override;
 
   nscolor GetWidgetAutoColor(mozilla::ComputedStyle* aStyle,
                              uint8_t aWidgetType) override;
 
-  NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext, 
-                             nsIFrame* aFrame,
-                             uint8_t aWidgetType,
-                             mozilla::LayoutDeviceIntMargin* aResult) override;
+  MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext,
+                                                     nsIFrame* aFrame,
+                                                     uint8_t aWidgetType) override;
 
   bool GetWidgetPadding(nsDeviceContext* aContext,
                         nsIFrame* aFrame,
                         uint8_t aWidgetType,
-                        mozilla::LayoutDeviceIntMargin* aResult) override;
+                        LayoutDeviceIntMargin* aResult) override;
 
   virtual bool GetWidgetOverflow(nsDeviceContext* aContext,
                                    nsIFrame* aFrame,
                                    uint8_t aWidgetType,
                                    nsRect* aOverflowRect) override;
 
   NS_IMETHOD GetMinimumWidgetSize(nsPresContext* aPresContext, nsIFrame* aFrame,
                                   uint8_t aWidgetType,
@@ -95,24 +94,23 @@ protected:
                                 int32_t& aPart, int32_t& aState);
   nsresult ClassicGetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
                                        int32_t& aPart, int32_t& aState, bool& aFocused);
   nsresult ClassicDrawWidgetBackground(gfxContext* aContext,
                                        nsIFrame* aFrame,
                                        uint8_t aWidgetType,
                                        const nsRect& aRect,
                                        const nsRect& aClipRect);
-  nsresult ClassicGetWidgetBorder(nsDeviceContext* aContext, 
-                                  nsIFrame* aFrame,
-                                  uint8_t aWidgetType,
-                                  mozilla::LayoutDeviceIntMargin* aResult);
+  MOZ_MUST_USE LayoutDeviceIntMargin ClassicGetWidgetBorder(nsDeviceContext* aContext,
+                                                            nsIFrame* aFrame,
+                                                            uint8_t aWidgetType);
   bool ClassicGetWidgetPadding(nsDeviceContext* aContext,
                                nsIFrame* aFrame,
                                uint8_t aWidgetType,
-                               mozilla::LayoutDeviceIntMargin* aResult);
+                               LayoutDeviceIntMargin* aResult);
   nsresult ClassicGetMinimumWidgetSize(nsIFrame* aFrame, uint8_t aWidgetType,
                                        mozilla::LayoutDeviceIntSize* aResult,
                                        bool* aIsOverridable);
   bool ClassicThemeSupportsWidget(nsIFrame* aFrame, uint8_t aWidgetType);
   void DrawCheckedRect(HDC hdc, const RECT& rc, int32_t fore, int32_t back,
                        HBRUSH defaultBack);
   nsresult DrawCustomScrollbarPart(gfxContext* aContext,
                                    nsIFrame* aFrame,
@@ -126,19 +124,21 @@ protected:
   RECT CalculateProgressOverlayRect(nsIFrame* aFrame, RECT* aWidgetRect,
                                     bool aIsVertical, bool aIsIndeterminate,
                                     bool aIsClassic);
   void DrawThemedProgressMeter(nsIFrame* aFrame, int aWidgetType,
                                HANDLE aTheme, HDC aHdc,
                                int aPart, int aState,
                                RECT* aWidgetRect, RECT* aClipRect);
 
-  nsresult GetCachedWidgetBorder(nsIFrame* aFrame, HANDLE aTheme, nsUXThemeClass aThemeClass,
-                                 uint8_t aWidgetType, int32_t aPart, int32_t aState,
-                                 mozilla::LayoutDeviceIntMargin* aResult);
+  MOZ_MUST_USE LayoutDeviceIntMargin GetCachedWidgetBorder(HANDLE aTheme,
+                                                           nsUXThemeClass aThemeClass,
+                                                           uint8_t aWidgetType,
+                                                           int32_t aPart,
+                                                           int32_t aState);
 
   nsresult GetCachedMinimumWidgetSize(nsIFrame* aFrame, HANDLE aTheme, nsUXThemeClass aThemeClass,
                                       uint8_t aWidgetType, int32_t aPart, int32_t aState,
                                       THEMESIZE aSizeReq, mozilla::LayoutDeviceIntSize* aResult);
 
   SIZE GetCachedGutterSize(HANDLE theme);
 
 private:
@@ -146,17 +146,17 @@ private:
   TimeStamp mProgressIndeterminateTimeStamp;
 
   // eUXNumClasses * THEME_PART_DISTINCT_VALUE_COUNT is about 800 at the time of writing
   // this, and nsIntMargin is 16 bytes wide, which makes this cache (1/8 + 16) * 800
   // bytes, or about ~12KB. We could probably reduce this cache to 3KB by caching on
   // the aWidgetType value instead, but there would be some uncacheable values, since
   // we derive some theme parts from other arguments.
   uint8_t mBorderCacheValid[(eUXNumClasses * THEME_PART_DISTINCT_VALUE_COUNT + 7) / 8];
-  mozilla::LayoutDeviceIntMargin mBorderCache[eUXNumClasses * THEME_PART_DISTINCT_VALUE_COUNT];
+  LayoutDeviceIntMargin mBorderCache[eUXNumClasses * THEME_PART_DISTINCT_VALUE_COUNT];
 
   // See the above not for mBorderCache and friends. However mozilla::LayoutDeviceIntSize
   // is half the size of nsIntMargin, making the cache roughly half as large. In total
   // the caches should come to about 18KB.
   uint8_t mMinimumWidgetSizeCacheValid[(eUXNumClasses * THEME_PART_DISTINCT_VALUE_COUNT + 7) / 8];
   mozilla::LayoutDeviceIntSize mMinimumWidgetSizeCache[eUXNumClasses * THEME_PART_DISTINCT_VALUE_COUNT];
 
   bool mGutterSizeCacheValid;