<!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>[164888] trunk/Source/WebCore</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/164888">164888</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2014-02-28 15:05:58 -0800 (Fri, 28 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Subpixel rendering: Add subpixel support to border type of double, groove, ridge, inset and outset.
https://bugs.webkit.org/show_bug.cgi?id=129226

Reviewed by Simon Fraser.

This is the conversion of double, inset, outset, groove and ridge border type
painting to support device pixel precision width/height.

Regression is covered by existing tests.

* rendering/RenderObject.cpp:
(WebCore::RenderObject::drawLineForBoxSide):
* rendering/RenderObject.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjecth">trunk/Source/WebCore/rendering/RenderObject.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (164887 => 164888)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-28 23:04:05 UTC (rev 164887)
+++ trunk/Source/WebCore/ChangeLog        2014-02-28 23:05:58 UTC (rev 164888)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2014-02-28  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        Subpixel rendering: Add subpixel support to border type of double, groove, ridge, inset and outset.
+        https://bugs.webkit.org/show_bug.cgi?id=129226
+
+        Reviewed by Simon Fraser.
+
+        This is the conversion of double, inset, outset, groove and ridge border type
+        painting to support device pixel precision width/height.
+
+        Regression is covered by existing tests.
+
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::drawLineForBoxSide):
+        * rendering/RenderObject.h:
+
</ins><span class="cx"> 2014-02-28  Adenilson Cavalcanti  &lt;cavalcantii@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Filters should test for area instead of single dimension
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (164887 => 164888)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp        2014-02-28 23:04:05 UTC (rev 164887)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp        2014-02-28 23:05:58 UTC (rev 164888)
</span><span class="lines">@@ -722,9 +722,10 @@
</span><span class="cx">     return toRenderBlock(o);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, LayoutUnit x1, LayoutUnit y1, LayoutUnit x2, LayoutUnit y2,
-    BoxSide side, Color color, EBorderStyle borderStyle, int adjacentWidth1, int adjacentWidth2, bool antialias)
</del><ins>+void RenderObject::drawLineForBoxSide(GraphicsContext* graphicsContext, float x1, float y1, float x2, float y2,
+    BoxSide side, Color color, EBorderStyle borderStyle, float adjacentWidth1, float adjacentWidth2, bool antialias)
</ins><span class="cx"> {
</span><ins>+    float deviceScaleFactor = document().deviceScaleFactor();
</ins><span class="cx">     float thickness;
</span><span class="cx">     float length;
</span><span class="cx">     if (side == BSTop || side == BSBottom) {
</span><span class="lines">@@ -734,21 +735,15 @@
</span><span class="cx">         thickness = x2 - x1;
</span><span class="cx">         length = y2 - y1;
</span><span class="cx">     }
</span><ins>+    // FIXME: flooring is a temporary solution until the device pixel snapping is added here for all border types (including recursive calls such as groove-&gt;(inset/outset)).
+    thickness = floorToDevicePixel(thickness, deviceScaleFactor);
+    length = floorToDevicePixel(length, deviceScaleFactor);
</ins><span class="cx"> 
</span><del>-    if (borderStyle == DOUBLE &amp;&amp; thickness &lt; 3)
</del><ins>+    if (borderStyle == DOUBLE &amp;&amp; (thickness * deviceScaleFactor) &lt; 3)
</ins><span class="cx">         borderStyle = SOLID;
</span><span class="cx"> 
</span><del>-    float pixelSnappingFactor = document().deviceScaleFactor();
</del><span class="cx">     // FIXME: We really would like this check to be an ASSERT as we don't want to draw empty borders. However
</span><span class="cx">     // nothing guarantees that the following recursive calls to drawLineForBoxSide will have non-null dimensions.
</span><del>-    // FIXME: flooring is a temporary solution until the device pixel snapping is added here for all border types.
-    if (borderStyle == SOLID) {
-        thickness = roundToDevicePixel(thickness, pixelSnappingFactor);
-        length = roundToDevicePixel(length, pixelSnappingFactor);
-    } else {
-        thickness = floorf(thickness);
-        length = floorf(length);
-    }
</del><span class="cx">     if (!thickness || !length)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -767,14 +762,18 @@
</span><span class="cx">                 graphicsContext-&gt;setStrokeThickness(thickness);
</span><span class="cx">                 graphicsContext-&gt;setStrokeStyle(borderStyle == DASHED ? DashedStroke : DottedStroke);
</span><span class="cx"> 
</span><ins>+                // 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);
+
</ins><span class="cx">                 switch (side) {
</span><span class="cx">                     case BSBottom:
</span><span class="cx">                     case BSTop:
</span><del>-                        graphicsContext-&gt;drawLine(IntPoint(x1, (y1 + y2) / 2), IntPoint(x2, (y1 + y2) / 2));
</del><ins>+                        graphicsContext-&gt;drawLine(FloatPoint(x1, adjustedY), FloatPoint(x2, adjustedY));
</ins><span class="cx">                         break;
</span><span class="cx">                     case BSRight:
</span><span class="cx">                     case BSLeft:
</span><del>-                        graphicsContext-&gt;drawLine(IntPoint((x1 + x2) / 2, y1), IntPoint((x1 + x2) / 2, y2));
</del><ins>+                        graphicsContext-&gt;drawLine(FloatPoint(adjustedX, y1), FloatPoint(adjustedX, y2));
</ins><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">                 graphicsContext-&gt;setShouldAntialias(wasAntialiased);
</span><span class="lines">@@ -783,7 +782,7 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case DOUBLE: {
</span><del>-            int thirdOfThickness = (thickness + 1) / 3;
</del><ins>+            float thirdOfThickness = ceilToDevicePixel(thickness / 3, deviceScaleFactor);
</ins><span class="cx">             ASSERT(thirdOfThickness);
</span><span class="cx"> 
</span><span class="cx">             if (adjacentWidth1 == 0 &amp;&amp; adjacentWidth2 == 0) {
</span><span class="lines">@@ -797,57 +796,67 @@
</span><span class="cx">                 switch (side) {
</span><span class="cx">                     case BSTop:
</span><span class="cx">                     case BSBottom:
</span><del>-                        graphicsContext-&gt;drawRect(IntRect(x1, y1, length, thirdOfThickness));
-                        graphicsContext-&gt;drawRect(IntRect(x1, y2 - thirdOfThickness, length, thirdOfThickness));
</del><ins>+                        graphicsContext-&gt;drawRect(pixelSnappedForPainting(x1, y1, length, thirdOfThickness, deviceScaleFactor));
+                        graphicsContext-&gt;drawRect(pixelSnappedForPainting(x1, y2 - thirdOfThickness, length, thirdOfThickness, deviceScaleFactor));
</ins><span class="cx">                         break;
</span><span class="cx">                     case BSLeft:
</span><span class="cx">                     case BSRight:
</span><del>-                        // FIXME: Why do we offset the border by 1 in this case but not the other one?
-                        if (length &gt; 1) {
-                            graphicsContext-&gt;drawRect(IntRect(x1, y1 + 1, thirdOfThickness, length - 1));
-                            graphicsContext-&gt;drawRect(IntRect(x2 - thirdOfThickness, y1 + 1, thirdOfThickness, length - 1));
-                        }
</del><ins>+                        graphicsContext-&gt;drawRect(pixelSnappedForPainting(x1, y1, thirdOfThickness, length, deviceScaleFactor));
+                        graphicsContext-&gt;drawRect(pixelSnappedForPainting(x2 - thirdOfThickness, y1, thirdOfThickness, length, deviceScaleFactor));
</ins><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 graphicsContext-&gt;setShouldAntialias(wasAntialiased);
</span><span class="cx">                 graphicsContext-&gt;setStrokeStyle(oldStrokeStyle);
</span><span class="cx">             } else {
</span><del>-                int adjacent1BigThird = ((adjacentWidth1 &gt; 0) ? adjacentWidth1 + 1 : adjacentWidth1 - 1) / 3;
-                int adjacent2BigThird = ((adjacentWidth2 &gt; 0) ? adjacentWidth2 + 1 : adjacentWidth2 - 1) / 3;
</del><ins>+                float adjacent1BigThird = ceilToDevicePixel(adjacentWidth1 / 3, deviceScaleFactor);
+                float adjacent2BigThird = ceilToDevicePixel(adjacentWidth2 / 3, deviceScaleFactor);
</ins><span class="cx"> 
</span><ins>+                float offset1 = floorToDevicePixel(fabs(adjacentWidth1) * 2 / 3, deviceScaleFactor);
+                float offset2 = floorToDevicePixel(fabs(adjacentWidth2) * 2 / 3, deviceScaleFactor);
+
+                float mitreOffset1 = adjacentWidth1 &lt; 0 ? offset1 : 0;
+                float mitreOffset2 = adjacentWidth1 &gt; 0 ? offset1 : 0;
+                float mitreOffset3 = adjacentWidth2 &lt; 0 ? offset2 : 0;
+                float mitreOffset4 = adjacentWidth2 &gt; 0 ? offset2 : 0;
+
+                FloatRect paintBorderRect;
</ins><span class="cx">                 switch (side) {
</span><span class="cx">                     case BSTop:
</span><del>-                        drawLineForBoxSide(graphicsContext, x1 + std::max((-adjacentWidth1 * 2 + 1) / 3, 0),
-                                   y1, x2 - std::max((-adjacentWidth2 * 2 + 1) / 3, 0), y1 + thirdOfThickness,
-                                   side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias);
-                        drawLineForBoxSide(graphicsContext, x1 + std::max((adjacentWidth1 * 2 + 1) / 3, 0),
-                                   y2 - thirdOfThickness, x2 - std::max((adjacentWidth2 * 2 + 1) / 3, 0), y2,
-                                   side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias);
</del><ins>+                        paintBorderRect = pixelSnappedForPainting(LayoutRect(x1 + mitreOffset1, y1, (x2 - mitreOffset3) - (x1 + mitreOffset1), thirdOfThickness), deviceScaleFactor);
+                        drawLineForBoxSide(graphicsContext, paintBorderRect.x(), paintBorderRect.y(), paintBorderRect.maxX(), paintBorderRect.maxY(), side, color, SOLID,
+                            adjacent1BigThird, adjacent2BigThird, antialias);
+
+                        paintBorderRect = pixelSnappedForPainting(LayoutRect(x1 + mitreOffset2, y2 - thirdOfThickness, (x2 - mitreOffset4) - (x1 + mitreOffset2), thirdOfThickness), deviceScaleFactor);
+                        drawLineForBoxSide(graphicsContext, paintBorderRect.x(), paintBorderRect.y(), paintBorderRect.maxX(), paintBorderRect.maxY(), side, color, SOLID,
+                            adjacent1BigThird, adjacent2BigThird, antialias);
</ins><span class="cx">                         break;
</span><span class="cx">                     case BSLeft:
</span><del>-                        drawLineForBoxSide(graphicsContext, x1, y1 + std::max((-adjacentWidth1 * 2 + 1) / 3, 0),
-                                   x1 + thirdOfThickness, y2 - std::max((-adjacentWidth2 * 2 + 1) / 3, 0),
-                                   side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias);
-                        drawLineForBoxSide(graphicsContext, x2 - thirdOfThickness, y1 + std::max((adjacentWidth1 * 2 + 1) / 3, 0),
-                                   x2, y2 - std::max((adjacentWidth2 * 2 + 1) / 3, 0),
-                                   side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias);
</del><ins>+                        paintBorderRect = pixelSnappedForPainting(LayoutRect(x1, y1 + mitreOffset1, thirdOfThickness, (y2 - mitreOffset3) - (y1 + mitreOffset1)), deviceScaleFactor);
+                        drawLineForBoxSide(graphicsContext, paintBorderRect.x(), paintBorderRect.y(), paintBorderRect.maxX(), paintBorderRect.maxY(), side, color, SOLID,
+                            adjacent1BigThird, adjacent2BigThird, antialias);
+
+                        paintBorderRect = pixelSnappedForPainting(LayoutRect(x2 - thirdOfThickness, y1 + mitreOffset2, thirdOfThickness, (y2 - mitreOffset4) - (y1 + mitreOffset2)), deviceScaleFactor);
+                        drawLineForBoxSide(graphicsContext, paintBorderRect.x(), paintBorderRect.y(), paintBorderRect.maxX(), paintBorderRect.maxY(), side, color, SOLID,
+                            adjacent1BigThird, adjacent2BigThird, antialias);
</ins><span class="cx">                         break;
</span><span class="cx">                     case BSBottom:
</span><del>-                        drawLineForBoxSide(graphicsContext, x1 + std::max((adjacentWidth1 * 2 + 1) / 3, 0),
-                                   y1, x2 - std::max((adjacentWidth2 * 2 + 1) / 3, 0), y1 + thirdOfThickness,
-                                   side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias);
-                        drawLineForBoxSide(graphicsContext, x1 + std::max((-adjacentWidth1 * 2 + 1) / 3, 0),
-                                   y2 - thirdOfThickness, x2 - std::max((-adjacentWidth2 * 2 + 1) / 3, 0), y2,
-                                   side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias);
</del><ins>+                        paintBorderRect = pixelSnappedForPainting(LayoutRect(x1 + mitreOffset2, y1, (x2 - mitreOffset4) - (x1 + mitreOffset2), thirdOfThickness), deviceScaleFactor);
+                        drawLineForBoxSide(graphicsContext, paintBorderRect.x(), paintBorderRect.y(), paintBorderRect.maxX(), paintBorderRect.maxY(), side, color, SOLID,
+                            adjacent1BigThird, adjacent2BigThird, antialias);
+
+                        paintBorderRect = pixelSnappedForPainting(LayoutRect(x1 + mitreOffset1, y2 - thirdOfThickness, (x2 - mitreOffset3) - (x1 + mitreOffset1), thirdOfThickness), deviceScaleFactor);
+                        drawLineForBoxSide(graphicsContext, paintBorderRect.x(), paintBorderRect.y(), paintBorderRect.maxX(), paintBorderRect.maxY(), side, color, SOLID,
+                            adjacent1BigThird, adjacent2BigThird, antialias);
</ins><span class="cx">                         break;
</span><span class="cx">                     case BSRight:
</span><del>-                        drawLineForBoxSide(graphicsContext, x1, y1 + std::max((adjacentWidth1 * 2 + 1) / 3, 0),
-                                   x1 + thirdOfThickness, y2 - std::max((adjacentWidth2 * 2 + 1) / 3, 0),
-                                   side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias);
-                        drawLineForBoxSide(graphicsContext, x2 - thirdOfThickness, y1 + std::max((-adjacentWidth1 * 2 + 1) / 3, 0),
-                                   x2, y2 - std::max((-adjacentWidth2 * 2 + 1) / 3, 0),
-                                   side, color, SOLID, adjacent1BigThird, adjacent2BigThird, antialias);
</del><ins>+                        paintBorderRect = pixelSnappedForPainting(LayoutRect(x1, y1 + mitreOffset2, thirdOfThickness, (y2 - mitreOffset4) - (y1 + mitreOffset2)), deviceScaleFactor);
+                        drawLineForBoxSide(graphicsContext, paintBorderRect.x(), paintBorderRect.y(), paintBorderRect.maxX(), paintBorderRect.maxY(), side, color, SOLID,
+                            adjacent1BigThird, adjacent2BigThird, antialias);
+
+                        paintBorderRect = pixelSnappedForPainting(LayoutRect(x2 - thirdOfThickness, y1 + mitreOffset1, thirdOfThickness, (y2 - mitreOffset3) - (y1 + mitreOffset1)), deviceScaleFactor);
+                        drawLineForBoxSide(graphicsContext, paintBorderRect.x(), paintBorderRect.y(), paintBorderRect.maxX(), paintBorderRect.maxY(), side, color, SOLID,
+                            adjacent1BigThird, adjacent2BigThird, antialias);
</ins><span class="cx">                         break;
</span><span class="cx">                     default:
</span><span class="cx">                         break;
</span><span class="lines">@@ -867,33 +876,53 @@
</span><span class="cx">                 s2 = INSET;
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            int adjacent1BigHalf = ((adjacentWidth1 &gt; 0) ? adjacentWidth1 + 1 : adjacentWidth1 - 1) / 2;
-            int adjacent2BigHalf = ((adjacentWidth2 &gt; 0) ? adjacentWidth2 + 1 : adjacentWidth2 - 1) / 2;
</del><ins>+            float adjacent1BigHalf = ceilToDevicePixel(adjacentWidth1 / 2, deviceScaleFactor);
+            float adjacent2BigHalf = ceilToDevicePixel(adjacentWidth2 / 2, deviceScaleFactor);
</ins><span class="cx"> 
</span><ins>+            float adjacent1SmallHalf = floorToDevicePixel(adjacentWidth1 / 2, deviceScaleFactor);
+            float adjacent2SmallHalf = floorToDevicePixel(adjacentWidth2 / 2, deviceScaleFactor);
+
+            float offset1 = 0;
+            float offset2 = 0;
+            float offset3 = 0;
+            float offset4 = 0;
+
+            if (((side == BSTop || side == BSLeft) &amp;&amp; adjacentWidth1 &lt; 0) || ((side == BSBottom || side == BSRight) &amp;&amp; adjacentWidth1 &gt; 0))
+                offset1 = floorToDevicePixel(adjacentWidth1 / 2, deviceScaleFactor);
+
+            if (((side == BSTop || side == BSLeft) &amp;&amp; adjacentWidth2 &lt; 0) || ((side == BSBottom || side == BSRight) &amp;&amp; adjacentWidth2 &gt; 0))
+                offset2 = ceilToDevicePixel(adjacentWidth2 / 2, deviceScaleFactor);
+
+            if (((side == BSTop || side == BSLeft) &amp;&amp; adjacentWidth1 &gt; 0) || ((side == BSBottom || side == BSRight) &amp;&amp; adjacentWidth1 &lt; 0))
+                offset3 = floorToDevicePixel(fabs(adjacentWidth1) / 2, deviceScaleFactor);
+
+            if (((side == BSTop || side == BSLeft) &amp;&amp; adjacentWidth2 &gt; 0) || ((side == BSBottom || side == BSRight) &amp;&amp; adjacentWidth2 &lt; 0))
+                offset4 = ceilToDevicePixel(adjacentWidth2 / 2, deviceScaleFactor);
+
+            float adjustedX = ceilToDevicePixel((x1 + x2) / 2, deviceScaleFactor);
+            float adjustedY = ceilToDevicePixel((y1 + y2) / 2, deviceScaleFactor);
+            /// Quads can't use the default snapping rect functions.
+            x1 = roundToDevicePixel(x1, deviceScaleFactor);
+            x2 = roundToDevicePixel(x2, deviceScaleFactor);
+            y1 = roundToDevicePixel(y1, deviceScaleFactor);
+            y2 = roundToDevicePixel(y2, deviceScaleFactor);
+
</ins><span class="cx">             switch (side) {
</span><span class="cx">                 case BSTop:
</span><del>-                    drawLineForBoxSide(graphicsContext, x1 + std::max(-adjacentWidth1, 0) / 2, y1, x2 - std::max(-adjacentWidth2, 0) / 2, (y1 + y2 + 1) / 2,
-                               side, color, s1, adjacent1BigHalf, adjacent2BigHalf, antialias);
-                    drawLineForBoxSide(graphicsContext, x1 + std::max(adjacentWidth1 + 1, 0) / 2, (y1 + y2 + 1) / 2, x2 - std::max(adjacentWidth2 + 1, 0) / 2, y2,
-                               side, color, s2, adjacentWidth1 / 2, adjacentWidth2 / 2, antialias);
</del><ins>+                    drawLineForBoxSide(graphicsContext, x1 + offset1, y1, x2 - offset2, adjustedY, side, color, s1, adjacent1BigHalf, adjacent2BigHalf, antialias);
+                    drawLineForBoxSide(graphicsContext, x1 + offset3, adjustedY, x2 - offset4, y2, side, color, s2, adjacent1SmallHalf, adjacent2SmallHalf, antialias);
</ins><span class="cx">                     break;
</span><span class="cx">                 case BSLeft:
</span><del>-                    drawLineForBoxSide(graphicsContext, x1, y1 + std::max(-adjacentWidth1, 0) / 2, (x1 + x2 + 1) / 2, y2 - std::max(-adjacentWidth2, 0) / 2,
-                               side, color, s1, adjacent1BigHalf, adjacent2BigHalf, antialias);
-                    drawLineForBoxSide(graphicsContext, (x1 + x2 + 1) / 2, y1 + std::max(adjacentWidth1 + 1, 0) / 2, x2, y2 - std::max(adjacentWidth2 + 1, 0) / 2,
-                               side, color, s2, adjacentWidth1 / 2, adjacentWidth2 / 2, antialias);
</del><ins>+                    drawLineForBoxSide(graphicsContext, x1, y1 + offset1, adjustedX, y2 - offset2, side, color, s1, adjacent1BigHalf, adjacent2BigHalf, antialias);
+                    drawLineForBoxSide(graphicsContext, adjustedX, y1 + offset3, x2, y2 - offset4, side, color, s2, adjacent1SmallHalf, adjacent2SmallHalf, antialias);
</ins><span class="cx">                     break;
</span><span class="cx">                 case BSBottom:
</span><del>-                    drawLineForBoxSide(graphicsContext, x1 + std::max(adjacentWidth1, 0) / 2, y1, x2 - std::max(adjacentWidth2, 0) / 2, (y1 + y2 + 1) / 2,
-                               side, color, s2, adjacent1BigHalf, adjacent2BigHalf, antialias);
-                    drawLineForBoxSide(graphicsContext, x1 + std::max(-adjacentWidth1 + 1, 0) / 2, (y1 + y2 + 1) / 2, x2 - std::max(-adjacentWidth2 + 1, 0) / 2, y2,
-                               side, color, s1, adjacentWidth1 / 2, adjacentWidth2 / 2, antialias);
</del><ins>+                    drawLineForBoxSide(graphicsContext, x1 + offset1, y1, x2 - offset2, adjustedY, side, color, s2, adjacent1BigHalf, adjacent2BigHalf, antialias);
+                    drawLineForBoxSide(graphicsContext, x1 + offset3, adjustedY, x2 - offset4, y2, side, color, s1, adjacent1SmallHalf, adjacent2SmallHalf, antialias);
</ins><span class="cx">                     break;
</span><span class="cx">                 case BSRight:
</span><del>-                    drawLineForBoxSide(graphicsContext, x1, y1 + std::max(adjacentWidth1, 0) / 2, (x1 + x2 + 1) / 2, y2 - std::max(adjacentWidth2, 0) / 2,
-                               side, color, s2, adjacent1BigHalf, adjacent2BigHalf, antialias);
-                    drawLineForBoxSide(graphicsContext, (x1 + x2 + 1) / 2, y1 + std::max(-adjacentWidth1 + 1, 0) / 2, x2, y2 - std::max(-adjacentWidth2 + 1, 0) / 2,
-                               side, color, s1, adjacentWidth1 / 2, adjacentWidth2 / 2, antialias);
</del><ins>+                    drawLineForBoxSide(graphicsContext, x1, y1 + offset1, adjustedX, y2 - offset2, side, color, s2, adjacent1BigHalf, adjacent2BigHalf, antialias);
+                    drawLineForBoxSide(graphicsContext, adjustedX, y1 + offset3, x2, y2 - offset4, side, color, s1, adjacent1SmallHalf, adjacent2SmallHalf, antialias);
</ins><span class="cx">                     break;
</span><span class="cx">             }
</span><span class="cx">             break;
</span><span class="lines">@@ -919,36 +948,42 @@
</span><span class="cx">                 // this matters for rects in transformed contexts.
</span><span class="cx">                 bool wasAntialiased = graphicsContext-&gt;shouldAntialias();
</span><span class="cx">                 graphicsContext-&gt;setShouldAntialias(antialias);
</span><del>-                graphicsContext-&gt;drawRect(pixelSnappedForPainting(x1, y1, x2 - x1, y2 - y1, pixelSnappingFactor));
</del><ins>+                graphicsContext-&gt;drawRect(pixelSnappedForPainting(x1, y1, x2 - x1, y2 - y1, deviceScaleFactor));
</ins><span class="cx">                 graphicsContext-&gt;setShouldAntialias(wasAntialiased);
</span><span class="cx">                 graphicsContext-&gt;setStrokeStyle(oldStrokeStyle);
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><ins>+
+            // FIXME: These roundings should be replaced by ASSERT(device pixel positioned) when all the callers transitioned to device pixels.
+            x1 = roundToDevicePixel(x1, deviceScaleFactor);
+            y1 = roundToDevicePixel(y1, deviceScaleFactor);
+            x2 = roundToDevicePixel(x2, deviceScaleFactor);
+            y2 = roundToDevicePixel(y2, deviceScaleFactor);
</ins><span class="cx">             FloatPoint quad[4];
</span><span class="cx">             switch (side) {
</span><span class="cx">                 case BSTop:
</span><del>-                    quad[0] = FloatPoint(x1 + std::max(-adjacentWidth1, 0), y1);
-                    quad[1] = FloatPoint(x1 + std::max(adjacentWidth1, 0), y2);
-                    quad[2] = FloatPoint(x2 - std::max(adjacentWidth2, 0), y2);
-                    quad[3] = FloatPoint(x2 - std::max(-adjacentWidth2, 0), y1);
</del><ins>+                    quad[0] = FloatPoint(x1 + std::max&lt;float&gt;(-adjacentWidth1, 0), y1);
+                    quad[1] = FloatPoint(x1 + std::max&lt;float&gt;(adjacentWidth1, 0), y2);
+                    quad[2] = FloatPoint(x2 - std::max&lt;float&gt;(adjacentWidth2, 0), y2);
+                    quad[3] = FloatPoint(x2 - std::max&lt;float&gt;(-adjacentWidth2, 0), y1);
</ins><span class="cx">                     break;
</span><span class="cx">                 case BSBottom:
</span><del>-                    quad[0] = FloatPoint(x1 + std::max(adjacentWidth1, 0), y1);
-                    quad[1] = FloatPoint(x1 + std::max(-adjacentWidth1, 0), y2);
-                    quad[2] = FloatPoint(x2 - std::max(-adjacentWidth2, 0), y2);
-                    quad[3] = FloatPoint(x2 - std::max(adjacentWidth2, 0), y1);
</del><ins>+                    quad[0] = FloatPoint(x1 + std::max&lt;float&gt;(adjacentWidth1, 0), y1);
+                    quad[1] = FloatPoint(x1 + std::max&lt;float&gt;(-adjacentWidth1, 0), y2);
+                    quad[2] = FloatPoint(x2 - std::max&lt;float&gt;(-adjacentWidth2, 0), y2);
+                    quad[3] = FloatPoint(x2 - std::max&lt;float&gt;(adjacentWidth2, 0), y1);
</ins><span class="cx">                     break;
</span><span class="cx">                 case BSLeft:
</span><del>-                    quad[0] = FloatPoint(x1, y1 + std::max(-adjacentWidth1, 0));
-                    quad[1] = FloatPoint(x1, y2 - std::max(-adjacentWidth2, 0));
-                    quad[2] = FloatPoint(x2, y2 - std::max(adjacentWidth2, 0));
-                    quad[3] = FloatPoint(x2, y1 + std::max(adjacentWidth1, 0));
</del><ins>+                    quad[0] = FloatPoint(x1, y1 + std::max&lt;float&gt;(-adjacentWidth1, 0));
+                    quad[1] = FloatPoint(x1, y2 - std::max&lt;float&gt;(-adjacentWidth2, 0));
+                    quad[2] = FloatPoint(x2, y2 - std::max&lt;float&gt;(adjacentWidth2, 0));
+                    quad[3] = FloatPoint(x2, y1 + std::max&lt;float&gt;(adjacentWidth1, 0));
</ins><span class="cx">                     break;
</span><span class="cx">                 case BSRight:
</span><del>-                    quad[0] = FloatPoint(x1, y1 + std::max(adjacentWidth1, 0));
-                    quad[1] = FloatPoint(x1, y2 - std::max(adjacentWidth2, 0));
-                    quad[2] = FloatPoint(x2, y2 - std::max(-adjacentWidth2, 0));
-                    quad[3] = FloatPoint(x2, y1 + std::max(-adjacentWidth1, 0));
</del><ins>+                    quad[0] = FloatPoint(x1, y1 + std::max&lt;float&gt;(adjacentWidth1, 0));
+                    quad[1] = FloatPoint(x1, y2 - std::max&lt;float&gt;(adjacentWidth2, 0));
+                    quad[2] = FloatPoint(x2, y2 - std::max&lt;float&gt;(-adjacentWidth2, 0));
+                    quad[3] = FloatPoint(x2, y1 + std::max&lt;float&gt;(-adjacentWidth1, 0));
</ins><span class="cx">                     break;
</span><span class="cx">             }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.h (164887 => 164888)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.h        2014-02-28 23:04:05 UTC (rev 164887)
+++ trunk/Source/WebCore/rendering/RenderObject.h        2014-02-28 23:05:58 UTC (rev 164888)
</span><span class="lines">@@ -876,8 +876,7 @@
</span><span class="cx"> 
</span><span class="cx">     RespectImageOrientationEnum shouldRespectImageOrientation() const;
</span><span class="cx"> 
</span><del>-    void drawLineForBoxSide(GraphicsContext*, LayoutUnit x1, LayoutUnit y1, LayoutUnit x2, LayoutUnit y2, BoxSide,
-                            Color, EBorderStyle, int adjbw1, int adjbw2, bool antialias = false);
</del><ins>+    void drawLineForBoxSide(GraphicsContext*, float x1, float y1, float x2, float y2, BoxSide, Color, EBorderStyle, float adjbw1, float adjbw2, bool antialias = false);
</ins><span class="cx"> protected:
</span><span class="cx">     int columnNumberForOffset(int offset);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>