<!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>[179976] branches/safari-600.5-branch</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/179976">179976</a></dd>
<dt>Author</dt> <dd>lforschler@apple.com</dd>
<dt>Date</dt> <dd>2015-02-11 17:46:51 -0800 (Wed, 11 Feb 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/177377">r177377</a>. rdar://problem/19526158</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6005branchLayoutTestsChangeLog">branches/safari-600.5-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6005branchLayoutTestsfastrubyrubyjustificationexpectedhtml">branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html</a></li>
<li><a href="#branchessafari6005branchLayoutTestsfastrubyrubyjustificationhtml">branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html</a></li>
<li><a href="#branchessafari6005branchSourceWebCoreChangeLog">branches/safari-600.5-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingInlineBoxh">branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingInlineFlowBoxcpp">branches/safari-600.5-branch/Source/WebCore/rendering/InlineFlowBox.cpp</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingInlineTextBoxh">branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingRenderBlockFlowh">branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockFlow.h</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingRenderBlockLineLayoutcpp">branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingRenderRubyBasecpp">branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingRenderRubyBaseh">branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.h</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingRenderRubyRuncpp">branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.cpp</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingRenderTextcpp">branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.cpp</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingRenderTexth">branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6005branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/LayoutTests/ChangeLog (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/ChangeLog        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/LayoutTests/ChangeLog        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -1,5 +1,21 @@
</span><span class="cx"> 2015-02-11 Lucas Forschler <lforschler@apple.com>
</span><span class="cx">
</span><ins>+ Merge r177377
+
+ 2014-12-16 Myles C. Maxfield <litherum@gmail.com>
+
+ Ruby does not preserve expansion opportunities from enclosing context
+ https://bugs.webkit.org/show_bug.cgi?id=139618
+
+ Updating test for new expansion logic.
+
+ Reviewed by David Hyatt.
+
+ * fast/ruby/ruby-justification-expected.html:
+ * fast/ruby/ruby-justification.html:
+
+2015-02-11 Lucas Forschler <lforschler@apple.com>
+
</ins><span class="cx"> Merge r179706
</span><span class="cx">
</span><span class="cx"> 2015-02-05 Maciej Stachowiak <mjs@apple.com>
</span></span></pre></div>
<a id="branchessafari6005branchLayoutTestsfastrubyrubyjustificationexpectedhtml"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -9,7 +9,13 @@
</span><span class="cx"> <div>
</span><span class="cx"> abcdefg <ruby>abcdefg<rt><span style="color: transparent;">a</span></ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
</span><span class="cx"> </div>
</span><ins>+<div>
+abcdefg <ruby>a<rt><span style="color: transparent;">a</span></ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
</ins><span class="cx"> </div>
</span><ins>+<div>
+a<span style="background: green;">&#x685c;</span>b mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+</div>
</ins><span class="cx"> <div style="font-family: Ahem; font-size: 16px;">
</span><span class="cx"> <ruby>abcdefg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;abcdefg<rt>a</ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
</span><span class="cx"> </div>
</span></span></pre></div>
<a id="branchessafari6005branchLayoutTestsfastrubyrubyjustificationhtml"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -9,6 +9,12 @@
</span><span class="cx"> <div>
</span><span class="cx"> <ruby>abcdefg abcdefg<rt><span style="color: transparent;">a</span></ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
</span><span class="cx"> </div>
</span><ins>+<div>
+abcdefg <ruby>a<rt><span style="color: transparent;">aaaaaaaaaaaaaaaaaaaaaaa</span></ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+a<ruby><rb style="background: green;">&#x685c;</rb><rt> </ruby>b mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
</ins><span class="cx"> <div style="font-family: Ahem;">
</span><span class="cx"> <ruby>abcdefg abcdefg<rt>a</ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
</span><span class="cx"> </div>
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/ChangeLog (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/ChangeLog        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/ChangeLog        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -1,5 +1,66 @@
</span><span class="cx"> 2015-02-11 Lucas Forschler <lforschler@apple.com>
</span><span class="cx">
</span><ins>+ Merge r177377
+
+ 2014-12-16 Myles C. Maxfield <litherum@gmail.com>
+
+ Ruby does not preserve expansion opportunities from enclosing context
+ https://bugs.webkit.org/show_bug.cgi?id=139618
+
+ Reviewed by David Hyatt.
+
+ There is currently no sharing of expansion opportunity information between
+ ruby bases and the text surrounding the ruby. This patch adds a bit on
+ RenderText, m_contentIsKnownToFollow, which affects how expansion
+ opportunities are handled at paint-time, as well as a bit on RenderRubyBase,
+ m_isAfterExpansion, which affects how expansions are calculated when laying
+ out a line. This patch also adds a field to RenderRubyBase which represents
+ the base's starting position within a ruby. This field is necessary because
+ an expansion from a line might occur at the very beginning of a ruby base,
+ so we have to remember some state from expansion time to RenderRubyBase
+ layout time.
+
+ Added more tests to fast/ruby/ruby-justification.html.
+
+ * rendering/InlineBox.h:
+ (WebCore::InlineBox::setExpansionWithoutGrowing):
+ (WebCore::InlineBox::expansion):
+ * rendering/InlineFlowBox.cpp:
+ (WebCore::InlineFlowBox::removeChild): Keep the bit on InlineTextBox up to
+ date.
+ (WebCore::InlineFlowBox::placeBoxRangeInInlineDirection): Set expansion
+ information in InlineFlowBoxes so the total expansion for a whole line
+ is held in the RootInlineBox's expansion.
+ * rendering/InlineTextBox.h:
+ (WebCore::InlineTextBox::expansionBehavior):
+ * rendering/RenderBlockFlow.h:
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::RenderBlockFlow::updateRubyForJustifiedText):
+ updateRubyForJustifiedText() had a bunch of problems with it. First of all,
+ it didn't actually set the InlineBoxes as dirty, so the second layout pass
+ sometimes wouldn't perform any updates. Secondarily, it didn't take
+ overhangs into account. Thirdly, it didn't mark the ruby base and text as
+ needing layout so that subsequent layouts would actually traverse into them.
+ (WebCore::RenderBlockFlow::computeExpansionForJustifiedText):
+ (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment):
+ This nested if triangle is super nasty, but I'm not sure of a better way to
+ write it.
+ (WebCore::updateRubyForJustifiedText): Deleted.
+ (WebCore::computeExpansionForJustifiedText): Deleted.
+ * rendering/RenderRubyBase.cpp:
+ (WebCore::RenderRubyBase::RenderRubyBase):
+ (WebCore::RenderRubyBase::adjustInlineDirectionLineBounds):
+ * rendering/RenderRubyBase.h:
+ * rendering/RenderRubyRun.cpp:
+ (WebCore::RenderRubyRun::layout):
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::RenderText):
+ * rendering/RenderText.h:
+ (WebCore::RenderText::contentIsKnownToFollow):
+ (WebCore::RenderText::setContentIsKnownToFollow):
+
+2015-02-11 Lucas Forschler <lforschler@apple.com>
+
</ins><span class="cx"> Merge r179750
</span><span class="cx">
</span><span class="cx"> 2015-02-06 Maciej Stachowiak <mjs@apple.com>
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingInlineBoxh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -245,7 +245,7 @@
</span><span class="cx"> void invalidateParentChildList();
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- int expansion() const { return m_bitfields.expansion(); }
</del><ins>+ //int expansion() const { return m_bitfields.expansion(); }
</ins><span class="cx">
</span><span class="cx"> bool visibleToHitTesting() const { return renderer().style().visibility() == VISIBLE && renderer().style().pointerEvents() != PE_NONE; }
</span><span class="cx">
</span><span class="lines">@@ -279,6 +279,12 @@
</span><span class="cx"> m_bitfields.setExpansion(newExpansion);
</span><span class="cx"> m_logicalWidth += m_bitfields.expansion();
</span><span class="cx"> }
</span><ins>+ void setExpansionWithoutGrowing(float newExpansion)
+ {
+ ASSERT(!m_bitfields.expansion());
+ m_bitfields.setExpansion(newExpansion);
+ }
+ float expansion() const { return m_bitfields.expansion(); }
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> InlineBox* m_next; // The next element on the same line as us.
</span><span class="lines">@@ -416,7 +422,6 @@
</span><span class="cx"> void setHasHyphen(bool hasHyphen) { m_bitfields.setHasEllipsisBoxOrHyphen(hasHyphen); }
</span><span class="cx"> bool canHaveLeadingExpansion() const { return m_bitfields.hasSelectedChildrenOrCanHaveLeadingExpansion(); }
</span><span class="cx"> void setCanHaveLeadingExpansion(bool canHaveLeadingExpansion) { m_bitfields.setHasSelectedChildrenOrCanHaveLeadingExpansion(canHaveLeadingExpansion); }
</span><del>- int expansion() { return m_bitfields.expansion(); }
</del><span class="cx">
</span><span class="cx"> // For InlineFlowBox and InlineTextBox
</span><span class="cx"> bool extracted() const { return m_bitfields.extracted(); }
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingInlineFlowBoxcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/InlineFlowBox.cpp (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/InlineFlowBox.cpp        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/InlineFlowBox.cpp        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -179,6 +179,14 @@
</span><span class="cx"> if (!isDirty())
</span><span class="cx"> dirtyLineBoxes();
</span><span class="cx">
</span><ins>+ if (child->prevLeafChild() && child->prevLeafChild()->isInlineTextBox()) {
+ if (child->isInlineTextBox())
+ toInlineTextBox(child->prevLeafChild())->renderer().setContentIsKnownToFollow(toInlineTextBox(child)->renderer().contentIsKnownToFollow());
+ // FIXME: Handle the case where we remove the last inline box, and it's not a text box. If we're trying to share
+ // expansion opportunites both inside and outside a replaced element (such as for ruby bases), we need to search
+ // outside the current inline box tree to determine if there is content that follows the new last inline item.
+ }
+
</ins><span class="cx"> root().childRemoved(child);
</span><span class="cx">
</span><span class="cx"> if (child == m_firstChild)
</span><span class="lines">@@ -375,6 +383,7 @@
</span><span class="cx">
</span><span class="cx"> float InlineFlowBox::placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild, float& logicalLeft, float& minLogicalLeft, float& maxLogicalRight, bool& needsWordSpacing)
</span><span class="cx"> {
</span><ins>+ float totalExpansion = 0;
</ins><span class="cx"> for (InlineBox* curr = firstChild; curr && curr != lastChild; curr = curr->nextOnLine()) {
</span><span class="cx"> if (curr->renderer().isText()) {
</span><span class="cx"> InlineTextBox* text = toInlineTextBox(curr);
</span><span class="lines">@@ -388,6 +397,7 @@
</span><span class="cx"> if (knownToHaveNoOverflow())
</span><span class="cx"> minLogicalLeft = std::min(logicalLeft, minLogicalLeft);
</span><span class="cx"> logicalLeft += text->logicalWidth();
</span><ins>+ totalExpansion += text->expansion();
</ins><span class="cx"> if (knownToHaveNoOverflow())
</span><span class="cx"> maxLogicalRight = std::max(logicalLeft, maxLogicalRight);
</span><span class="cx"> } else {
</span><span class="lines">@@ -407,6 +417,7 @@
</span><span class="cx"> if (knownToHaveNoOverflow())
</span><span class="cx"> minLogicalLeft = std::min(logicalLeft, minLogicalLeft);
</span><span class="cx"> logicalLeft = flow->placeBoxesInInlineDirection(logicalLeft, needsWordSpacing);
</span><ins>+ totalExpansion += flow->expansion();
</ins><span class="cx"> if (knownToHaveNoOverflow())
</span><span class="cx"> maxLogicalRight = std::max(logicalLeft, maxLogicalRight);
</span><span class="cx"> logicalLeft += flow->marginLogicalRight();
</span><span class="lines">@@ -429,6 +440,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+ setExpansionWithoutGrowing(totalExpansion);
</ins><span class="cx"> return logicalLeft;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingInlineTextBoxh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -166,7 +166,7 @@
</span><span class="cx"> TextRun::ExpansionBehavior expansionBehavior() const
</span><span class="cx"> {
</span><span class="cx"> return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : TextRun::ForbidLeadingExpansion)
</span><del>- | (expansion() && nextLeafChild() && !nextLeafChild()->isLineBreak() ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion);
</del><ins>+ | (renderer().contentIsKnownToFollow() || (expansion() && nextLeafChild() && !nextLeafChild()->isLineBreak()) ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void behavesLikeText() const = delete;
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingRenderBlockFlowh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockFlow.h (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockFlow.h        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockFlow.h        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -552,6 +552,8 @@
</span><span class="cx"> RootInlineBox* constructLine(BidiRunList<BidiRun>&, const LineInfo&);
</span><span class="cx"> void setMarginsForRubyRun(BidiRun*, RenderRubyRun&, RenderObject*, const LineInfo&);
</span><span class="cx"> void computeInlineDirectionPositionsForLine(RootInlineBox*, const LineInfo&, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&, WordMeasurements&);
</span><ins>+ void updateRubyForJustifiedText(RenderRubyRun&, BidiRun&, const Vector<unsigned, 16>& expansionOpportunities, unsigned& expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth, RenderObject* previousObject, const LineInfo&, size_t& expansionIndex);
+ void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth, const LineInfo&);
</ins><span class="cx"> BidiRun* computeInlineDirectionPositionsForSegment(RootInlineBox*, const LineInfo&, ETextAlign, float& logicalLeft,
</span><span class="cx"> float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceRun, GlyphOverflowAndFallbackFontsMap& textBoxDataMap, VerticalPositionCache&, WordMeasurements&);
</span><span class="cx"> void computeBlockDirectionPositionsForLine(RootInlineBox*, BidiRun*, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&);
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingRenderBlockLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -540,7 +540,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline void updateRubyForJustifiedText(RenderRubyRun& rubyRun, BidiRun& r, const Vector<unsigned, 16>& expansionOpportunities, unsigned& expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth, size_t& i)
</del><ins>+void RenderBlockFlow::updateRubyForJustifiedText(RenderRubyRun& rubyRun, BidiRun& r, const Vector<unsigned, 16>& expansionOpportunities, unsigned& expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth, RenderObject* previousObject, const LineInfo& lineInfo, size_t& i)
</ins><span class="cx"> {
</span><span class="cx"> if (!rubyRun.rubyBase() || !rubyRun.rubyBase()->firstRootBox() || rubyRun.rubyBase()->firstRootBox()->nextRootBox() || !r.renderer().style().collapseWhiteSpace())
</span><span class="cx"> return;
</span><span class="lines">@@ -563,26 +563,47 @@
</span><span class="cx">
</span><span class="cx"> if (totalOpportunitiesInRun) {
</span><span class="cx"> ASSERT(!rubyRun.hasOverrideWidth());
</span><del>- rubyRun.setOverrideLogicalContentWidth(rubyRun.logicalWidth() + totalExpansion);
</del><ins>+ float newBaseWidth = rubyRun.logicalWidth() + totalExpansion + marginStartForChild(rubyRun) + marginEndForChild(rubyRun);
+ float newRubyRunWidth = rubyRun.logicalWidth() + totalExpansion;
+ rubyBase.setInitialOffset((newRubyRunWidth - newBaseWidth) / 2);
+ rubyRun.setOverrideLogicalContentWidth(newRubyRunWidth);
</ins><span class="cx"> rubyRun.setNeedsLayout(MarkOnlyThis);
</span><ins>+ rootBox.markDirty();
+ if (RenderRubyText* rubyText = rubyRun.rubyText()) {
+ if (RootInlineBox* textRootBox = rubyText->firstRootBox())
+ textRootBox->markDirty();
+ }
</ins><span class="cx"> rubyRun.layoutBlock(true);
</span><span class="cx"> rubyRun.clearOverrideLogicalContentWidth();
</span><del>- r.box()->setExpansion(totalExpansion);
</del><ins>+ setMarginsForRubyRun(&r, rubyRun, previousObject, lineInfo); // Expanding the base might mean there's less of a need for overhang
+ r.box()->setExpansion(newRubyRunWidth - r.box()->logicalWidth());
</ins><span class="cx">
</span><ins>+ // This relayout caused the size of the RenderRubyText and the RenderRubyBase to change, dependent on the line's current expansion. Next time we relayout the
+ // RenderRubyRun, make sure that we relayout the RenderRubyBase and RenderRubyText as well.
+ rubyBase.setNeedsLayout(MarkOnlyThis);
+ if (RenderRubyText* rubyText = rubyRun.rubyText())
+ rubyText->setNeedsLayout(MarkOnlyThis);
+ if (rubyBase.lastLeafChild() && rubyBase.lastLeafChild()->isText() && r.box() && r.box()->nextLeafChild() && !r.box()->nextLeafChild()->isLineBreak())
+ toRenderText(rubyBase.lastLeafChild())->setContentIsKnownToFollow(true);
+
</ins><span class="cx"> totalLogicalWidth += totalExpansion;
</span><span class="cx"> expansionOpportunityCount -= totalOpportunitiesInRun;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth)
</del><ins>+void RenderBlockFlow::computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth, const LineInfo& lineInfo)
</ins><span class="cx"> {
</span><span class="cx"> if (!expansionOpportunityCount || availableLogicalWidth <= totalLogicalWidth)
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ RenderObject* previousObject = nullptr;
+
</ins><span class="cx"> size_t i = 0;
</span><span class="cx"> for (BidiRun* r = firstRun; r; r = r->next()) {
</span><del>- if (!r->box() || r == trailingSpaceRun)
</del><ins>+ if (!r->box() || r == trailingSpaceRun) {
+ previousObject = &r->renderer();
</ins><span class="cx"> continue;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> if (r->renderer().isText()) {
</span><span class="cx"> unsigned opportunitiesInRun = expansionOpportunities[i++];
</span><span class="lines">@@ -598,8 +619,10 @@
</span><span class="cx"> }
</span><span class="cx"> expansionOpportunityCount -= opportunitiesInRun;
</span><span class="cx"> } else if (r->renderer().isRubyRun())
</span><del>- updateRubyForJustifiedText(toRenderRubyRun(r->renderer()), *r, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, i);
</del><ins>+ updateRubyForJustifiedText(toRenderRubyRun(r->renderer()), *r, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, previousObject, lineInfo, i);
</ins><span class="cx">
</span><ins>+ previousObject = &r->renderer();
+
</ins><span class="cx"> if (!expansionOpportunityCount)
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="lines">@@ -699,7 +722,7 @@
</span><span class="cx"> bool needsWordSpacing = false;
</span><span class="cx"> float totalLogicalWidth = lineBox->getFlowSpacingLogicalWidth();
</span><span class="cx"> unsigned expansionOpportunityCount = 0;
</span><del>- bool isAfterExpansion = true;
</del><ins>+ bool isAfterExpansion = this->isRubyBase() ? toRenderRubyBase(*this).isAfterExpansion() : true;
</ins><span class="cx"> Vector<unsigned, 16> expansionOpportunities;
</span><span class="cx"> RenderObject* previousObject = 0;
</span><span class="cx">
</span><span class="lines">@@ -735,6 +758,7 @@
</span><span class="cx"> if (r->renderer().isRubyRun() && textAlign == JUSTIFY && r != trailingSpaceRun && toRenderRubyRun(r->renderer()).rubyBase()) {
</span><span class="cx"> auto* rubyBase = toRenderRubyRun(r->renderer()).rubyBase();
</span><span class="cx"> if (rubyBase->firstRootBox() && !rubyBase->firstRootBox()->nextRootBox() && r->renderer().style().collapseWhiteSpace()) {
</span><ins>+ rubyBase->setIsAfterExpansion(isAfterExpansion);
</ins><span class="cx"> for (auto* leafChild = rubyBase->firstRootBox()->firstLeafChild(); leafChild; leafChild = leafChild->nextLeafChild()) {
</span><span class="cx"> if (!leafChild->isInlineTextBox())
</span><span class="cx"> continue;
</span><span class="lines">@@ -772,13 +796,28 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (isAfterExpansion && !expansionOpportunities.isEmpty()) {
</span><del>- expansionOpportunities.last()--;
- expansionOpportunityCount--;
</del><ins>+ bool shouldShareExpansionsWithContainingLine = true;
+ if (this->isRubyBase()) {
+ if (RenderRubyRun* rubyRun = toRenderRubyBase(*this).rubyRun()) {
+ if (RenderElement* rubyElement = rubyRun->parent()) {
+ if (rubyElement->style().display() == INLINE) {
+ if (RenderBlock* containingBlock = rubyElement->containingBlock()) {
+ if (containingBlock->style().textAlign() == JUSTIFY)
+ shouldShareExpansionsWithContainingLine = false;
+ }
+ }
+ }
+ }
+ }
+ if (shouldShareExpansionsWithContainingLine) {
+ expansionOpportunities.last()--;
+ expansionOpportunityCount--;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> updateLogicalWidthForAlignment(textAlign, lineBox, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth, expansionOpportunityCount);
</span><span class="cx">
</span><del>- computeExpansionForJustifiedText(firstRun, trailingSpaceRun, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth);
</del><ins>+ computeExpansionForJustifiedText(firstRun, trailingSpaceRun, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, lineInfo);
</ins><span class="cx">
</span><span class="cx"> return r;
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingRenderRubyBasecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx">
</span><span class="cx"> RenderRubyBase::RenderRubyBase(Document& document, PassRef<RenderStyle> style)
</span><span class="cx"> : RenderBlockFlow(document, WTF::move(style))
</span><ins>+ , m_initialOffset(0)
+ , m_isAfterExpansion(true)
</ins><span class="cx"> {
</span><span class="cx"> setInline(false);
</span><span class="cx"> }
</span><span class="lines">@@ -143,6 +145,12 @@
</span><span class="cx">
</span><span class="cx"> void RenderRubyBase::adjustInlineDirectionLineBounds(int expansionOpportunityCount, float& logicalLeft, float& logicalWidth) const
</span><span class="cx"> {
</span><ins>+ if (rubyRun()->hasOverrideWidth() && firstRootBox() && !firstRootBox()->nextRootBox()) {
+ logicalLeft += m_initialOffset;
+ logicalWidth -= 2 * m_initialOffset;
+ return;
+ }
+
</ins><span class="cx"> LayoutUnit maxPreferredLogicalWidth = rubyRun() && rubyRun()->hasOverrideWidth() ? rubyRun()->overrideLogicalContentWidth() : this->maxPreferredLogicalWidth();
</span><span class="cx"> if (maxPreferredLogicalWidth >= logicalWidth)
</span><span class="cx"> return;
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingRenderRubyBaseh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.h (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.h        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.h        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -50,6 +50,17 @@
</span><span class="cx">
</span><span class="cx"> virtual void cachePriorCharactersIfNeeded(const LazyLineBreakIterator&) override;
</span><span class="cx">
</span><ins>+ void setIsAfterExpansion(bool isAfterExpansion) { m_isAfterExpansion = isAfterExpansion; }
+ bool isAfterExpansion() { return m_isAfterExpansion; }
+
+ void setInitialOffset(float initialOffset) { m_initialOffset = initialOffset; }
+
+ void reset()
+ {
+ m_initialOffset = 0;
+ m_isAfterExpansion = true;
+ }
+
</ins><span class="cx"> private:
</span><span class="cx"> virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const;
</span><span class="cx"> virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const;
</span><span class="lines">@@ -62,6 +73,9 @@
</span><span class="cx">
</span><span class="cx"> // Allow RenderRubyRun to manipulate the children within ruby bases.
</span><span class="cx"> friend class RenderRubyRun;
</span><ins>+
+ float m_initialOffset;
+ unsigned m_isAfterExpansion : 1;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> RENDER_OBJECT_TYPE_CASTS(RenderRubyBase, isRubyBase())
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingRenderRubyRuncpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.cpp (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.cpp        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.cpp        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -233,6 +233,9 @@
</span><span class="cx">
</span><span class="cx"> void RenderRubyRun::layout()
</span><span class="cx"> {
</span><ins>+ if (RenderRubyBase* base = rubyBase())
+ base->reset();
+
</ins><span class="cx"> RenderBlockFlow::layout();
</span><span class="cx">
</span><span class="cx"> RenderRubyText* rt = rubyText();
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingRenderTextcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.cpp (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.cpp        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.cpp        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -163,6 +163,7 @@
</span><span class="cx"> , m_knownToHaveNoOverflowAndNoFallbackFonts(false)
</span><span class="cx"> , m_useBackslashAsYenSymbol(false)
</span><span class="cx"> , m_originalTextDiffersFromRendered(false)
</span><ins>+ , m_contentIsKnownToFollow(false)
</ins><span class="cx"> #if ENABLE(IOS_TEXT_AUTOSIZING)
</span><span class="cx"> , m_candidateComputedTextSize(0)
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingRenderTexth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.h (179975 => 179976)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.h        2015-02-12 01:25:20 UTC (rev 179975)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderText.h        2015-02-12 01:46:51 UTC (rev 179976)
</span><span class="lines">@@ -156,6 +156,9 @@
</span><span class="cx"> void deleteLineBoxesBeforeSimpleLineLayout();
</span><span class="cx"> const SimpleLineLayout::Layout* simpleLineLayout() const;
</span><span class="cx">
</span><ins>+ bool contentIsKnownToFollow() { return m_contentIsKnownToFollow; }
+ void setContentIsKnownToFollow(bool contentIsKnownToFollow) { m_contentIsKnownToFollow = contentIsKnownToFollow; }
+
</ins><span class="cx"> protected:
</span><span class="cx"> virtual void computePreferredLogicalWidths(float leadWidth);
</span><span class="cx"> virtual void willBeDestroyed() override;
</span><span class="lines">@@ -191,21 +194,22 @@
</span><span class="cx"> void node() const = delete;
</span><span class="cx">
</span><span class="cx"> // We put the bitfield first to minimize padding on 64-bit.
</span><del>- bool m_hasBreakableChar : 1; // Whether or not we can be broken into multiple lines.
- bool m_hasBreak : 1; // Whether or not we have a hard break (e.g., <pre> with '\n').
- bool m_hasTab : 1; // Whether or not we have a variable width tab character (e.g., <pre> with '\t').
- bool m_hasBeginWS : 1; // Whether or not we begin with WS (only true if we aren't pre)
- bool m_hasEndWS : 1; // Whether or not we end with WS (only true if we aren't pre)
- bool m_linesDirty : 1; // This bit indicates that the text run has already dirtied specific
</del><ins>+ unsigned m_hasBreakableChar : 1; // Whether or not we can be broken into multiple lines.
+ unsigned m_hasBreak : 1; // Whether or not we have a hard break (e.g., <pre> with '\n').
+ unsigned m_hasTab : 1; // Whether or not we have a variable width tab character (e.g., <pre> with '\t').
+ unsigned m_hasBeginWS : 1; // Whether or not we begin with WS (only true if we aren't pre)
+ unsigned m_hasEndWS : 1; // Whether or not we end with WS (only true if we aren't pre)
+ unsigned m_linesDirty : 1; // This bit indicates that the text run has already dirtied specific
</ins><span class="cx"> // line boxes, and this hint will enable layoutInlineChildren to avoid
</span><span class="cx"> // just dirtying everything when character data is modified (e.g., appended/inserted
</span><span class="cx"> // or removed).
</span><del>- bool m_containsReversedText : 1;
- bool m_isAllASCII : 1;
- bool m_canUseSimpleFontCodePath : 1;
- mutable bool m_knownToHaveNoOverflowAndNoFallbackFonts : 1;
- bool m_useBackslashAsYenSymbol : 1;
- bool m_originalTextDiffersFromRendered : 1;
</del><ins>+ unsigned m_containsReversedText : 1;
+ unsigned m_isAllASCII : 1;
+ unsigned m_canUseSimpleFontCodePath : 1;
+ mutable unsigned m_knownToHaveNoOverflowAndNoFallbackFonts : 1;
+ unsigned m_useBackslashAsYenSymbol : 1;
+ unsigned m_originalTextDiffersFromRendered : 1;
+ unsigned m_contentIsKnownToFollow : 1;
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(IOS_TEXT_AUTOSIZING)
</span><span class="cx"> // FIXME: This should probably be part of the text sizing structures in Document instead. That would save some memory.
</span></span></pre>
</div>
</div>
</body>
</html>