<!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>[177658] trunk</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/177658">177658</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2014-12-22 15:18:59 -0800 (Mon, 22 Dec 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Incorrect dashed and dotted border painting.
https://bugs.webkit.org/show_bug.cgi?id=139872
rdar://problem/18024205

Reviewed by Simon Fraser.

This patch makes dashed/dotted border painting symmetric and consistent.
It also works with subpixel positioning.

Source/WebCore:

Tests: fast/borders/border-painting-correctness-dashed.html
       fast/borders/border-painting-correctness-dotted.html

* platform/graphics/cg/GraphicsContextCG.cpp:
(WebCore::GraphicsContext::drawLine):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::drawLineForBoxSide):

LayoutTests:

* fast/borders/border-painting-correctness-dashed-expected.html: Added.
* fast/borders/border-painting-correctness-dashed.html: Added.
* fast/borders/border-painting-correctness-dotted-expected.html: Added.
* fast/borders/border-painting-correctness-dotted.html: Added.
* fast/borders/resources/border-painting-correctness-dashed-expected.png: Added.
* fast/borders/resources/border-painting-correctness-dotted-expected.png: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscgGraphicsContextCGcpp">trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastbordersborderpaintingcorrectnessdashedexpectedhtml">trunk/LayoutTests/fast/borders/border-painting-correctness-dashed-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastbordersborderpaintingcorrectnessdashedhtml">trunk/LayoutTests/fast/borders/border-painting-correctness-dashed.html</a></li>
<li><a href="#trunkLayoutTestsfastbordersborderpaintingcorrectnessdottedexpectedhtml">trunk/LayoutTests/fast/borders/border-painting-correctness-dotted-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastbordersborderpaintingcorrectnessdottedhtml">trunk/LayoutTests/fast/borders/border-painting-correctness-dotted.html</a></li>
<li><a href="#trunkLayoutTestsfastbordersresourcesborderpaintingcorrectnessdashedexpectedpng">trunk/LayoutTests/fast/borders/resources/border-painting-correctness-dashed-expected.png</a></li>
<li><a href="#trunkLayoutTestsfastbordersresourcesborderpaintingcorrectnessdottedexpectedpng">trunk/LayoutTests/fast/borders/resources/border-painting-correctness-dotted-expected.png</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (177657 => 177658)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-12-22 23:09:22 UTC (rev 177657)
+++ trunk/LayoutTests/ChangeLog        2014-12-22 23:18:59 UTC (rev 177658)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2014-12-22  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        Incorrect dashed and dotted border painting.
+        https://bugs.webkit.org/show_bug.cgi?id=139872
+        rdar://problem/18024205
+
+        Reviewed by Simon Fraser.
+
+        This patch makes dashed/dotted border painting symmetric and consistent.
+        It also works with subpixel positioning.
+
+        * fast/borders/border-painting-correctness-dashed-expected.html: Added.
+        * fast/borders/border-painting-correctness-dashed.html: Added.
+        * fast/borders/border-painting-correctness-dotted-expected.html: Added.
+        * fast/borders/border-painting-correctness-dotted.html: Added.
+        * fast/borders/resources/border-painting-correctness-dashed-expected.png: Added.
+        * fast/borders/resources/border-painting-correctness-dotted-expected.png: Added.
+
</ins><span class="cx"> 2014-12-22  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION: fast/xmlhttprequest/xmlhttprequest-recursive-sync-event.html is flaky
</span></span></pre></div>
<a id="trunkLayoutTestsfastbordersborderpaintingcorrectnessdashedexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/borders/border-painting-correctness-dashed-expected.html (0 => 177658)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/borders/border-painting-correctness-dashed-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/borders/border-painting-correctness-dashed-expected.html        2014-12-22 23:18:59 UTC (rev 177658)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that dashed borders look ok.&lt;/title&gt;
+&lt;style&gt;
+  body {
+    margin: 0px;
+  }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;img src=&quot;./resources/border-painting-correctness-dashed-expected.png&quot; /&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastbordersborderpaintingcorrectnessdashedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/borders/border-painting-correctness-dashed.html (0 => 177658)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/borders/border-painting-correctness-dashed.html                                (rev 0)
+++ trunk/LayoutTests/fast/borders/border-painting-correctness-dashed.html        2014-12-22 23:18:59 UTC (rev 177658)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+&lt;DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that dashed borders look ok.&lt;/title&gt;
+&lt;style&gt;
+  div {
+    position: absolute;
+    border: 1px dashed green;
+  }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;pre id=container&gt;&lt;/pre&gt;
+&lt;script&gt;
+  var cont = document.getElementById(&quot;container&quot;);
+  var borderWidth = 1;
+  for (h = 0; h &lt; 500; h += 180) {
+    for (v = 0; v &lt; 500; v += 180) {
+      width = 0;
+      for (i = 90; i &gt;= 0; i -= 2 * borderWidth) {
+        var element = document.createElement(&quot;div&quot;);
+        element.style.top = h + i + &quot;px&quot;;
+        element.style.left = v + i + &quot;px&quot;;
+        element.style.width = width + &quot;px&quot;;
+        element.style.height = width + &quot;px&quot;;
+        element.style.borderWidth = borderWidth;
+        cont.appendChild(element);
+        width += 4 * borderWidth;
+      }
+      borderWidth += 1;
+    }
+  }
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastbordersborderpaintingcorrectnessdottedexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/borders/border-painting-correctness-dotted-expected.html (0 => 177658)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/borders/border-painting-correctness-dotted-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/borders/border-painting-correctness-dotted-expected.html        2014-12-22 23:18:59 UTC (rev 177658)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that dotted borders look ok.&lt;/title&gt;
+&lt;style&gt;
+  body {
+    margin: 0px;
+  }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;img src=&quot;./resources/border-painting-correctness-dotted-expected.png&quot; /&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastbordersborderpaintingcorrectnessdottedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/borders/border-painting-correctness-dotted.html (0 => 177658)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/borders/border-painting-correctness-dotted.html                                (rev 0)
+++ trunk/LayoutTests/fast/borders/border-painting-correctness-dotted.html        2014-12-22 23:18:59 UTC (rev 177658)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+&lt;DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that dotted borders look ok.&lt;/title&gt;
+&lt;style&gt;
+  div {
+    position: absolute;
+    border: 1px dotted green;
+  }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;pre id=container&gt;&lt;/pre&gt;
+&lt;script&gt;
+  var cont = document.getElementById(&quot;container&quot;);
+  var borderWidth = 1;
+  for (h = 0; h &lt; 500; h += 180) {
+    for (v = 0; v &lt; 500; v += 180) {
+      width = 0;
+      for (i = 90; i &gt;= 0; i -= 2 * borderWidth) {
+        var element = document.createElement(&quot;div&quot;);
+        element.style.top = h + i + &quot;px&quot;;
+        element.style.left = v + i + &quot;px&quot;;
+        element.style.width = width + &quot;px&quot;;
+        element.style.height = width + &quot;px&quot;;
+        element.style.borderWidth = borderWidth;
+        cont.appendChild(element);
+        width += 4 * borderWidth;
+      }
+      borderWidth += 1;
+    }
+  }
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastbordersresourcesborderpaintingcorrectnessdashedexpectedpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/fast/borders/resources/border-painting-correctness-dashed-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/fast/borders/resources/border-painting-correctness-dashed-expected.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestsfastbordersresourcesborderpaintingcorrectnessdottedexpectedpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/fast/borders/resources/border-painting-correctness-dotted-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/fast/borders/resources/border-painting-correctness-dotted-expected.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (177657 => 177658)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-12-22 23:09:22 UTC (rev 177657)
+++ trunk/Source/WebCore/ChangeLog        2014-12-22 23:18:59 UTC (rev 177658)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2014-12-22  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        Incorrect dashed and dotted border painting.
+        https://bugs.webkit.org/show_bug.cgi?id=139872
+        rdar://problem/18024205
+
+        Reviewed by Simon Fraser.
+
+        This patch makes dashed/dotted border painting symmetric and consistent.
+        It also works with subpixel positioning.
+
+        Tests: fast/borders/border-painting-correctness-dashed.html
+               fast/borders/border-painting-correctness-dotted.html
+
+        * platform/graphics/cg/GraphicsContextCG.cpp:
+        (WebCore::GraphicsContext::drawLine):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::drawLineForBoxSide):
+
</ins><span class="cx"> 2014-12-22  Timothy Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         TextIndicatorWindow is larger than it needs to be, especially when not bouncing
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscgGraphicsContextCGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp (177657 => 177658)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp        2014-12-22 23:09:22 UTC (rev 177657)
+++ trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp        2014-12-22 23:18:59 UTC (rev 177658)
</span><span class="lines">@@ -285,119 +285,80 @@
</span><span class="cx">     if (strokeStyle() == NoStroke)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    float width = strokeThickness();
</del><ins>+    CGContextRef context = platformContext();
+    float thickness = strokeThickness();
+    ASSERT(thickness);
+    bool isVerticalLine = (point1.x() + thickness == point2.x());
+    StrokeStyle strokeStyle = this-&gt;strokeStyle();
+    float strokeWidth = isVerticalLine ? point2.y() - point1.y() : point2.x() - point1.x();
+    ASSERT(strokeWidth);
+    float cornerWidth = 0;
</ins><span class="cx"> 
</span><del>-    FloatPoint p1 = point1;
-    FloatPoint p2 = point2;
-    bool isVerticalLine = (p1.x() == p2.x());
-    
-    // For odd widths, we add in 0.5 to the appropriate x/y so that the float arithmetic
-    // works out.  For example, with a border width of 3, KHTML will pass us (y1+y2)/2, e.g.,
-    // (50+53)/2 = 103/2 = 51 when we want 51.5. It is always true that an even width gave
-    // us a perfect position, but an odd width gave us a position that is off by exactly 0.5.
-    if (strokeStyle() == DottedStroke || strokeStyle() == DashedStroke) {
</del><ins>+    if (strokeStyle == DottedStroke || strokeStyle == DashedStroke) {
+        // 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());
</ins><span class="cx">         if (isVerticalLine) {
</span><del>-            p1.move(0, width);
-            p2.move(0, -width);
</del><ins>+            CGContextFillRect(context, FloatRect(point1.x(), point1.y(), thickness, cornerWidth));
+            CGContextFillRect(context, FloatRect(point1.x(), point2.y() - cornerWidth, thickness, cornerWidth));
</ins><span class="cx">         } else {
</span><del>-            p1.move(width, 0);
-            p2.move(-width, 0);
</del><ins>+            CGContextFillRect(context, FloatRect(point1.x(), point1.y(), cornerWidth, thickness));
+            CGContextFillRect(context, FloatRect(point2.x() - cornerWidth, point1.y(), cornerWidth, thickness));
</ins><span class="cx">         }
</span><del>-    }
-    
-    if (((int)width) % 2) {
-        if (isVerticalLine) {
-            // We're a vertical line.  Adjust our x.
-            p1.move(0.5f, 0.0f);
-            p2.move(0.5f, 0.0f);
-        } else {
-            // We're a horizontal line. Adjust our y.
-            p1.move(0.0f, 0.5f);
-            p2.move(0.0f, 0.5f);
</del><ins>+        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 &lt;= patternWidth + 1)
+            return;
+
+        // 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 = floorf(strokeWidth / patternWidth);
+        bool oddNumberOfSegments = numberOfSegments % 2;
+        float remainder = strokeWidth - (numberOfSegments * patternWidth);
+        if (oddNumberOfSegments &amp;&amp; remainder)
+            patternOffset -= remainder / 2;
+        else if (!oddNumberOfSegments) {
+            if (remainder)
+                patternOffset += patternOffset - (patternWidth + remainder)  / 2;
+            else
+                patternOffset += patternWidth  / 2;
</ins><span class="cx">         }
</span><ins>+        const CGFloat dashedLine[2] = { static_cast&lt;CGFloat&gt;(patternWidth), static_cast&lt;CGFloat&gt;(patternWidth) };
+        CGContextSetLineDash(context, patternOffset, dashedLine, 2);
</ins><span class="cx">     }
</span><del>-    
-    int patWidth = 0;
-    switch (strokeStyle()) {
-    case NoStroke:
-    case SolidStroke:
-    case DoubleStroke:
-    case WavyStroke: // FIXME: https://bugs.webkit.org/show_bug.cgi?id=94112 - Needs platform support.
-        break;
-    case DottedStroke:
-        patWidth = (int)width;
-        break;
-    case DashedStroke:
-        patWidth = 3 * (int)width;
-        break;
</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><span class="cx"> 
</span><del>-    CGContextRef context = platformContext();
-
</del><span class="cx">     if (shouldAntialias()) {
</span><del>-        bool willAntialias = false;
</del><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">         // Force antialiasing on for line patterns as they don't look good with it turned off (&lt;rdar://problem/5459772&gt;).
</span><del>-        willAntialias = patWidth;
</del><ins>+        CGContextSetShouldAntialias(context, strokeStyle == DottedStroke || strokeStyle == DashedStroke);
+#else
+        CGContextSetShouldAntialias(context, false);
</ins><span class="cx"> #endif
</span><del>-        CGContextSetShouldAntialias(context, willAntialias);
</del><span class="cx">     }
</span><del>-
-    if (patWidth) {
-        CGContextSaveGState(context);
-
-        // 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.
-        setCGFillColor(context, strokeColor(), strokeColorSpace());  // The save/restore make it safe to mutate the fill color here without setting it back to the old color.
-        if (isVerticalLine) {
-            CGContextFillRect(context, FloatRect(p1.x() - width / 2, p1.y() - width, width, width));
-            CGContextFillRect(context, FloatRect(p2.x() - width / 2, p2.y(), width, width));
-        } else {
-            CGContextFillRect(context, FloatRect(p1.x() - width, p1.y() - width / 2, width, width));
-            CGContextFillRect(context, FloatRect(p2.x(), p2.y() - width / 2, width, width));
-        }
-
-        // 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 distance = (isVerticalLine ? (int)(point2.y() - point1.y()) : (point2.x() - point1.x())) - 2*(int)width;
-        int remainder = distance % patWidth;
-        int coverage = distance - remainder;
-        int numSegments = coverage / patWidth;
-
-        float patternOffset = 0.0f;
-        // Special case 1px dotted borders for speed.
-        if (patWidth == 1)
-            patternOffset = 1.0f;
-        else {
-            bool evenNumberOfSegments = !(numSegments % 2);
-            if (remainder)
-                evenNumberOfSegments = !evenNumberOfSegments;
-            if (evenNumberOfSegments) {
-                if (remainder) {
-                    patternOffset += patWidth - remainder;
-                    patternOffset += remainder / 2;
-                } else
-                    patternOffset = patWidth / 2;
-            } else {
-                if (remainder)
-                    patternOffset = (patWidth - remainder)/2;
-            }
-        }
-
-        const CGFloat dottedLine[2] = { static_cast&lt;CGFloat&gt;(patWidth), static_cast&lt;CGFloat&gt;(patWidth) };
-        CGContextSetLineDash(context, patternOffset, dottedLine, 2);
-    }
-
</del><span class="cx">     CGContextBeginPath(context);
</span><span class="cx">     CGContextMoveToPoint(context, p1.x(), p1.y());
</span><span class="cx">     CGContextAddLineToPoint(context, p2.x(), p2.y());
</span><del>-
</del><span class="cx">     CGContextStrokePath(context);
</span><del>-
-    if (patWidth)
-        CGContextRestoreGState(context);
-
</del><span class="cx">     if (shouldAntialias())
</span><span class="cx">         CGContextSetShouldAntialias(context, true);
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (177657 => 177658)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp        2014-12-22 23:09:22 UTC (rev 177657)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp        2014-12-22 23:18:59 UTC (rev 177658)
</span><span class="lines">@@ -733,31 +733,15 @@
</span><span class="cx">             return;
</span><span class="cx">         case DOTTED:
</span><span class="cx">         case DASHED: {
</span><del>-            if (thickness &gt; 0) {
-                bool wasAntialiased = graphicsContext-&gt;shouldAntialias();
-                StrokeStyle oldStrokeStyle = graphicsContext-&gt;strokeStyle();
-                graphicsContext-&gt;setShouldAntialias(antialias);
-                graphicsContext-&gt;setStrokeColor(color, style.colorSpace());
-                graphicsContext-&gt;setStrokeThickness(thickness);
-                graphicsContext-&gt;setStrokeStyle(borderStyle == DASHED ? DashedStroke : DottedStroke);
-
-                // FIXME: There's some odd adjustment in GraphicsContext::drawLine() that disables device pixel precision line drawing.
-                int adjustedX = floorToInt((x1 + x2) / 2);
-                int adjustedY = floorToInt((y1 + y2) / 2);
-
-                switch (side) {
-                    case BSBottom:
-                    case BSTop:
-                        graphicsContext-&gt;drawLine(FloatPoint(x1, adjustedY), FloatPoint(x2, adjustedY));
-                        break;
-                    case BSRight:
-                    case BSLeft:
-                        graphicsContext-&gt;drawLine(FloatPoint(adjustedX, y1), FloatPoint(adjustedX, y2));
-                        break;
-                }
-                graphicsContext-&gt;setShouldAntialias(wasAntialiased);
-                graphicsContext-&gt;setStrokeStyle(oldStrokeStyle);
-            }
</del><ins>+            bool wasAntialiased = graphicsContext-&gt;shouldAntialias();
+            StrokeStyle oldStrokeStyle = graphicsContext-&gt;strokeStyle();
+            graphicsContext-&gt;setShouldAntialias(antialias);
+            graphicsContext-&gt;setStrokeColor(color, style.colorSpace());
+            graphicsContext-&gt;setStrokeThickness(thickness);
+            graphicsContext-&gt;setStrokeStyle(borderStyle == DASHED ? DashedStroke : DottedStroke);
+            graphicsContext-&gt;drawLine(roundPointToDevicePixels(LayoutPoint(x1, y1), deviceScaleFactor), roundPointToDevicePixels(LayoutPoint(x2, y2), deviceScaleFactor));
+            graphicsContext-&gt;setShouldAntialias(wasAntialiased);
+            graphicsContext-&gt;setStrokeStyle(oldStrokeStyle);
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case DOUBLE: {
</span></span></pre>
</div>
</div>

</body>
</html>