<!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>[179071] branches/safari-600.1.4.15-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/179071">179071</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2015-01-24 12:16:36 -0800 (Sat, 24 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/176262">r176262</a>.  rdar://problem/19432679</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6001415branchLayoutTestsChangeLog">branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari6001415branchSourceWebCoreChangeLog">branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorerenderingRenderBlockcpp">branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorerenderingRenderBlockFlowcpp">branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorerenderingRenderRubyBaseh">branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyBase.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorerenderingRenderRubyTextcpp">branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorerenderingRenderRubyTexth">branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorerenderingRootInlineBoxcpp">branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RootInlineBox.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari6001415branchLayoutTestsfastrepaintselectionrubyrlexpectedtxt">branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl-expected.txt</a></li>
<li><a href="#branchessafari6001415branchLayoutTestsfastrepaintselectionrubyrlhtml">branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6001415branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog (179070 => 179071)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog        2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/LayoutTests/ChangeLog        2015-01-24 20:16:36 UTC (rev 179071)
</span><span class="lines">@@ -1,5 +1,21 @@
</span><span class="cx"> 2015-01-24  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r176262.
+
+    2014-11-17  David Hyatt  &lt;hyatt@apple.com&gt;
+
+        Improve Ruby selection (getting rid of overlap and improving gap filling)
+        https://bugs.webkit.org/show_bug.cgi?id=138250
+
+        Reviewed by Dean Jackson.
+
+        Added fast/repaint/selection-ruby-rl.html
+
+        * fast/repaint/selection-ruby-rl-expected.txt: Added.
+        * fast/repaint/selection-ruby-rl.html: Added.
+
+2015-01-24  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
</ins><span class="cx">         Merge r174860.
</span><span class="cx"> 
</span><span class="cx">     2014-10-18  Chris Fleizach  &lt;cfleizach@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6001415branchLayoutTestsfastrepaintselectionrubyrlexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl-expected.txt (0 => 179071)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl-expected.txt                                (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl-expected.txt        2015-01-24 20:16:36 UTC (rev 179071)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.Some ruby
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+Testing both hit testing and painting of selection.
+(repaint rects
+  (rect 774 39 18 83)
+)
+
</ins></span></pre></div>
<a id="branchessafari6001415branchLayoutTestsfastrepaintselectionrubyrlhtml"></a>
<div class="addfile"><h4>Added: branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl.html (0 => 179071)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl.html                                (rev 0)
+++ branches/safari-600.1.4.15-branch/LayoutTests/fast/repaint/selection-ruby-rl.html        2015-01-24 20:16:36 UTC (rev 179071)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;resources/text-based-repaint.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+function repaintTest() {
+    if (eventSender) {
+        eventSender.mouseMoveTo(790, 40);
+        eventSender.mouseDown();
+        eventSender.mouseMoveTo(790, 40);
+        eventSender.mouseMoveTo(790, 120);
+        eventSender.mouseUp();
+    }
+}
+&lt;/script&gt;
+
+&lt;/head&gt;
+&lt;body style=&quot;-webkit-writing-mode:vertical-rl&quot; onload=&quot;runRepaintTest()&quot;&gt;
+&lt;span&gt;Testing both hit testing&lt;/span&gt; and painting of selection.&lt;br&gt;
+Testing both hit testing and painting of selection.&lt;br&gt;
+&lt;ruby&gt;Testing both hit testing and painting of selection.&lt;rt&gt;Some ruby&lt;/rt&gt;&lt;/ruby&gt;&lt;br&gt;
+Testing both hit testing and painting of selection.&lt;br&gt;
+Testing both hit testing and painting of selection.&lt;br&gt;
+Testing both hit testing and painting of selection.&lt;br&gt;
+Testing both hit testing and painting of selection.&lt;br&gt;
+Testing both hit testing and painting of selection.&lt;br&gt;
+Testing both hit testing and painting of selection.&lt;br&gt;
+Testing both hit testing and painting of selection.&lt;br&gt;
+&lt;/body&gt;
</ins></span></pre></div>
<a id="branchessafari6001415branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog (179070 => 179071)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog        2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog        2015-01-24 20:16:36 UTC (rev 179071)
</span><span class="lines">@@ -1,5 +1,40 @@
</span><span class="cx"> 2015-01-24  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r176262.
+
+    2014-11-17  David Hyatt  &lt;hyatt@apple.com&gt;
+
+        Improve Ruby selection (getting rid of overlap and improving gap filling)
+        https://bugs.webkit.org/show_bug.cgi?id=138250
+
+        Reviewed by Dean Jackson.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::selectionGaps):
+        (WebCore::RenderBlock::blockSelectionGaps):
+        Add Ruby text in along with the Ruby base.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::inlineSelectionGaps):
+        Don't let block gaps get filled in here.
+
+        * rendering/RenderRubyBase.h:
+        Expose accessor to the ruby run.
+
+        * rendering/RenderRubyText.cpp:
+        (WebCore::RenderRubyText::rubyRun):
+        * rendering/RenderRubyText.h:
+        Add accessor to the ruby run.
+
+        * rendering/RootInlineBox.cpp:
+        (WebCore::RootInlineBox::selectionTop):
+        (WebCore::RootInlineBox::selectionBottom):
+        Improve selectionTop and selectionBottom of ruby bases to avoid the
+        ruby text. Improve the selectionTop and selectionBottom of ruby texts
+        to fill the gap up to the previous/next line as appropriate.
+
+2015-01-24  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
</ins><span class="cx">         Merge r175260.
</span><span class="cx"> 
</span><span class="cx">     2014-10-28  David Hyatt  &lt;hyatt@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlock.cpp (179070 => 179071)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlock.cpp        2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlock.cpp        2015-01-24 20:16:36 UTC (rev 179071)
</span><span class="lines">@@ -1965,7 +1965,7 @@
</span><span class="cx">         result = blockSelectionGaps(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, cache, paintInfo);
</span><span class="cx"> 
</span><span class="cx">     // Go ahead and fill the vertical gap all the way to the bottom of our block if the selection extends past our block.
</span><del>-    if (&amp;rootBlock == this &amp;&amp; (selectionState() != SelectionBoth &amp;&amp; selectionState() != SelectionEnd) &amp;&amp; !isRubyBase()) {
</del><ins>+    if (&amp;rootBlock == this &amp;&amp; (selectionState() != SelectionBoth &amp;&amp; selectionState() != SelectionEnd) &amp;&amp; !isRubyBase() &amp;&amp; !isRubyText()) {
</ins><span class="cx">         result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock,
</span><span class="cx">             lastLogicalTop, lastLogicalLeft, lastLogicalRight, logicalHeight(), cache, paintInfo));
</span><span class="cx">     }
</span><span class="lines">@@ -2010,7 +2010,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         bool paintsOwnSelection = curr-&gt;shouldPaintSelectionGaps() || curr-&gt;isTable(); // FIXME: Eventually we won't special-case table like this.
</span><del>-        bool fillBlockGaps = !isRubyBase() &amp;&amp; (paintsOwnSelection || (curr-&gt;canBeSelectionLeaf() &amp;&amp; childState != SelectionNone));
</del><ins>+        bool fillBlockGaps = (paintsOwnSelection || (curr-&gt;canBeSelectionLeaf() &amp;&amp; childState != SelectionNone)) &amp;&amp; !isRubyBase() &amp;&amp; !isRubyText();
</ins><span class="cx">         if (fillBlockGaps) {
</span><span class="cx">             // We need to fill the vertical gap above this object.
</span><span class="cx">             if (childState == SelectionEnd || childState == SelectionInside) {
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlockFlow.cpp (179070 => 179071)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlockFlow.cpp        2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderBlockFlow.cpp        2015-01-24 20:16:36 UTC (rev 179071)
</span><span class="lines">@@ -3003,7 +3003,7 @@
</span><span class="cx">         LayoutUnit selHeight = curr-&gt;selectionHeightAdjustedForPrecedingBlock();
</span><span class="cx"> 
</span><span class="cx">         if (!containsStart &amp;&amp; !lastSelectedLine &amp;&amp;
</span><del>-            selectionState() != SelectionStart &amp;&amp; selectionState() != SelectionBoth)
</del><ins>+            selectionState() != SelectionStart &amp;&amp; selectionState() != SelectionBoth &amp;&amp; !isRubyBase())
</ins><span class="cx">             result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, selTop, cache, paintInfo));
</span><span class="cx">         
</span><span class="cx">         LayoutRect logicalRect(curr-&gt;logicalLeft(), selTop, curr-&gt;logicalWidth(), selTop + selHeight);
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorerenderingRenderRubyBaseh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyBase.h (179070 => 179071)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyBase.h        2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyBase.h        2015-01-24 20:16:36 UTC (rev 179071)
</span><span class="lines">@@ -46,6 +46,8 @@
</span><span class="cx"> 
</span><span class="cx">     virtual bool isRubyBase() const { return true; }
</span><span class="cx"> 
</span><ins>+    RenderRubyRun* rubyRun() const;
+
</ins><span class="cx"> private:
</span><span class="cx">     virtual bool isChildAllowed(const RenderObject&amp;, const RenderStyle&amp;) const;
</span><span class="cx">     virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const;
</span><span class="lines">@@ -56,12 +58,12 @@
</span><span class="cx">     void moveInlineChildren(RenderRubyBase* toBase, RenderObject* beforeChild = 0);
</span><span class="cx">     void moveBlockChildren(RenderRubyBase* toBase, RenderObject* beforeChild = 0);
</span><span class="cx"> 
</span><del>-    RenderRubyRun* rubyRun() const;
-
</del><span class="cx">     // Allow RenderRubyRun to manipulate the children within ruby bases.
</span><span class="cx">     friend class RenderRubyRun;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+RENDER_OBJECT_TYPE_CASTS(RenderRubyBase, isRubyBase())
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // RenderRubyBase_h
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorerenderingRenderRubyTextcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.cpp (179070 => 179071)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.cpp        2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.cpp        2015-01-24 20:16:36 UTC (rev 179071)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;RenderRubyText.h&quot;
</span><ins>+#include &quot;RenderRubyRun.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -44,6 +45,12 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RenderRubyRun* RenderRubyText::rubyRun() const
+{
+    ASSERT(parent());
+    return toRenderRubyRun(parent());
+}
+
</ins><span class="cx"> bool RenderRubyText::isChildAllowed(const RenderObject&amp; child, const RenderStyle&amp;) const
</span><span class="cx"> {
</span><span class="cx">     return child.isInline();
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorerenderingRenderRubyTexth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.h (179070 => 179071)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.h        2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderRubyText.h        2015-01-24 20:16:36 UTC (rev 179071)
</span><span class="lines">@@ -43,6 +43,8 @@
</span><span class="cx">     Element&amp; element() const { return toElement(nodeForNonAnonymous()); }
</span><span class="cx"> 
</span><span class="cx">     virtual bool isChildAllowed(const RenderObject&amp;, const RenderStyle&amp;) const override;
</span><ins>+    
+    RenderRubyRun* rubyRun() const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     virtual const char* renderName() const override { return &quot;RenderRubyText&quot;; }
</span><span class="lines">@@ -54,6 +56,8 @@
</span><span class="cx">     virtual void adjustInlineDirectionLineBounds(int expansionOpportunityCount, float&amp; logicalLeft, float&amp; logicalWidth) const override;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+RENDER_OBJECT_TYPE_CASTS(RenderRubyText, isRubyText())
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // RenderRubyText_h
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorerenderingRootInlineBoxcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RootInlineBox.cpp (179070 => 179071)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RootInlineBox.cpp        2015-01-24 20:16:32 UTC (rev 179070)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RootInlineBox.cpp        2015-01-24 20:16:36 UTC (rev 179071)
</span><span class="lines">@@ -33,6 +33,9 @@
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;PaintInfo.h&quot;
</span><span class="cx"> #include &quot;RenderFlowThread.h&quot;
</span><ins>+#include &quot;RenderRubyBase.h&quot;
+#include &quot;RenderRubyRun.h&quot;
+#include &quot;RenderRubyText.h&quot;
</ins><span class="cx"> #include &quot;RenderView.h&quot;
</span><span class="cx"> #include &quot;VerticalPositionCache.h&quot;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="lines">@@ -596,13 +599,41 @@
</span><span class="cx"> LayoutUnit RootInlineBox::selectionTop() const
</span><span class="cx"> {
</span><span class="cx">     LayoutUnit selectionTop = m_lineTop;
</span><del>-
</del><ins>+    
</ins><span class="cx">     if (m_hasAnnotationsBefore)
</span><span class="cx">         selectionTop -= !renderer().style().isFlippedLinesWritingMode() ? computeOverAnnotationAdjustment(m_lineTop) : computeUnderAnnotationAdjustment(m_lineTop);
</span><span class="cx"> 
</span><span class="cx">     if (renderer().style().isFlippedLinesWritingMode())
</span><span class="cx">         return selectionTop;
</span><span class="cx"> 
</span><ins>+    if (renderer().isRubyBase()) {
+        // The ruby base selection should avoid intruding into the ruby text. This is only the case if there is an actual ruby text above us.
+        RenderRubyBase* base = &amp;toRenderRubyBase(renderer());
+        RenderRubyRun* run = base-&gt;rubyRun();
+        if (run) {
+            RenderRubyText* text = run-&gt;rubyText();
+            if (text &amp;&amp; text-&gt;logicalTop() &lt; base-&gt;logicalTop()) {
+                // The ruby text is above the ruby base. Just return now in order to avoid painting on top of the ruby text.
+                return selectionTop;
+            }
+        }
+    } else if (renderer().isRubyText()) {
+        // The ruby text selection should go all the way to the selection top of the containing line.
+        RenderRubyText* text = &amp;toRenderRubyText(renderer());
+        RenderRubyRun* run = text-&gt;rubyRun();
+        if (run &amp;&amp; run-&gt;inlineBoxWrapper()) {
+            RenderRubyBase* base = run-&gt;rubyBase();
+            if (base &amp;&amp; text-&gt;logicalTop() &lt; base-&gt;logicalTop()) {
+                // The ruby text is above the ruby base.
+                const RootInlineBox&amp; containingLine = run-&gt;inlineBoxWrapper()-&gt;root();
+                LayoutUnit enclosingSelectionTop = containingLine.selectionTop();
+                LayoutUnit deltaBetweenObjects = text-&gt;logicalTop() + run-&gt;logicalTop();
+                LayoutUnit selectionTopInRubyTextCoords = enclosingSelectionTop - deltaBetweenObjects;
+                return std::min(selectionTop, selectionTopInRubyTextCoords);
+            }
+        }
+    }
+
</ins><span class="cx">     LayoutUnit prevBottom = prevRootBox() ? prevRootBox()-&gt;selectionBottom() : blockFlow().borderAndPaddingBefore();
</span><span class="cx">     if (prevBottom &lt; selectionTop &amp;&amp; blockFlow().containsFloats()) {
</span><span class="cx">         // This line has actually been moved further down, probably from a large line-height, but possibly because the
</span><span class="lines">@@ -651,9 +682,37 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_hasAnnotationsAfter)
</span><span class="cx">         selectionBottom += !renderer().style().isFlippedLinesWritingMode() ? computeUnderAnnotationAdjustment(m_lineBottom) : computeOverAnnotationAdjustment(m_lineBottom);
</span><del>-
</del><ins>+    
</ins><span class="cx">     if (!renderer().style().isFlippedLinesWritingMode() || !nextRootBox())
</span><span class="cx">         return selectionBottom;
</span><ins>+    
+    if (renderer().isRubyBase()) {
+        // The ruby base selection should avoid intruding into the ruby text. This is only the case if there is an actual ruby text below us.
+        RenderRubyBase* base = &amp;toRenderRubyBase(renderer());
+        RenderRubyRun* run = base-&gt;rubyRun();
+        if (run) {
+            RenderRubyText* text = run-&gt;rubyText();
+            if (text &amp;&amp; text-&gt;logicalTop() &gt; base-&gt;logicalTop()) {
+                // The ruby text is below the ruby base. Just return now in order to avoid painting on top of the ruby text.
+                return selectionBottom;
+            }
+        }
+    } else if (renderer().isRubyText()) {
+        // The ruby text selection should go all the way to the selection bottom of the containing line.
+        RenderRubyText* text = &amp;toRenderRubyText(renderer());
+        RenderRubyRun* run = text-&gt;rubyRun();
+        if (run &amp;&amp; run-&gt;inlineBoxWrapper()) {
+            RenderRubyBase* base = run-&gt;rubyBase();
+            if (base &amp;&amp; text-&gt;logicalTop() &gt; base-&gt;logicalTop()) {
+                // The ruby text is above the ruby base.
+                const RootInlineBox&amp; containingLine = run-&gt;inlineBoxWrapper()-&gt;root();
+                LayoutUnit enclosingSelectionBottom = containingLine.selectionBottom();
+                LayoutUnit deltaBetweenObjects = text-&gt;logicalTop() + run-&gt;logicalTop();
+                LayoutUnit selectionBottomInRubyTextCoords = enclosingSelectionBottom - deltaBetweenObjects;
+                return std::min(selectionBottom, selectionBottomInRubyTextCoords);
+            }
+        }
+    }
</ins><span class="cx"> 
</span><span class="cx">     LayoutUnit nextTop = nextRootBox()-&gt;selectionTop();
</span><span class="cx">     if (nextTop &gt; selectionBottom &amp;&amp; blockFlow().containsFloats()) {
</span></span></pre>
</div>
</div>

</body>
</html>