<!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>[184150] 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/184150">184150</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2015-05-11 21:01:50 -0700 (Mon, 11 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Text is misplaced when custom font does not have space glyph.
https://bugs.webkit.org/show_bug.cgi?id=144879

Reviewed by Myles C. Maxfield

This patch ensures that we use fallback font for the missing space glyph only when the rendered text has space in it.

If a font does not provide all the glyphs required to render the associated text, we initiate fallback fonts. It is done while
measuring the text at layout time. However due to the fact that we always pre-measure space, a font with no space glyph in it is never sufficient.
(even when the text does not require space at all)
Fallback fonts impact line positions through ascent/descent calculation.

Source/WebCore:

Test: fast/text/font-with-no-space-glyph.html

* rendering/RenderText.cpp:
(WebCore::RenderText::computePreferredLogicalWidths):
* rendering/line/BreakingContext.h:
(WebCore::WordTrailingSpace::WordTrailingSpace):
(WebCore::WordTrailingSpace::width):
(WebCore::BreakingContext::handleText):

LayoutTests:

* fast/ruby/ruby-expansion-cjk-2-expected.html: progression
* fast/ruby/ruby-expansion-cjk-3-expected.html: progression
* fast/ruby/ruby-expansion-cjk-4-expected.html: progression
* fast/ruby/ruby-expansion-cjk-5-expected.html: progression
* fast/ruby/ruby-expansion-cjk-expected.html: progression
* fast/text/font-with-no-space-glyph-expected.html: Added.
* fast/text/font-with-no-space-glyph.html: Added.
* platform/mac/svg/fonts/svg-font-general-expected.html: progression</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastrubyrubyexpansioncjk2expectedhtml">trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-2-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastrubyrubyexpansioncjk3expectedhtml">trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-3-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastrubyrubyexpansioncjk4expectedhtml">trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-4-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastrubyrubyexpansioncjk5expectedhtml">trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-5-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastrubyrubyexpansioncjkexpectedhtml">trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-expected.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacsvgfontssvgfontgeneralexpectedhtml">trunk/LayoutTests/platform/mac/svg/fonts/svg-font-general-expected.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextcpp">trunk/Source/WebCore/rendering/RenderText.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderinglineBreakingContexth">trunk/Source/WebCore/rendering/line/BreakingContext.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttextfontwithnospaceglyphexpectedhtml">trunk/LayoutTests/fast/text/font-with-no-space-glyph-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasttextfontwithnospaceglyphhtml">trunk/LayoutTests/fast/text/font-with-no-space-glyph.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (184149 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-05-12 02:45:47 UTC (rev 184149)
+++ trunk/LayoutTests/ChangeLog        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2015-05-11  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        Text is misplaced when custom font does not have space glyph.
+        https://bugs.webkit.org/show_bug.cgi?id=144879
+
+        Reviewed by Myles C. Maxfield
+
+        This patch ensures that we use fallback font for the missing space glyph only when the rendered text has space in it.
+
+        If a font does not provide all the glyphs required to render the associated text, we initiate fallback fonts. It is done while
+        measuring the text at layout time. However due to the fact that we always pre-measure space, a font with no space glyph in it is never sufficient.
+        (even when the text does not require space at all)
+        Fallback fonts impact line positions through ascent/descent calculation.
+
+        * fast/ruby/ruby-expansion-cjk-2-expected.html: progression
+        * fast/ruby/ruby-expansion-cjk-3-expected.html: progression
+        * fast/ruby/ruby-expansion-cjk-4-expected.html: progression
+        * fast/ruby/ruby-expansion-cjk-5-expected.html: progression
+        * fast/ruby/ruby-expansion-cjk-expected.html: progression
+        * fast/text/font-with-no-space-glyph-expected.html: Added.
+        * fast/text/font-with-no-space-glyph.html: Added.
+        * platform/mac/svg/fonts/svg-font-general-expected.html: progression
+
</ins><span class="cx"> 2015-05-11  Joanmarie Diggs  &lt;jdiggs@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         AX: [ATK] Always include rows in the tree of accessible tables
</span></span></pre></div>
<a id="trunkLayoutTestsfastrubyrubyexpansioncjk2expectedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-2-expected.html (184149 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-2-expected.html        2015-05-12 02:45:47 UTC (rev 184149)
+++ trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-2-expected.html        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -10,7 +10,7 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 120px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 113px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 180px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 360px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="lines">@@ -18,7 +18,7 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 240px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 226px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 220px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 81px; height: 41px; left: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 400px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 360px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 339px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 200px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 81px; height: 41px; left: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 380px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="lines">@@ -34,13 +34,13 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 480px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 452px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 300px; height: 20px; left: 0px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 300px; height: 20px; right: 00px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 130px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 380px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; right: 129px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><del>-&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</del><ins>+&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 62.5px; background: black;&quot;&gt;&lt;/div&gt;
</ins><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;/body&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfastrubyrubyexpansioncjk3expectedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-3-expected.html (184149 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-3-expected.html        2015-05-12 02:45:47 UTC (rev 184149)
+++ trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-3-expected.html        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 120px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 113px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 265px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 40px; height: 41px; left: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 40px; top: 19px; background: green;&quot;&gt;&lt;/div&gt;
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 240px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 226px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 135px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 40px; height: 41px; left: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 40px; top: 19px; background: green;&quot;&gt;&lt;/div&gt;
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 360px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 339px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 199px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 40px; height: 41px; left: 0px; top: 19px; background: green;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 40px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 480px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 452px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 135px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 40px; height: 41px; left: 0px; top: 19px; background: green;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 40px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfastrubyrubyexpansioncjk4expectedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-4-expected.html (184149 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-4-expected.html        2015-05-12 02:45:47 UTC (rev 184149)
+++ trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-4-expected.html        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -20,10 +20,10 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; right: 166px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 40px; height: 41px; right: 40px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 40px; height: 41px; right: 0px; top: 19px; background: green;&quot;&gt;&lt;/div&gt;
</span><del>-&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</del><ins>+&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 63px; background: black;&quot;&gt;&lt;/div&gt;
</ins><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 243px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 236px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 200px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 199px; top: 21px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 0px; top: 40px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 91px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 384px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 370px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 100px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 100px; height: 50px; left: 0px; top: 10px; background: rgb(0, 255, 0);&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; right: 479px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfastrubyrubyexpansioncjk5expectedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-5-expected.html (184149 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-5-expected.html        2015-05-12 02:45:47 UTC (rev 184149)
+++ trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-5-expected.html        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -9,7 +9,7 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 480px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 100px; height: 50px; right: 0px; top: 10px; background: rgb(0, 255, 0);&quot;&gt;&lt;/div&gt;
</span><del>-&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</del><ins>+&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 63px; background: black;&quot;&gt;&lt;/div&gt;
</ins><span class="cx"> &lt;/div&gt;
</span><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/html&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfastrubyrubyexpansioncjkexpectedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-expected.html (184149 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-expected.html        2015-05-12 02:45:47 UTC (rev 184149)
+++ trunk/LayoutTests/fast/ruby/ruby-expansion-cjk-expected.html        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -7,28 +7,28 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 380px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 40px; height: 41px; right: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><del>-&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</del><ins>+&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 63px; background: black;&quot;&gt;&lt;/div&gt;
</ins><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 120px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 106px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 199px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 153px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 606px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 40px; height: 41px; right: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><del>-&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</del><ins>+&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 63px; background: black;&quot;&gt;&lt;/div&gt;
</ins><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 240px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 212px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 199px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 153px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 606px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 40px; height: 41px; right: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><del>-&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</del><ins>+&lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 63px; background: black;&quot;&gt;&lt;/div&gt;
</ins><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 360px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 318px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 200px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 81px; height: 41px; left: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 41px; height: 41px; left: 380px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 800px; height: 41px; left: 0px; top: 70px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;/div&gt;
</span><span class="cx"> 
</span><del>-&lt;div style=&quot;position: absolute; left: 0px; top: 480px; width: 100%;&quot;&gt;
</del><ins>+&lt;div style=&quot;position: absolute; left: 0px; top: 431px; width: 100%;&quot;&gt;
</ins><span class="cx"> &lt;div style=&quot;position: absolute; width: 400px; height: 20px; left: 70px; top: 0px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 81px; height: 41px; left: 0px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;position: absolute; width: 81px; height: 41px; left: 230px; top: 19px; background: black;&quot;&gt;&lt;/div&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsfasttextfontwithnospaceglyphexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/font-with-no-space-glyph-expected.html (0 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/font-with-no-space-glyph-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/font-with-no-space-glyph-expected.html        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that when a font has no space glyph, we only use fallback fonts when space glyph is needed.&lt;/title&gt;
+&lt;script&gt;
+        if (window.internals)
+            internals.settings.setSimpleLineLayoutEnabled(false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;display: none;&quot;&gt;
+        &lt;defs&gt;
+                &lt;font id=&quot;ValidTestFont&quot; horiz-adv-x=&quot;450&quot; &gt;
+                                &lt;font-face font-family=&quot;SVGFreeSansASCIISubset&quot; units-per-em=&quot;1000&quot; panose-1=&quot;2 11 5 4 2 2 2 2 2 4&quot; ascent=&quot;35&quot; descent=&quot;10&quot; alphabetic=&quot;0&quot;/&gt;
+                                &lt;glyph unicode=&quot;a&quot; glyph-name=&quot;a&quot; horiz-adv-x=&quot;556&quot; d=&quot;M535 49V-14Q500 -23 478 -23Q407 -23 394 40Q393 47 392 54Q309 -22 218 -23H214Q104 -23 61 52Q42 86 42 131V132Q42 234 134 272Q170 287 264 299L302 304Q375 313 386 342V343V344L389 362V384Q389 448 308 460Q291 462 272 462Q169 462 152 387Q150 378 149 369H65Q68 441 101 478Q156 539 275 539Q451 539 470 423Q472 411 472 397V396V88Q472 47 517 47L535 49ZM389 165V259Q357 244 275 233Q266 232 255 230Q149 215 133 161L129 135V134Q129 69 196 54Q212 50 232 50Q304 50 356 97Q388 126 389 161Q389 162 389 162V162V163V163V165Z&quot;/&gt;
+                                &lt;glyph unicode=&quot;b&quot; glyph-name=&quot;b&quot; horiz-adv-x=&quot;556&quot; d=&quot;M54 729H137V453Q194 539 299 539Q427 539 486 431Q523 363 523 265V264Q523 103 432 26Q375 -23 295 -23Q188 -23 129 67V0H54V729ZM283 461Q200 461 161 377Q137 328 137 259V258Q137 133 206 81Q239 55 283 55Q367 55 409 134Q436 185 436 254V255Q436 382 364 435Q331 460 288 461Q285 461 283 461Z&quot;/&gt;
+                                &lt;glyph unicode=&quot;f&quot; glyph-name=&quot;f&quot; horiz-adv-x=&quot;278&quot; d=&quot;M258 524V456H171V0H88V456H18V524H88V613Q88 701 162 725Q184 732 211 732Q234 732 258 727V658L229 659Q172 659 171 608V606V524H258Z&quot;/&gt;
+                                &lt;glyph unicode=&quot;o&quot; glyph-name=&quot;o&quot; horiz-adv-x=&quot;556&quot; d=&quot;M272 539Q424 539 481 410Q510 345 510 255V254Q510 87 408 16Q352 -23 273 -23Q129 -23 69 96Q36 162 36 257V258Q36 432 141 502Q196 539 272 539ZM273 462Q180 462 142 370Q123 323 123 259V258Q123 121 201 73Q232 54 273 54Q363 54 402 142Q423 189 423 254V255Q423 400 341 446Q311 462 273 462Z&quot;/&gt;
+                                &lt;glyph unicode=&quot;r&quot; glyph-name=&quot;r&quot; horiz-adv-x=&quot;333&quot; d=&quot;M69 524H146V429Q204 522 262 536Q275 539 289 539L321 536V451Q249 450 218 429Q215 427 212 425Q153 382 153 273V272V0H69V524Z&quot;/&gt;
+                &lt;glyph unicode=&quot; &quot; glyph-name=&quot;space&quot; horiz-adv-x=&quot;224&quot; 
+                &lt;/font&gt;
+        &lt;/defs&gt;
+    &lt;/svg&gt;&lt;div style=&quot;font-family: SVGFreeSansASCIISubset&quot;&gt;foobar&lt;/div&gt;&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttextfontwithnospaceglyphhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/font-with-no-space-glyph.html (0 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/font-with-no-space-glyph.html                                (rev 0)
+++ trunk/LayoutTests/fast/text/font-with-no-space-glyph.html        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -0,0 +1,22 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that when a font has no space glyph, we only use fallback fonts when space glyph is needed.&lt;/title&gt;
+&lt;script&gt;
+        if (window.internals)
+            internals.settings.setSimpleLineLayoutEnabled(false);
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; style=&quot;display: none;&quot;&gt;
+        &lt;defs&gt;
+                &lt;font id=&quot;ValidTestFont&quot; horiz-adv-x=&quot;450&quot; &gt;
+                                &lt;font-face font-family=&quot;SVGFreeSansASCIISubset&quot; units-per-em=&quot;1000&quot; panose-1=&quot;2 11 5 4 2 2 2 2 2 4&quot; ascent=&quot;35&quot; descent=&quot;10&quot; alphabetic=&quot;0&quot;/&gt;
+                                &lt;glyph unicode=&quot;a&quot; glyph-name=&quot;a&quot; horiz-adv-x=&quot;556&quot; d=&quot;M535 49V-14Q500 -23 478 -23Q407 -23 394 40Q393 47 392 54Q309 -22 218 -23H214Q104 -23 61 52Q42 86 42 131V132Q42 234 134 272Q170 287 264 299L302 304Q375 313 386 342V343V344L389 362V384Q389 448 308 460Q291 462 272 462Q169 462 152 387Q150 378 149 369H65Q68 441 101 478Q156 539 275 539Q451 539 470 423Q472 411 472 397V396V88Q472 47 517 47L535 49ZM389 165V259Q357 244 275 233Q266 232 255 230Q149 215 133 161L129 135V134Q129 69 196 54Q212 50 232 50Q304 50 356 97Q388 126 389 161Q389 162 389 162V162V163V163V165Z&quot;/&gt;
+                                &lt;glyph unicode=&quot;b&quot; glyph-name=&quot;b&quot; horiz-adv-x=&quot;556&quot; d=&quot;M54 729H137V453Q194 539 299 539Q427 539 486 431Q523 363 523 265V264Q523 103 432 26Q375 -23 295 -23Q188 -23 129 67V0H54V729ZM283 461Q200 461 161 377Q137 328 137 259V258Q137 133 206 81Q239 55 283 55Q367 55 409 134Q436 185 436 254V255Q436 382 364 435Q331 460 288 461Q285 461 283 461Z&quot;/&gt;
+                                &lt;glyph unicode=&quot;f&quot; glyph-name=&quot;f&quot; horiz-adv-x=&quot;278&quot; d=&quot;M258 524V456H171V0H88V456H18V524H88V613Q88 701 162 725Q184 732 211 732Q234 732 258 727V658L229 659Q172 659 171 608V606V524H258Z&quot;/&gt;
+                                &lt;glyph unicode=&quot;o&quot; glyph-name=&quot;o&quot; horiz-adv-x=&quot;556&quot; d=&quot;M272 539Q424 539 481 410Q510 345 510 255V254Q510 87 408 16Q352 -23 273 -23Q129 -23 69 96Q36 162 36 257V258Q36 432 141 502Q196 539 272 539ZM273 462Q180 462 142 370Q123 323 123 259V258Q123 121 201 73Q232 54 273 54Q363 54 402 142Q423 189 423 254V255Q423 400 341 446Q311 462 273 462Z&quot;/&gt;
+                                &lt;glyph unicode=&quot;r&quot; glyph-name=&quot;r&quot; horiz-adv-x=&quot;333&quot; d=&quot;M69 524H146V429Q204 522 262 536Q275 539 289 539L321 536V451Q249 450 218 429Q215 427 212 425Q153 382 153 273V272V0H69V524Z&quot;/&gt;
+                &lt;/font&gt;
+        &lt;/defs&gt;
+    &lt;/svg&gt;&lt;div style=&quot;font-family: SVGFreeSansASCIISubset&quot;&gt;foobar&lt;/div&gt;&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacsvgfontssvgfontgeneralexpectedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/svg/fonts/svg-font-general-expected.html (184149 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/svg/fonts/svg-font-general-expected.html        2015-05-12 02:45:47 UTC (rev 184149)
+++ trunk/LayoutTests/platform/mac/svg/fonts/svg-font-general-expected.html        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -24,7 +24,6 @@
</span><span class="cx"> &lt;div&gt;&lt;span style=&quot;font: 50px Litherum;&quot;&gt;AAA&lt;/span&gt;&lt;span style=&quot;position: relative; left: 50px;&quot;&gt;AAA&lt;/span&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div&gt;&lt;span style=&quot;font: 50px Litherum4;&quot;&gt;AAA&lt;/span&gt;AAA&lt;/div&gt;
</span><span class="cx"> &lt;div&gt;&lt;div style=&quot;display: inline-block; width: 150px; height: 52px; position: relative;&quot;&gt;&lt;div style=&quot;position: absolute; width: 25px; height: 30px; left: 0px; bottom: 0px; background: black;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;position: absolute; width: 25px; height: 30px; left: 50px; bottom: 0px; background: black;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;position: absolute; width: 25px; height: 30px; left: 100px; bottom: 0px; background: black;&quot;&gt;&lt;/div&gt;&lt;/div&gt;AAA&lt;/div&gt;
</span><del>-&lt;div style=&quot;height: 7px;&quot;&gt;&lt;/div&gt;
</del><span class="cx"> &lt;div&gt;&lt;span style=&quot;font: 50px Litherum4;&quot;&gt;D&lt;/span&gt;&lt;span style=&quot;font-size: 50px;&quot;&gt;A&lt;/span&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;font-size: 50px;&quot;&gt;&lt;span class=&quot;a&quot;&gt;A&lt;/span&gt;Z&lt;span class=&quot;a&quot;&gt;A&lt;/span&gt;Z&lt;span class=&quot;a&quot;&gt;A&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;a&quot;&gt;&amp;#x672c;&lt;/span&gt;N&lt;span class=&quot;a&quot;&gt;&amp;#x672c;&lt;/span&gt;N&lt;span class=&quot;a&quot;&gt;&amp;#x672c;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
</span><span class="cx"> &lt;div style=&quot;display: inline-block; position: relative; width: 200px; height: 206px;&quot;&gt;&lt;div style=&quot;position: absolute; top: 2px; left: 0px; width: 50px; height: 100px; background: black;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;position: absolute; top: 2px; left: 50px; width: 50px; height: 50px; background: black;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;position: absolute; bottom: -1px; left: 0px; width: 50px; height: 100px; background: black;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;position: absolute; bottom: 49px; left: 50px; width: 50px; height: 50px; background: black;&quot;&gt;&lt;/div&gt;&lt;/div&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (184149 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-12 02:45:47 UTC (rev 184149)
+++ trunk/Source/WebCore/ChangeLog        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2015-05-11  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        Text is misplaced when custom font does not have space glyph.
+        https://bugs.webkit.org/show_bug.cgi?id=144879
+
+        Reviewed by Myles C. Maxfield
+
+        This patch ensures that we use fallback font for the missing space glyph only when the rendered text has space in it.
+
+        If a font does not provide all the glyphs required to render the associated text, we initiate fallback fonts. It is done while
+        measuring the text at layout time. However due to the fact that we always pre-measure space, a font with no space glyph in it is never sufficient.
+        (even when the text does not require space at all)
+        Fallback fonts impact line positions through ascent/descent calculation.
+
+        Test: fast/text/font-with-no-space-glyph.html
+
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::computePreferredLogicalWidths):
+        * rendering/line/BreakingContext.h:
+        (WebCore::WordTrailingSpace::WordTrailingSpace):
+        (WebCore::WordTrailingSpace::width):
+        (WebCore::BreakingContext::handleText):
+
</ins><span class="cx"> 2015-05-11  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Small tidyup in animations code
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderText.cpp (184149 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderText.cpp        2015-05-12 02:45:47 UTC (rev 184149)
+++ trunk/Source/WebCore/rendering/RenderText.cpp        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include &quot;RenderText.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;AXObjectCache.h&quot;
</span><ins>+#include &quot;BreakingContext.h&quot;
</ins><span class="cx"> #include &quot;CharacterProperties.h&quot;
</span><span class="cx"> #include &quot;EllipsisBox.h&quot;
</span><span class="cx"> #include &quot;FloatQuad.h&quot;
</span><span class="lines">@@ -714,8 +715,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Non-zero only when kerning is enabled, in which case we measure words with their trailing
</span><span class="cx">     // space, then subtract its width.
</span><del>-    float wordTrailingSpaceWidth = font.typesettingFeatures() &amp; Kerning ? font.width(RenderBlock::constructTextRun(this, font, &amp;space, 1, style), &amp;fallbackFonts) + wordSpacing : 0;
-
</del><ins>+    WordTrailingSpace wordTrailingSpace(*this, style);
</ins><span class="cx">     // If automatic hyphenation is allowed, we keep track of the width of the widest word (or word
</span><span class="cx">     // fragment) encountered so far, and only try hyphenating words that are wider.
</span><span class="cx">     float maxWordWidth = std::numeric_limits&lt;float&gt;::max();
</span><span class="lines">@@ -804,8 +804,11 @@
</span><span class="cx">             float currMinWidth = 0;
</span><span class="cx">             bool isSpace = (j &lt; len) &amp;&amp; isSpaceAccordingToStyle(c, style);
</span><span class="cx">             float w;
</span><del>-            if (wordTrailingSpaceWidth &amp;&amp; isSpace)
-                w = widthFromCache(font, i, wordLen + 1, leadWidth + currMaxWidth, &amp;fallbackFonts, &amp;glyphOverflow, style) - wordTrailingSpaceWidth;
</del><ins>+            Optional&lt;float&gt; wordTrailingSpaceWidth;
+            if (isSpace)
+                wordTrailingSpaceWidth = wordTrailingSpace.width(fallbackFonts);
+            if (wordTrailingSpaceWidth)
+                w = widthFromCache(font, i, wordLen + 1, leadWidth + currMaxWidth, &amp;fallbackFonts, &amp;glyphOverflow, style) - wordTrailingSpaceWidth.value();
</ins><span class="cx">             else {
</span><span class="cx">                 w = widthFromCache(font, i, wordLen, leadWidth + currMaxWidth, &amp;fallbackFonts, &amp;glyphOverflow, style);
</span><span class="cx">                 if (c == softHyphen &amp;&amp; style.hyphens() != HyphensNone)
</span><span class="lines">@@ -818,8 +821,11 @@
</span><span class="cx"> 
</span><span class="cx">                 if (suffixStart) {
</span><span class="cx">                     float suffixWidth;
</span><del>-                    if (wordTrailingSpaceWidth &amp;&amp; isSpace)
-                        suffixWidth = widthFromCache(font, i + suffixStart, wordLen - suffixStart + 1, leadWidth + currMaxWidth, 0, 0, style) - wordTrailingSpaceWidth;
</del><ins>+                    Optional&lt;float&gt; wordTrailingSpaceWidth;
+                    if (isSpace)
+                        wordTrailingSpaceWidth = wordTrailingSpace.width(fallbackFonts);
+                    if (wordTrailingSpaceWidth)
+                        suffixWidth = widthFromCache(font, i + suffixStart, wordLen - suffixStart + 1, leadWidth + currMaxWidth, 0, 0, style) - wordTrailingSpaceWidth.value();
</ins><span class="cx">                     else
</span><span class="cx">                         suffixWidth = widthFromCache(font, i + suffixStart, wordLen - suffixStart, leadWidth + currMaxWidth, 0, 0, style);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderinglineBreakingContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/line/BreakingContext.h (184149 => 184150)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/line/BreakingContext.h        2015-05-12 02:45:47 UTC (rev 184149)
+++ trunk/Source/WebCore/rendering/line/BreakingContext.h        2015-05-12 04:01:50 UTC (rev 184150)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> #include &quot;RenderSVGInlineText.h&quot;
</span><span class="cx"> #include &quot;TrailingObjects.h&quot;
</span><span class="cx"> #include &quot;break_lines.h&quot;
</span><ins>+#include &lt;wtf/Optional.h&gt;
</ins><span class="cx"> #include &lt;wtf/text/StringView.h&gt;
</span><span class="cx"> #include &lt;wtf/unicode/CharacterNames.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -62,6 +63,34 @@
</span><span class="cx">     HashSet&lt;const Font*&gt; fallbackFonts;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+struct WordTrailingSpace {
+    WordTrailingSpace(RenderText&amp; renderer, const RenderStyle&amp; style, TextLayout* textLayout = nullptr)
+        : m_renderer(renderer)
+        , m_style(style)
+        , m_textLayout(textLayout)
+    {
+    }
+
+    WTF::Optional&lt;float&gt; width(HashSet&lt;const Font*&gt;&amp; fallbackFonts)
+    {
+        if (m_state == WordTrailingSpaceState::Computed)
+            return m_width;
+
+        const FontCascade&amp; font = m_style.fontCascade();
+        if ((font.typesettingFeatures() &amp; Kerning) &amp;&amp; !m_textLayout)
+            m_width = font.width(RenderBlock::constructTextRun(&amp;m_renderer, font, &amp;space, 1, m_style), &amp;fallbackFonts) + font.wordSpacing();
+        m_state = WordTrailingSpaceState::Computed;
+        return m_width;
+    }
+private:
+    enum class WordTrailingSpaceState { Uninitialized, Computed };
+    WordTrailingSpaceState m_state { WordTrailingSpaceState::Uninitialized };
+    WTF::Optional&lt;float&gt; m_width;
+    RenderText&amp; m_renderer;
+    const RenderStyle&amp; m_style;
+    TextLayout* m_textLayout { nullptr };
+};
+
</ins><span class="cx"> class BreakingContext {
</span><span class="cx"> public:
</span><span class="cx">     BreakingContext(LineBreaker&amp; lineBreaker, InlineBidiResolver&amp; resolver, LineInfo&amp; inLineInfo, LineWidth&amp; lineWidth, RenderTextInfo&amp; inRenderTextInfo, FloatingObject* inLastFloatFromPreviousLine, bool appliedStartWidth, RenderBlockFlow&amp; block)
</span><span class="lines">@@ -740,10 +769,9 @@
</span><span class="cx">     // Non-zero only when kerning is enabled and TextLayout isn't used, in which case we measure
</span><span class="cx">     // words with their trailing space, then subtract its width.
</span><span class="cx">     HashSet&lt;const Font*&gt; fallbackFonts;
</span><del>-    float wordTrailingSpaceWidth = (font.typesettingFeatures() &amp; Kerning) &amp;&amp; !textLayout ? font.width(RenderBlock::constructTextRun(&amp;renderText, font, &amp;space, 1, style), &amp;fallbackFonts) + wordSpacing : 0;
-
</del><span class="cx">     UChar lastCharacter = m_renderTextInfo.lineBreakIterator.lastCharacter();
</span><span class="cx">     UChar secondToLastCharacter = m_renderTextInfo.lineBreakIterator.secondToLastCharacter();
</span><ins>+    WordTrailingSpace wordTrailingSpace(renderText, style, textLayout);
</ins><span class="cx">     for (; m_current.offset() &lt; renderText.textLength(); m_current.fastIncrementInTextNode()) {
</span><span class="cx">         bool previousCharacterIsSpace = m_currentCharacterIsSpace;
</span><span class="cx">         bool previousCharacterIsWS = m_currentCharacterIsWS;
</span><span class="lines">@@ -801,8 +829,13 @@
</span><span class="cx">             wordMeasurement.startOffset = lastSpace;
</span><span class="cx"> 
</span><span class="cx">             float additionalTempWidth;
</span><del>-            if (wordTrailingSpaceWidth &amp;&amp; c == ' ')
-                additionalTempWidth = textWidth(renderText, lastSpace, m_current.offset() + 1 - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout) - wordTrailingSpaceWidth;
</del><ins>+            WTF::Optional&lt;float&gt; wordTrailingSpaceWidth;
+            if (c == ' ')
+                wordTrailingSpaceWidth = wordTrailingSpace.width(fallbackFonts);
+            if (wordTrailingSpaceWidth) {
+                additionalTempWidth = textWidth(renderText, lastSpace, m_current.offset() + 1 - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace,
+                    wordMeasurement.fallbackFonts, textLayout) - wordTrailingSpaceWidth.value();
+            }
</ins><span class="cx">             else
</span><span class="cx">                 additionalTempWidth = textWidth(renderText, lastSpace, m_current.offset() - lastSpace, font, m_width.currentWidth(), isFixedPitch, m_collapseWhiteSpace, wordMeasurement.fallbackFonts, textLayout);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>