<!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>[197519] 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/197519">197519</a></dd>
<dt>Author</dt> <dd>hyatt@apple.com</dd>
<dt>Date</dt> <dd>2016-03-03 13:49:32 -0800 (Thu, 03 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add support for the "last" value of hanging-punctuation
https://bugs.webkit.org/show_bug.cgi?id=154977
Reviewed by Darin Adler and Simon Fraser.
Source/WebCore:
New tests in fast/text.
This patch adds support for the new "last" value and also fixes up both
"first" and "last" to work with leading and trailing whitespace that ends
up getting collapsed away.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::inlineAncestorHasStartBorderPaddingOrMargin):
(WebCore::inlineAncestorHasEndBorderPaddingOrMargin):
(WebCore::isLastInFlowRun):
(WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
* rendering/RenderText.cpp:
(WebCore::isHangablePunctuationAtLineEnd):
(WebCore::RenderText::hangablePunctuationStartWidth):
(WebCore::RenderText::hangablePunctuationEndWidth):
(WebCore::RenderText::firstCharacterIndexStrippingSpaces):
(WebCore::RenderText::lastCharacterIndexStrippingSpaces):
(WebCore::RenderText::trimmedPrefWidths):
* rendering/RenderText.h:
* rendering/line/BreakingContext.h:
(WebCore::BreakingContext::handleText):
LayoutTests:
* fast/text/hanging-punctuation-first-and-last-together-expected.html: Added.
* fast/text/hanging-punctuation-first-and-last-together.html: Added.
* fast/text/hanging-punctuation-first-ws-expected.html: Added.
* fast/text/hanging-punctuation-first-ws.html: Added.
* fast/text/hanging-punctuation-last-expected.html: Added.
* fast/text/hanging-punctuation-last-rtl-expected.html: Added.
* fast/text/hanging-punctuation-last-rtl.html: Added.
* fast/text/hanging-punctuation-last-ws-expected.html: Added.
* fast/text/hanging-punctuation-last-ws.html: Added.
* fast/text/hanging-punctuation-last.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockLineLayoutcpp">trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTextcpp">trunk/Source/WebCore/rendering/RenderText.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTexth">trunk/Source/WebCore/rendering/RenderText.h</a></li>
<li><a href="#trunkSourceWebCorerenderinglineBreakingContexth">trunk/Source/WebCore/rendering/line/BreakingContext.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttexthangingpunctuationfirstandlasttogetherexpectedhtml">trunk/LayoutTests/fast/text/hanging-punctuation-first-and-last-together-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasttexthangingpunctuationfirstandlasttogetherhtml">trunk/LayoutTests/fast/text/hanging-punctuation-first-and-last-together.html</a></li>
<li><a href="#trunkLayoutTestsfasttexthangingpunctuationfirstwsexpectedhtml">trunk/LayoutTests/fast/text/hanging-punctuation-first-ws-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasttexthangingpunctuationfirstwshtml">trunk/LayoutTests/fast/text/hanging-punctuation-first-ws.html</a></li>
<li><a href="#trunkLayoutTestsfasttexthangingpunctuationlastexpectedhtml">trunk/LayoutTests/fast/text/hanging-punctuation-last-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasttexthangingpunctuationlastrtlexpectedhtml">trunk/LayoutTests/fast/text/hanging-punctuation-last-rtl-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasttexthangingpunctuationlastrtlhtml">trunk/LayoutTests/fast/text/hanging-punctuation-last-rtl.html</a></li>
<li><a href="#trunkLayoutTestsfasttexthangingpunctuationlastwsexpectedhtml">trunk/LayoutTests/fast/text/hanging-punctuation-last-ws-expected.html</a></li>
<li><a href="#trunkLayoutTestsfasttexthangingpunctuationlastwshtml">trunk/LayoutTests/fast/text/hanging-punctuation-last-ws.html</a></li>
<li><a href="#trunkLayoutTestsfasttexthangingpunctuationlasthtml">trunk/LayoutTests/fast/text/hanging-punctuation-last.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (197518 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-03 21:46:07 UTC (rev 197518)
+++ trunk/LayoutTests/ChangeLog        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2016-03-03 Dave Hyatt <hyatt@apple.com>
+
+ Add support for the "last" value of hanging-punctuation
+ https://bugs.webkit.org/show_bug.cgi?id=154977
+
+ Reviewed by Darin Adler and Simon Fraser.
+
+ * fast/text/hanging-punctuation-first-and-last-together-expected.html: Added.
+ * fast/text/hanging-punctuation-first-and-last-together.html: Added.
+ * fast/text/hanging-punctuation-first-ws-expected.html: Added.
+ * fast/text/hanging-punctuation-first-ws.html: Added.
+ * fast/text/hanging-punctuation-last-expected.html: Added.
+ * fast/text/hanging-punctuation-last-rtl-expected.html: Added.
+ * fast/text/hanging-punctuation-last-rtl.html: Added.
+ * fast/text/hanging-punctuation-last-ws-expected.html: Added.
+ * fast/text/hanging-punctuation-last-ws.html: Added.
+ * fast/text/hanging-punctuation-last.html: Added.
+
</ins><span class="cx"> 2016-03-03 Brady Eidson <beidson@apple.com>
</span><span class="cx">
</span><span class="cx"> storage/indexeddb/delete-in-upgradeneeded-close-in-open-success.html flaky on mac-wk2.
</span></span></pre></div>
<a id="trunkLayoutTestsfasttexthangingpunctuationfirstandlasttogetherexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/hanging-punctuation-first-and-last-together-expected.html (0 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/hanging-punctuation-first-and-last-together-expected.html         (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-first-and-last-together-expected.html        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<head>
+ <style>
+ body { font-family: 'Ahem'; color:green }
+ .hang { margin:1em; border:1px solid black }
+ </style>
+</head>
+<body>
+ <div style="float:left" class="hang"><div style="margin: 0 -1em">(Hang test)</div></div>
+ <div style="clear:both">
+ <div class="hang" style="width:10em; text-align:justify;"><span style="margin:0 -1em">(This should hang.<br>(This should also hang.)</span></div>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttexthangingpunctuationfirstandlasttogetherhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/hanging-punctuation-first-and-last-together.html (0 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/hanging-punctuation-first-and-last-together.html         (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-first-and-last-together.html        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<head>
+<style>
+ body { font-family: 'Ahem'; color:green }
+ .hang { hanging-punctuation: first last; margin:1em; border:1px solid black }
+</style>
+</head>
+<body>
+<div style="float:left" class="hang">(Hang test)</div>
+<div style="clear:both">
+<div class="hang" style="width:10em; text-align:justify;">(This should hang.<br>(This should also hang.)</div>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttexthangingpunctuationfirstwsexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/hanging-punctuation-first-ws-expected.html (0 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/hanging-punctuation-first-ws-expected.html         (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-first-ws-expected.html        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+<head>
+<style>
+ body { font-family: 'Ahem'; color:green }
+ .hang { text-indent: -1em; margin:1em }
+</style>
+</head>
+<body>
+<div style="float:left" class="hang">(Hang test)</div>
+<div style="clear:both">
+<div class="hang">(This should hang.<br>(This should not.</div>
+<div class="hang" style="text-align:justify; width:300px;">(This should hang and justifybecause and now were fine.</div>
+<div class="hang" style="text-align:justify; width:300px;"><span>(</span>This should hang.</div>
+<div style="margin-left:1em; text-align:justify; width:300px;"><span style="border-left:1em solid blue">(</span>This should not hang.</div>
+<div class="hang" style="text-indent:1em; text-align:justify; width:300px;">(This should hang into the text-indent.</div>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfasttexthangingpunctuationfirstwshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/hanging-punctuation-first-ws.html (0 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/hanging-punctuation-first-ws.html         (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-first-ws.html        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+<head>
+<style>
+ body { font-family: 'Ahem'; color:green }
+ .hang { hanging-punctuation: first; margin:1em }
+</style>
+</head>
+<body>
+<div style="float:left" class="hang"> (Hang test)</div>
+<div style="clear:both">
+<div class="hang"> (This should hang.<br>(This should not.</div>
+<div class="hang" style="text-align:justify; width:300px;"> (This should hang and justifybecause and now were fine.</div>
+<div class="hang" style="text-align:justify; width:300px;"> <span> (</span>This should hang.</div>
+<div class="hang" style="text-align:justify; width:300px;"> <span style="border-left:1em solid blue"> (</span>This should not hang.</div>
+<div class="hang" style="text-indent:2em; text-align:justify; width:300px;"> (This should hang into the text-indent.</div>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfasttexthangingpunctuationlastexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/hanging-punctuation-last-expected.html (0 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/hanging-punctuation-last-expected.html         (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-last-expected.html        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<head>
+ <style>
+ body { font-family: 'Ahem'; color:green }
+ .hang { margin:1em }
+ </style>
+</head>
+<body>
+<div style="float:left;" class="hang">(Hang test)</div>
+<div style="clear:both">
+ <div class="hang" style="width:5em">No.<br>Yes.)</div>
+ <div class="hang" style="text-align:justify; width:5em;">Yes <span>)</span></div>
+ <div class="hang" style="text-align:justify; width:4em;">No. <span style="border-right:1em solid blue">)</span></div>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttexthangingpunctuationlastrtlexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/hanging-punctuation-last-rtl-expected.html (0 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/hanging-punctuation-last-rtl-expected.html         (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-last-rtl-expected.html        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<head>
+ <style>
+ body { font-family: 'Ahem'; color:green; direction:rtl }
+ .hang { margin:1em }
+ </style>
+</head>
+<body>
+<div style="float:right;" class="hang">(Hang test)</div>
+<div style="clear:both">
+ <div class="hang" style="width:5em">No.<br>Yes.)</div>
+ <div class="hang" style="text-align:justify; width:5em;">Yes <span>)</span></div>
+ <div class="hang" style="text-align:justify; width:4em;">No. <span style="border-left:1em solid blue">)</span></div>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttexthangingpunctuationlastrtlhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/hanging-punctuation-last-rtl.html (0 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/hanging-punctuation-last-rtl.html         (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-last-rtl.html        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+<head>
+<style>
+ body { font-family: 'Ahem'; color:green; direction:rtl }
+ .hang { hanging-punctuation: last; margin:1em }
+</style>
+</head>
+<body>
+<div style="float:right;" class="hang">(Hang test)</div>
+<div style="clear:both">
+<div class="hang" style="width:4em"
+ >No.<br>Yes.)</div>
+<div class="hang" style="text-align:justify; width:4em;">Yes <span>)</span></div>
+<div class="hang" style="text-align:justify; width:4em;">No. <span style="border-left:1em solid blue">)</span></div>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttexthangingpunctuationlastwsexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/hanging-punctuation-last-ws-expected.html (0 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/hanging-punctuation-last-ws-expected.html         (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-last-ws-expected.html        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<head>
+ <style>
+ body { font-family: 'Ahem'; color:green }
+ .hang { margin:1em }
+ </style>
+</head>
+<body>
+<div style="float:left;" class="hang">(Hang test)</div>
+<div style="clear:both">
+ <div class="hang" style="width:5em">No.<br>Yes.)</div>
+ <div class="hang" style="text-align:justify; width:5em;">Yes <span>)</span></div>
+ <div class="hang" style="text-align:justify; width:4em;">No. <span style="border-right:1em solid blue">)</span></div>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttexthangingpunctuationlastwshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/hanging-punctuation-last-ws.html (0 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/hanging-punctuation-last-ws.html         (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-last-ws.html        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<head>
+<style>
+ body { font-family: 'Ahem'; color:green }
+ .hang { hanging-punctuation: last; margin:1em }
+</style>
+</head>
+<body>
+<div style="float:left;" class="hang">(Hang test) </div>
+<div style="clear:both">
+<div class="hang" style="width:4em">No.<br>Yes.) </div>
+<div class="hang" style="text-align:justify; width:4em;">Yes <span>) </span></div>
+<div class="hang" style="text-align:justify; width:4em;">No. <span style="border-right:1em solid blue">) </span> </div>
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttexthangingpunctuationlasthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/text/hanging-punctuation-last.html (0 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/text/hanging-punctuation-last.html         (rev 0)
+++ trunk/LayoutTests/fast/text/hanging-punctuation-last.html        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+<head>
+<style>
+ body { font-family: 'Ahem'; color:green }
+ .hang { hanging-punctuation: last; margin:1em }
+</style>
+</head>
+<body>
+<div style="float:left;" class="hang">(Hang test)</div>
+<div style="clear:both">
+<div class="hang" style="width:4em"
+ >No.<br>Yes.)</div>
+<div class="hang" style="text-align:justify; width:4em;">Yes <span>)</span></div>
+<div class="hang" style="text-align:justify; width:4em;">No. <span style="border-right:1em solid blue">)</span></div>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197518 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-03 21:46:07 UTC (rev 197518)
+++ trunk/Source/WebCore/ChangeLog        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2016-03-03 Dave Hyatt <hyatt@apple.com>
+
+ Add support for the "last" value of hanging-punctuation
+ https://bugs.webkit.org/show_bug.cgi?id=154977
+
+ Reviewed by Darin Adler and Simon Fraser.
+
+ New tests in fast/text.
+
+ This patch adds support for the new "last" value and also fixes up both
+ "first" and "last" to work with leading and trailing whitespace that ends
+ up getting collapsed away.
+
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths):
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::inlineAncestorHasStartBorderPaddingOrMargin):
+ (WebCore::inlineAncestorHasEndBorderPaddingOrMargin):
+ (WebCore::isLastInFlowRun):
+ (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
+ * rendering/RenderText.cpp:
+ (WebCore::isHangablePunctuationAtLineEnd):
+ (WebCore::RenderText::hangablePunctuationStartWidth):
+ (WebCore::RenderText::hangablePunctuationEndWidth):
+ (WebCore::RenderText::firstCharacterIndexStrippingSpaces):
+ (WebCore::RenderText::lastCharacterIndexStrippingSpaces):
+ (WebCore::RenderText::trimmedPrefWidths):
+ * rendering/RenderText.h:
+ * rendering/line/BreakingContext.h:
+ (WebCore::BreakingContext::handleText):
+
</ins><span class="cx"> 2016-03-03 Andy Estes <aestes@apple.com>
</span><span class="cx">
</span><span class="cx"> Adopt CFNetwork storage partitioning SPI
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (197518 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2016-03-03 21:46:07 UTC (rev 197518)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -4065,6 +4065,9 @@
</span><span class="cx"> bool isPrevChildInlineFlow = false;
</span><span class="cx"> bool shouldBreakLineAfterText = false;
</span><span class="cx"> bool canHangPunctuationAtStart = styleToUse.hangingPunctuation() & FirstHangingPunctuation;
</span><ins>+ bool canHangPunctuationAtEnd = styleToUse.hangingPunctuation() & LastHangingPunctuation;
+ RenderText* lastText = nullptr;
+
</ins><span class="cx"> bool addedStartPunctuationHang = false;
</span><span class="cx">
</span><span class="cx"> while (RenderObject* child = childIterator.next()) {
</span><span class="lines">@@ -4111,6 +4114,7 @@
</span><span class="cx"> float childMax = 0;
</span><span class="cx">
</span><span class="cx"> if (!child->isText()) {
</span><ins>+ lastText = nullptr;
</ins><span class="cx"> if (child->isLineBreakOpportunity()) {
</span><span class="cx"> minLogicalWidth = preferredWidth(minLogicalWidth, inlineMin);
</span><span class="cx"> inlineMin = 0;
</span><span class="lines">@@ -4217,6 +4221,7 @@
</span><span class="cx"> if (!child->isFloating()) {
</span><span class="cx"> stripFrontSpaces = false;
</span><span class="cx"> trailingSpaceChild = nullptr;
</span><ins>+ lastText = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> } else if (is<RenderText>(*child)) {
</span><span class="cx"> // Case (3). Text.
</span><span class="lines">@@ -4234,6 +4239,7 @@
</span><span class="cx"> float beginMin, endMin;
</span><span class="cx"> bool beginWS, endWS;
</span><span class="cx"> float beginMax, endMax;
</span><ins>+ bool strippingBeginWS = stripFrontSpaces;
</ins><span class="cx"> renderText.trimmedPrefWidths(inlineMax, beginMin, beginWS, endMin, endWS,
</span><span class="cx"> hasBreakableChar, hasBreak, beginMax, endMax,
</span><span class="cx"> childMin, childMax, stripFrontSpaces);
</span><span class="lines">@@ -4246,6 +4252,8 @@
</span><span class="cx"> }
</span><span class="cx"> continue;
</span><span class="cx"> }
</span><ins>+
+ lastText = &renderText;
</ins><span class="cx">
</span><span class="cx"> if (stripFrontSpaces)
</span><span class="cx"> trailingSpaceChild = child;
</span><span class="lines">@@ -4276,7 +4284,8 @@
</span><span class="cx">
</span><span class="cx"> // See if we have a hanging punctuation situation at the start.
</span><span class="cx"> if (canHangPunctuationAtStart && !addedStartPunctuationHang) {
</span><del>- float hangStartWidth = renderText.hangablePunctuationStartWidth();
</del><ins>+ unsigned startIndex = strippingBeginWS ? renderText.firstCharacterIndexStrippingSpaces() : 0;
+ float hangStartWidth = renderText.hangablePunctuationStartWidth(startIndex);
</ins><span class="cx"> childMin -= hangStartWidth;
</span><span class="cx"> beginMin -= hangStartWidth;
</span><span class="cx"> childMax -= hangStartWidth;
</span><span class="lines">@@ -4349,6 +4358,13 @@
</span><span class="cx">
</span><span class="cx"> if (styleToUse.collapseWhiteSpace())
</span><span class="cx"> stripTrailingSpace(inlineMax, inlineMin, trailingSpaceChild);
</span><ins>+
+ if (canHangPunctuationAtEnd && lastText && lastText->textLength() > 0) {
+ unsigned endIndex = trailingSpaceChild == lastText ? lastText->lastCharacterIndexStrippingSpaces() : lastText->textLength() - 1;
+ float endHangWidth = lastText->hangablePunctuationEndWidth(endIndex);
+ inlineMin -= endHangWidth;
+ inlineMax -= endHangWidth;
+ }
</ins><span class="cx">
</span><span class="cx"> minLogicalWidth = preferredWidth(minLogicalWidth, inlineMin);
</span><span class="cx"> maxLogicalWidth = preferredWidth(maxLogicalWidth, inlineMax);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (197518 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2016-03-03 21:46:07 UTC (rev 197518)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -817,6 +817,17 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static bool inlineAncestorHasEndBorderPaddingOrMargin(const RenderBlockFlow& block, const InlineBox& box)
+{
+ bool isLTR = block.style().isLeftToRightDirection();
+ for (auto* currentBox = box.parent(); currentBox; currentBox = currentBox->parent()) {
+ if ((isLTR && currentBox->marginBorderPaddingLogicalRight() > 0)
+ || (!isLTR && currentBox->marginBorderPaddingLogicalLeft() > 0))
+ return true;
+ }
+ return false;
+}
+
</ins><span class="cx"> static bool isLastInFlowRun(BidiRun& runToCheck)
</span><span class="cx"> {
</span><span class="cx"> for (auto* run = runToCheck.next(); run; run = run->next()) {
</span><span class="lines">@@ -833,6 +844,7 @@
</span><span class="cx"> {
</span><span class="cx"> bool needsWordSpacing = false;
</span><span class="cx"> bool canHangPunctuationAtStart = style().hangingPunctuation() & FirstHangingPunctuation;
</span><ins>+ bool canHangPunctuationAtEnd = style().hangingPunctuation() & LastHangingPunctuation;
</ins><span class="cx"> bool isLTR = style().isLeftToRightDirection();
</span><span class="cx"> float totalLogicalWidth = lineBox->getFlowSpacingLogicalWidth();
</span><span class="cx"> unsigned expansionOpportunityCount = 0;
</span><span class="lines">@@ -852,13 +864,22 @@
</span><span class="cx"> auto& textBox = downcast<InlineTextBox>(*run->box());
</span><span class="cx"> if (canHangPunctuationAtStart && lineInfo.isFirstLine() && (isLTR || isLastInFlowRun(*run))
</span><span class="cx"> && !inlineAncestorHasStartBorderPaddingOrMargin(*this, *run->box())) {
</span><del>- float hangStartWidth = renderText.hangablePunctuationStartWidth();
</del><ins>+ float hangStartWidth = renderText.hangablePunctuationStartWidth(run->m_start);
</ins><span class="cx"> availableLogicalWidth += hangStartWidth;
</span><span class="cx"> if (style().isLeftToRightDirection())
</span><span class="cx"> logicalLeft -= hangStartWidth;
</span><span class="cx"> canHangPunctuationAtStart = false;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ if (canHangPunctuationAtEnd && lineInfo.isLastLine() && run->m_stop > 0 && (!isLTR || isLastInFlowRun(*run))
+ && !inlineAncestorHasEndBorderPaddingOrMargin(*this, *run->box())) {
+ float hangEndWidth = renderText.hangablePunctuationEndWidth(run->m_stop - 1);
+ availableLogicalWidth += hangEndWidth;
+ if (!style().isLeftToRightDirection())
+ logicalLeft -= hangEndWidth;
+ canHangPunctuationAtEnd = false;
+ }
+
</ins><span class="cx"> if (textAlign == JUSTIFY && run != trailingSpaceRun) {
</span><span class="cx"> ExpansionBehavior expansionBehavior = expansionBehaviorForInlineTextBox(*this, textBox, previousRun, run->next(), textAlign, isAfterExpansion);
</span><span class="cx"> applyExpansionBehavior(textBox, expansionBehavior);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderText.cpp (197518 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderText.cpp        2016-03-03 21:46:07 UTC (rev 197518)
+++ trunk/Source/WebCore/rendering/RenderText.cpp        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -512,22 +512,75 @@
</span><span class="cx"> return U_GET_GC_MASK(c) & (U_GC_PE_MASK | U_GC_PI_MASK | U_GC_PF_MASK);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-float RenderText::hangablePunctuationStartWidth() const
</del><ins>+float RenderText::hangablePunctuationStartWidth(unsigned index) const
</ins><span class="cx"> {
</span><span class="cx"> if (!textLength())
</span><span class="cx"> return 0;
</span><span class="cx">
</span><span class="cx"> ASSERT(m_text);
</span><span class="cx"> StringImpl& text = *m_text.impl();
</span><del>- if (!isHangablePunctuationAtLineStart(text[0]))
</del><ins>+
+ if (!isHangablePunctuationAtLineStart(text[index]))
</ins><span class="cx"> return 0;
</span><del>-
</del><ins>+
</ins><span class="cx"> const RenderStyle& style = this->style();
</span><span class="cx"> const FontCascade& font = style.fontCascade();
</span><span class="cx">
</span><span class="cx"> return widthFromCache(font, 0, 1, 0, 0, 0, style);
</span><span class="cx"> }
</span><ins>+
+float RenderText::hangablePunctuationEndWidth(unsigned index) const
+{
+ if (!textLength())
+ return 0;
</ins><span class="cx">
</span><ins>+ ASSERT(m_text);
+ StringImpl& text = *m_text.impl();
+
+ if (!isHangablePunctuationAtLineEnd(text[index]))
+ return 0;
+
+ const RenderStyle& style = this->style();
+ const FontCascade& font = style.fontCascade();
+
+ return widthFromCache(font, 0, 1, 0, 0, 0, style);
+}
+
+unsigned RenderText::firstCharacterIndexStrippingSpaces() const
+{
+ if (!style().collapseWhiteSpace())
+ return 0;
+
+ ASSERT(m_text);
+ StringImpl& text = *m_text.impl();
+
+ unsigned i = 0;
+ for ( ; i < textLength(); ++i) {
+ if (text[i] != ' ' && (text[i] != '\n' || style().preserveNewline()) && text[i] != '\t')
+ break;
+ }
+ return i;
+}
+
+unsigned RenderText::lastCharacterIndexStrippingSpaces() const
+{
+ if (!textLength())
+ return 0;
+
+ if (!style().collapseWhiteSpace())
+ return textLength() - 1;
+
+ ASSERT(m_text);
+ StringImpl& text = *m_text.impl();
+
+ int i = textLength() - 1;
+ for ( ; i >= 0; --i) {
+ if (text[i] != ' ' && (text[i] != '\n' || style().preserveNewline()) && text[i] != '\t')
+ break;
+ }
+ return i;
+}
+
</ins><span class="cx"> void RenderText::trimmedPrefWidths(float leadWidth,
</span><span class="cx"> float& beginMinW, bool& beginWS,
</span><span class="cx"> float& endMinW, bool& endWS,
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderText.h (197518 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderText.h        2016-03-03 21:46:07 UTC (rev 197518)
+++ trunk/Source/WebCore/rendering/RenderText.h        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -102,7 +102,10 @@
</span><span class="cx"> bool& hasBreakableChar, bool& hasBreak,
</span><span class="cx"> float& beginMaxW, float& endMaxW,
</span><span class="cx"> float& minW, float& maxW, bool& stripFrontSpaces);
</span><del>- float hangablePunctuationStartWidth() const;
</del><ins>+ float hangablePunctuationStartWidth(unsigned index) const;
+ float hangablePunctuationEndWidth(unsigned index) const;
+ unsigned firstCharacterIndexStrippingSpaces() const;
+ unsigned lastCharacterIndexStrippingSpaces() const;
</ins><span class="cx">
</span><span class="cx"> WEBCORE_EXPORT virtual IntRect linesBoundingBox() const;
</span><span class="cx"> LayoutRect linesVisualOverflowBoundingBox() const;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderinglineBreakingContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/line/BreakingContext.h (197518 => 197519)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/line/BreakingContext.h        2016-03-03 21:46:07 UTC (rev 197518)
+++ trunk/Source/WebCore/rendering/line/BreakingContext.h        2016-03-03 21:49:32 UTC (rev 197519)
</span><span class="lines">@@ -738,7 +738,8 @@
</span><span class="cx"> bool isFixedPitch = font.isFixedPitch();
</span><span class="cx"> bool canHyphenate = style.hyphens() == HyphensAuto && WebCore::canHyphenate(style.locale());
</span><span class="cx"> bool canHangPunctuationAtStart = style.hangingPunctuation() & FirstHangingPunctuation;
</span><del>-
</del><ins>+ bool canHangPunctuationAtEnd = style.hangingPunctuation() & LastHangingPunctuation;
+ int endPunctuationIndex = canHangPunctuationAtEnd && m_collapseWhiteSpace ? renderText.lastCharacterIndexStrippingSpaces() : renderText.textLength() - 1;
</ins><span class="cx"> unsigned lastSpace = m_current.offset();
</span><span class="cx"> float wordSpacing = m_currentStyle->fontCascade().wordSpacing();
</span><span class="cx"> float lastSpaceWordSpacing = 0;
</span><span class="lines">@@ -788,9 +789,16 @@
</span><span class="cx"> UChar c = m_current.current();
</span><span class="cx"> m_currentCharacterIsSpace = c == ' ' || c == '\t' || (!m_preservesNewline && (c == '\n'));
</span><span class="cx">
</span><del>- if (canHangPunctuationAtStart && !m_current.offset() && m_width.isFirstLine() && !m_width.committedWidth() && !wrapW && !m_current.offset())
- m_width.addUncommittedWidth(-renderText.hangablePunctuationStartWidth());
-
</del><ins>+ if (canHangPunctuationAtStart && m_width.isFirstLine() && !m_width.committedWidth() && !wrapW && !inlineLogicalWidth(m_current.renderer(), true, false)) {
+ m_width.addUncommittedWidth(-renderText.hangablePunctuationStartWidth(m_current.offset()));
+ canHangPunctuationAtStart = false;
+ }
+
+ if (canHangPunctuationAtEnd && !m_nextObject && (int)m_current.offset() == endPunctuationIndex && !inlineLogicalWidth(m_current.renderer(), false, true)) {
+ m_width.addUncommittedWidth(-renderText.hangablePunctuationEndWidth(endPunctuationIndex));
+ canHangPunctuationAtStart = false;
+ }
+
</ins><span class="cx"> if (!m_collapseWhiteSpace || !m_currentCharacterIsSpace)
</span><span class="cx"> m_lineInfo.setEmpty(false, &m_block, &m_width);
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>