Modified: trunk/LayoutTests/ChangeLog (183510 => 183511)
--- trunk/LayoutTests/ChangeLog 2015-04-28 21:51:04 UTC (rev 183510)
+++ trunk/LayoutTests/ChangeLog 2015-04-28 22:21:25 UTC (rev 183511)
@@ -1,3 +1,15 @@
+2015-04-28 Zalan Bujtas <za...@apple.com>
+
+ Checkboxes on bugs.webkit.org are painted with stripes at some zoom levels.
+ https://bugs.webkit.org/show_bug.cgi?id=144351
+
+ Reviewed by Simon Fraser.
+
+ This patch ensures that CG context is properly restored after painting dashed/dotted lines.
+
+ * fast/forms/checkbox-painting-with-hr-expected.html: Added.
+ * fast/forms/checkbox-painting-with-hr.html: Added.
+
2015-04-28 Andreas Kling <akl...@apple.com>
DFG should generate efficient code for branching on a string's boolean value.
Added: trunk/LayoutTests/fast/forms/checkbox-painting-with-hr-expected.html (0 => 183511)
--- trunk/LayoutTests/fast/forms/checkbox-painting-with-hr-expected.html (rev 0)
+++ trunk/LayoutTests/fast/forms/checkbox-painting-with-hr-expected.html 2015-04-28 22:21:25 UTC (rev 183511)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that checkboxes are painted properly when dashed/dotted horizontal rule is present.</title>
+</head>
+<body>
+ <input type="checkbox" checked="checked">
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/checkbox-painting-with-hr.html (0 => 183511)
--- trunk/LayoutTests/fast/forms/checkbox-painting-with-hr.html (rev 0)
+++ trunk/LayoutTests/fast/forms/checkbox-painting-with-hr.html 2015-04-28 22:21:25 UTC (rev 183511)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that checkboxes are painted properly when dashed/dotted horizontal rule is present.</title>
+<style>
+ hr {
+ margin-top: -10px;
+ border: 1px dashed white;
+ }
+</style>
+</head>
+<body>
+ <hr>
+ <input type="checkbox" checked="checked">
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (183510 => 183511)
--- trunk/Source/WebCore/ChangeLog 2015-04-28 21:51:04 UTC (rev 183510)
+++ trunk/Source/WebCore/ChangeLog 2015-04-28 22:21:25 UTC (rev 183511)
@@ -1,3 +1,17 @@
+2015-04-28 Zalan Bujtas <za...@apple.com>
+
+ Checkboxes on bugs.webkit.org are painted with stripes at some zoom levels.
+ https://bugs.webkit.org/show_bug.cgi?id=144351
+
+ Reviewed by Simon Fraser.
+
+ This patch ensures that CG context is properly restored after painting dashed/dotted lines.
+
+ Test: fast/forms/checkbox-painting-with-hr.html
+
+ * platform/graphics/cg/GraphicsContextCG.cpp:
+ (WebCore::GraphicsContext::drawLine):
+
2015-04-28 Simon Fraser <simon.fra...@apple.com>
Provide contentsToView() and viewToContents() functions on ScrollView, and use them
Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (183510 => 183511)
--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2015-04-28 21:51:04 UTC (rev 183510)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp 2015-04-28 22:21:25 UTC (rev 183511)
@@ -294,11 +294,12 @@
CGContextRef context = platformContext();
StrokeStyle strokeStyle = this->strokeStyle();
float cornerWidth = 0;
+ bool drawsDashedLine = strokeStyle == DottedStroke || strokeStyle == DashedStroke;
- if (strokeStyle == DottedStroke || strokeStyle == DashedStroke) {
+ if (drawsDashedLine) {
+ CGContextSaveGState(context);
// Figure out end points to ensure we always paint corners.
cornerWidth = strokeStyle == DottedStroke ? thickness : std::min(2 * thickness, std::max(thickness, strokeWidth / 3));
- CGContextSaveGState(context);
setCGFillColor(context, strokeColor(), strokeColorSpace());
if (isVerticalLine) {
CGContextFillRect(context, FloatRect(point1.x(), point1.y(), thickness, cornerWidth));
@@ -307,12 +308,13 @@
CGContextFillRect(context, FloatRect(point1.x(), point1.y(), cornerWidth, thickness));
CGContextFillRect(context, FloatRect(point2.x() - cornerWidth, point1.y(), cornerWidth, thickness));
}
- CGContextRestoreGState(context);
strokeWidth -= 2 * cornerWidth;
float patternWidth = strokeStyle == DottedStroke ? thickness : std::min(3 * thickness, std::max(thickness, strokeWidth / 3));
// Check if corner drawing sufficiently covers the line.
- if (strokeWidth <= patternWidth + 1)
+ if (strokeWidth <= patternWidth + 1) {
+ CGContextRestoreGState(context);
return;
+ }
// Pattern starts with full fill and ends with the empty fill.
// 1. Let's start with the empty phase after the corner.
@@ -360,6 +362,8 @@
CGContextMoveToPoint(context, p1.x(), p1.y());
CGContextAddLineToPoint(context, p2.x(), p2.y());
CGContextStrokePath(context);
+ if (drawsDashedLine)
+ CGContextRestoreGState(context);
if (shouldAntialias())
CGContextSetShouldAntialias(context, true);
}