<!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>[168528] 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/168528">168528</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2014-05-09 07:20:49 -0700 (Fri, 09 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/168095">r168095</a>): 1-pixel gap between adjacent selection inlines
https://bugs.webkit.org/show_bug.cgi?id=132474
&lt;rdar://problem/16797394&gt;

Reviewed by David Hyatt.

This patch changes text selection rectangle calculation from integral to device
pixel snapping. It ensures that selection rect painting matches box boundaries for inline elements.
Directional rounding (horizontal only atm) is moved out from Font class and now accessible
to all the painting code. RTL snapping strategy is changed from floor to round to match ltr behavior.
However this patch does not address all the integral snapping across inline elements. There are
a few places where we still calculate enclosing rects where snapping is sufficient.

Source/WebCore:
Test: fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines.html

* platform/LayoutUnit.h:
(WebCore::roundToDevicePixel): added fudge factor to change rounding direction as directed.
* platform/graphics/Font.cpp:
(WebCore::Font::adjustSelectionRectForText):
(WebCore::Font::selectionRectForText): Deleted.
* platform/graphics/Font.h:
* platform/graphics/FontFastPath.cpp:
(WebCore::Font::adjustSelectionRectForSimpleText): removed directional rounding.
(WebCore::Font::selectionRectForSimpleText): Deleted.
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::drawHighlightForText): Deleted.
* platform/graphics/GraphicsContext.h:
* platform/graphics/LayoutPoint.h:
(WebCore::roundedForPainting):
* platform/graphics/LayoutRect.h:
(WebCore::directionalPixelSnappedForPainting): Snap top right corner for rtl direction.
* platform/graphics/cairo/FontCairoHarfbuzzNG.cpp:
(WebCore::Font::adjustSelectionRectForComplexText):
(WebCore::Font::selectionRectForComplexText): Deleted.
* platform/graphics/mac/FontComplexTextMac.cpp:
(WebCore::Font::adjustSelectionRectForComplexText): removed directional rounding.
(WebCore::Font::selectionRectForComplexText): Deleted.
* platform/graphics/win/FontWin.cpp:
(WebCore::Font::adjustSelectionRectForComplexText):
(WebCore::Font::selectionRectForComplexText): Deleted.
* rendering/EllipsisBox.cpp:
(WebCore::EllipsisBox::selectionRect):
(WebCore::EllipsisBox::paintSelection):
* rendering/InlineTextBox.cpp:
(WebCore::integralEnclosingRectForSelection): helper to address enclosing empty rect problem.
(WebCore::InlineTextBox::localSelectionRect):
(WebCore::InlineTextBox::paintSelection):
(WebCore::InlineTextBox::paintCompositionBackground):
(WebCore::InlineTextBox::paintDocumentMarker):
(WebCore::InlineTextBox::paintTextMatchMarker):
(WebCore::InlineTextBox::computeRectForReplacementMarker):
(WebCore::InlineTextBox::positionForOffset):
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::selectionRectForTextFragment):

