WebKit Bugzilla
Attachment 346631 Details for
Bug 160484
: iOS doesn't support indeterminate checkboxes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-160484-20180806092124.patch (text/plain), 10.17 KB, created by
Aditya Keerthi
on 2018-08-06 09:21:24 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Aditya Keerthi
Created:
2018-08-06 09:21:24 PDT
Size:
10.17 KB
patch
obsolete
>Subversion Revision: 234486 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c396503a91039d7428f4df97b3fcf30c8ec73bc4..8daf3f733b72c8e97990c492916739d5e0c60605 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,27 @@ >+2018-08-06 Aditya Keerthi <akeerthi@apple.com> >+ >+ [iOS] Indeterminate checkboxes appear unchecked >+ https://bugs.webkit.org/show_bug.cgi?id=160484 >+ <rdar://problem/31143185> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add support for rendering indeterminate checkboxes on iOS. >+ >+ We now paint the unchecked appearance only if the checkbox is not checked and is >+ not indeterminate. Otherwise, we draw a checkmark if the checkbox is in the >+ checked state and a dash if the checkbox is in the indeterminate state. Both of >+ these states share the same dark background. >+ >+ Test: fast/forms/ios/render-indeterminate-checkbox.html >+ >+ * css/html.css: >+ (input[type="checkbox"]:indeterminate): >+ (input[type="checkbox"]:indeterminate:disabled): >+ * rendering/RenderThemeIOS.mm: >+ (WebCore::drawJoinedLines): >+ (WebCore::RenderThemeIOS::paintCheckboxDecorations): >+ > 2018-08-01 Alex Christensen <achristensen@webkit.org> > > Move all calls to ResourceLoader::start to WebKitLegacy >diff --git a/Source/WebCore/css/html.css b/Source/WebCore/css/html.css >index b271d7558533e528968d43c0b08a529b334c5bae..7e73832f0d84220ee41a62eaad0df0d503b698d7 100644 >--- a/Source/WebCore/css/html.css >+++ b/Source/WebCore/css/html.css >@@ -858,6 +858,15 @@ input[type="radio"] { > background-color: rgba(255, 255, 255, 0.01); > } > >+input[type="checkbox"]:indeterminate { >+ background: rgba(0, 0, 0, 0.8); >+} >+ >+input[type="checkbox"]:indeterminate:disabled { >+ opacity: 0.4; >+ background: rgba(0, 0, 0, 0.8); >+} >+ > input:matches([type="checkbox"], [type="radio"]):checked { > background: rgba(0, 0, 0, 0.8); > border-color: rgba(255, 255, 255, 0.0); >diff --git a/Source/WebCore/rendering/RenderThemeIOS.mm b/Source/WebCore/rendering/RenderThemeIOS.mm >index d69b20b9c75dd13a23bf50d2d87c84b62b881efb..de51ab930cfb10ae289e814664fa94043e04cb3b 100644 >--- a/Source/WebCore/rendering/RenderThemeIOS.mm >+++ b/Source/WebCore/rendering/RenderThemeIOS.mm >@@ -371,14 +371,16 @@ static CGPoint shortened(CGPoint start, CGPoint end, float width) > return CGPointMake(start.x + x * ratio, start.y + y * ratio); > } > >-static void drawJoinedLines(CGContextRef context, CGPoint points[], unsigned count, bool antialias, CGLineCap lineCap) >+static void drawJoinedLines(CGContextRef context, Vector<CGPoint> points, CGLineCap lineCap, float lineWidth, Color strokeColor) > { >- CGContextSetShouldAntialias(context, antialias); >+ CGContextSetLineWidth(context, lineWidth); >+ CGContextSetStrokeColorWithColor(context, cachedCGColor(strokeColor)); >+ CGContextSetShouldAntialias(context, true); > CGContextBeginPath(context); > CGContextSetLineCap(context, lineCap); > CGContextMoveToPoint(context, points[0].x, points[0].y); > >- for (unsigned i = 1; i < count; ++i) >+ for (unsigned i = 1; i < points.size(); ++i) > CGContextAddLineToPoint(context, points[i].x, points[i].y); > > CGContextStrokePath(context); >@@ -392,46 +394,62 @@ bool RenderThemeIOS::paintCheckboxDecorations(const RenderObject& box, const Pai > float width = clip.width(); > float height = clip.height(); > >+ bool checked = isChecked(box); >+ bool indeterminate = isIndeterminate(box); >+ > CGContextRef cgContext = paintInfo.context().platformContext(); >- if (isChecked(box)) { >- drawAxialGradient(cgContext, gradientWithName(ConcaveGradient), clip.location(), FloatPoint(clip.x(), clip.maxY()), LinearInterpolation); >+ 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 }; >+ static const float thicknessRatio = 2 / 14.0; >+ static const CGSize size = { 14.0f, 14.0f }; >+ float lineWidth = std::min(width, height) * 2.0f * thicknessRatio; >+ >+ Vector<CGPoint> line; >+ Vector<CGPoint> shadow; >+ >+ 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 } > }; > >- float lineWidth = std::min(width, height) * 2.0f * thicknessRatio; >- >- CGPoint line[3] = { >+ 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) > }; >- CGPoint shadow[3] = { >+ >+ 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>(lineWidth, 1); >- CGContextSetLineWidth(cgContext, lineWidth); >- CGContextSetStrokeColorWithColor(cgContext, cachedCGColor(Color(0.0f, 0.0f, 0.0f, 0.7f))); >- drawJoinedLines(cgContext, shadow, 3, true, kCGLineCapSquare); >- >- lineWidth = std::max<float>(std::min(clip.width(), clip.height()) * thicknessRatio, 1); >- CGContextSetLineWidth(cgContext, lineWidth); >- CGContextSetStrokeColorWithColor(cgContext, cachedCGColor(Color(1.0f, 1.0f, 1.0f, 240 / 255.0f))); >- drawJoinedLines(cgContext, line, 3, true, kCGLineCapButt); >- } else { >- 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); >+ shadow = { >+ shortened(line[0], line[1], lineWidth / 4.0f), >+ shortened(line[1], line[0], lineWidth / 4.0f) >+ }; > } > >+ 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; > } > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 70ba58a862776369f0f5286dbacc6ba75762d2bf..92ede8e3e2478a595c55920d3137e4f9b53d5681 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,18 @@ >+2018-08-06 Aditya Keerthi <akeerthi@apple.com> >+ >+ [iOS] Indeterminate checkboxes appear unchecked >+ https://bugs.webkit.org/show_bug.cgi?id=160484 >+ <rdar://problem/31143185> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added reftest to ensure that the indeterminate checkbox does not appear the same >+ as an unchecked checkbox. >+ >+ * fast/forms/ios/render-indeterminate-checkbox-expected-mismatch.html: Added. >+ * fast/forms/ios/render-indeterminate-checkbox.html: Added. >+ * platform/ios/fast/forms/indeterminate-expected.txt: Rebaseline. >+ > 2018-08-01 Ryosuke Niwa <rniwa@webkit.org> > > REGRESSION(r227983): fast/dom/adopt-node-crash-2.html is flaky >diff --git a/LayoutTests/fast/forms/ios/render-indeterminate-checkbox-expected-mismatch.html b/LayoutTests/fast/forms/ios/render-indeterminate-checkbox-expected-mismatch.html >new file mode 100644 >index 0000000000000000000000000000000000000000..a10afc15be80dc32c647ab00a29795e0ef12d684 >--- /dev/null >+++ b/LayoutTests/fast/forms/ios/render-indeterminate-checkbox-expected-mismatch.html >@@ -0,0 +1,14 @@ >+<!DOCTYPE html> >+<html> >+<body onload="runTest()"> >+ <input type=checkbox> >+ <div>Test passes if indeterminate checkbox appears different from unchecked checkbox.</div> >+</body> >+<script> >+function runTest() >+{ >+ let checkbox = document.querySelector("input"); >+ checkbox.indeterminate = true; >+} >+</script> >+</html> >diff --git a/LayoutTests/fast/forms/ios/render-indeterminate-checkbox.html b/LayoutTests/fast/forms/ios/render-indeterminate-checkbox.html >new file mode 100644 >index 0000000000000000000000000000000000000000..d805baee020b679a7755c538d28aaf4aebb4cacc >--- /dev/null >+++ b/LayoutTests/fast/forms/ios/render-indeterminate-checkbox.html >@@ -0,0 +1,7 @@ >+<!DOCTYPE html> >+<html> >+<body> >+ <input type=checkbox> >+ <div>Test passes if indeterminate checkbox appears different from unchecked checkbox.</div> >+</body> >+</html> >diff --git a/LayoutTests/platform/ios/fast/forms/indeterminate-expected.txt b/LayoutTests/platform/ios/fast/forms/indeterminate-expected.txt >index 338cbefef1263d0ab18baaf611118043c16e325b..eb88e8a80c8afca5ed46585bf1c2e26994ef7232 100644 >--- a/LayoutTests/platform/ios/fast/forms/indeterminate-expected.txt >+++ b/LayoutTests/platform/ios/fast/forms/indeterminate-expected.txt >@@ -7,4 +7,4 @@ layer at (0,0) size 800x600 > text run at (20,2) width 500: " This checkbox should look 50% transparent and should be in the mixed state." > RenderText {#text} at (0,0) size 0x0 > layer at (10,11) size 16x16 >- RenderBlock {INPUT} at (2,3) size 16x16 [bgcolor=#FFFFFF02] [border: (1px solid #4C4C4C)] >+ RenderBlock {INPUT} at (2,3) size 16x16 [bgcolor=#000000CC] [border: (1px solid #4C4C4C)]
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 160484
:
346567
|
346577
|
346631
|
346633