From e8163acb37b6fb63238ceb5a4beda497060d573c Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Tue, 7 Oct 2014 16:18:02 +0200 Subject: [PATCH] Bug 846730 - Draw native-themed textarea borders using filling instead of stroking. r=smichaud --- widget/cocoa/nsNativeThemeCocoa.mm | 40 ++++++++++++------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index 5f97372d6d6b..66ee8eb1693a 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -2798,33 +2798,25 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext, CGContextFillRect(cgContext, macRect); - CGContextSetLineWidth(cgContext, 1.0); - CGContextSetShouldAntialias(cgContext, false); - - // stroke everything but the top line of the text area - CGContextSetRGBStrokeColor(cgContext, 0.6, 0.6, 0.6, 1.0); - CGContextBeginPath(cgContext); - CGContextMoveToPoint(cgContext, macRect.origin.x, macRect.origin.y + 1); - CGContextAddLineToPoint(cgContext, macRect.origin.x, macRect.origin.y + macRect.size.height); - CGContextAddLineToPoint(cgContext, macRect.origin.x + macRect.size.width - 1, macRect.origin.y + macRect.size.height); - CGContextAddLineToPoint(cgContext, macRect.origin.x + macRect.size.width - 1, macRect.origin.y + 1); - CGContextStrokePath(cgContext); - - // stroke the line across the top of the text area - CGContextSetRGBStrokeColor(cgContext, 0.4510, 0.4510, 0.4510, 1.0); - CGContextBeginPath(cgContext); - CGContextMoveToPoint(cgContext, macRect.origin.x, macRect.origin.y + 1); - CGContextAddLineToPoint(cgContext, macRect.origin.x + macRect.size.width - 1, macRect.origin.y + 1); - CGContextStrokePath(cgContext); + // #737373 for the top border, #999999 for the rest. + float x = macRect.origin.x, y = macRect.origin.y; + float w = macRect.size.width, h = macRect.size.height; + CGContextSetRGBFillColor(cgContext, 0.4510, 0.4510, 0.4510, 1.0); + CGContextFillRect(cgContext, CGRectMake(x, y, w, 1)); + CGContextSetRGBFillColor(cgContext, 0.6, 0.6, 0.6, 1.0); + CGContextFillRect(cgContext, CGRectMake(x, y + 1, 1, h - 1)); + CGContextFillRect(cgContext, CGRectMake(x + w - 1, y + 1, 1, h - 1)); + CGContextFillRect(cgContext, CGRectMake(x + 1, y + h - 1, w - 2, 1)); // draw a focus ring if (eventState.HasState(NS_EVENT_STATE_FOCUS)) { - // We need to bring the rectangle in by 1 pixel on each side. - CGRect cgr = CGRectMake(macRect.origin.x + 1, - macRect.origin.y + 1, - macRect.size.width - 2, - macRect.size.height - 2); - HIThemeDrawFocusRect(&cgr, true, cgContext, kHIThemeOrientationNormal); + NSGraphicsContext* savedContext = [NSGraphicsContext currentContext]; + [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:YES]]; + CGContextSaveGState(cgContext); + NSSetFocusRingStyle(NSFocusRingOnly); + NSRectFill(NSRectFromCGRect(macRect)); + CGContextRestoreGState(cgContext); + [NSGraphicsContext setCurrentContext:savedContext]; } } break;