From c0a29b5c2a78a6b875bb94f60f85321a0cbe37cd Mon Sep 17 00:00:00 2001 From: Steven Michaud Date: Sun, 9 Nov 2008 16:30:46 -0600 Subject: [PATCH] 10.4-only top crash at [@ nsNativeThemeCocoa::DrawCellWithScaling]. b=458961 r=mstange,stuart.morgan sr=vlad a=vlad --- widget/src/cocoa/nsNativeThemeCocoa.mm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/widget/src/cocoa/nsNativeThemeCocoa.mm b/widget/src/cocoa/nsNativeThemeCocoa.mm index f01a68cf516..7b4fd991c3d 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.mm +++ b/widget/src/cocoa/nsNativeThemeCocoa.mm @@ -256,8 +256,7 @@ static void DrawCellWithScaling(NSCell *cell, if (drawRect.size.height < minimumSize.height) drawRect.size.height = minimumSize.height; - CGAffineTransform savedCTM = CGContextGetCTM(cgContext); - NSGraphicsContext* savedContext = [NSGraphicsContext currentContext]; + [NSGraphicsContext saveGraphicsState]; if (flip) { // This flips the image in place and is necessary to work around a bug in the way @@ -274,12 +273,16 @@ static void DrawCellWithScaling(NSCell *cell, // Inflate the rect Gecko gave us by the margin for the control. InflateControlRect(&drawRect, controlSize, marginSet); + NSGraphicsContext* savedContext = [NSGraphicsContext currentContext]; + // Set up the graphics context we've been asked to draw to. [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:YES]]; // [NSView focusView] may return nil here, but // [NSCell drawWithFrame:inView:] can deal with that. [cell drawWithFrame:drawRect inView:[NSView focusView]]; + + [NSGraphicsContext setCurrentContext:savedContext]; } else { float w = ceil(drawRect.size.width); @@ -303,6 +306,8 @@ static void DrawCellWithScaling(NSCell *cell, CGContextTranslateCTM(ctx, MAX_FOCUS_RING_WIDTH, MAX_FOCUS_RING_WIDTH); + NSGraphicsContext* savedContext = [NSGraphicsContext currentContext]; + [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES]]; // [NSView focusView] may return nil here, but @@ -330,9 +335,7 @@ static void DrawCellWithScaling(NSCell *cell, CGContextRelease(ctx); } - CGContextSetCTM(cgContext, savedCTM); - - [NSGraphicsContext setCurrentContext:savedContext]; + [NSGraphicsContext restoreGraphicsState]; #if DRAW_IN_FRAME_DEBUG CGContextSetRGBFillColor(cgContext, 0.0, 0.0, 0.5, 0.25);