From cdd2c2e7a39a33552f90cc9201ad64bf901c1d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 28 Jan 2021 14:17:01 +0000 Subject: [PATCH] Bug 1689286 - Make the number input spinners look nicer with padding. r=spohl If you add padding to the input on the inline-end, like some of the examples in bug 1674431, then the darker border looks off. Without it, the number input still looks nice, so I think we should do this. We might want to introduce the padding by default (see bug 1689286). Differential Revision: https://phabricator.services.mozilla.com/D103270 --- widget/nsNativeBasicTheme.cpp | 25 +++++-------------------- widget/nsNativeBasicTheme.h | 1 - 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/widget/nsNativeBasicTheme.cpp b/widget/nsNativeBasicTheme.cpp index d182f330d736..716b5e500e9b 100644 --- a/widget/nsNativeBasicTheme.cpp +++ b/widget/nsNativeBasicTheme.cpp @@ -768,24 +768,9 @@ void nsNativeBasicTheme::PaintSpinnerButton(nsIFrame* aFrame, DPIRatio aDpiRatio) { auto [backgroundColor, borderColor] = ComputeButtonColors(aState); - RefPtr pathRect = MakePathForRect(*aDrawTarget, aRect.ToUnknownRect()); + aDrawTarget->FillRect(aRect.ToUnknownRect(), + ColorPattern(ToDeviceColor(backgroundColor))); - aDrawTarget->Fill(pathRect, ColorPattern(ToDeviceColor(backgroundColor))); - - RefPtr builder = aDrawTarget->CreatePathBuilder(); - Point p; - if (IsFrameRTL(aFrame)) { - p = Point(aRect.x + aRect.width - 0.5f, aRect.y); - } else { - p = Point(aRect.x - 0.5f, aRect.y); - } - builder->MoveTo(p); - p = Point(p.x, p.y + aRect.height); - builder->LineTo(p); - RefPtr path = builder->Finish(); - - aDrawTarget->Stroke(path, ColorPattern(ToDeviceColor(borderColor)), - StrokeOptions(kSpinnerBorderWidth * aDpiRatio)); const float arrowPolygonX[] = {-5.25f, -0.75f, 0.75f, 5.25f, 5.25f, 4.5f, 0.75f, -0.75f, -4.5f, -5.25f}; const float arrowPolygonY[] = {-1.875f, 2.625f, 2.625f, -1.875f, -4.125f, @@ -795,15 +780,15 @@ void nsNativeBasicTheme::PaintSpinnerButton(nsIFrame* aFrame, const float scaleY = aAppearance == StyleAppearance::SpinnerDownbutton ? scaleX : -scaleX; - builder = aDrawTarget->CreatePathBuilder(); + RefPtr builder = aDrawTarget->CreatePathBuilder(); auto center = aRect.Center().ToUnknownPoint(); - p = center + Point(arrowPolygonX[0] * scaleX, arrowPolygonY[0] * scaleY); + Point p = center + Point(arrowPolygonX[0] * scaleX, arrowPolygonY[0] * scaleY); builder->MoveTo(p); for (int32_t i = 1; i < arrowNumPoints; i++) { p = center + Point(arrowPolygonX[i] * scaleX, arrowPolygonY[i] * scaleY); builder->LineTo(p); } - path = builder->Finish(); + RefPtr path = builder->Finish(); aDrawTarget->Fill(path, ColorPattern(ToDeviceColor(borderColor))); } diff --git a/widget/nsNativeBasicTheme.h b/widget/nsNativeBasicTheme.h index c30edb3a3bf3..d527606cde0d 100644 --- a/widget/nsNativeBasicTheme.h +++ b/widget/nsNativeBasicTheme.h @@ -113,7 +113,6 @@ static const CSSCoord kMinimumSpinnerButtonHeight = 9.0f; static const CSSCoord kButtonBorderWidth = 1.0f; static const CSSCoord kMenulistBorderWidth = 1.0f; static const CSSCoord kTextFieldBorderWidth = 1.0f; -static const CSSCoord kSpinnerBorderWidth = 1.0f; static const CSSCoord kRangeHeight = 6.0f; static const CSSCoord kProgressbarHeight = 6.0f; static const CSSCoord kMeterHeight = 12.0f;