<!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>[213029] releases/WebKitGTK/webkit-2.16</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/213029">213029</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2017-02-26 23:43:27 -0800 (Sun, 26 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/212693">r212693</a> - Simple line layout: Implement absoluteQuadsForRange.
https://bugs.webkit.org/show_bug.cgi?id=168613
&lt;rdar://problem/30614618&gt;

Reviewed by Simon Fraser.

Source/WebCore:

This patch ensures that the commonly used Range::getClientRects calls do not
throw us off of the simple line layout path.

Test: fast/dom/Range/simple-line-layout-getclientrects.html

* rendering/RenderText.cpp:
(WebCore::RenderText::absoluteQuadsForRange):
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::collectAbsoluteQuadsForRange): Special case empty ranges with multiple empty runs.
* rendering/SimpleLineLayoutFunctions.h:
* rendering/SimpleLineLayoutResolver.cpp:
(WebCore::SimpleLineLayout::RunResolver::rangeForRendererWithOffsets):
* rendering/SimpleLineLayoutResolver.h:

LayoutTests:

* fast/dom/Range/simple-line-layout-getclientrects-expected.html: Added.
* fast/dom/Range/simple-line-layout-getclientrects.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit216LayoutTestsChangeLog">releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCoreChangeLog">releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCorerenderingRenderTextcpp">releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderText.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCorerenderingSimpleLineLayoutFunctionscpp">releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCorerenderingSimpleLineLayoutFunctionsh">releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutFunctions.h</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCorerenderingSimpleLineLayoutResolvercpp">releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp</a></li>
<li><a href="#releasesWebKitGTKwebkit216SourceWebCorerenderingSimpleLineLayoutResolverh">releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#releasesWebKitGTKwebkit216LayoutTestsfastdomRangesimplelinelayoutgetclientrectsexpectedhtml">releases/WebKitGTK/webkit-2.16/LayoutTests/fast/dom/Range/simple-line-layout-getclientrects-expected.html</a></li>
<li><a href="#releasesWebKitGTKwebkit216LayoutTestsfastdomRangesimplelinelayoutgetclientrectshtml">releases/WebKitGTK/webkit-2.16/LayoutTests/fast/dom/Range/simple-line-layout-getclientrects.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="releasesWebKitGTKwebkit216LayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog (213028 => 213029)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog        2017-02-27 07:43:14 UTC (rev 213028)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog        2017-02-27 07:43:27 UTC (rev 213029)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-02-20  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        Simple line layout: Implement absoluteQuadsForRange.
+        https://bugs.webkit.org/show_bug.cgi?id=168613
+        &lt;rdar://problem/30614618&gt;
+
+        Reviewed by Simon Fraser.
+
+        * fast/dom/Range/simple-line-layout-getclientrects-expected.html: Added.
+        * fast/dom/Range/simple-line-layout-getclientrects.html: Added.
+
</ins><span class="cx"> 2017-02-20  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed GTK+ gardening. Fix tests reporting missing results.
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216LayoutTestsfastdomRangesimplelinelayoutgetclientrectsexpectedhtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.16/LayoutTests/fast/dom/Range/simple-line-layout-getclientrects-expected.html (0 => 213029)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/LayoutTests/fast/dom/Range/simple-line-layout-getclientrects-expected.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/fast/dom/Range/simple-line-layout-getclientrects-expected.html        2017-02-27 07:43:27 UTC (rev 213029)
</span><span class="lines">@@ -0,0 +1,101 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that simple and normal line layout produce the same getClientRects result.&lt;/title&gt;
+&lt;style&gt;
+.rangeBox {
+    position:absolute;
+    outline: 5px solid green;
+}
+
+.box {
+    width: 400px;
+    line-height: 40px;
+}
+
+.outer {
+    outline: 2px solid green;
+}
+
+#test8 {
+    -webkit-transform: translate(50px, 100px) rotate(50deg);
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div class=&quot;box&quot; id=&quot;test1&quot;&gt;1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test2&quot;&gt;2 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test3&quot;&gt;3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test4&quot;&gt;4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do &lt;div class=&quot;outer&quot;&gt;eiusmod tempor&lt;/div&gt; incididunt ut labore etdolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test5&quot;&gt;5 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do &lt;div class=&quot;outer&quot;&gt;eiusmod tempor&lt;/div&gt; incididunt ut labore etdolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test6&quot;&gt;6 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test7&quot;&gt;7 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test8&quot;&gt;8 &lt;div&gt;Lorem ipsum dolor sit amet,&lt;/div&gt; consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test9&quot;&gt;9 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test10&quot;&gt;10 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;script&gt;
+    if (window.internals)
+        internals.settings.setSimpleLineLayoutEnabled(false);
+
+    function visualizeClientRects(range) {
+            var rects = range.getClientRects();
+        for (var i = 0; i &lt; rects.length; ++i) {
+                var rect = rects[i];
+                rangeBox = document.createElement('div');
+                rangeBox.className = &quot;rangeBox&quot;;
+                var style = &quot;&quot;;
+                style += &quot;left: &quot;   + rect.left + &quot;px;&quot;;
+                style += &quot;top: &quot;    + rect.top + &quot;px;&quot;;
+                style += &quot;width: &quot;  + (rect.right - rect.left) + &quot;px;&quot;;
+                style += &quot;height: &quot; + (rect.bottom - rect.top) + &quot;px;&quot;;
+                rangeBox.setAttribute(&quot;style&quot;, style);
+                document.documentElement.appendChild(rangeBox);
+        }
+    }
+
+    var range = document.createRange();
+    range.selectNode(document.getElementById('test1'));
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStart(document.getElementById('test2').firstChild, 10);
+    range.selectNodeContents(document.getElementById('test2'));
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStart(document.getElementById('test3').firstChild, 11);
+    range.setEnd(document.getElementById('test3').lastChild, 200);
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.selectNode(document.getElementById('test4'));
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.selectNodeContents(document.getElementById('test5'));
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStart(document.getElementById('test6').firstChild, 11);
+    range.setEnd(document.getElementById('test6').lastChild, 0);
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStart(document.getElementById('test7'), 0);
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStart(document.getElementById('test8').firstChild, 0);
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStartBefore(document.getElementById('test9'));
+    range.setEndAfter(document.getElementById('test9').firstChild);
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStartBefore(document.getElementById('test10'));
+    range.setEndBefore(document.getElementById('test10').firstChild);
+    visualizeClientRects(range);
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit216LayoutTestsfastdomRangesimplelinelayoutgetclientrectshtml"></a>
<div class="addfile"><h4>Added: releases/WebKitGTK/webkit-2.16/LayoutTests/fast/dom/Range/simple-line-layout-getclientrects.html (0 => 213029)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/LayoutTests/fast/dom/Range/simple-line-layout-getclientrects.html                                (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/fast/dom/Range/simple-line-layout-getclientrects.html        2017-02-27 07:43:27 UTC (rev 213029)
</span><span class="lines">@@ -0,0 +1,98 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;head&gt;
+&lt;title&gt;This tests that simple and normal line layout produce the same getClientRects result.&lt;/title&gt;
+&lt;style&gt;
+.rangeBox {
+    position:absolute;
+    outline: 5px solid green;
+}
+
+.box {
+    width: 400px;
+    line-height: 40px;
+}
+
+.outer {
+    outline: 2px solid green;
+}
+
+#test8 {
+    -webkit-transform: translate(50px, 100px) rotate(50deg);
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;div class=&quot;box&quot; id=&quot;test1&quot;&gt;1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test2&quot;&gt;2 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test3&quot;&gt;3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test4&quot;&gt;4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do &lt;div class=&quot;outer&quot;&gt;eiusmod tempor&lt;/div&gt; incididunt ut labore etdolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test5&quot;&gt;5 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do &lt;div class=&quot;outer&quot;&gt;eiusmod tempor&lt;/div&gt; incididunt ut labore etdolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test6&quot;&gt;6 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test7&quot;&gt;7 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test8&quot;&gt;8 &lt;div&gt;Lorem ipsum dolor sit amet,&lt;/div&gt; consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test9&quot;&gt;9 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;div class=&quot;box&quot; id=&quot;test10&quot;&gt;10 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&lt;/div&gt;
+&lt;script&gt;
+    function visualizeClientRects(range) {
+            var rects = range.getClientRects();
+        for (var i = 0; i &lt; rects.length; ++i) {
+                var rect = rects[i];
+                rangeBox = document.createElement('div');
+                rangeBox.className = &quot;rangeBox&quot;;
+                var style = &quot;&quot;;
+                style += &quot;left: &quot;   + rect.left + &quot;px;&quot;;
+                style += &quot;top: &quot;    + rect.top + &quot;px;&quot;;
+                style += &quot;width: &quot;  + (rect.right - rect.left) + &quot;px;&quot;;
+                style += &quot;height: &quot; + (rect.bottom - rect.top) + &quot;px;&quot;;
+                rangeBox.setAttribute(&quot;style&quot;, style);
+                document.documentElement.appendChild(rangeBox);
+        }
+    }
+
+    var range = document.createRange();
+    range.selectNode(document.getElementById('test1'));
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStart(document.getElementById('test2').firstChild, 10);
+    range.selectNodeContents(document.getElementById('test2'));
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStart(document.getElementById('test3').firstChild, 11);
+    range.setEnd(document.getElementById('test3').lastChild, 200);
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.selectNode(document.getElementById('test4'));
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.selectNodeContents(document.getElementById('test5'));
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStart(document.getElementById('test6').firstChild, 11);
+    range.setEnd(document.getElementById('test6').lastChild, 0);
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStart(document.getElementById('test7'), 0);
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStart(document.getElementById('test8').firstChild, 0);
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStartBefore(document.getElementById('test9'));
+    range.setEndAfter(document.getElementById('test9').firstChild);
+    visualizeClientRects(range);
+
+    range = document.createRange();
+    range.setStartBefore(document.getElementById('test10'));
+    range.setEndBefore(document.getElementById('test10').firstChild);
+    visualizeClientRects(range);
+&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog (213028 => 213029)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog        2017-02-27 07:43:14 UTC (rev 213028)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog        2017-02-27 07:43:27 UTC (rev 213029)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2017-02-20  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        Simple line layout: Implement absoluteQuadsForRange.
+        https://bugs.webkit.org/show_bug.cgi?id=168613
+        &lt;rdar://problem/30614618&gt;
+
+        Reviewed by Simon Fraser.
+
+        This patch ensures that the commonly used Range::getClientRects calls do not
+        throw us off of the simple line layout path.
+
+        Test: fast/dom/Range/simple-line-layout-getclientrects.html
+
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::absoluteQuadsForRange):
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::collectAbsoluteQuadsForRange): Special case empty ranges with multiple empty runs.
+        * rendering/SimpleLineLayoutFunctions.h:
+        * rendering/SimpleLineLayoutResolver.cpp:
+        (WebCore::SimpleLineLayout::RunResolver::rangeForRendererWithOffsets):
+        * rendering/SimpleLineLayoutResolver.h:
+
</ins><span class="cx"> 2017-02-20  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Nullptr dereferences when stopping a load
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCorerenderingRenderTextcpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderText.cpp (213028 => 213029)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderText.cpp        2017-02-27 07:43:14 UTC (rev 213028)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/RenderText.cpp        2017-02-27 07:43:27 UTC (rev 213029)
</span><span class="lines">@@ -422,18 +422,18 @@
</span><span class="cx"> 
</span><span class="cx"> Vector&lt;FloatQuad&gt; RenderText::absoluteQuadsForRange(unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const
</span><span class="cx"> {
</span><del>-    const_cast&lt;RenderText&amp;&gt;(*this).ensureLineBoxes();
-
</del><span class="cx">     // Work around signed/unsigned issues. This function takes unsigneds, and is often passed UINT_MAX
</span><del>-    // to mean &quot;all the way to the end&quot;. InlineTextBox coordinates are unsigneds, so changing this 
-    // function to take ints causes various internal mismatches. But selectionRect takes ints, and 
-    // passing UINT_MAX to it causes trouble. Ideally we'd change selectionRect to take unsigneds, but 
</del><ins>+    // to mean &quot;all the way to the end&quot;. InlineTextBox coordinates are unsigneds, so changing this
+    // function to take ints causes various internal mismatches. But selectionRect takes ints, and
+    // passing UINT_MAX to it causes trouble. Ideally we'd change selectionRect to take unsigneds, but
</ins><span class="cx">     // that would cause many ripple effects, so for now we'll just clamp our unsigned parameters to INT_MAX.
</span><span class="cx">     ASSERT(end == UINT_MAX || end &lt;= INT_MAX);
</span><span class="cx">     ASSERT(start &lt;= INT_MAX);
</span><span class="cx">     start = std::min(start, static_cast&lt;unsigned&gt;(INT_MAX));
</span><span class="cx">     end = std::min(end, static_cast&lt;unsigned&gt;(INT_MAX));
</span><del>-    
</del><ins>+    if (simpleLineLayout() &amp;&amp; !useSelectionHeight)
+        return collectAbsoluteQuadsForRange(*this, start, end, *simpleLineLayout(), wasFixed);
+    const_cast&lt;RenderText&amp;&gt;(*this).ensureLineBoxes();
</ins><span class="cx">     return m_lineBoxes.absoluteQuadsForRange(*this, start, end, useSelectionHeight, wasFixed);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCorerenderingSimpleLineLayoutFunctionscpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp (213028 => 213029)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp        2017-02-27 07:43:14 UTC (rev 213028)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp        2017-02-27 07:43:27 UTC (rev 213029)
</span><span class="lines">@@ -232,6 +232,37 @@
</span><span class="cx">     return run.start() + style.fontCascade().offsetForPosition(textRun, point.x() - run.logicalLeft(), true);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Vector&lt;FloatQuad&gt; collectAbsoluteQuadsForRange(const RenderObject&amp; renderer, unsigned start, unsigned end, const Layout&amp; layout, bool* wasFixed)
+{
+    auto&amp; style = downcast&lt;RenderBlockFlow&gt;(*renderer.parent()).style();
+    Vector&lt;FloatQuad&gt; quads;
+    auto resolver = runResolver(downcast&lt;RenderBlockFlow&gt;(*renderer.parent()), layout);
+    for (auto run : resolver.rangeForRendererWithOffsets(renderer, start, end)) {
+        // This run is fully contained.
+        if (start &lt;= run.start() &amp;&amp; end &gt;= run.end()) {
+            quads.append(renderer.localToAbsoluteQuad(FloatQuad(run.rect()), UseTransforms, wasFixed));
+            continue;
+        }
+        // Partially contained run.
+        TextRun textRun(run.text(), run.logicalLeft(), run.expansion(), run.expansionBehavior());
+        textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
+        LayoutRect runRect(run.rect());
+        // Special case empty ranges.
+        if (start == end) {
+            runRect.setWidth(0);
+            quads.append(renderer.localToAbsoluteQuad(FloatQuad(runRect), UseTransforms, wasFixed));
+            continue;
+        }
+        ASSERT(start &lt; run.end());
+        ASSERT(end &gt; run.start());
+        auto localStart = std::max(run.start(), start) - run.start();
+        auto localEnd = std::min(run.end(), end) - run.start();
+        style.fontCascade().adjustSelectionRectForText(textRun, runRect, localStart, localEnd);
+        quads.append(renderer.localToAbsoluteQuad(FloatQuad(runRect), UseTransforms, wasFixed));
+    }
+    return quads;
+}
+
</ins><span class="cx"> #if ENABLE(TREE_DEBUGGING)
</span><span class="cx"> static void printPrefix(int&amp; printedCharacters, int depth)
</span><span class="cx"> {
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCorerenderingSimpleLineLayoutFunctionsh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutFunctions.h (213028 => 213029)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutFunctions.h        2017-02-27 07:43:14 UTC (rev 213028)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutFunctions.h        2017-02-27 07:43:27 UTC (rev 213029)
</span><span class="lines">@@ -58,6 +58,7 @@
</span><span class="cx"> Vector&lt;IntRect&gt; collectAbsoluteRects(const RenderObject&amp;, const Layout&amp;, const LayoutPoint&amp; accumulatedOffset);
</span><span class="cx"> Vector&lt;FloatQuad&gt; collectAbsoluteQuads(const RenderObject&amp;, const Layout&amp;, bool* wasFixed);
</span><span class="cx"> unsigned textOffsetForPoint(const LayoutPoint&amp;, const RenderText&amp;, const Layout&amp;);
</span><ins>+Vector&lt;FloatQuad&gt; collectAbsoluteQuadsForRange(const RenderObject&amp;, unsigned start, unsigned end, const Layout&amp;, bool* wasFixed);
</ins><span class="cx"> 
</span><span class="cx"> LayoutUnit lineHeightFromFlow(const RenderBlockFlow&amp;);
</span><span class="cx"> LayoutUnit baselineFromFlow(const RenderBlockFlow&amp;);
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCorerenderingSimpleLineLayoutResolvercpp"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp (213028 => 213029)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp        2017-02-27 07:43:14 UTC (rev 213028)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.cpp        2017-02-27 07:43:27 UTC (rev 213029)
</span><span class="lines">@@ -219,6 +219,26 @@
</span><span class="cx">     return --it;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Range&lt;RunResolver::Iterator&gt; RunResolver::rangeForRendererWithOffsets(const RenderObject&amp; renderer, unsigned startOffset, unsigned endOffset) const
+{
+    ASSERT(startOffset &lt;= endOffset);
+    auto range = rangeForRenderer(renderer);
+    auto it = range.begin();
+    // Advance to the firt run with the start offset inside.
+    while (it != range.end() &amp;&amp; (*it).end() &lt;= startOffset)
+        ++it;
+    if (it == range.end())
+        return { end(), end() };
+    auto rangeBegin = it;
+    // Special case empty ranges that start at the edge of the run. Apparently normal line layout include those.
+    if (endOffset == startOffset &amp;&amp; (*it).start() == endOffset)
+        return { rangeBegin, ++it };
+    // Advance beyond the last run with the end offset.
+    while (it != range.end() &amp;&amp; (*it).start() &lt; endOffset)
+        ++it;
+    return { rangeBegin, it };
+}
+
</ins><span class="cx"> LineResolver::Iterator::Iterator(RunResolver::Iterator runIterator)
</span><span class="cx">     : m_runIterator(runIterator)
</span><span class="cx"> {
</span></span></pre></div>
<a id="releasesWebKitGTKwebkit216SourceWebCorerenderingSimpleLineLayoutResolverh"></a>
<div class="modfile"><h4>Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.h (213028 => 213029)</h4>
<pre class="diff"><span>
<span class="info">--- releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.h        2017-02-27 07:43:14 UTC (rev 213028)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/rendering/SimpleLineLayoutResolver.h        2017-02-27 07:43:27 UTC (rev 213029)
</span><span class="lines">@@ -116,6 +116,7 @@
</span><span class="cx">     Range&lt;Iterator&gt; rangeForRect(const LayoutRect&amp;) const;
</span><span class="cx">     Range&lt;Iterator&gt; rangeForRenderer(const RenderObject&amp;) const;
</span><span class="cx">     Iterator runForPoint(const LayoutPoint&amp;) const;
</span><ins>+    Range&lt;Iterator&gt; rangeForRendererWithOffsets(const RenderObject&amp;, unsigned start, unsigned end) const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     enum class IndexType { First, Last };
</span></span></pre>
</div>
</div>

</body>
</html>