LayoutTests:
* fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines-expected.html: Added.
* fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines.html: Added.
* platform/mac/editing/selection/mixed-editability-10-expected.txt: progression.
* platform/mac/fast/forms/cursor-at-editable-content-boundary-expected.txt: progression.
* platform/mac/platform/mac/editing/input/caret-primary-bidi-expected.txt: Added. change in rounding strategy.
* platform/mac/svg/text/caret-in-svg-text-expected.txt: Added. progression + change in rounding strategy.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmaceditingselectionmixededitability10expectedtxt">trunk/LayoutTests/platform/mac/editing/selection/mixed-editability-10-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacfastformscursorateditablecontentboundaryexpectedtxt">trunk/LayoutTests/platform/mac/fast/forms/cursor-at-editable-content-boundary-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformLayoutUnith">trunk/Source/WebCore/platform/LayoutUnit.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontcpp">trunk/Source/WebCore/platform/graphics/Font.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFonth">trunk/Source/WebCore/platform/graphics/Font.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontFastPathcpp">trunk/Source/WebCore/platform/graphics/FontFastPath.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContextcpp">trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsGraphicsContexth">trunk/Source/WebCore/platform/graphics/GraphicsContext.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsLayoutPointh">trunk/Source/WebCore/platform/graphics/LayoutPoint.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsLayoutRecth">trunk/Source/WebCore/platform/graphics/LayoutRect.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscairoFontCairoHarfbuzzNGcpp">trunk/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsmacFontComplexTextMaccpp">trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicswinFontWincpp">trunk/Source/WebCore/platform/graphics/win/FontWin.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingEllipsisBoxcpp">trunk/Source/WebCore/rendering/EllipsisBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingInlineTextBoxcpp">trunk/Source/WebCore/rendering/InlineTextBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgSVGInlineTextBoxcpp">trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastinlinehidpipixelgapbetweenadjacentselectioninlinesexpectedhtml">trunk/LayoutTests/fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastinlinehidpipixelgapbetweenadjacentselectioninlineshtml">trunk/LayoutTests/fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines.html</a></li>
<li>trunk/LayoutTests/platform/mac/platform/mac/editing/input/</li>
<li><a href="#trunkLayoutTestsplatformmacplatformmaceditinginputcaretprimarybidiexpectedtxt">trunk/LayoutTests/platform/mac/platform/mac/editing/input/caret-primary-bidi-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacsvgtextcaretinsvgtextexpectedtxt">trunk/LayoutTests/platform/mac/svg/text/caret-in-svg-text-expected.txt</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/LayoutTests/ChangeLog        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2014-05-09  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        REGRESSION (r168095): 1-pixel gap between adjacent selection inlines
+        https://bugs.webkit.org/show_bug.cgi?id=132474
+        &lt;rdar://problem/16797394&gt;
+
+        Reviewed by David Hyatt.
+
+        This patch changes text selection rectangle calculation from integral to device
+        pixel snapping. It ensures that selection rect painting matches box boundaries for inline elements.
+        Directional rounding (horizontal only atm) is moved out from Font class and now accessible
+        to all the painting code. RTL snapping strategy is changed from floor to round to match ltr behavior.
+        However this patch does not address all the integral snapping across inline elements. There are
+        a few places where we still calculate enclosing rects where snapping is sufficient.
+
+        * fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines-expected.html: Added.
+        * fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines.html: Added.
+        * platform/mac/editing/selection/mixed-editability-10-expected.txt: progression.
+        * platform/mac/fast/forms/cursor-at-editable-content-boundary-expected.txt: progression.
+        * platform/mac/platform/mac/editing/input/caret-primary-bidi-expected.txt: Added. change in rounding strategy.
+        * platform/mac/svg/text/caret-in-svg-text-expected.txt: Added. progression + change in rounding strategy.
+
</ins><span class="cx"> 2014-05-09  Martin Hodovan  &lt;mhodovan@inf.u-szeged.hu&gt;
</span><span class="cx"> 
</span><span class="cx">         ASSERTION FAILED: !m_code || m_code == defaultExceptionCode
</span></span></pre></div>
<a id="trunkLayoutTestsfastinlinehidpipixelgapbetweenadjacentselectioninlinesexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines-expected.html (0 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines-expected.html        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that there's no pixel gap between adjacent inlines when selected.&lt;/title&gt;
+&lt;style&gt;
+  body {
+    margin: 0px;
+    font-size: 16px;
+  }
+  .bckg {
+    width: 46px;
+    height: 18px;
+    background: rgba(255, 0, 0, 0.9);
+    z-index: -10000;
+  }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div class=bckg&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastinlinehidpipixelgapbetweenadjacentselectioninlineshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines.html (0 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines.html                                (rev 0)
+++ trunk/LayoutTests/fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines.html        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that there's no pixel gap between adjacent inlines when selected.&lt;/title&gt;
+&lt;style&gt;
+  body {
+    margin: 0px;
+    color: rgba(255, 255, 255, 0);
+    font-size: 16px;
+  }
+  ::selection {
+    background: rgba(255, 0, 0, 0.9);
+  }
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div id=&quot;container&quot;&gt;&lt;span&gt;foo&lt;/span&gt; foo&lt;/div&gt;
+&lt;script&gt;
+  var range = document.createRange(); 
+  range.selectNode(document.getElementById(&quot;container&quot;)); 
+  window.getSelection().addRange(range);
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmaceditingselectionmixededitability10expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/editing/selection/mixed-editability-10-expected.txt (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/editing/selection/mixed-editability-10-expected.txt        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/LayoutTests/platform/mac/editing/selection/mixed-editability-10-expected.txt        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -15,8 +15,8 @@
</span><span class="cx"> #6 non editable DIV element with an editable empty span element
</span><span class="cx"> 
</span><span class="cx"> Hello: 
</span><del>-Anchor ([object HTMLDivElement], 0 caret[40,540] refpos=41) is incorrect.
-Anchor ([object HTMLDivElement], 3 caret[75,540] refpos=77) is incorrect.
</del><ins>+Anchor ([object HTMLDivElement], 0 caret[41,540] refpos=41) is correct.
+Anchor ([object HTMLDivElement], 3 caret[76,540] refpos=77) is incorrect.
</ins><span class="cx"> Anchor ([object HTMLDivElement], 1 caret[43,472] refpos=43) is correct.
</span><span class="cx"> Anchor ([object HTMLDivElement], 0 caret[8,472] refpos=8) is correct.
</span><span class="cx"> Anchor ([object HTMLDivElement], 0 caret[73,404] refpos=73) is correct.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfastformscursorateditablecontentboundaryexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/fast/forms/cursor-at-editable-content-boundary-expected.txt (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/forms/cursor-at-editable-content-boundary-expected.txt        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/LayoutTests/platform/mac/fast/forms/cursor-at-editable-content-boundary-expected.txt        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -6,5 +6,6 @@
</span><span class="cx"> 
</span><span class="cx"> vertical text.
</span><span class="cx"> 
</span><ins>+FAIL test id: textarea_rtl (text width: 108 != caretRange: 107), which means moving caret in the text, caret might be invisible or overlap with element.
</ins><span class="cx"> FAIL test id: textarea_rtl_no_wrap (text width: 108 != caretRange: 107), which means moving caret in the text, caret might be invisible or overlap with element.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacplatformmaceditinginputcaretprimarybidiexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/platform/mac/editing/input/caret-primary-bidi-expected.txt (0 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/platform/mac/editing/input/caret-primary-bidi-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/platform/mac/editing/input/caret-primary-bidi-expected.txt        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -0,0 +1,87 @@
</span><ins>+0: 8,564,0,28
+1: 21,564,0,28
+2: 36,564,0,28
+3: 49,564,0,28
+4: 155,564,0,28
+5: 141,564,0,28
+6: 85,564,0,28
+7: 101,564,0,28
+8: 116,564,0,28
+9: 131,564,0,28
+10: 73,564,0,28
+11: 56,564,0,28
+12: 170,564,0,28
+13: 185,564,0,28
+14: 199,564,0,28
+15: 208,564,0,28
+16: 8,536,0,28
+17: 114,536,0,28
+18: 101,536,0,28
+19: 45,536,0,28
+20: 60,536,0,28
+21: 75,536,0,28
+22: 90,536,0,28
+23: 33,536,0,28
+24: 16,536,0,28
+25: 130,536,0,28
+26: 8,508,0,28
+27: 149,508,0,28
+28: 135,508,0,28
+29: 125,508,0,28
+30: 33,508,0,28
+31: 16,508,0,28
+32: 164,508,0,28
+33: 8,478,0,28
+34: 32,478,0,28
+35: 18,478,0,28
+36: 47,478,0,28
+37: 60,478,0,28
+38: 76,478,0,28
+39: 88,478,0,28
+40: 113,478,0,28
+41: 96,478,0,28
+42: 125,478,0,28
+43: 791,450,0,28
+44: 765,450,0,28
+45: 780,450,0,28
+46: 751,450,0,28
+47: 736,450,0,28
+48: 722,450,0,28
+49: 712,450,0,28
+50: 682,450,0,28
+51: 697,450,0,28
+52: 667,450,0,28
+53: 655,450,0,28
+54: 637,450,0,28
+55: 630,450,0,28
+56: 608,450,0,28
+57: 621,450,0,28
+58: 592,450,0,28
+59: 791,422,0,28
+60: 777,422,0,28
+61: 763,422,0,28
+62: 753,422,0,28
+63: 722,422,0,28
+64: 738,422,0,28
+65: 707,422,0,28
+66: 695,422,0,28
+67: 678,422,0,28
+68: 670,422,0,28
+69: 791,394,0,28
+70: 777,394,0,28
+71: 763,394,0,28
+72: 753,394,0,28
+73: 661,394,0,28
+74: 644,394,0,28
+75: 636,394,0,28
+76: 791,364,0,28
+77: 765,364,0,28
+78: 780,364,0,28
+79: 751,364,0,28
+80: 736,364,0,28
+81: 722,364,0,28
+82: 712,364,0,28
+83: 690,364,0,28
+84: 703,364,0,28
+85: 675,364,0,28
+
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacsvgtextcaretinsvgtextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/platform/mac/svg/text/caret-in-svg-text-expected.txt (0 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/svg/text/caret-in-svg-text-expected.txt                                (rev 0)
+++ trunk/LayoutTests/platform/mac/svg/text/caret-in-svg-text-expected.txt        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+Sheriff Woody
+שדגש
+
+Success
+Success
+Failure. Was: 19,546,0,18, expected: 58,546,0,18
+Failure. Was: 58,546,0,18, expected: 20,546,0,18
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/ChangeLog        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -1,3 +1,60 @@
</span><ins>+2014-05-09  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        REGRESSION (r168095): 1-pixel gap between adjacent selection inlines
+        https://bugs.webkit.org/show_bug.cgi?id=132474
+        &lt;rdar://problem/16797394&gt;
+
+        Reviewed by David Hyatt.
+
+        This patch changes text selection rectangle calculation from integral to device
+        pixel snapping. It ensures that selection rect painting matches box boundaries for inline elements.
+        Directional rounding (horizontal only atm) is moved out from Font class and now accessible
+        to all the painting code. RTL snapping strategy is changed from floor to round to match ltr behavior.
+        However this patch does not address all the integral snapping across inline elements. There are
+        a few places where we still calculate enclosing rects where snapping is sufficient.
+
+        Test: fast/inline/hidpi-pixel-gap-between-adjacent-selection-inlines.html
+
+        * platform/LayoutUnit.h:
+        (WebCore::roundToDevicePixel): added fudge factor to change rounding direction as directed.
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::adjustSelectionRectForText):
+        (WebCore::Font::selectionRectForText): Deleted.
+        * platform/graphics/Font.h:
+        * platform/graphics/FontFastPath.cpp:
+        (WebCore::Font::adjustSelectionRectForSimpleText): removed directional rounding.
+        (WebCore::Font::selectionRectForSimpleText): Deleted.
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore::GraphicsContext::drawHighlightForText): Deleted.
+        * platform/graphics/GraphicsContext.h:
+        * platform/graphics/LayoutPoint.h:
+        (WebCore::roundedForPainting):
+        * platform/graphics/LayoutRect.h:
+        (WebCore::directionalPixelSnappedForPainting): Snap top right corner for rtl direction.
+        * platform/graphics/cairo/FontCairoHarfbuzzNG.cpp:
+        (WebCore::Font::adjustSelectionRectForComplexText):
+        (WebCore::Font::selectionRectForComplexText): Deleted.
+        * platform/graphics/mac/FontComplexTextMac.cpp:
+        (WebCore::Font::adjustSelectionRectForComplexText): removed directional rounding.
+        (WebCore::Font::selectionRectForComplexText): Deleted.
+        * platform/graphics/win/FontWin.cpp:
+        (WebCore::Font::adjustSelectionRectForComplexText):
+        (WebCore::Font::selectionRectForComplexText): Deleted.
+        * rendering/EllipsisBox.cpp:
+        (WebCore::EllipsisBox::selectionRect):
+        (WebCore::EllipsisBox::paintSelection):
+        * rendering/InlineTextBox.cpp:
+        (WebCore::integralEnclosingRectForSelection): helper to address enclosing empty rect problem.
+        (WebCore::InlineTextBox::localSelectionRect):
+        (WebCore::InlineTextBox::paintSelection):
+        (WebCore::InlineTextBox::paintCompositionBackground):
+        (WebCore::InlineTextBox::paintDocumentMarker):
+        (WebCore::InlineTextBox::paintTextMatchMarker):
+        (WebCore::InlineTextBox::computeRectForReplacementMarker):
+        (WebCore::InlineTextBox::positionForOffset):
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::selectionRectForTextFragment):
+
</ins><span class="cx"> 2014-05-09  Martin Hodovan  &lt;mhodovan@inf.u-szeged.hu&gt;
</span><span class="cx"> 
</span><span class="cx">         ASSERTION FAILED: !m_code || m_code == defaultExceptionCode
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformLayoutUnith"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/LayoutUnit.h (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/LayoutUnit.h        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/platform/LayoutUnit.h        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -935,9 +935,9 @@
</span><span class="cx">     return value.floor();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline float roundToDevicePixel(LayoutUnit value, float pixelSnappingFactor)
</del><ins>+inline float roundToDevicePixel(LayoutUnit value, float pixelSnappingFactor, bool needsDirectionalRounding = false)
</ins><span class="cx"> {
</span><del>-    return roundf((value.rawValue() * pixelSnappingFactor) / kEffectiveFixedPointDenominator) / pixelSnappingFactor;
</del><ins>+    return roundf(((value.rawValue() - (needsDirectionalRounding ? LayoutUnit::epsilon() / 2.0f : 0)) * pixelSnappingFactor) / kEffectiveFixedPointDenominator) / pixelSnappingFactor;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> inline float floorToDevicePixel(LayoutUnit value, float pixelSnappingFactor)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.cpp        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -26,8 +26,8 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;FloatRect.h&quot;
</span><span class="cx"> #include &quot;FontCache.h&quot;
</span><del>-#include &quot;IntPoint.h&quot;
</del><span class="cx"> #include &quot;GlyphBuffer.h&quot;
</span><ins>+#include &quot;LayoutRect.h&quot;
</ins><span class="cx"> #include &quot;TextRun.h&quot;
</span><span class="cx"> #include &quot;WidthIterator.h&quot;
</span><span class="cx"> #include &lt;wtf/MainThread.h&gt;
</span><span class="lines">@@ -507,7 +507,7 @@
</span><span class="cx">     return success;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-FloatRect Font::selectionRectForText(const TextRun&amp; run, const FloatPoint&amp; point, int h, int from, int to) const
</del><ins>+void Font::adjustSelectionRectForText(const TextRun&amp; run, LayoutRect&amp; selectionRect, int from, int to) const
</ins><span class="cx"> {
</span><span class="cx">     to = (to == -1 ? run.length() : to);
</span><span class="cx"> 
</span><span class="lines">@@ -517,9 +517,9 @@
</span><span class="cx">         codePathToUse = Complex;
</span><span class="cx"> 
</span><span class="cx">     if (codePathToUse != Complex)
</span><del>-        return selectionRectForSimpleText(run, point, h, from, to);
</del><ins>+        return adjustSelectionRectForSimpleText(run, selectionRect, from, to);
</ins><span class="cx"> 
</span><del>-    return selectionRectForComplexText(run, point, h, from, to);
</del><ins>+    return adjustSelectionRectForComplexText(run, selectionRect, from, to);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int Font::offsetForPosition(const TextRun&amp; run, float x, bool includePartialGlyphs) const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFonth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/Font.h (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/Font.h        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/platform/graphics/Font.h        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx"> class FontSelector;
</span><span class="cx"> class GlyphBuffer;
</span><span class="cx"> class GraphicsContext;
</span><ins>+class LayoutRect;
</ins><span class="cx"> class RenderText;
</span><span class="cx"> class TextLayout;
</span><span class="cx"> class TextRun;
</span><span class="lines">@@ -123,7 +124,7 @@
</span><span class="cx">     static float width(TextLayout&amp;, unsigned from, unsigned len, HashSet&lt;const SimpleFontData*&gt;* fallbackFonts = 0);
</span><span class="cx"> 
</span><span class="cx">     int offsetForPosition(const TextRun&amp;, float position, bool includePartialGlyphs) const;
</span><del>-    FloatRect selectionRectForText(const TextRun&amp;, const FloatPoint&amp;, int h, int from = 0, int to = -1) const;
</del><ins>+    void adjustSelectionRectForText(const TextRun&amp;, LayoutRect&amp; selectionRect, int from = 0, int to = -1) const;
</ins><span class="cx"> 
</span><span class="cx">     bool isSmallCaps() const { return m_fontDescription.smallCaps(); }
</span><span class="cx"> 
</span><span class="lines">@@ -202,7 +203,7 @@
</span><span class="cx">     void drawEmphasisMarks(GraphicsContext*, const TextRun&amp;, const GlyphBuffer&amp;, const AtomicString&amp;, const FloatPoint&amp;) const;
</span><span class="cx">     float floatWidthForSimpleText(const TextRun&amp;, HashSet&lt;const SimpleFontData*&gt;* fallbackFonts = 0, GlyphOverflow* = 0) const;
</span><span class="cx">     int offsetForPositionForSimpleText(const TextRun&amp;, float position, bool includePartialGlyphs) const;
</span><del>-    FloatRect selectionRectForSimpleText(const TextRun&amp;, const FloatPoint&amp;, int h, int from, int to) const;
</del><ins>+    void adjustSelectionRectForSimpleText(const TextRun&amp;, LayoutRect&amp; selectionRect, int from, int to) const;
</ins><span class="cx"> 
</span><span class="cx">     bool getEmphasisMarkGlyphData(const AtomicString&amp;, GlyphData&amp;) const;
</span><span class="cx"> 
</span><span class="lines">@@ -215,7 +216,7 @@
</span><span class="cx">     void drawEmphasisMarksForComplexText(GraphicsContext*, const TextRun&amp;, const AtomicString&amp; mark, const FloatPoint&amp;, int from, int to) const;
</span><span class="cx">     float floatWidthForComplexText(const TextRun&amp;, HashSet&lt;const SimpleFontData*&gt;* fallbackFonts = 0, GlyphOverflow* = 0) const;
</span><span class="cx">     int offsetForPositionForComplexText(const TextRun&amp;, float position, bool includePartialGlyphs) const;
</span><del>-    FloatRect selectionRectForComplexText(const TextRun&amp;, const FloatPoint&amp;, int h, int from, int to) const;
</del><ins>+    void adjustSelectionRectForComplexText(const TextRun&amp;, LayoutRect&amp; selectionRect, int from, int to) const;
</ins><span class="cx"> 
</span><span class="cx">     friend struct WidthIterator;
</span><span class="cx">     friend class SVGTextRunRenderingContext;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontFastPathcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontFastPath.cpp (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontFastPath.cpp        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/platform/graphics/FontFastPath.cpp        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include &quot;FontGlyphs.h&quot;
</span><span class="cx"> #include &quot;GlyphBuffer.h&quot;
</span><span class="cx"> #include &quot;GlyphPageTreeNode.h&quot;
</span><ins>+#include &quot;LayoutRect.h&quot;
</ins><span class="cx"> #include &quot;SimpleFontData.h&quot;
</span><span class="cx"> #include &quot;TextRun.h&quot;
</span><span class="cx"> #include &quot;WidthIterator.h&quot;
</span><span class="lines">@@ -295,7 +296,7 @@
</span><span class="cx">     return it.m_runWidthSoFar;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-FloatRect Font::selectionRectForSimpleText(const TextRun&amp; run, const FloatPoint&amp; point, int h, int from, int to) const
</del><ins>+void Font::adjustSelectionRectForSimpleText(const TextRun&amp; run, LayoutRect&amp; selectionRect, int from, int to) const
</ins><span class="cx"> {
</span><span class="cx">     GlyphBuffer glyphBuffer;
</span><span class="cx">     WidthIterator it(this, run);
</span><span class="lines">@@ -303,15 +304,15 @@
</span><span class="cx">     float beforeWidth = it.m_runWidthSoFar;
</span><span class="cx">     it.advance(to, &amp;glyphBuffer);
</span><span class="cx">     float afterWidth = it.m_runWidthSoFar;
</span><ins>+    float totalWidth = -1;
</ins><span class="cx"> 
</span><del>-    // Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning.
</del><span class="cx">     if (run.rtl()) {
</span><span class="cx">         it.advance(run.length(), &amp;glyphBuffer);
</span><del>-        float totalWidth = it.m_runWidthSoFar;
-        return FloatRect(floorf(point.x() + totalWidth - afterWidth), point.y(), roundf(point.x() + totalWidth - beforeWidth) - floorf(point.x() + totalWidth - afterWidth), h);
-    }
-
-    return FloatRect(floorf(point.x() + beforeWidth), point.y(), roundf(point.x() + afterWidth) - floorf(point.x() + beforeWidth), h);
</del><ins>+        totalWidth = it.m_runWidthSoFar;
+        selectionRect.move(totalWidth - afterWidth, 0);
+    } else
+        selectionRect.move(beforeWidth, 0);
+    selectionRect.setWidth(afterWidth - beforeWidth);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> int Font::offsetForPositionForSimpleText(const TextRun&amp; run, float x, bool includePartialGlyphs) const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -547,14 +547,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GraphicsContext::drawHighlightForText(const Font&amp; font, const TextRun&amp; run, const FloatPoint&amp; point, int h, const Color&amp; backgroundColor, ColorSpace colorSpace, int from, int to)
-{
-    if (paintingDisabled())
-        return;
-
-    fillRect(font.selectionRectForText(run, point, h, from, to), backgroundColor, colorSpace);
-}
-
</del><span class="cx"> void GraphicsContext::drawImage(Image* image, ColorSpace styleColorSpace, const FloatPoint&amp; p, CompositeOperator op, ImageOrientationDescription description)
</span><span class="cx"> {
</span><span class="cx">     if (!image)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsGraphicsContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.h (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.h        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -354,8 +354,6 @@
</span><span class="cx"> #else
</span><span class="cx">         float drawBidiText(const Font&amp;, const TextRun&amp;, const FloatPoint&amp;, Font::CustomFontNotReadyAction = Font::DoNotPaintIfFontNotReady, BidiStatus* = 0, int length = -1);
</span><span class="cx"> #endif
</span><del>-        void drawHighlightForText(const Font&amp;, const TextRun&amp;, const FloatPoint&amp;, int h, const Color&amp; backgroundColor, ColorSpace, int from = 0, int to = -1);
-
</del><span class="cx">         enum RoundingMode {
</span><span class="cx">             RoundAllSides,
</span><span class="cx">             RoundOriginAndDimensions
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsLayoutPointh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/LayoutPoint.h (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/LayoutPoint.h        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/platform/graphics/LayoutPoint.h        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -184,12 +184,14 @@
</span><span class="cx">     return IntSize(snapSizeToPixel(s.width(), p.x()), snapSizeToPixel(s.height(), p.y()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline FloatPoint roundedForPainting(const LayoutPoint&amp; point, float pixelSnappingFactor)
</del><ins>+inline FloatPoint roundedForPainting(const LayoutPoint&amp; point, float pixelSnappingFactor, bool directionalRoundingToRight = true, bool directionalRoundingToBottom = true)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(SUBPIXEL_LAYOUT)
</span><del>-    return FloatPoint(roundToDevicePixel(point.x(), pixelSnappingFactor), roundToDevicePixel(point.y(), pixelSnappingFactor));
</del><ins>+    return FloatPoint(roundToDevicePixel(point.x(), pixelSnappingFactor, !directionalRoundingToRight), roundToDevicePixel(point.y(), pixelSnappingFactor, !directionalRoundingToBottom));
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(pixelSnappingFactor);
</span><ins>+    UNUSED_PARAM(directionalRoundingToRight);
+    UNUSED_PARAM(directionalRoundingToBottom);
</ins><span class="cx">     return FloatPoint(point);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsLayoutRecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/LayoutRect.h (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/LayoutRect.h        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/platform/graphics/LayoutRect.h        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -247,6 +247,18 @@
</span><span class="cx">     return pixelSnappedForPainting(LayoutRect(x, y, width, height), pixelSnappingFactor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// FIXME: This needs to take vertical centering into account too.
+inline FloatRect directionalPixelSnappedForPainting(const LayoutRect&amp; rect, float deviceScaleFactor, bool ltr)
+{
+    if (!ltr) {
+        FloatPoint snappedTopRight = roundedForPainting(rect.maxXMinYCorner(), deviceScaleFactor, ltr);
+        float snappedWidth = snapSizeToDevicePixel(rect.width(), rect.maxX(), deviceScaleFactor);
+        float snappedHeight = snapSizeToDevicePixel(rect.height(), rect.y(), deviceScaleFactor);
+        return FloatRect(snappedTopRight.x() - snappedWidth, snappedTopRight.y(), snappedWidth, snappedHeight);
+    }
+    return pixelSnappedForPainting(rect, deviceScaleFactor);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // LayoutRect_h
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscairoFontCairoHarfbuzzNGcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;GraphicsContext.h&quot;
</span><span class="cx"> #include &quot;HarfBuzzShaper.h&quot;
</span><ins>+#include &quot;LayoutRect.h&quot;
</ins><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="cx"> #include &quot;NotImplemented.h&quot;
</span><span class="cx"> #include &quot;PlatformContextCairo.h&quot;
</span><span class="lines">@@ -84,13 +85,16 @@
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-FloatRect Font::selectionRectForComplexText(const TextRun&amp; run, const FloatPoint&amp; point, int h, int from, int to) const
</del><ins>+void Font::adjustSelectionRectForComplexText(const TextRun&amp; run, LayoutRect&amp; selectionRect, int from, int to) const
</ins><span class="cx"> {
</span><span class="cx">     HarfBuzzShaper shaper(this, run);
</span><del>-    if (shaper.shape())
-        return shaper.selectionRect(point, h, from, to);
</del><ins>+    if (shaper.shape()) {
+        // FIXME: This should mimic Mac port.
+        FloatRect rect = shaper.selectionRect(FloatPoint(selectionRect.location()), selectionRect.height().toInt(), from, to);
+        selectionRect = LayoutRect(rect);
+        return;
+    }
</ins><span class="cx">     LOG_ERROR(&quot;Shaper couldn't shape text run.&quot;);
</span><del>-    return FloatRect();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsmacFontComplexTextMaccpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -30,14 +30,14 @@
</span><span class="cx"> #include &quot;GlyphBuffer.h&quot;
</span><span class="cx"> #include &quot;GraphicsContext.h&quot;
</span><span class="cx"> #include &quot;IntRect.h&quot;
</span><ins>+#include &quot;LayoutRect.h&quot;
</ins><span class="cx"> #include &quot;SimpleFontData.h&quot;
</span><span class="cx"> #include &quot;TextRun.h&quot;
</span><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-FloatRect Font::selectionRectForComplexText(const TextRun&amp; run, const FloatPoint&amp; point, int h,
-                                            int from, int to) const
</del><ins>+void Font::adjustSelectionRectForComplexText(const TextRun&amp; run, LayoutRect&amp; selectionRect, int from, int to) const
</ins><span class="cx"> {
</span><span class="cx">     ComplexTextController controller(this, run);
</span><span class="cx">     controller.advance(from);
</span><span class="lines">@@ -45,13 +45,11 @@
</span><span class="cx">     controller.advance(to);
</span><span class="cx">     float afterWidth = controller.runWidthSoFar();
</span><span class="cx"> 
</span><del>-    // Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning
-    if (run.rtl()) {
-        float totalWidth = controller.totalWidth();
-        return FloatRect(floorf(point.x() + totalWidth - afterWidth), point.y(), roundf(point.x() + totalWidth - beforeWidth) - floorf(point.x() + totalWidth - afterWidth), h);
-    } 
-
-    return FloatRect(floorf(point.x() + beforeWidth), point.y(), roundf(point.x() + afterWidth) - floorf(point.x() + beforeWidth), h);
</del><ins>+    if (run.rtl())
+        selectionRect.move(controller.totalWidth() - afterWidth, 0);
+    else
+        selectionRect.move(beforeWidth, 0);
+    selectionRect.setWidth(afterWidth - beforeWidth);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> float Font::getGlyphsAndAdvancesForComplexText(const TextRun&amp; run, int from, int to, GlyphBuffer&amp; glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicswinFontWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/win/FontWin.cpp (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/win/FontWin.cpp        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/platform/graphics/win/FontWin.cpp        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include &quot;GlyphBuffer.h&quot;
</span><span class="cx"> #include &quot;GraphicsContext.h&quot;
</span><span class="cx"> #include &quot;IntRect.h&quot;
</span><ins>+#include &quot;LayoutRect.h&quot;
</ins><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="cx"> #include &quot;SimpleFontData.h&quot;
</span><span class="cx"> #include &quot;TextRun.h&quot;
</span><span class="lines">@@ -50,8 +51,7 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-FloatRect Font::selectionRectForComplexText(const TextRun&amp; run, const FloatPoint&amp; point, int h,
-                                            int from, int to) const
</del><ins>+void Font::adjustSelectionRectForComplexText(const TextRun&amp; run, LayoutRect&amp; selectionRect, int from, int to) const
</ins><span class="cx"> {
</span><span class="cx">     UniscribeController it(this, run);
</span><span class="cx">     it.advance(from);
</span><span class="lines">@@ -59,14 +59,11 @@
</span><span class="cx">     it.advance(to);
</span><span class="cx">     float afterWidth = it.runWidthSoFar();
</span><span class="cx"> 
</span><del>-    // Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning
-    if (run.rtl()) {
-        it.advance(run.length());
-        float totalWidth = it.runWidthSoFar();
-        return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h);
-    } 
-    
-    return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
</del><ins>+    if (run.rtl())
+        selectionRect.move(controller.totalWidth() - afterWidth, 0);
+    else
+        selectionRect.move(beforeWidth, 0);
+    selectionRect.setWidth(afterWidth - beforeWidth);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> float Font::getGlyphsAndAdvancesForComplexText(const TextRun&amp; run, int from, int to, GlyphBuffer&amp; glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingEllipsisBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/EllipsisBox.cpp (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/EllipsisBox.cpp        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/rendering/EllipsisBox.cpp        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -113,7 +113,10 @@
</span><span class="cx">     const Font&amp; font = lineStyle.font();
</span><span class="cx">     const RootInlineBox&amp; rootBox = root();
</span><span class="cx">     // FIXME: Why is this always LTR? Fix by passing correct text run flags below.
</span><del>-    return enclosingIntRect(font.selectionRectForText(RenderBlock::constructTextRun(&amp;blockFlow(), font, m_str, lineStyle, TextRun::AllowTrailingExpansion), IntPoint(x(), y() + rootBox.selectionTopAdjustedForPrecedingBlock()), rootBox.selectionHeightAdjustedForPrecedingBlock()));
</del><ins>+    LayoutRect selectionRect = LayoutRect(x(), y() + rootBox.selectionTopAdjustedForPrecedingBlock(), 0, rootBox.selectionHeightAdjustedForPrecedingBlock());
+    font.adjustSelectionRectForText(RenderBlock::constructTextRun(&amp;blockFlow(), font, m_str, lineStyle, TextRun::AllowTrailingExpansion), selectionRect);
+    // FIXME: use directional pixel snapping instead.
+    return enclosingIntRect(selectionRect);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint&amp; paintOffset, const RenderStyle&amp; style, const Font&amp; font)
</span><span class="lines">@@ -129,15 +132,12 @@
</span><span class="cx">         c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
</span><span class="cx"> 
</span><span class="cx">     const RootInlineBox&amp; rootBox = root();
</span><del>-    LayoutUnit top = rootBox.selectionTop();
-    LayoutUnit h = rootBox.selectionHeight();
-
</del><span class="cx">     GraphicsContextStateSaver stateSaver(*context);
</span><del>-    float deviceScaleFactor = renderer().document().deviceScaleFactor();
-    context-&gt;clip(pixelSnappedForPainting(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h, renderer().document().deviceScaleFactor()));
</del><span class="cx">     // FIXME: Why is this always LTR? Fix by passing correct text run flags below.
</span><del>-    FloatPoint localOrigin = roundedForPainting(LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + top), deviceScaleFactor);
-    context-&gt;drawHighlightForText(font, RenderBlock::constructTextRun(&amp;blockFlow(), font, m_str, style, TextRun::AllowTrailingExpansion), localOrigin, h, c, style.colorSpace());
</del><ins>+    LayoutRect selectionRect = LayoutRect(x() + paintOffset.x(), y() + paintOffset.y() + rootBox.selectionTop(), 0, rootBox.selectionHeight());
+    TextRun run = RenderBlock::constructTextRun(&amp;blockFlow(), font, m_str, style, TextRun::AllowTrailingExpansion);
+    font.adjustSelectionRectForText(run, selectionRect, 0, -1);
+    context-&gt;fillRect(directionalPixelSnappedForPainting(selectionRect, renderer().document().deviceScaleFactor(), run.ltr()), c, style.colorSpace());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool EllipsisBox::nodeAtPoint(const HitTestRequest&amp; request, HitTestResult&amp; result, const HitTestLocation&amp; locationInContainer, const LayoutPoint&amp; accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/InlineTextBox.cpp        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -265,6 +265,16 @@
</span><span class="cx">     return style.font();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// FIXME: remove this function, when switching to directional pixel snapping.
+static IntRect integralEnclosingRectForSelection(const LayoutRect&amp; rect)
+{
+    // Empty rects with fractional x, y values turn into non-empty rects when converting to enclosing.
+    // We need to ensure that empty rects stay empty after the conversion, because the selection code expects them to be empty.
+    IntPoint location = flooredIntPoint(rect.minXMinYCorner());
+    IntPoint maxPoint = IntPoint(rect.width() ? rect.maxX().ceil() : location.x(), rect.height() ? rect.maxY().ceil() : location.y());
+    return IntRect(location, maxPoint - location);
+}
+
</ins><span class="cx"> LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) const
</span><span class="cx"> {
</span><span class="cx">     int sPos = std::max(startPos - m_start, 0);
</span><span class="lines">@@ -275,8 +285,8 @@
</span><span class="cx"> 
</span><span class="cx">     FontCachePurgePreventer fontCachePurgePreventer;
</span><span class="cx"> 
</span><del>-    LayoutUnit selTop = selectionTop();
-    LayoutUnit selHeight = selectionHeight();
</del><ins>+    LayoutUnit selectionTop = this-&gt;selectionTop();
+    LayoutUnit selectionHeight = this-&gt;selectionHeight();
</ins><span class="cx">     const RenderStyle&amp; lineStyle = this-&gt;lineStyle();
</span><span class="cx">     const Font&amp; font = fontToUse(lineStyle, renderer());
</span><span class="cx"> 
</span><span class="lines">@@ -286,22 +296,20 @@
</span><span class="cx">     if (respectHyphen)
</span><span class="cx">         endPos = textRun.length();
</span><span class="cx"> 
</span><del>-    FloatPoint startingPoint = FloatPoint(logicalLeft(), selTop);
-    LayoutRect r;
</del><ins>+    LayoutRect selectionRect = LayoutRect(LayoutPoint(logicalLeft(), selectionTop), LayoutSize(m_logicalWidth, selectionHeight));
+    // Avoid computing the font width when the entire line box is selected as an optimization.
</ins><span class="cx">     if (sPos || ePos != static_cast&lt;int&gt;(m_len))
</span><del>-        r = enclosingIntRect(font.selectionRectForText(textRun, startingPoint, selHeight, sPos, ePos));
-    else // Avoid computing the font width when the entire line box is selected as an optimization.
-        r = enclosingIntRect(FloatRect(startingPoint, FloatSize(m_logicalWidth, selHeight)));
-
-    LayoutUnit logicalWidth = r.width();
-    if (r.x() &gt; logicalRight())
</del><ins>+        font.adjustSelectionRectForText(textRun, selectionRect, sPos, ePos);
+    IntRect snappedSelectionRect = integralEnclosingRectForSelection(selectionRect);
+    LayoutUnit logicalWidth = snappedSelectionRect.width();
+    if (snappedSelectionRect.x() &gt; logicalRight())
</ins><span class="cx">         logicalWidth  = 0;
</span><del>-    else if (r.maxX() &gt; logicalRight())
-        logicalWidth = logicalRight() - r.x();
</del><ins>+    else if (snappedSelectionRect.maxX() &gt; logicalRight())
+        logicalWidth = logicalRight() - snappedSelectionRect.x();
</ins><span class="cx"> 
</span><del>-    LayoutPoint topPoint = isHorizontal() ? LayoutPoint(r.x(), selTop) : LayoutPoint(selTop, r.x());
-    LayoutUnit width = isHorizontal() ? logicalWidth : selHeight;
-    LayoutUnit height = isHorizontal() ? selHeight : logicalWidth;
</del><ins>+    LayoutPoint topPoint = isHorizontal() ? LayoutPoint(snappedSelectionRect.x(), selectionTop) : LayoutPoint(selectionTop, snappedSelectionRect.x());
+    LayoutUnit width = isHorizontal() ? logicalWidth : selectionHeight;
+    LayoutUnit height = isHorizontal() ? selectionHeight : logicalWidth;
</ins><span class="cx"> 
</span><span class="cx">     return LayoutRect(topPoint, LayoutSize(width, height));
</span><span class="cx"> }
</span><span class="lines">@@ -759,10 +767,9 @@
</span><span class="cx">     LayoutUnit deltaY = renderer().style().isFlippedLinesWritingMode() ? selectionBottom - logicalBottom() : logicalTop() - selectionTop;
</span><span class="cx">     LayoutUnit selectionHeight = std::max&lt;LayoutUnit&gt;(0, selectionBottom - selectionTop);
</span><span class="cx"> 
</span><del>-    float deviceScaleFactor = renderer().document().deviceScaleFactor();
-    FloatPoint localOrigin = roundedForPainting(LayoutPoint(boxOrigin.x(), boxOrigin.y() - deltaY), deviceScaleFactor);
-    context-&gt;clip(pixelSnappedForPainting(LayoutRect(LayoutPoint(localOrigin), LayoutSize(m_logicalWidth, selectionHeight)), deviceScaleFactor));
-    context-&gt;drawHighlightForText(font, textRun, localOrigin, selectionHeight, c, style.colorSpace(), sPos, ePos);
</del><ins>+    LayoutRect selectionRect = LayoutRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_logicalWidth, selectionHeight);
+    font.adjustSelectionRectForText(textRun, selectionRect, sPos, ePos);
+    context-&gt;fillRect(directionalPixelSnappedForPainting(selectionRect, renderer().document().deviceScaleFactor(), textRun.ltr()), c, style.colorSpace());
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(context);
</span><span class="cx">     UNUSED_PARAM(boxOrigin);
</span><span class="lines">@@ -793,10 +800,11 @@
</span><span class="cx">     
</span><span class="cx">     updateGraphicsContext(*context, TextPaintStyle(c, style.colorSpace())); // Don't draw text at all!
</span><span class="cx"> 
</span><del>-    int deltaY = renderer().style().isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
-    int selHeight = selectionHeight();
-    FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
-    context-&gt;drawHighlightForText(font, constructTextRun(style, font), localOrigin, selHeight, c, style.colorSpace(), sPos, ePos);
</del><ins>+    LayoutUnit deltaY = renderer().style().isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
+    LayoutRect selectionRect = LayoutRect(boxOrigin.x(), boxOrigin.y() - deltaY, 0, selectionHeight());
+    TextRun textRun = constructTextRun(style, font);
+    font.adjustSelectionRectForText(textRun, selectionRect, sPos, ePos);
+    context-&gt;fillRect(directionalPixelSnappedForPainting(selectionRect, renderer().document().deviceScaleFactor(), textRun.ltr()), c, style.colorSpace());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorationStyle)
</span><span class="lines">@@ -1178,8 +1186,9 @@
</span><span class="cx">         FloatPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY);
</span><span class="cx">         TextRun run = constructTextRun(style, font);
</span><span class="cx"> 
</span><del>-        // FIXME: Convert the document markers to float rects.
-        IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, startPoint, selHeight, startPosition, endPosition));
</del><ins>+        LayoutRect selectionRect = LayoutRect(startPoint, FloatSize(0, selHeight));
+        font.adjustSelectionRectForText(run, selectionRect, startPosition, endPosition);
+        IntRect markerRect = integralEnclosingRectForSelection(selectionRect);
</ins><span class="cx">         start = markerRect.x() - startPoint.x();
</span><span class="cx">         width = markerRect.width();
</span><span class="cx">         
</span><span class="lines">@@ -1212,45 +1221,51 @@
</span><span class="cx">     pt-&gt;drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y() + underlineOffset), width, lineStyleForMarkerType(marker-&gt;type()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPoint&amp; boxOrigin, DocumentMarker* marker, const RenderStyle&amp; style, const Font&amp; font)
</del><ins>+void InlineTextBox::paintTextMatchMarker(GraphicsContext* context, const FloatPoint&amp; boxOrigin, DocumentMarker* marker, const RenderStyle&amp; style, const Font&amp; font)
</ins><span class="cx"> {
</span><del>-    // Use same y positioning and height as for selection, so that when the selection and this highlight are on
-    // the same word there are no pieces sticking out.
-    int deltaY = renderer().style().isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
-    int selHeight = selectionHeight();
</del><ins>+    LayoutUnit selectionHeight = this-&gt;selectionHeight();
</ins><span class="cx"> 
</span><span class="cx">     int sPos = std::max(marker-&gt;startOffset() - m_start, (unsigned)0);
</span><span class="cx">     int ePos = std::min(marker-&gt;endOffset() - m_start, (unsigned)m_len);
</span><span class="cx">     TextRun run = constructTextRun(style, font);
</span><span class="cx"> 
</span><span class="cx">     // Always compute and store the rect associated with this marker. The computed rect is in absolute coordinates.
</span><del>-    IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoint(x(), selectionTop()), selHeight, sPos, ePos));
-    markerRect = renderer().localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox();
</del><ins>+    // FIXME: figure out how renderedRect and selectionRect are different.
+    LayoutRect renderedRect = LayoutRect(LayoutPoint(x(), selectionTop()), FloatSize(0, selectionHeight));
+    font.adjustSelectionRectForText(run, renderedRect, sPos, ePos);
+    IntRect markerRect = integralEnclosingRectForSelection(renderedRect);
+    markerRect = renderer().localToAbsoluteQuad(FloatQuad(markerRect)).enclosingBoundingBox();
</ins><span class="cx">     toRenderedDocumentMarker(marker)-&gt;setRenderedRect(markerRect);
</span><span class="cx">     
</span><span class="cx">     // Optionally highlight the text
</span><span class="cx">     if (renderer().frame().editor().markedTextMatchesAreHighlighted()) {
</span><span class="cx">         Color color = marker-&gt;activeMatch() ? renderer().theme().platformActiveTextSearchHighlightColor() : renderer().theme().platformInactiveTextSearchHighlightColor();
</span><del>-        GraphicsContextStateSaver stateSaver(*pt);
-        updateGraphicsContext(*pt, TextPaintStyle(color, style.colorSpace())); // Don't draw text at all!
-        pt-&gt;clip(FloatRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_logicalWidth, selHeight));
-        pt-&gt;drawHighlightForText(font, run, FloatPoint(boxOrigin.x(), boxOrigin.y() - deltaY), selHeight, color, style.colorSpace(), sPos, ePos);
</del><ins>+        GraphicsContextStateSaver stateSaver(*context);
+        updateGraphicsContext(*context, TextPaintStyle(color, style.colorSpace())); // Don't draw text at all!
+
+        // Use same y positioning and height as for selection, so that when the selection and this highlight are on
+        // the same word there are no pieces sticking out.
+        LayoutUnit deltaY = renderer().style().isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
+        LayoutRect selectionRect = LayoutRect(boxOrigin.x(), boxOrigin.y() - deltaY, 0, selectionHeight);
+        font.adjustSelectionRectForText(run, selectionRect, sPos, ePos);
+        context-&gt;fillRect(directionalPixelSnappedForPainting(selectionRect, renderer().document().deviceScaleFactor(), run.ltr()), color, style.colorSpace());
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InlineTextBox::computeRectForReplacementMarker(DocumentMarker* marker, const RenderStyle&amp; style, const Font&amp; font)
</span><span class="cx"> {
</span><span class="cx">     // Replacement markers are not actually drawn, but their rects need to be computed for hit testing.
</span><del>-    int top = selectionTop();
-    int h = selectionHeight();
</del><ins>+    LayoutUnit top = selectionTop();
+    LayoutUnit h = selectionHeight();
</ins><span class="cx">     
</span><span class="cx">     int sPos = std::max(marker-&gt;startOffset() - m_start, (unsigned)0);
</span><span class="cx">     int ePos = std::min(marker-&gt;endOffset() - m_start, (unsigned)m_len);
</span><span class="cx">     TextRun run = constructTextRun(style, font);
</span><del>-    IntPoint startPoint = IntPoint(x(), top);
-    
</del><ins>+
</ins><span class="cx">     // Compute and store the rect associated with this marker.
</span><del>-    IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, startPoint, h, sPos, ePos));
</del><ins>+    LayoutRect selectionRect = LayoutRect(LayoutPoint(x(), top), LayoutSize(0, h));
+    font.adjustSelectionRectForText(run, selectionRect, sPos, ePos);
+    IntRect markerRect = integralEnclosingRectForSelection(selectionRect);
</ins><span class="cx">     markerRect = renderer().localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox();
</span><span class="cx">     toRenderedDocumentMarker(marker)-&gt;setRenderedRect(markerRect);
</span><span class="cx"> }
</span><span class="lines">@@ -1431,7 +1446,10 @@
</span><span class="cx">     int from = !isLeftToRightDirection() ? offset - m_start : 0;
</span><span class="cx">     int to = !isLeftToRightDirection() ? m_len : offset - m_start;
</span><span class="cx">     // FIXME: Do we need to add rightBearing here?
</span><del>-    return font.selectionRectForText(constructTextRun(lineStyle, font), IntPoint(logicalLeft(), 0), 0, from, to).maxX();
</del><ins>+    LayoutRect selectionRect = LayoutRect(logicalLeft(), 0, 0, 0);
+    TextRun run = constructTextRun(lineStyle, font);
+    font.adjustSelectionRectForText(run, selectionRect, from, to);
+    return directionalPixelSnappedForPainting(selectionRect, renderer().document().deviceScaleFactor(), run.ltr()).maxX();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextRun InlineTextBox::constructTextRun(const RenderStyle&amp; style, const Font&amp; font, BufferForAppendingHyphen* charactersWithHyphen) const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgSVGInlineTextBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (168527 => 168528)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp        2014-05-09 13:34:47 UTC (rev 168527)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp        2014-05-09 14:20:49 UTC (rev 168528)
</span><span class="lines">@@ -125,12 +125,15 @@
</span><span class="cx"> 
</span><span class="cx">     textOrigin.move(0, -scaledFontMetrics.floatAscent());
</span><span class="cx"> 
</span><del>-    FloatRect selectionRect = scaledFont.selectionRectForText(constructTextRun(style, fragment), textOrigin, fragment.height * scalingFactor, startPosition, endPosition);
</del><ins>+    LayoutRect selectionRect = LayoutRect(textOrigin, LayoutSize(0, fragment.height * scalingFactor));
+    TextRun run = constructTextRun(style, fragment);
+    scaledFont.adjustSelectionRectForText(run, selectionRect, startPosition, endPosition);
+    FloatRect snappedSelectionRect = directionalPixelSnappedForPainting(selectionRect, renderer().document().deviceScaleFactor(), run.ltr());
</ins><span class="cx">     if (scalingFactor == 1)
</span><del>-        return selectionRect;
</del><ins>+        return snappedSelectionRect;
</ins><span class="cx"> 
</span><span class="cx">     selectionRect.scale(1 / scalingFactor);
</span><del>-    return selectionRect;
</del><ins>+    return snappedSelectionRect;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPosition) const
</span></span></pre>
</div>
</div>

</body>
</html>