Bug 1258711 - Skip the pixel cap when drawing scrollbar tracks or thumbs, since they don't use intermediate surfaces internally to CoreUI, and shouldn't blow up. r=mstange, a=lizzard
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 11 Apr 2016 09:53:17 -0400
changeset 323930 527bc99e29e1e05c9c487b61e159bb1cbc2cb28e
parent 323929 7d39fe1e571c9bd656d66e05732ebd11419c5e77
child 323931 f45daad066f8ce75602ad61d800253d689edd9e2
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, lizzard
bugs1258711
milestone47.0a2
Bug 1258711 - Skip the pixel cap when drawing scrollbar tracks or thumbs, since they don't use intermediate surfaces internally to CoreUI, and shouldn't blow up. r=mstange, a=lizzard MozReview-Commit-ID: BrSqOnwEKUf
widget/cocoa/nsNativeThemeCocoa.mm
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -896,19 +896,19 @@ static void DrawCellWithSnapping(NSCell 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 @interface NSWindow(CoreUIRendererPrivate)
 + (CUIRendererRef)coreUIRenderer;
 @end
 
 static void
-RenderWithCoreUILegacy(CGRect aRect, CGContextRef cgContext, NSDictionary* aOptions)
+RenderWithCoreUILegacy(CGRect aRect, CGContextRef cgContext, NSDictionary* aOptions, bool aSkipAreaCheck)
 {
-  if (aRect.size.width * aRect.size.height <= BITMAP_MAX_AREA) {
+  if (aSkipAreaCheck || (aRect.size.width * aRect.size.height <= BITMAP_MAX_AREA)) {
     CUIRendererRef renderer = [NSWindow respondsToSelector:@selector(coreUIRenderer)]
       ? [NSWindow coreUIRenderer] : nil;
     CUIDraw(renderer, aRect, cgContext, (CFDictionaryRef)aOptions, NULL);
   }
 }
 
 static id
 GetAquaAppearance()
@@ -941,17 +941,17 @@ RenderWithCoreUI(CGRect aRect, CGContext
   if (appearance && [appearance respondsToSelector:@selector(_drawInRect:context:options:)]) {
     // Render through NSAppearance on Mac OS 10.10 and up. This will call
     // CUIDraw with a CoreUI renderer that will give us the correct 10.10
     // style. Calling CUIDraw directly with [NSWindow coreUIRenderer] still
     // renders 10.9-style widgets on 10.10.
     [appearance _drawInRect:aRect context:cgContext options:aOptions];
   } else {
     // 10.9 and below
-    RenderWithCoreUILegacy(aRect, cgContext, aOptions);
+    RenderWithCoreUILegacy(aRect, cgContext, aOptions, false);
   }
 }
 
 static float VerticalAlignFactor(nsIFrame *aFrame)
 {
   if (!aFrame)
     return 0.5f; // default: center
 
@@ -2897,17 +2897,18 @@ nsNativeThemeCocoa::DrawWidgetBackground
                   (isOverlay ? @"kCUIWidgetOverlayScrollBar" : @"scrollbar"), @"widget",
                   (isSmall ? @"small" : @"regular"), @"size",
                   (isRolledOver ? @"rollover" : @"normal"), @"state",
                   (isHorizontal ? @"kCUIOrientHorizontal" : @"kCUIOrientVertical"), @"kCUIOrientationKey",
                   (isOnTopOfDarkBackground ? @"kCUIVariantWhite" : @""), @"kCUIVariantKey",
                   [NSNumber numberWithBool:YES], @"indiconly",
                   [NSNumber numberWithBool:YES], @"kCUIThumbProportionKey",
                   [NSNumber numberWithBool:YES], @"is.flipped",
-                  nil]);
+                  nil],
+                true);
       }
       break;
     case NS_THEME_SCROLLBAR_BUTTON_UP:
     case NS_THEME_SCROLLBAR_BUTTON_LEFT:
 #if SCROLLBARS_VISUAL_DEBUG
       CGContextSetRGBFillColor(cgContext, 1.0, 0, 0, 0.6);
       CGContextFillRect(cgContext, macRect);
 #endif
@@ -2936,27 +2937,29 @@ nsNativeThemeCocoa::DrawWidgetBackground
               if (aFrame->StyleVisibility()->mDirection !=
                     NS_STYLE_DIRECTION_RTL) {
                 macRect.origin.x += 3.0;
               } else {
                 macRect.origin.x -= 1.0;
               }
             }
           }
+
           const BOOL isOnTopOfDarkBackground = IsDarkBackground(aFrame);
           RenderWithCoreUILegacy(macRect, cgContext,
                   [NSDictionary dictionaryWithObjectsAndKeys:
                     (isOverlay ? @"kCUIWidgetOverlayScrollBar" : @"scrollbar"), @"widget",
                     (isSmall ? @"small" : @"regular"), @"size",
                     (isHorizontal ? @"kCUIOrientHorizontal" : @"kCUIOrientVertical"), @"kCUIOrientationKey",
                     (isOnTopOfDarkBackground ? @"kCUIVariantWhite" : @""), @"kCUIVariantKey",
                     [NSNumber numberWithBool:YES], @"noindicator",
                     [NSNumber numberWithBool:YES], @"kCUIThumbProportionKey",
                     [NSNumber numberWithBool:YES], @"is.flipped",
-                    nil]);
+                    nil],
+                  true);
         }
       }
       break;
 
     case NS_THEME_TEXTFIELD_MULTILINE: {
       // we have to draw this by hand because there is no HITheme value for it
       CGContextSetRGBFillColor(cgContext, 1.0, 1.0, 1.0, 1.0);