<!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>[179029] 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/179029">179029</a></dd>
<dt>Author</dt> <dd>dburkart@apple.com</dd>
<dt>Date</dt> <dd>2015-01-23 15:04:58 -0800 (Fri, 23 Jan 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/174489">r174489</a>. <rdar://problem/19452129></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6005branchLayoutTestsChangeLog">branches/safari-600.5-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6005branchSourceWebCoreChangeLog">branches/safari-600.5-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6005branchSourceWebCoreplatformgraphicsFonth">branches/safari-600.5-branch/Source/WebCore/platform/graphics/Font.h</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingInlineBoxh">branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingInlineTextBoxh">branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingRenderBlockLineLayoutcpp">branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingRenderBoxcpp">branches/safari-600.5-branch/Source/WebCore/rendering/RenderBox.cpp</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingRenderRubyBasecpp">branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp</a></li>
<li><a href="#branchessafari6005branchSourceWebCorerenderingRenderRubyRunh">branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari6005branchLayoutTestsfastrubyrubyjustificationexpectedhtml">branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html</a></li>
<li><a href="#branchessafari6005branchLayoutTestsfastrubyrubyjustificationhittestexpectedtxt">branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest-expected.txt</a></li>
<li><a href="#branchessafari6005branchLayoutTestsfastrubyrubyjustificationhittesthtml">branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest.html</a></li>
<li><a href="#branchessafari6005branchLayoutTestsfastrubyrubyjustificationhtml">branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html</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 (179028 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/ChangeLog        2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/LayoutTests/ChangeLog        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2015-01-23 Dana Burkart <dburkart@apple.com>
+
+ Merged r174489. <rdar://problem/19452129>
+
+ 2014-10-08 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Inline ruby does not get justified correctly
+ https://bugs.webkit.org/show_bug.cgi?id=137421
+
+ Reviewed by Dave Hyatt.
+
+ Test that ruby gets spaces inside the ruby base, and that hit testing the
+ ruby base gives us correct answers.
+
+ * fast/ruby/ruby-justification-expected.html: Added.
+ * fast/ruby/ruby-justification-hittest-expected.txt: Added.
+ * fast/ruby/ruby-justification-hittest.html: Added.
+ * fast/ruby/ruby-justification.html: Added.
+ * platform/mac/fast/ruby/bopomofo-rl-expected.txt: Ruby text gets the CSS
+ property text-align: justify, which worked prior to this patch. However, this
+ patch now justifies ruby bases, so now if there is text that is both a ruby
+ base and ruby text (such as ruby in ruby) it correctly gets justified. This
+ test does such, and therefore needs to be rebaselined.
+
</ins><span class="cx"> 2015-01-22 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r175264. rdar://problem/19451378
</span></span></pre></div>
<a id="branchessafari6005branchLayoutTestsfastrubyrubyjustificationexpectedhtmlfromrev174489trunkLayoutTestsfastrubyrubyjustificationexpectedhtml"></a>
<div class="copfile"><h4>Copied: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html (from rev 174489, trunk/LayoutTests/fast/ruby/ruby-justification-expected.html) (0 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html         (rev 0)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-expected.html        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+This test makes sure that ruby inside text-align: justify has its contents justified.
+<div style="text-align: justify; font-size: 16px;">
+<div>
+abcdefg abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+abcdefg abcdefg abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+abcdefg <ruby>abcdefg<rt><span style="color: transparent;">a</span></ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+</div>
+<div style="font-family: Ahem; font-size: 16px;">
+<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
+</div>
+<div style="text-align: right;">
+a
+</div>
+<div style="text-align: justify;">
+abcdefg abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
</ins></span></pre></div>
<a id="branchessafari6005branchLayoutTestsfastrubyrubyjustificationhittestexpectedtxtfromrev174489trunkLayoutTestsfastrubyrubyjustificationhittestexpectedtxt"></a>
<div class="copfile"><h4>Copied: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest-expected.txt (from rev 174489, trunk/LayoutTests/fast/ruby/ruby-justification-hittest-expected.txt) (0 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest-expected.txt         (rev 0)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest-expected.txt        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+This test makes sure that hit testing works with ruby inside text-align: justify.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS right is 792
+PASS document.elementFromPoint(right - 1, bottom - 1).id is "ruby"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+abcdefg abcdefga mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
</ins></span></pre></div>
<a id="branchessafari6005branchLayoutTestsfastrubyrubyjustificationhittesthtmlfromrev174489trunkLayoutTestsfastrubyrubyjustificationhittesthtml"></a>
<div class="copfile"><h4>Copied: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest.html (from rev 174489, trunk/LayoutTests/fast/ruby/ruby-justification-hittest.html) (0 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest.html         (rev 0)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification-hittest.html        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<div style="text-align: justify; font-family: Ahem;">
+<ruby id="ruby">abcdefg abcdefg<rt>a</ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<script>
+description("This test makes sure that hit testing works with ruby inside text-align: justify.");
+var ruby = document.getElementById("ruby");
+var boundingRect = ruby.getBoundingClientRect();
+var right = boundingRect.right;
+var bottom = boundingRect.bottom;
+shouldBe("right", "792");
+shouldBeEqualToString("document.elementFromPoint(right - 1, bottom - 1).id", "ruby");
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="branchessafari6005branchLayoutTestsfastrubyrubyjustificationhtmlfromrev174489trunkLayoutTestsfastrubyrubyjustificationhtml"></a>
<div class="copfile"><h4>Copied: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html (from rev 174489, trunk/LayoutTests/fast/ruby/ruby-justification.html) (0 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html         (rev 0)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-justification.html        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+This test makes sure that ruby inside text-align: justify has its contents justified.
+<div style="text-align: justify; font-size: 16px;">
+<div>
+<ruby>abcdefg abcdefg<rt> </ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+<ruby>abcdefg abcdefg<rt> </ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+<ruby>abcdefg abcdefg<rt><span style="color: transparent;">a</span></ruby> abcdefg mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div style="font-family: Ahem;">
+<ruby>abcdefg abcdefg<rt>a</ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+<div>
+<ruby>abcdefg abcdefg<rt style="text-align: right; font-size: 16px;">a</ruby> mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+</div>
+</div>
</ins></span></pre></div>
<a id="branchessafari6005branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/ChangeLog (179028 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/ChangeLog        2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/ChangeLog        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2015-01-23 Dana Burkart <dburkart@apple.com>
+
+ Merged r174489. <rdar://problem/19452129>
+
+ 2014-10-08 Myles C. Maxfield <litherum@gmail.com>
+
+ Inline ruby does not get justified correctly
+ https://bugs.webkit.org/show_bug.cgi?id=137421
+
+ Reviewed by Dave Hyatt.
+
+ We justify text in two passes: one counts expansion opportunities within a line,
+ and the other doles out widths and expansion amounts to constituent inline boxes.
+ This patch simply modifies both passes to descend into ruby bases. Once it has
+ done so, we then re-layout the ruby run with the newly found width.
+
+ Tests: fast/ruby/ruby-justification-hittest.html
+ fast/ruby/ruby-justification.html
+
+ * rendering/InlineBox.h:
+ (WebCore::InlineBox::setExpansion): updateRubyForJustifiedText() has to set the
+ expansion for an inline box, so make setExpansion() public.
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::updateRubyForJustifiedText): Given values that have already been
+ computed in computeInlineDirectionPositionsForSegment(), adjust the widths and
+ expansion values for all the various pieces of ruby.
+ (WebCore::computeExpansionForJustifiedText): Call updateRubyForJustifiedText() if
+ necessary.
+ (WebCore::RenderBlockFlow::computeInlineDirectionPositionsForSegment): When
+ counting expansion opportunities in a line, include ruby bases.
+ * rendering/RenderRubyRun.h: Fix grammar in comment.
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::stringView): Give default arguments to function.
+ * rendering/RenderText.h: Ditto.
+
</ins><span class="cx"> 2015-01-22 Dana Burkart <dburkart@apple.com>
</span><span class="cx">
</span><span class="cx"> Merged r178967. <rdar://problem/19572776>
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCoreplatformgraphicsFonth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/platform/graphics/Font.h (179028 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/platform/graphics/Font.h        2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/platform/graphics/Font.h        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -201,6 +201,9 @@
</span><span class="cx"> static bool isCJKIdeograph(UChar32);
</span><span class="cx"> static bool isCJKIdeographOrSymbol(UChar32);
</span><span class="cx">
</span><ins>+ // BEWARE: If isAfterExpansion is true after this function call, then the returned value includes a trailing opportunity
+ // which may or may not actually be present. RenderBlockFlow::computeInlineDirectionPositionsForSegment() compensates
+ // for this by decrementing the returned value if isAfterExpansion is true at the end of a line.
</ins><span class="cx"> static unsigned expansionOpportunityCount(const LChar*, size_t length, TextDirection, bool& isAfterExpansion);
</span><span class="cx"> static unsigned expansionOpportunityCount(const UChar*, size_t length, TextDirection, bool& isAfterExpansion);
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingInlineBoxh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h (179028 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h        2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -271,6 +271,13 @@
</span><span class="cx"> bool dirOverride() const { return m_bitfields.dirOverride(); }
</span><span class="cx"> void setDirOverride(bool dirOverride) { m_bitfields.setDirOverride(dirOverride); }
</span><span class="cx">
</span><ins>+ void setExpansion(float newExpansion)
+ {
+ m_logicalWidth -= m_bitfields.expansion();
+ m_bitfields.setExpansion(newExpansion);
+ m_logicalWidth += m_bitfields.expansion();
+ }
+
</ins><span class="cx"> private:
</span><span class="cx"> InlineBox* m_next; // The next element on the same line as us.
</span><span class="cx"> InlineBox* m_prev; // The previous element on the same line as us.
</span><span class="lines">@@ -408,7 +415,6 @@
</span><span class="cx"> bool canHaveLeadingExpansion() const { return m_bitfields.hasSelectedChildrenOrCanHaveLeadingExpansion(); }
</span><span class="cx"> void setCanHaveLeadingExpansion(bool canHaveLeadingExpansion) { m_bitfields.setHasSelectedChildrenOrCanHaveLeadingExpansion(canHaveLeadingExpansion); }
</span><span class="cx"> int expansion() { return m_bitfields.expansion(); }
</span><del>- void setExpansion(int expansion) { m_bitfields.setExpansion(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="branchessafari6005branchSourceWebCorerenderingInlineTextBoxh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h (179028 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h        2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/InlineTextBox.h        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -133,13 +133,6 @@
</span><span class="cx"> public:
</span><span class="cx"> virtual bool isLineBreak() const override final;
</span><span class="cx">
</span><del>- void setExpansion(int newExpansion)
- {
- m_logicalWidth -= expansion();
- InlineBox::setExpansion(newExpansion);
- m_logicalWidth += newExpansion;
- }
-
</del><span class="cx"> private:
</span><span class="cx"> virtual bool isInlineTextBox() const override final { return true; }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingRenderBlockLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp (179028 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx"> #include "RenderFlowThread.h"
</span><span class="cx"> #include "RenderLineBreak.h"
</span><span class="cx"> #include "RenderRegion.h"
</span><ins>+#include "RenderRubyBase.h"
+#include "RenderRubyText.h"
</ins><span class="cx"> #include "RenderView.h"
</span><span class="cx"> #include "SVGRootInlineBox.h"
</span><span class="cx"> #include "Settings.h"
</span><span class="lines">@@ -538,8 +540,42 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth)
</del><ins>+static inline void updateRubyForJustifiedText(RenderRubyRun& rubyRun, BidiRun& r, const Vector<unsigned, 16>& expansionOpportunities, unsigned& expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth, size_t& i)
</ins><span class="cx"> {
</span><ins>+ if (!rubyRun.rubyBase() || !rubyRun.rubyBase()->firstRootBox() || rubyRun.rubyBase()->firstRootBox()->nextRootBox() || !r.renderer().style().collapseWhiteSpace())
+ return;
+
+ auto& rubyBase = *rubyRun.rubyBase();
+ auto& rootBox = *rubyBase.firstRootBox();
+
+ float totalExpansion = 0;
+ unsigned totalOpportunitiesInRun = 0;
+ for (auto* leafChild = rootBox.firstLeafChild(); leafChild; leafChild = leafChild->nextLeafChild()) {
+ if (!leafChild->isInlineTextBox())
+ continue;
+
+ unsigned opportunitiesInRun = expansionOpportunities[i++];
+ ASSERT(opportunitiesInRun <= expansionOpportunityCount);
+ auto expansion = (availableLogicalWidth - totalLogicalWidth) * opportunitiesInRun / expansionOpportunityCount;
+ totalExpansion += expansion;
+ totalOpportunitiesInRun += opportunitiesInRun;
+ }
+
+ if (totalOpportunitiesInRun) {
+ ASSERT(!rubyRun.hasOverrideWidth());
+ rubyRun.setOverrideLogicalContentWidth(rubyRun.logicalWidth() + totalExpansion);
+ rubyRun.setNeedsLayout(MarkOnlyThis);
+ rubyRun.layoutBlock(true);
+ rubyRun.clearOverrideLogicalContentWidth();
+ r.box()->setExpansion(totalExpansion);
+
+ totalLogicalWidth += totalExpansion;
+ expansionOpportunityCount -= totalOpportunitiesInRun;
+ }
+}
+
+static inline void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth)
+{
</ins><span class="cx"> if (!expansionOpportunityCount || availableLogicalWidth <= totalLogicalWidth)
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="lines">@@ -561,9 +597,11 @@
</span><span class="cx"> totalLogicalWidth += expansion;
</span><span class="cx"> }
</span><span class="cx"> expansionOpportunityCount -= opportunitiesInRun;
</span><del>- if (!expansionOpportunityCount)
- break;
- }
</del><ins>+ } else if (r->renderer().isRubyRun())
+ updateRubyForJustifiedText(toRenderRubyRun(r->renderer()), *r, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth, i);
+
+ if (!expansionOpportunityCount)
+ break;
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -693,7 +731,33 @@
</span><span class="cx">
</span><span class="cx"> setLogicalWidthForTextRun(lineBox, r, &rt, totalLogicalWidth, lineInfo, textBoxDataMap, verticalPositionCache, wordMeasurements);
</span><span class="cx"> } else {
</span><del>- isAfterExpansion = false;
</del><ins>+ bool encounteredJustifiedRuby = false;
+ if (r->renderer().isRubyRun() && textAlign == JUSTIFY && r != trailingSpaceRun && toRenderRubyRun(r->renderer()).rubyBase()) {
+ auto* rubyBase = toRenderRubyRun(r->renderer()).rubyBase();
+ if (rubyBase->firstRootBox() && !rubyBase->firstRootBox()->nextRootBox() && r->renderer().style().collapseWhiteSpace()) {
+ for (auto* leafChild = rubyBase->firstRootBox()->firstLeafChild(); leafChild; leafChild = leafChild->nextLeafChild()) {
+ if (!leafChild->isInlineTextBox())
+ continue;
+ if (!isAfterExpansion)
+ toInlineTextBox(leafChild)->setCanHaveLeadingExpansion(true);
+ encounteredJustifiedRuby = true;
+ RenderText& renderText = toRenderText(leafChild->renderer());
+
+ unsigned opportunitiesInRun;
+ if (renderText.is8Bit())
+ opportunitiesInRun = Font::expansionOpportunityCount(renderText.characters8() + r->m_start, r->m_stop - r->m_start, r->box()->direction(), isAfterExpansion);
+ else
+ opportunitiesInRun = Font::expansionOpportunityCount(renderText.characters16() + r->m_start, r->m_stop - r->m_start, r->box()->direction(), isAfterExpansion);
+
+ expansionOpportunities.append(opportunitiesInRun);
+ expansionOpportunityCount += opportunitiesInRun;
+ }
+ }
+ }
+
+ if (!encounteredJustifiedRuby)
+ isAfterExpansion = false;
+
</ins><span class="cx"> if (!r->renderer().isRenderInline()) {
</span><span class="cx"> RenderBox& renderBox = toRenderBox(r->renderer());
</span><span class="cx"> if (renderBox.isRubyRun())
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingRenderBoxcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderBox.cpp (179028 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderBox.cpp        2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderBox.cpp        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -2283,7 +2283,7 @@
</span><span class="cx"> // width. Use the width from the style context.
</span><span class="cx"> // FIXME: Account for block-flow in flexible boxes.
</span><span class="cx"> // https://bugs.webkit.org/show_bug.cgi?id=46418
</span><del>- if (hasOverrideWidth() && (style().borderFit() == BorderFitLines || parent()->isFlexibleBoxIncludingDeprecated())) {
</del><ins>+ if (hasOverrideWidth() && (isRubyRun() || style().borderFit() == BorderFitLines || parent()->isFlexibleBoxIncludingDeprecated())) {
</ins><span class="cx"> computedValues.m_extent = overrideLogicalContentWidth() + borderAndPaddingLogicalWidth();
</span><span class="cx"> return;
</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 (179028 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp        2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -143,7 +143,7 @@
</span><span class="cx">
</span><span class="cx"> void RenderRubyBase::adjustInlineDirectionLineBounds(int expansionOpportunityCount, float& logicalLeft, float& logicalWidth) const
</span><span class="cx"> {
</span><del>- int maxPreferredLogicalWidth = this->maxPreferredLogicalWidth();
</del><ins>+ LayoutUnit maxPreferredLogicalWidth = rubyRun() && rubyRun()->hasOverrideWidth() ? rubyRun()->overrideLogicalContentWidth() : this->maxPreferredLogicalWidth();
</ins><span class="cx"> if (maxPreferredLogicalWidth >= logicalWidth)
</span><span class="cx"> return;
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari6005branchSourceWebCorerenderingRenderRubyRunh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.h (179028 => 179029)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.h        2015-01-23 23:03:28 UTC (rev 179028)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.h        2015-01-23 23:04:58 UTC (rev 179029)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> class RenderRubyBase;
</span><span class="cx"> class RenderRubyText;
</span><span class="cx">
</span><del>-// RenderRubyRun are 'inline-block/table' like objects,and wrap a single pairing of a ruby base with its ruby text(s).
</del><ins>+// RenderRubyRuns are 'inline-block/table' like objects, and wrap a single pairing of a ruby base with its ruby text(s).
</ins><span class="cx"> // See RenderRuby.h for further comments on the structure
</span><span class="cx">
</span><span class="cx"> class RenderRubyRun final : public RenderBlockFlow {
</span></span></pre>
</div>
</div>
</body>
</html>