<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[192221] releases/WebKitGTK/webkit-2.10</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/192221">192221</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2015-11-10 02:50:07 -0800 (Tue, 10 Nov 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/191658">r191658</a> - [Cairo] Incorrect dashed and dotted border painting after <a href="http://trac.webkit.org/projects/webkit/changeset/177686">r177686</a>.
https://bugs.webkit.org/show_bug.cgi?id=141967

Reviewed by Gyuyoung Kim.

Fix the incorrect dashed/dotted border painting in cairo.

Source/WebCore:

* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::drawLine):
(WebCore::calculateStrokePatternOffset): Deleted.
(WebCore::drawLineOnCairoContext): Deleted.

LayoutTests:

* platform/gtk/TestExpectations: Removed the passed test.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit210LayoutTestsChangeLog">releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210LayoutTestsplatformgtkTestExpectations">releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/TestExpectations</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicscairoGraphicsContextCairocpp">releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit210LayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog (192220 => 192221)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog        2015-11-10 10:44:55 UTC (rev 192220)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/ChangeLog        2015-11-10 10:50:07 UTC (rev 192221)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-10-27  Hunseop Jeong  &lt;hs85.jeong@samsung.com&gt;
+
+        [Cairo] Incorrect dashed and dotted border painting after r177686.
+        https://bugs.webkit.org/show_bug.cgi?id=141967
+
+        Reviewed by Gyuyoung Kim.
+
+        Fix the incorrect dashed/dotted border painting in cairo.
+
+        * platform/gtk/TestExpectations: Removed the passed test.
+
</ins><span class="cx"> 2015-10-27  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Null dereference loading Blink layout test editing/execCommand/format-block-uneditable-crash.html
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210LayoutTestsplatformgtkTestExpectations"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/TestExpectations (192220 => 192221)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/TestExpectations        2015-11-10 10:44:55 UTC (rev 192220)
+++ releases/WebKitGTK/webkit-2.10/LayoutTests/platform/gtk/TestExpectations        2015-11-10 10:50:07 UTC (rev 192221)
</span><span class="lines">@@ -534,7 +534,6 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/141837 fast/borders/border-painting-correctness-dashed.html [ ImageOnlyFailure ]
</span><span class="cx"> webkit.org/b/141837 fast/borders/border-painting-correctness-dotted.html [ ImageOnlyFailure ]
</span><del>-webkit.org/b/141838 fast/borders/0px-borders.html [ ImageOnlyFailure ]
</del><span class="cx"> 
</span><span class="cx"> webkit.org/b/141458 imported/mozilla/svg/blend-color-burn.svg [ ImageOnlyFailure ]
</span><span class="cx"> webkit.org/b/141458 imported/mozilla/svg/blend-color-dodge.svg [ ImageOnlyFailure ]
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog (192220 => 192221)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog        2015-11-10 10:44:55 UTC (rev 192220)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/ChangeLog        2015-11-10 10:50:07 UTC (rev 192221)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-10-27  Hunseop Jeong  &lt;hs85.jeong@samsung.com&gt;
+
+        [Cairo] Incorrect dashed and dotted border painting after r177686.
+        https://bugs.webkit.org/show_bug.cgi?id=141967
+
+        Reviewed by Gyuyoung Kim.
+
+        Fix the incorrect dashed/dotted border painting in cairo.
+
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::drawLine):
+        (WebCore::calculateStrokePatternOffset): Deleted.
+        (WebCore::drawLineOnCairoContext): Deleted.
+
</ins><span class="cx"> 2015-10-27  Jiewen Tan  &lt;jiewen_tan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Null dereference loading Blink layout test editing/execCommand/format-block-uneditable-crash.html
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit210SourceWebCoreplatformgraphicscairoGraphicsContextCairocpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (192220 => 192221)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2015-11-10 10:44:55 UTC (rev 192220)
+++ releases/WebKitGTK/webkit-2.10/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp        2015-11-10 10:50:07 UTC (rev 192221)
</span><span class="lines">@@ -253,93 +253,91 @@
</span><span class="cx">     cairo_restore(cr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static double calculateStrokePatternOffset(int distance, int patternWidth)
</del><ins>+// This is only used to draw borders, so we should not draw shadows.
+void GraphicsContext::drawLine(const FloatPoint&amp; point1, const FloatPoint&amp; point2)
</ins><span class="cx"> {
</span><del>-    // Example: 80 pixels with a width of 30 pixels. Remainder is 20.
-    // The maximum pixels of line we could paint will be 50 pixels.
-    int remainder = distance % patternWidth;
-    int numSegments = (distance - remainder) / patternWidth;
</del><ins>+    if (paintingDisabled())
+        return;
</ins><span class="cx"> 
</span><del>-    // Special case 1px dotted borders for speed.
-    if (patternWidth == 1)
-        return 1;
</del><ins>+    if (strokeStyle() == NoStroke)
+        return;
</ins><span class="cx"> 
</span><del>-    bool evenNumberOfSegments = !(numSegments % 2);
-    if (remainder)
-        evenNumberOfSegments = !evenNumberOfSegments;
-
-    if (evenNumberOfSegments) {
-        if (remainder)
-            return (patternWidth - remainder) + (remainder / 2);
-        return patternWidth / 2;
-    }
-
-    // Odd number of segments.
-    if (remainder)
-        return (patternWidth - remainder) / 2.f;
-    return 0;
-}
-
-static void drawLineOnCairoContext(GraphicsContext* graphicsContext, cairo_t* context, const FloatPoint&amp; point1, const FloatPoint&amp; point2)
-{
-    StrokeStyle style = graphicsContext-&gt;strokeStyle();
-    if (style == NoStroke)
</del><ins>+    const Color&amp; strokeColor = this-&gt;strokeColor();
+    float thickness = strokeThickness();
+    bool isVerticalLine = (point1.x() + thickness == point2.x());
+    float strokeWidth = isVerticalLine ? point2.y() - point1.y() : point2.x() - point1.x();
+    if (!thickness || !strokeWidth)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    const Color&amp; strokeColor = graphicsContext-&gt;strokeColor();
-    int strokeThickness = floorf(graphicsContext-&gt;strokeThickness());
-    if (graphicsContext-&gt;strokeThickness() &lt; 1)
-        strokeThickness = 1;
</del><ins>+    cairo_t* cairoContext = platformContext()-&gt;cr();
+    StrokeStyle strokeStyle = this-&gt;strokeStyle();
+    float cornerWidth = 0;
+    bool drawsDashedLine = strokeStyle == DottedStroke || strokeStyle == DashedStroke;
</ins><span class="cx"> 
</span><del>-    int patternWidth = 0;
-    if (style == DottedStroke)
-        patternWidth = strokeThickness;
-    else if (style == DashedStroke)
-        patternWidth = 3 * strokeThickness;
-
-    bool isVerticalLine = point1.x() == point2.x();
-    FloatPoint point1OnPixelBoundaries = point1;
-    FloatPoint point2OnPixelBoundaries = point2;
-    GraphicsContext::adjustLineToPixelBoundaries(point1OnPixelBoundaries, point2OnPixelBoundaries, strokeThickness, style);
-
-    if (patternWidth) {
-        // Do a rect fill of our endpoints.  This ensures we always have the
-        // appearance of being a border.  We then draw the actual dotted/dashed line.
-        FloatRect firstRect(point1OnPixelBoundaries, FloatSize(strokeThickness, strokeThickness));
-        FloatRect secondRect(point2OnPixelBoundaries, FloatSize(strokeThickness, strokeThickness));
</del><ins>+    if (drawsDashedLine) {
+        cairo_save(cairoContext);
+        // Figure out end points to ensure we always paint corners.
+        cornerWidth = strokeStyle == DottedStroke ? thickness : std::min(2 * thickness, std::max(thickness, strokeWidth / 3));
</ins><span class="cx">         if (isVerticalLine) {
</span><del>-            firstRect.move(-strokeThickness / 2, -strokeThickness);
-            secondRect.move(-strokeThickness / 2, 0);
</del><ins>+            fillRectWithColor(cairoContext, FloatRect(point1.x(), point1.y(), thickness, cornerWidth), strokeColor);
+            fillRectWithColor(cairoContext, FloatRect(point1.x(), point2.y() - cornerWidth, thickness, cornerWidth), strokeColor);
</ins><span class="cx">         } else {
</span><del>-            firstRect.move(-strokeThickness, -strokeThickness / 2);
-            secondRect.move(0, -strokeThickness / 2);
</del><ins>+            fillRectWithColor(cairoContext, FloatRect(point1.x(), point1.y(), cornerWidth, thickness), strokeColor);
+            fillRectWithColor(cairoContext, FloatRect(point2.x() - cornerWidth, point1.y(), cornerWidth, thickness), strokeColor);
</ins><span class="cx">         }
</span><del>-        fillRectWithColor(context, firstRect, strokeColor);
-        fillRectWithColor(context, secondRect, strokeColor);
</del><ins>+        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 &lt;= patternWidth + 1) {
+            cairo_restore(cairoContext);
+            return;
+        }
</ins><span class="cx"> 
</span><del>-        int distance = (isVerticalLine ? (point2.y() - point1.y()) : (point2.x() - point1.x())) - 2 * strokeThickness;
-        double patternOffset = calculateStrokePatternOffset(distance, patternWidth);
-        double patternWidthAsDouble = patternWidth;
-        cairo_set_dash(context, &amp;patternWidthAsDouble, 1, patternOffset);
</del><ins>+        // Pattern starts with full fill and ends with the empty fill.
+        // 1. Let's start with the empty phase after the corner.
+        // 2. Check if we've got odd or even number of patterns and whether they fully cover the line.
+        // 3. In case of even number of patterns and/or remainder, move the pattern start position
+        // so that the pattern is balanced between the corners.
+        float patternOffset = patternWidth;
+        int numberOfSegments = std::floor(strokeWidth / patternWidth);
+        bool oddNumberOfSegments = numberOfSegments % 2;
+        float remainder = strokeWidth - (numberOfSegments * patternWidth);
+        if (oddNumberOfSegments &amp;&amp; remainder)
+            patternOffset -= remainder / 2.f;
+        else if (!oddNumberOfSegments) {
+            if (remainder)
+                patternOffset += patternOffset - (patternWidth + remainder) / 2.f;
+            else
+                patternOffset += patternWidth / 2.f;
+        }
+        const double dashedLine[2] = { static_cast&lt;double&gt;(patternWidth), static_cast&lt;double&gt;(patternWidth) };
+        cairo_set_dash(cairoContext, dashedLine, 2, patternOffset);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    setSourceRGBAFromColor(context, strokeColor);
-    cairo_set_line_width(context, strokeThickness);
-    cairo_move_to(context, point1OnPixelBoundaries.x(), point1OnPixelBoundaries.y());
-    cairo_line_to(context, point2OnPixelBoundaries.x(), point2OnPixelBoundaries.y());
-    cairo_stroke(context);
-}
</del><ins>+    FloatPoint p1 = point1;
+    FloatPoint p2 = point2;
+    // Center line and cut off corners for pattern patining.
+    if (isVerticalLine) {
+        float centerOffset = (p2.x() - p1.x()) / 2;
+        p1.move(centerOffset, cornerWidth);
+        p2.move(-centerOffset, -cornerWidth);
+    } else {
+        float centerOffset = (p2.y() - p1.y()) / 2;
+        p1.move(cornerWidth, centerOffset);
+        p2.move(-cornerWidth, -centerOffset);
+    }
</ins><span class="cx"> 
</span><del>-// This is only used to draw borders, so we should not draw shadows.
-void GraphicsContext::drawLine(const FloatPoint&amp; point1, const FloatPoint&amp; point2)
-{
-    if (paintingDisabled())
-        return;
</del><ins>+    if (shouldAntialias())
+        cairo_set_antialias(cairoContext, CAIRO_ANTIALIAS_NONE);
</ins><span class="cx"> 
</span><del>-    cairo_t* cairoContext = platformContext()-&gt;cr();
-    cairo_save(cairoContext);
-    drawLineOnCairoContext(this, cairoContext, point1, point2);
-    cairo_restore(cairoContext);
</del><ins>+    cairo_new_path(cairoContext);
+    cairo_move_to(cairoContext, p1.x(), p1.y());
+    cairo_line_to(cairoContext, p2.x(), p2.y());
+    cairo_stroke(cairoContext);
+    if (drawsDashedLine)
+        cairo_restore(cairoContext);
+    if (shouldAntialias())
+        cairo_set_antialias(cairoContext, CAIRO_ANTIALIAS_DEFAULT);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // This method is only used to draw the little circles used in lists.
</span></span></pre>
</div>
</div>

</body>
</html>