Bug 1421088 - Create DrawSourceList. r=spohl
authorMarkus Stange <mstange@themasta.com>
Fri, 01 Dec 2017 18:01:16 -0500
changeset 466954 66258c83a95313769ce1ae4d48ebaf64e7598660
parent 466953 9e10ce956b5702644ff634f452c5bd0e7d550d57
child 466955 f60cf13a310f10b369ba60dab49cf7b6a98f5ebf
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 - Create DrawSourceList. r=spohl MozReview-Commit-ID: AZoLMcl9YLr
widget/cocoa/nsNativeThemeCocoa.h
widget/cocoa/nsNativeThemeCocoa.mm
--- a/widget/cocoa/nsNativeThemeCocoa.h
+++ b/widget/cocoa/nsNativeThemeCocoa.h
@@ -387,16 +387,18 @@ protected:
                      bool aIsMain);
   void DrawResizer(CGContextRef cgContext, const HIRect& aRect, bool aIsRTL);
   void DrawScrollbarThumb(CGContextRef cgContext, const CGRect& inBoxRect,
                           ScrollbarParams aParams);
   void DrawScrollbarTrack(CGContextRef cgContext, const CGRect& inBoxRect,
                           ScrollbarParams aParams);
   void DrawMultilineTextField(CGContextRef cgContext, const CGRect& inBoxRect,
                               bool aIsFocused);
+  void DrawSourceList(CGContextRef cgContext, const CGRect& inBoxRect,
+                      bool aIsActive);
 
   // Scrollbars
   nsIFrame* GetParentScrollbarFrame(nsIFrame *aFrame);
   bool IsParentScrollbarRolledOver(nsIFrame* aFrame);
 
 private:
   NSButtonCell* mDisclosureButtonCell;
   NSButtonCell* mHelpButtonCell;
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -2791,16 +2791,38 @@ nsNativeThemeCocoa::DrawMultilineTextFie
     CGContextSaveGState(cgContext);
     NSSetFocusRingStyle(NSFocusRingOnly);
     NSRectFill(NSRectFromCGRect(inBoxRect));
     CGContextRestoreGState(cgContext);
     [NSGraphicsContext setCurrentContext:savedContext];
   }
 }
 
+void
+nsNativeThemeCocoa::DrawSourceList(CGContextRef cgContext,
+                                   const CGRect& inBoxRect,
+                                   bool aIsActive)
+{
+  CGGradientRef backgroundGradient;
+  CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
+  CGFloat activeGradientColors[8] = { 0.9137, 0.9294, 0.9490, 1.0,
+                                      0.8196, 0.8471, 0.8784, 1.0 };
+  CGFloat inactiveGradientColors[8] = { 0.9686, 0.9686, 0.9686, 1.0,
+                                        0.9216, 0.9216, 0.9216, 1.0 };
+  CGPoint start = inBoxRect.origin;
+  CGPoint end = CGPointMake(inBoxRect.origin.x,
+                            inBoxRect.origin.y + inBoxRect.size.height);
+  backgroundGradient =
+    CGGradientCreateWithColorComponents(rgb, aIsActive ? activeGradientColors
+                                                        : inactiveGradientColors, NULL, 2);
+  CGContextDrawLinearGradient(cgContext, backgroundGradient, start, end, 0);
+  CGGradientRelease(backgroundGradient);
+  CGColorSpaceRelease(rgb);
+}
+
 static void
 DrawVibrancyBackground(CGContextRef cgContext, CGRect inBoxRect,
                        nsIFrame* aFrame, nsITheme::ThemeGeometryType aThemeGeometryType)
 {
   DrawVibrancyBackground(cgContext, inBoxRect,
                          VibrancyFillColor(aFrame, aThemeGeometryType), 0);
 }
 
@@ -3331,32 +3353,17 @@ nsNativeThemeCocoa::DrawWidgetBackground
     }
       break;
 
     case NS_THEME_MAC_SOURCE_LIST: {
       if (VibrancyManager::SystemSupportsVibrancy()) {
         ThemeGeometryType type = ThemeGeometryTypeForWidget(aFrame, aWidgetType);
         DrawVibrancyBackground(cgContext, macRect, aFrame, type);
       } else {
-        CGGradientRef backgroundGradient;
-        CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
-        CGFloat activeGradientColors[8] = { 0.9137, 0.9294, 0.9490, 1.0,
-                                            0.8196, 0.8471, 0.8784, 1.0 };
-        CGFloat inactiveGradientColors[8] = { 0.9686, 0.9686, 0.9686, 1.0,
-                                              0.9216, 0.9216, 0.9216, 1.0 };
-        CGPoint start = macRect.origin;
-        CGPoint end = CGPointMake(macRect.origin.x,
-                                  macRect.origin.y + macRect.size.height);
-        BOOL isActive = FrameIsInActiveWindow(aFrame);
-        backgroundGradient =
-          CGGradientCreateWithColorComponents(rgb, isActive ? activeGradientColors
-                                                            : inactiveGradientColors, NULL, 2);
-        CGContextDrawLinearGradient(cgContext, backgroundGradient, start, end, 0);
-        CGGradientRelease(backgroundGradient);
-        CGColorSpaceRelease(rgb);
+        DrawSourceList(cgContext, macRect, FrameIsInActiveWindow(aFrame));
       }
     }
       break;
 
     case NS_THEME_MAC_SOURCE_LIST_SELECTION:
     case NS_THEME_MAC_ACTIVE_SOURCE_LIST_SELECTION: {
       // If we're in XUL tree, we need to rely on the source list's clear
       // background display item. If we cleared the background behind the