Don't pass an nsIFrame to DrawSearchField. draft
authorMarkus Stange <mstange@themasta.com>
Fri, 17 Nov 2017 17:04:34 -0500
changeset 700296 74f2f55ce5a12314ab8f7cd6fe9b48c427821f46
parent 700295 60e829297ac3797879ffd987de4651da3ca60570
child 700297 df935d7713334c860a3582e3a57378c3f00b6861
push id89787
push userbmo:mstange@themasta.com
push dateSun, 19 Nov 2017 21:49:28 +0000
milestone59.0a1
Don't pass an nsIFrame to DrawSearchField.
widget/cocoa/nsNativeThemeCocoa.h
widget/cocoa/nsNativeThemeCocoa.mm
--- a/widget/cocoa/nsNativeThemeCocoa.h
+++ b/widget/cocoa/nsNativeThemeCocoa.h
@@ -191,17 +191,18 @@ protected:
                  mozilla::EventStates inState, bool inDirection,
                  bool inIsReverse, int32_t inCurrentValue, int32_t inMinValue,
                  int32_t inMaxValue, nsIFrame* aFrame);
   void DrawCheckboxOrRadio(CGContextRef cgContext, bool inCheckbox,
                            const HIRect& inBoxRect, CheckboxOrRadioState aState,
                            ButtonParams aButtonParams,
                            float aVerticalAlignFactor);
   void DrawSearchField(CGContextRef cgContext, const HIRect& inBoxRect,
-                       nsIFrame* aFrame, mozilla::EventStates inState);
+                       bool aIsInsideToolbar, bool aIsDisabled, bool aIsFocused,
+                       bool aIsRTL, float aVerticalAlignFactor);
   void DrawRoundedBezelPushButton(CGContextRef cgContext,
                                   const HIRect& inBoxRect,
                                   ButtonParams aButtonParams);
   void DrawSquareBezelPushButton(CGContextRef cgContext,
                                  const HIRect& inBoxRect,
                                  ButtonParams aButtonParams);
   void DrawHelpButton(CGContextRef cgContext, const HIRect& inBoxRect,
                       ButtonParams aButtonParams);
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -1092,32 +1092,33 @@ IsInsideToolbar(nsIFrame* aFrame)
       return true;
     }
   }
   return false;
 }
 
 void
 nsNativeThemeCocoa::DrawSearchField(CGContextRef cgContext, const HIRect& inBoxRect,
-                                    nsIFrame* aFrame, EventStates inState)
+                                    bool aIsInsideToolbar, bool aIsDisabled,
+                                    bool aIsFocused, bool aIsRTL,
+                                    float aVerticalAlignFactor)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   NSSearchFieldCell* cell =
-    IsInsideToolbar(aFrame) ? mToolbarSearchFieldCell : mSearchFieldCell;
-  [cell setEnabled:!IsDisabled(aFrame, inState)];
-  [cell setShowsFirstResponder:IsFocused(aFrame)];
+    aIsInsideToolbar ? mToolbarSearchFieldCell : mSearchFieldCell;
+  [cell setEnabled:!aIsDisabled];
+  [cell setShowsFirstResponder:aIsFocused];
 
   // When using the 10.11 SDK, the default string will be shown if we don't
   // set the placeholder string.
   [cell setPlaceholderString:@""];
 
   DrawCellWithSnapping(cell, cgContext, inBoxRect, searchFieldSettings,
-                       VerticalAlignFactor(aFrame), mCellDrawView,
-                       IsFrameRTL(aFrame));
+                       aVerticalAlignFactor, mCellDrawView, aIsRTL);
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 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";
@@ -2836,17 +2837,19 @@ nsNativeThemeCocoa::DrawWidgetBackground
 
       DrawTextBox(cgContext, macRect,
                   IsDisabled(aFrame, eventState) || IsReadOnly(aFrame),
                   isFocused);
     }
       break;
 
     case NS_THEME_SEARCHFIELD:
-      DrawSearchField(cgContext, macRect, aFrame, eventState);
+      DrawSearchField(cgContext, macRect, IsInsideToolbar(aFrame),
+                      IsDisabled(aFrame, eventState), IsFocused(aFrame),
+                      IsFrameRTL(aFrame), VerticalAlignFactor(aFrame));
       break;
 
     case NS_THEME_PROGRESSBAR:
     {
       double value = GetProgressValue(aFrame);
       double maxValue = GetProgressMaxValue(aFrame);
       // Don't request repaints for scrollbars at 100% because those don't animate.
       if (value < maxValue) {