<!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>[166925] 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/166925">166925</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2014-04-08 07:50:38 -0700 (Tue, 08 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Subpixel rendering: Make border images device pixel aware.
https://bugs.webkit.org/show_bug.cgi?id=131209

Reviewed by Simon Fraser.

Snap border-image size and position to device pixels. It works both on generated and bitmap images.

Source/WebCore:

Test: fast/borders/hidpi-border-image-gradient-on-subpixels.html

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintNinePieceImage):

LayoutTests:

* fast/borders/hidpi-border-image-gradient-on-subpixels-expected.html: Added.
* fast/borders/hidpi-border-image-gradient-on-subpixels.html: 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="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastbordershidpiborderimagegradientonsubpixelsexpectedhtml">trunk/LayoutTests/fast/borders/hidpi-border-image-gradient-on-subpixels-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastbordershidpiborderimagegradientonsubpixelshtml">trunk/LayoutTests/fast/borders/hidpi-border-image-gradient-on-subpixels.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (166924 => 166925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-04-08 12:09:51 UTC (rev 166924)
+++ trunk/LayoutTests/ChangeLog        2014-04-08 14:50:38 UTC (rev 166925)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-04-08  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        Subpixel rendering: Make border images device pixel aware.
+        https://bugs.webkit.org/show_bug.cgi?id=131209
+
+        Reviewed by Simon Fraser.
+
+        Snap border-image size and position to device pixels. It works both on generated and bitmap images.
+
+        * fast/borders/hidpi-border-image-gradient-on-subpixels-expected.html: Added.
+        * fast/borders/hidpi-border-image-gradient-on-subpixels.html: Added.
+
</ins><span class="cx"> 2014-04-08  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         [SOUP] Control cookie management according ResourceRequest.allowCookies()
</span></span></pre></div>
<a id="trunkLayoutTestsfastbordershidpiborderimagegradientonsubpixelsexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/borders/hidpi-border-image-gradient-on-subpixels-expected.html (0 => 166925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/borders/hidpi-border-image-gradient-on-subpixels-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/borders/hidpi-border-image-gradient-on-subpixels-expected.html        2014-04-08 14:50:38 UTC (rev 166925)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that border images sized and positioned properly on subpixels.&lt;/title&gt;
+&lt;style&gt;
+  div {
+    border-width:0px 0px 0px 0.5px;
+    border-color: black;
+    border-style: solid;
+    position: fixed;
+  }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;container&quot;&gt;&lt;/p&gt;
+&lt;script&gt;
+  var container = document.getElementById(&quot;container&quot;);
+  w=5; h=5;
+  for (i = 0; i &lt; 15; ++i) {
+    b = 0;
+    for (j = 0; j &lt; 15; ++j) {
+      var e = document.createElement(&quot;div&quot;);
+      e.style.top = ((w + 1) * i) + &quot;px&quot;;
+      e.style.left = ((w + 1) * j) + &quot;px&quot;;
+      e.style.width = w + &quot;px&quot;;
+      e.style.height = h + &quot;px&quot;;
+      e.style.borderLeftWidth = b + &quot;px&quot;;
+      container.appendChild(e);
+      w+=0.1;
+      h+=0.1;
+      b+=0.5;
+    }
+  }
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastbordershidpiborderimagegradientonsubpixelshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/borders/hidpi-border-image-gradient-on-subpixels.html (0 => 166925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/borders/hidpi-border-image-gradient-on-subpixels.html                                (rev 0)
+++ trunk/LayoutTests/fast/borders/hidpi-border-image-gradient-on-subpixels.html        2014-04-08 14:50:38 UTC (rev 166925)
</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 border images sized and positioned properly on subpixels.&lt;/title&gt;
+&lt;style&gt;
+  div {
+    border-width:0px 0px 0px 0.5px;
+    position: fixed;
+    -webkit-border-image: -webkit-linear-gradient(black, black) 1 100%;
+  }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p id=&quot;container&quot;&gt;&lt;/p&gt;
+&lt;script&gt;
+  var container = document.getElementById(&quot;container&quot;);
+  w=5; h=5;
+  for (i = 0; i &lt; 15; ++i) {
+    b = 0;
+    for (j = 0; j &lt; 15; ++j) {
+      var e = document.createElement(&quot;div&quot;);
+      e.style.top = ((w + 1) * i) + &quot;px&quot;;
+      e.style.left = ((w + 1) * j) + &quot;px&quot;;
+      e.style.width = w + &quot;px&quot;;
+      e.style.height = h + &quot;px&quot;;
+      e.style.borderLeftWidth = b + &quot;px&quot;;
+      container.appendChild(e);
+      w+=0.1;
+      h+=0.1;
+      b+=0.5;
+    }
+  }
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (166924 => 166925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-04-08 12:09:51 UTC (rev 166924)
+++ trunk/Source/WebCore/ChangeLog        2014-04-08 14:50:38 UTC (rev 166925)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2014-04-08  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        Subpixel rendering: Make border images device pixel aware.
+        https://bugs.webkit.org/show_bug.cgi?id=131209
+
+        Reviewed by Simon Fraser.
+
+        Snap border-image size and position to device pixels. It works both on generated and bitmap images.
+
+        Test: fast/borders/hidpi-border-image-gradient-on-subpixels.html
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintNinePieceImage):
+
</ins><span class="cx"> 2014-04-08  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         [SOUP] Control cookie management according ResourceRequest.allowCookies()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (166924 => 166925)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-04-08 12:09:51 UTC (rev 166924)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-04-08 14:50:38 UTC (rev 166925)
</span><span class="lines">@@ -1244,39 +1244,40 @@
</span><span class="cx"> 
</span><span class="cx">     // FIXME: border-image is broken with full page zooming when tiling has to happen, since the tiling function
</span><span class="cx">     // doesn't have any understanding of the zoom that is in effect on the tile.
</span><ins>+    float deviceScaleFactor = document().deviceScaleFactor();
</ins><span class="cx">     LayoutRect rectWithOutsets = rect;
</span><span class="cx">     rectWithOutsets.expand(style.imageOutsets(ninePieceImage));
</span><del>-    IntRect borderImageRect = pixelSnappedIntRect(rectWithOutsets);
</del><ins>+    LayoutRect borderImageRect = LayoutRect(pixelSnappedForPainting(rectWithOutsets, deviceScaleFactor));
</ins><span class="cx"> 
</span><span class="cx">     LayoutSize imageSize = calculateImageIntrinsicDimensions(styleImage, borderImageRect.size(), DoNotScaleByEffectiveZoom);
</span><span class="cx"> 
</span><span class="cx">     // If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any.
</span><span class="cx">     styleImage-&gt;setContainerSizeForRenderer(this, imageSize, style.effectiveZoom());
</span><span class="cx"> 
</span><del>-    int imageWidth = imageSize.width();
-    int imageHeight = imageSize.height();
</del><ins>+    LayoutUnit imageWidth = imageSize.width();
+    LayoutUnit imageHeight = imageSize.height();
</ins><span class="cx">     RenderView* renderView = &amp;view();
</span><span class="cx"> 
</span><span class="cx">     float imageScaleFactor = styleImage-&gt;imageScaleFactor();
</span><del>-    int topSlice = std::min&lt;int&gt;(imageHeight, valueForLength(ninePieceImage.imageSlices().top(), imageHeight)) * imageScaleFactor;
-    int rightSlice = std::min&lt;int&gt;(imageWidth, valueForLength(ninePieceImage.imageSlices().right(), imageWidth)) * imageScaleFactor;
-    int bottomSlice = std::min&lt;int&gt;(imageHeight, valueForLength(ninePieceImage.imageSlices().bottom(), imageHeight)) * imageScaleFactor;
-    int leftSlice = std::min&lt;int&gt;(imageWidth, valueForLength(ninePieceImage.imageSlices().left(), imageWidth)) * imageScaleFactor;
</del><ins>+    LayoutUnit topSlice = std::min&lt;LayoutUnit&gt;(imageHeight, valueForLength(ninePieceImage.imageSlices().top(), imageHeight)) * imageScaleFactor;
+    LayoutUnit rightSlice = std::min&lt;LayoutUnit&gt;(imageWidth, valueForLength(ninePieceImage.imageSlices().right(), imageWidth)) * imageScaleFactor;
+    LayoutUnit bottomSlice = std::min&lt;LayoutUnit&gt;(imageHeight, valueForLength(ninePieceImage.imageSlices().bottom(), imageHeight)) * imageScaleFactor;
+    LayoutUnit leftSlice = std::min&lt;LayoutUnit&gt;(imageWidth, valueForLength(ninePieceImage.imageSlices().left(), imageWidth)) * imageScaleFactor;
</ins><span class="cx"> 
</span><span class="cx">     ENinePieceImageRule hRule = ninePieceImage.horizontalRule();
</span><span class="cx">     ENinePieceImageRule vRule = ninePieceImage.verticalRule();
</span><span class="cx"> 
</span><del>-    int topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), style.borderTopWidth(), topSlice, borderImageRect.height(), renderView);
-    int rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(), style.borderRightWidth(), rightSlice, borderImageRect.width(), renderView);
-    int bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().bottom(), style.borderBottomWidth(), bottomSlice, borderImageRect.height(), renderView);
-    int leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(), style.borderLeftWidth(), leftSlice, borderImageRect.width(), renderView);
</del><ins>+    LayoutUnit topWidth = computeBorderImageSide(ninePieceImage.borderSlices().top(), style.borderTopWidth(), topSlice, borderImageRect.height(), renderView);
+    LayoutUnit rightWidth = computeBorderImageSide(ninePieceImage.borderSlices().right(), style.borderRightWidth(), rightSlice, borderImageRect.width(), renderView);
+    LayoutUnit bottomWidth = computeBorderImageSide(ninePieceImage.borderSlices().bottom(), style.borderBottomWidth(), bottomSlice, borderImageRect.height(), renderView);
+    LayoutUnit leftWidth = computeBorderImageSide(ninePieceImage.borderSlices().left(), style.borderLeftWidth(), leftSlice, borderImageRect.width(), renderView);
</ins><span class="cx">     
</span><span class="cx">     // Reduce the widths if they're too large.
</span><span class="cx">     // The spec says: Given Lwidth as the width of the border image area, Lheight as its height, and Wside as the border image width
</span><span class="cx">     // offset for the side, let f = min(Lwidth/(Wleft+Wright), Lheight/(Wtop+Wbottom)). If f &lt; 1, then all W are reduced by
</span><span class="cx">     // multiplying them by f.
</span><del>-    int borderSideWidth = std::max(1, leftWidth + rightWidth);
-    int borderSideHeight = std::max(1, topWidth + bottomWidth);
</del><ins>+    LayoutUnit borderSideWidth = std::max&lt;LayoutUnit&gt;(1 / deviceScaleFactor, leftWidth + rightWidth);
+    LayoutUnit borderSideHeight = std::max&lt;LayoutUnit&gt;(1 / deviceScaleFactor, topWidth + bottomWidth);
</ins><span class="cx">     float borderSideScaleFactor = std::min((float)borderImageRect.width() / borderSideWidth, (float)borderImageRect.height() / borderSideHeight);
</span><span class="cx">     if (borderSideScaleFactor &lt; 1) {
</span><span class="cx">         topWidth *= borderSideScaleFactor;
</span><span class="lines">@@ -1305,29 +1306,29 @@
</span><span class="cx">     float rightSideScale = drawRight ? (float)rightWidth / rightSlice : 1;
</span><span class="cx">     float topSideScale = drawTop ? (float)topWidth / topSlice : 1;
</span><span class="cx">     float bottomSideScale = drawBottom ? (float)bottomWidth / bottomSlice : 1;
</span><del>-    
</del><ins>+
+    float x = borderImageRect.location().x();
+    float y = borderImageRect.location().y();
</ins><span class="cx">     if (drawLeft) {
</span><span class="cx">         // Paint the top and bottom left corners.
</span><span class="cx"> 
</span><span class="cx">         // The top left corner rect is (tx, ty, leftWidth, topWidth)
</span><span class="cx">         // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
</span><span class="cx">         if (drawTop)
</span><del>-            graphicsContext-&gt;drawImage(image.get(), colorSpace, IntRect(borderImageRect.location(), IntSize(leftWidth, topWidth)),
-                LayoutRect(0, 0, leftSlice, topSlice), op, ImageOrientationDescription());
</del><ins>+            graphicsContext-&gt;drawImage(image.get(), colorSpace, pixelSnappedForPainting(x, y, leftWidth, topWidth, deviceScaleFactor),
+                pixelSnappedForPainting(0, 0, leftSlice, topSlice, deviceScaleFactor), op, ImageOrientationDescription());
</ins><span class="cx"> 
</span><span class="cx">         // The bottom left corner rect is (tx, ty + h - bottomWidth, leftWidth, bottomWidth)
</span><span class="cx">         // The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
</span><span class="cx">         if (drawBottom)
</span><del>-            graphicsContext-&gt;drawImage(image.get(), colorSpace, IntRect(borderImageRect.x(), borderImageRect.maxY() - bottomWidth, leftWidth, bottomWidth),
-                LayoutRect(0, imageHeight - bottomSlice, leftSlice, bottomSlice), op, ImageOrientationDescription());
</del><ins>+            graphicsContext-&gt;drawImage(image.get(), colorSpace, pixelSnappedForPainting(x, borderImageRect.maxY() - bottomWidth, leftWidth, bottomWidth, deviceScaleFactor),
+                pixelSnappedForPainting(0, imageHeight - bottomSlice, leftSlice, bottomSlice, deviceScaleFactor), op, ImageOrientationDescription());
</ins><span class="cx"> 
</span><span class="cx">         // Paint the left edge.
</span><span class="cx">         // Have to scale and tile into the border rect.
</span><span class="cx">         if (sourceHeight &gt; 0)
</span><del>-            graphicsContext-&gt;drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x(), borderImageRect.y() + topWidth, leftWidth,
-                                            destinationHeight),
-                                            IntRect(0, topSlice, leftSlice, sourceHeight),
-                                            FloatSize(leftSideScale, leftSideScale), Image::StretchTile, (Image::TileRule)vRule, op);
</del><ins>+            graphicsContext-&gt;drawTiledImage(image.get(), colorSpace, pixelSnappedForPainting(x, y + topWidth, leftWidth, destinationHeight, deviceScaleFactor),
+                pixelSnappedForPainting(0, topSlice, leftSlice, sourceHeight, deviceScaleFactor), FloatSize(leftSideScale, leftSideScale), Image::StretchTile, (Image::TileRule)vRule, op);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (drawRight) {
</span><span class="lines">@@ -1335,37 +1336,33 @@
</span><span class="cx">         // The top right corner rect is (tx + w - rightWidth, ty, rightWidth, topWidth)
</span><span class="cx">         // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
</span><span class="cx">         if (drawTop)
</span><del>-            graphicsContext-&gt;drawImage(image.get(), colorSpace, IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.y(), rightWidth, topWidth),
-                LayoutRect(imageWidth - rightSlice, 0, rightSlice, topSlice), op, ImageOrientationDescription());
</del><ins>+            graphicsContext-&gt;drawImage(image.get(), colorSpace, pixelSnappedForPainting(borderImageRect.maxX() - rightWidth, y, rightWidth, topWidth, deviceScaleFactor),
+                pixelSnappedForPainting(imageWidth - rightSlice, 0, rightSlice, topSlice, deviceScaleFactor), op, ImageOrientationDescription());
</ins><span class="cx"> 
</span><span class="cx">         // The bottom right corner rect is (tx + w - rightWidth, ty + h - bottomWidth, rightWidth, bottomWidth)
</span><span class="cx">         // The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice)
</span><span class="cx">         if (drawBottom)
</span><del>-            graphicsContext-&gt;drawImage(image.get(), colorSpace, IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.maxY() - bottomWidth, rightWidth, bottomWidth),
-                LayoutRect(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice), op, ImageOrientationDescription());
</del><ins>+            graphicsContext-&gt;drawImage(image.get(), colorSpace, pixelSnappedForPainting(borderImageRect.maxX() - rightWidth, borderImageRect.maxY() - bottomWidth,
+                rightWidth, bottomWidth, deviceScaleFactor), pixelSnappedForPainting(imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice, deviceScaleFactor),
+                op, ImageOrientationDescription());
</ins><span class="cx"> 
</span><span class="cx">         // Paint the right edge.
</span><span class="cx">         if (sourceHeight &gt; 0)
</span><del>-            graphicsContext-&gt;drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.maxX() - rightWidth, borderImageRect.y() + topWidth, rightWidth,
-                                            destinationHeight),
-                                            IntRect(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight),
-                                            FloatSize(rightSideScale, rightSideScale),
-                                            Image::StretchTile, (Image::TileRule)vRule, op);
</del><ins>+            graphicsContext-&gt;drawTiledImage(image.get(), colorSpace, pixelSnappedForPainting(borderImageRect.maxX() - rightWidth, y + topWidth, rightWidth, deviceScaleFactor,
+                destinationHeight), pixelSnappedForPainting(imageWidth - rightSlice, topSlice, rightSlice, sourceHeight, deviceScaleFactor), FloatSize(rightSideScale, rightSideScale),
+                Image::StretchTile, (Image::TileRule)vRule, op);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Paint the top edge.
</span><span class="cx">     if (drawTop &amp;&amp; sourceWidth &gt; 0)
</span><del>-        graphicsContext-&gt;drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x() + leftWidth, borderImageRect.y(), destinationWidth, topWidth),
-                                        IntRect(leftSlice, 0, sourceWidth, topSlice),
-                                        FloatSize(topSideScale, topSideScale), (Image::TileRule)hRule, Image::StretchTile, op);
</del><ins>+        graphicsContext-&gt;drawTiledImage(image.get(), colorSpace, pixelSnappedForPainting(x + leftWidth, y, destinationWidth, topWidth, deviceScaleFactor),
+            pixelSnappedForPainting(leftSlice, 0, sourceWidth, topSlice, deviceScaleFactor), FloatSize(topSideScale, topSideScale), (Image::TileRule)hRule, Image::StretchTile, op);
</ins><span class="cx"> 
</span><span class="cx">     // Paint the bottom edge.
</span><span class="cx">     if (drawBottom &amp;&amp; sourceWidth &gt; 0)
</span><del>-        graphicsContext-&gt;drawTiledImage(image.get(), colorSpace, IntRect(borderImageRect.x() + leftWidth, borderImageRect.maxY() - bottomWidth,
-                                        destinationWidth, bottomWidth),
-                                        IntRect(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice),
-                                        FloatSize(bottomSideScale, bottomSideScale),
-                                        (Image::TileRule)hRule, Image::StretchTile, op);
</del><ins>+        graphicsContext-&gt;drawTiledImage(image.get(), colorSpace, pixelSnappedForPainting(x + leftWidth, borderImageRect.maxY() - bottomWidth, destinationWidth, bottomWidth, deviceScaleFactor),
+            pixelSnappedForPainting(leftSlice, imageHeight - bottomSlice, sourceWidth, bottomSlice, deviceScaleFactor), FloatSize(bottomSideScale, bottomSideScale),
+            (Image::TileRule)hRule, Image::StretchTile, op);
</ins><span class="cx"> 
</span><span class="cx">     // Paint the middle.
</span><span class="cx">     if (drawMiddle) {
</span><span class="lines">@@ -1390,8 +1387,8 @@
</span><span class="cx">             middleScaleFactor.setHeight(destinationHeight / sourceHeight);
</span><span class="cx">         
</span><span class="cx">         graphicsContext-&gt;drawTiledImage(image.get(), colorSpace,
</span><del>-            IntRect(borderImageRect.x() + leftWidth, borderImageRect.y() + topWidth, destinationWidth, destinationHeight),
-            IntRect(leftSlice, topSlice, sourceWidth, sourceHeight),
</del><ins>+            pixelSnappedForPainting(x + leftWidth, y + topWidth, destinationWidth, destinationHeight, deviceScaleFactor),
+            pixelSnappedForPainting(leftSlice, topSlice, sourceWidth, sourceHeight, deviceScaleFactor),
</ins><span class="cx">             middleScaleFactor, (Image::TileRule)hRule, (Image::TileRule)vRule, op);
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>