WebKit Bugzilla
Attachment 362314 Details for
Bug 194785
: Clean up and modernize RenderThemeIOS::paintCheckboxDecorations()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194785-20190218123052.patch (text/plain), 6.79 KB, created by
Daniel Bates
on 2019-02-18 12:30:53 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2019-02-18 12:30:53 PST
Size:
6.79 KB
patch
obsolete
>Subversion Revision: 241299 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 3df42d2998747067660c653fee8e5816cca42d24..9737a2b14a52c6710b0d04056c8b3e6564bc20b8 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,17 @@ >+2019-02-18 Daniel Bates <dabates@apple.com> >+ >+ Clean up and modernize RenderThemeIOS::paintCheckboxDecorations() >+ https://bugs.webkit.org/show_bug.cgi?id=194785 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Change from early return to else-clause to make the states clearer and make it more straightforward >+ to share more common code. Use constexpr, allocate temporary vectors with inline capacity, and >+ switch to uniform initializer syntax. >+ >+ * rendering/RenderThemeIOS.mm: >+ (WebCore::RenderThemeIOS::paintCheckboxDecorations): >+ > 2019-02-18 Daniel Bates <dabates@apple.com> > > [iOS] Focus ring for checkboxes, radio buttons, buttons and search fields should hug tighter to the contour >diff --git a/Source/WebCore/rendering/RenderThemeIOS.mm b/Source/WebCore/rendering/RenderThemeIOS.mm >index 5a679d4dfd44120d824f150ca1febc7a7de7f3b0..4b07ae19994f0dea3a2d25f668222a5b5bf9b028 100644 >--- a/Source/WebCore/rendering/RenderThemeIOS.mm >+++ b/Source/WebCore/rendering/RenderThemeIOS.mm >@@ -387,68 +387,57 @@ void RenderThemeIOS::adjustPaintRect(const RenderObject& renderer, LayoutRect& p > > bool RenderThemeIOS::paintCheckboxDecorations(const RenderObject& box, const PaintInfo& paintInfo, const IntRect& rect) > { >- GraphicsContextStateSaver stateSaver(paintInfo.context()); >- FloatRect clip = addRoundedBorderClip(box, paintInfo.context(), rect); >- >- float width = clip.width(); >- float height = clip.height(); >- > bool checked = isChecked(box); > bool indeterminate = isIndeterminate(box); >- > CGContextRef cgContext = paintInfo.context().platformContext(); >- if (!checked && !indeterminate) { >- FloatPoint bottomCenter(clip.x() + clip.width() / 2.0f, clip.maxY()); >- drawAxialGradient(cgContext, gradientWithName(ShadeGradient), clip.location(), FloatPoint(clip.x(), clip.maxY()), LinearInterpolation); >- drawRadialGradient(cgContext, gradientWithName(ShineGradient), bottomCenter, 0, bottomCenter, sqrtf((width * width) / 4.0f + height * height), ExponentialInterpolation); >- return false; >- } >- >- drawAxialGradient(cgContext, gradientWithName(ConcaveGradient), clip.location(), FloatPoint(clip.x(), clip.maxY()), LinearInterpolation); > >- static const float thicknessRatio = 2 / 14.0; >- static const CGSize size = { 14.0f, 14.0f }; >- float lineWidth = std::min(width, height) * 2.0f * thicknessRatio; >+ GraphicsContextStateSaver stateSaver { paintInfo.context() }; >+ auto clip = addRoundedBorderClip(box, paintInfo.context(), rect); >+ float width = clip.width(); >+ float height = clip.height(); > >- Vector<CGPoint> line; >- Vector<CGPoint> shadow; >+ if (checked || indeterminate) { >+ drawAxialGradient(cgContext, gradientWithName(ConcaveGradient), clip.location(), FloatPoint { clip.x(), clip.maxY() }, LinearInterpolation); >+ >+ constexpr float thicknessRatio = 2 / 14.0; >+ float lineWidth = std::min(width, height) * 2.0f * thicknessRatio; >+ >+ Vector<CGPoint, 3> line; >+ Vector<CGPoint, 3> shadow; >+ if (checked) { >+ constexpr CGSize size { 14.0f, 14.0f }; >+ constexpr CGPoint pathRatios[] = { >+ { 2.5f / size.width, 7.5f / size.height }, >+ { 5.5f / size.width, 10.5f / size.height }, >+ { 11.5f / size.width, 2.5f / size.height } >+ }; >+ >+ line.uncheckedAppend(CGPointMake(clip.x() + width * pathRatios[0].x, clip.y() + height * pathRatios[0].y)); >+ line.uncheckedAppend(CGPointMake(clip.x() + width * pathRatios[1].x, clip.y() + height * pathRatios[1].y)); >+ line.uncheckedAppend(CGPointMake(clip.x() + width * pathRatios[2].x, clip.y() + height * pathRatios[2].y)); >+ >+ shadow.uncheckedAppend(shortened(line[0], line[1], lineWidth / 4.0f)); >+ shadow.uncheckedAppend(line[1]); >+ shadow.uncheckedAppend(shortened(line[2], line[1], lineWidth / 4.0f)); >+ } else { >+ line.uncheckedAppend(CGPointMake(clip.x() + 3.5, clip.center().y())); >+ line.uncheckedAppend(CGPointMake(clip.maxX() - 3.5, clip.center().y())); > >- if (checked) { >- static const CGPoint pathRatios[3] = { >- { 2.5f / size.width, 7.5f / size.height }, >- { 5.5f / size.width, 10.5f / size.height }, >- { 11.5f / size.width, 2.5f / size.height } >- }; >+ shadow.uncheckedAppend(shortened(line[0], line[1], lineWidth / 4.0f)); >+ shadow.uncheckedAppend(shortened(line[1], line[0], lineWidth / 4.0f)); >+ } > >- line = { >- CGPointMake(clip.x() + width * pathRatios[0].x, clip.y() + height * pathRatios[0].y), >- CGPointMake(clip.x() + width * pathRatios[1].x, clip.y() + height * pathRatios[1].y), >- CGPointMake(clip.x() + width * pathRatios[2].x, clip.y() + height * pathRatios[2].y) >- }; >+ lineWidth = std::max<float>(lineWidth, 1); >+ drawJoinedLines(cgContext, Vector<CGPoint> { WTFMove(shadow) }, kCGLineCapSquare, lineWidth, Color { 0.0f, 0.0f, 0.0f, 0.7f }); > >- shadow = { >- shortened(line[0], line[1], lineWidth / 4.0f), >- line[1], >- shortened(line[2], line[1], lineWidth / 4.0f) >- }; >- } else if (indeterminate) { >- line = { >- CGPointMake(clip.x() + 3.5, clip.center().y()), >- CGPointMake(clip.maxX() - 3.5, clip.center().y()) >- }; >+ lineWidth = std::max<float>(std::min(clip.width(), clip.height()) * thicknessRatio, 1); >+ drawJoinedLines(cgContext, Vector<CGPoint> { WTFMove(line) }, kCGLineCapButt, lineWidth, Color { 1.0f, 1.0f, 1.0f, 240 / 255.0f }); >+ } else { >+ FloatPoint bottomCenter { clip.x() + clip.width() / 2.0f, clip.maxY() }; > >- shadow = { >- shortened(line[0], line[1], lineWidth / 4.0f), >- shortened(line[1], line[0], lineWidth / 4.0f) >- }; >+ drawAxialGradient(cgContext, gradientWithName(ShadeGradient), clip.location(), FloatPoint { clip.x(), clip.maxY() }, LinearInterpolation); >+ drawRadialGradient(cgContext, gradientWithName(ShineGradient), bottomCenter, 0, bottomCenter, sqrtf((width * width) / 4.0f + height * height), ExponentialInterpolation); > } >- >- lineWidth = std::max<float>(lineWidth, 1); >- drawJoinedLines(cgContext, shadow, kCGLineCapSquare, lineWidth, Color(0.0f, 0.0f, 0.0f, 0.7f)); >- >- lineWidth = std::max<float>(std::min(clip.width(), clip.height()) * thicknessRatio, 1); >- drawJoinedLines(cgContext, line, kCGLineCapButt, lineWidth, Color(1.0f, 1.0f, 1.0f, 240 / 255.0f)); >- > return false; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194785
: 362314