<!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>[266123] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/266123">266123</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2020-08-25 09:32:24 -0700 (Tue, 25 Aug 2020)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/266028">r266028</a>): platform/ios/ios/fast/coordinates/range-client-rects.html
https://bugs.webkit.org/show_bug.cgi?id=215772

Reviewed by Anders Carlsson.

Source/WebCore:

* dom/Range.cpp:
(WebCore::Range::getClientRects const): Call updateLayout since it's not safe
to start working with the render tree without updating it first. Not required
to fix this bug, but an obvious omission. Ideally should make a test to show
this is needed.
(WebCore::Range::getBoundingClientRect const): Ditto.

* dom/SimpleRange.cpp:
(WebCore::order): Added.
(WebCore::documentOrder): Removed bogus special case. Test case proving this is
wrong is coming in the next documentOrder-related patch. Not needed to fix this
bug, but seems dangerous to leave this in the tree the way it was.
(WebCore::firstIntersectingNodeWithDeprecatedZeroOffsetStartQuirk): Added.
(WebCore::IntersectingNodeIterator::IntersectingNodeIterator): Added.

* dom/SimpleRange.h: Added intersectingNodesWithDeprecatedZeroOffsetStartQuirk.

* rendering/RenderObject.cpp:
(WebCore::borderAndTextRects): Use intersectingNodesWithDeprecatedZeroOffsetStartQuirk
because this needs to get the set of nodes in a way that works for our incorrectly
formed selection ranges and includes the first element even when the range technically
starts inside that element. We need to fix those, but that's a big project that affects
a lot of editing code. For now, restoring the old quirk is expedient.
(WebCore::RenderObject::collectSelectionRectsInternal): Ditto.

LayoutTests:

* platform/ios-wk2/TestExpectations: Removed failure expectation.

* platform/ios/ios/fast/coordinates/element-client-rects-expected.txt:
* platform/ios/ios/fast/coordinates/element-client-rects.html:
* platform/ios/ios/fast/coordinates/range-client-rects-expected.txt:
* platform/ios/ios/fast/coordinates/range-client-rects.html:
Changed tests so it's easier to read their results by putting rectangles and
rectangle lists into strings instead of comparing one value per line.

* platform/ios/ios/fast/coordinates/resources/helpers.js:
(rectString): Added.
(rectStrings): Added.
(setExpectedClientRectValues): Deleted.
(verifyClientRect): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformiosiosfastcoordinateselementclientrectsexpectedtxt">trunk/LayoutTests/platform/ios/ios/fast/coordinates/element-client-rects-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiosiosfastcoordinateselementclientrectshtml">trunk/LayoutTests/platform/ios/ios/fast/coordinates/element-client-rects.html</a></li>
<li><a href="#trunkLayoutTestsplatformiosiosfastcoordinatesrangeclientrectsexpectedtxt">trunk/LayoutTests/platform/ios/ios/fast/coordinates/range-client-rects-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformiosiosfastcoordinatesrangeclientrectshtml">trunk/LayoutTests/platform/ios/ios/fast/coordinates/range-client-rects.html</a></li>
<li><a href="#trunkLayoutTestsplatformiosiosfastcoordinatesresourceshelpersjs">trunk/LayoutTests/platform/ios/ios/fast/coordinates/resources/helpers.js</a></li>
<li><a href="#trunkLayoutTestsplatformioswk2TestExpectations">trunk/LayoutTests/platform/ios-wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomRangecpp">trunk/Source/WebCore/dom/Range.cpp</a></li>
<li><a href="#trunkSourceWebCoredomSimpleRangecpp">trunk/Source/WebCore/dom/SimpleRange.cpp</a></li>
<li><a href="#trunkSourceWebCoredomSimpleRangeh">trunk/Source/WebCore/dom/SimpleRange.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/LayoutTests/ChangeLog 2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2020-08-25  Darin Adler  <darin@apple.com>
+
+        REGRESSION (r266028): platform/ios/ios/fast/coordinates/range-client-rects.html
+        https://bugs.webkit.org/show_bug.cgi?id=215772
+
+        Reviewed by Anders Carlsson.
+
+        * platform/ios-wk2/TestExpectations: Removed failure expectation.
+
+        * platform/ios/ios/fast/coordinates/element-client-rects-expected.txt:
+        * platform/ios/ios/fast/coordinates/element-client-rects.html:
+        * platform/ios/ios/fast/coordinates/range-client-rects-expected.txt:
+        * platform/ios/ios/fast/coordinates/range-client-rects.html:
+        Changed tests so it's easier to read their results by putting rectangles and
+        rectangle lists into strings instead of comparing one value per line.
+
+        * platform/ios/ios/fast/coordinates/resources/helpers.js:
+        (rectString): Added.
+        (rectStrings): Added.
+        (setExpectedClientRectValues): Deleted.
+        (verifyClientRect): Deleted.
+
</ins><span class="cx"> 2020-08-25  Hector Lopez  <hector_i_lopez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [ macOS wk2 Debug ] http/tests/websocket/construct-in-detached-frame.html is a flaky crash
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiosiosfastcoordinateselementclientrectsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios/ios/fast/coordinates/element-client-rects-expected.txt (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios/ios/fast/coordinates/element-client-rects-expected.txt    2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/LayoutTests/platform/ios/ios/fast/coordinates/element-client-rects-expected.txt       2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -1,32 +1,14 @@
</span><span class="cx"> This tests Element.getBoundingClientRects and getClientRects positions when unscaled, scaled, and panned.
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span><ins>+
</ins><span class="cx"> unscaled
</span><del>-PASS clientRect.left is 100
-PASS clientRect.right is 200
-PASS clientRect.top is 100
-PASS clientRect.bottom is 200
-PASS clientRect.width is 100
-PASS clientRect.height is 100
-PASS clientRect.left is 100
-PASS clientRect.right is 200
-PASS clientRect.top is 100
-PASS clientRect.bottom is 200
-PASS clientRect.width is 100
-PASS clientRect.height is 100
</del><ins>+PASS rectString(document.getElementById('box').getBoundingClientRect()) is "(100,100 100x100)"
+PASS rectStrings(document.getElementById('box').getClientRects()) is "(100,100 100x100)"
</ins><span class="cx"> 
</span><span class="cx"> scaled and panned
</span><del>-PASS clientRect.left is 90
-PASS clientRect.right is 190
-PASS clientRect.top is 90
-PASS clientRect.bottom is 190
-PASS clientRect.width is 100
-PASS clientRect.height is 100
-PASS clientRect.left is 90
-PASS clientRect.right is 190
-PASS clientRect.top is 90
-PASS clientRect.bottom is 190
-PASS clientRect.width is 100
-PASS clientRect.height is 100
</del><ins>+PASS rectString(document.getElementById('box').getBoundingClientRect()) is "(90,90 100x100)"
+PASS rectStrings(document.getElementById('box').getClientRects()) is "(90,90 100x100)"
+
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiosiosfastcoordinateselementclientrectshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios/ios/fast/coordinates/element-client-rects.html (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios/ios/fast/coordinates/element-client-rects.html    2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/LayoutTests/platform/ios/ios/fast/coordinates/element-client-rects.html       2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -20,18 +20,20 @@
</span><span class="cx"> 
</span><span class="cx"> var box = document.getElementById('box');
</span><span class="cx"> 
</span><ins>+debug('');
</ins><span class="cx"> debug('unscaled');
</span><del>-setExpectedClientRectValues(100, 200, 100, 200, 100, 100);
-verifyClientRect(box.getBoundingClientRect());
-verifyClientRect(box.getClientRects()[0]);
</del><ins>+shouldBeEqualToString("rectString(document.getElementById('box').getBoundingClientRect())", "(100,100 100x100)");
+shouldBeEqualToString("rectStrings(document.getElementById('box').getClientRects())", "(100,100 100x100)");
</ins><span class="cx"> 
</span><span class="cx"> debug('');
</span><span class="cx"> debug('scaled and panned');
</span><span class="cx"> setInitialScaleAndPanBy(scale, panX, panY);
</span><del>-setExpectedClientRectValues(100-panX, 200-panX, 100-panY, 200-panY, 100, 100);
-verifyClientRect(box.getBoundingClientRect());
-verifyClientRect(box.getClientRects()[0]);
</del><ins>+var rect = "(" + (100-panX) + "," + (100-panY) + " 100x100)";
+shouldBeEqualToString("rectString(document.getElementById('box').getBoundingClientRect())", rect);
+shouldBeEqualToString("rectStrings(document.getElementById('box').getClientRects())", rect);
</ins><span class="cx"> 
</span><ins>+debug('');
+
</ins><span class="cx"> var successfullyParsed = true;
</span><span class="cx"> endTest();
</span><span class="cx"> </script>
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiosiosfastcoordinatesrangeclientrectsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios/ios/fast/coordinates/range-client-rects-expected.txt (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios/ios/fast/coordinates/range-client-rects-expected.txt      2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/LayoutTests/platform/ios/ios/fast/coordinates/range-client-rects-expected.txt 2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -1,45 +1,14 @@
</span><span class="cx"> This tests Range.getBoundingClientRects and getClientRects positions when unscaled, scaled, and panned.
</span><span class="cx"> On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
</span><del>-PASS range.getClientRects().length is 2
</del><ins>+
</ins><span class="cx"> unscaled
</span><del>-PASS clientRect.left is 0
-PASS clientRect.right is 1500
-PASS clientRect.top is 0
-PASS clientRect.bottom is 1500
-PASS clientRect.width is 1500
-PASS clientRect.height is 1500
-PASS clientRect.left is 0
-PASS clientRect.right is 1500
-PASS clientRect.top is 0
-PASS clientRect.bottom is 1500
-PASS clientRect.width is 1500
-PASS clientRect.height is 1500
-PASS clientRect.left is 100
-PASS clientRect.right is 200
-PASS clientRect.top is 100
-PASS clientRect.bottom is 200
-PASS clientRect.width is 100
-PASS clientRect.height is 100
</del><ins>+PASS rectString(getSelection().getRangeAt(0).getBoundingClientRect()) is "(0,0 1500x1500)"
+PASS rectStrings(getSelection().getRangeAt(0).getClientRects()) is "(100,100 100x100) (0,0 1500x1500)"
</ins><span class="cx"> 
</span><span class="cx"> scaled and panned
</span><del>-PASS clientRect.left is -10
-PASS clientRect.right is 1490
-PASS clientRect.top is -10
-PASS clientRect.bottom is 1490
-PASS clientRect.width is 1500
-PASS clientRect.height is 1500
-PASS clientRect.left is -10
-PASS clientRect.right is 1490
-PASS clientRect.top is -10
-PASS clientRect.bottom is 1490
-PASS clientRect.width is 1500
-PASS clientRect.height is 1500
-PASS clientRect.left is 90
-PASS clientRect.right is 190
-PASS clientRect.top is 90
-PASS clientRect.bottom is 190
-PASS clientRect.width is 100
-PASS clientRect.height is 100
</del><ins>+PASS rectString(getSelection().getRangeAt(0).getBoundingClientRect()) is "(-10,-10 1500x1500)"
+PASS rectStrings(getSelection().getRangeAt(0).getClientRects()) is "(90,90 100x100) (-10,-10 1500x1500)"
+
</ins><span class="cx"> PASS successfullyParsed is true
</span><span class="cx"> 
</span><span class="cx"> TEST COMPLETE
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiosiosfastcoordinatesrangeclientrectshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios/ios/fast/coordinates/range-client-rects.html (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios/ios/fast/coordinates/range-client-rects.html      2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/LayoutTests/platform/ios/ios/fast/coordinates/range-client-rects.html 2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -31,25 +31,22 @@
</span><span class="cx"> // positioned absolutely inside it. The first client rect of the
</span><span class="cx"> // Range is the box.
</span><span class="cx"> document.execCommand("SelectAll");
</span><del>-var range = window.getSelection().getRangeAt(0);
-shouldBe('range.getClientRects().length', '2');
</del><span class="cx"> 
</span><ins>+debug('');
</ins><span class="cx"> debug('unscaled');
</span><del>-setExpectedClientRectValues(0, 1500, 0, 1500, 1500, 1500);
-verifyClientRect(range.getBoundingClientRect());
-verifyClientRect(range.getClientRects()[1]);
-setExpectedClientRectValues(100, 200, 100, 200, 100, 100);
-verifyClientRect(range.getClientRects()[0]);
</del><ins>+shouldBeEqualToString("rectString(getSelection().getRangeAt(0).getBoundingClientRect())", "(0,0 1500x1500)");
+shouldBeEqualToString("rectStrings(getSelection().getRangeAt(0).getClientRects())", "(100,100 100x100) (0,0 1500x1500)");
</ins><span class="cx"> 
</span><span class="cx"> debug('');
</span><span class="cx"> debug('scaled and panned');
</span><span class="cx"> setInitialScaleAndPanBy(scale, panX, panY);
</span><del>-setExpectedClientRectValues(0-panX, 1500-panX, 0-panY, 1500-panY, 1500, 1500);
-verifyClientRect(range.getBoundingClientRect());
-verifyClientRect(range.getClientRects()[1]);
-setExpectedClientRectValues(100-panX, 200-panX, 100-panY, 200-panY, 100, 100);
-verifyClientRect(range.getClientRects()[0]);
</del><ins>+var firstRect = "(" + (0-panX) + "," + (0-panX) + " 1500x1500)";
+var secondRect = "(" + (100-panX) + "," + (100-panX) + " 100x100)";
+shouldBeEqualToString("rectString(getSelection().getRangeAt(0).getBoundingClientRect())", firstRect);
+shouldBeEqualToString("rectStrings(getSelection().getRangeAt(0).getClientRects())", secondRect + " " + firstRect);
</ins><span class="cx"> 
</span><ins>+debug('');
+
</ins><span class="cx"> setDisplayOnDescriptionAndConsole('block');
</span><span class="cx"> 
</span><span class="cx"> var successfullyParsed = true;
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiosiosfastcoordinatesresourceshelpersjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios/ios/fast/coordinates/resources/helpers.js (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios/ios/fast/coordinates/resources/helpers.js 2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/LayoutTests/platform/ios/ios/fast/coordinates/resources/helpers.js    2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -19,25 +19,21 @@
</span><span class="cx"> 
</span><span class="cx"> // To verify client rect positions.
</span><span class="cx"> 
</span><del>-var expectedLeft, expectedRight, expectedTop, expectedBottom, expectedWidth, expectedHeight;
-function setExpectedClientRectValues(left, right, top, bottom, width, height) {
-    expectedLeft = left;
-    expectedRight = right;
-    expectedTop = top;
-    expectedBottom = bottom;
-    expectedWidth = width;
-    expectedHeight = width;
</del><ins>+function rectString(rect)
+{
+    return "(" + rect.x + "," + rect.y + " " + rect.width + "x" + rect.height + ")";
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-var clientRect;
-function verifyClientRect(o) {
-    clientRect = o;
-    shouldBe('clientRect.left', expectedLeft.toString());
-    shouldBe('clientRect.right', expectedRight.toString());
-    shouldBe('clientRect.top', expectedTop.toString());
-    shouldBe('clientRect.bottom', expectedBottom.toString());
-    shouldBe('clientRect.width', expectedWidth.toString());
-    shouldBe('clientRect.height', expectedHeight.toString());
</del><ins>+function rectStrings(rectList)
+{
+    var text = "";
+    var i;
+    for (i = 0; i < rectList.length; i++) {
+        if (i != 0)
+            text += " ";
+        text += rectString(rectList[i]);
+    }
+    return text;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // To verify page scroll offsets.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformioswk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-wk2/TestExpectations      2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations 2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -1863,8 +1863,6 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/215773 http/tests/websocket/tests/hybi/client-close-2.html [ Pass Failure ]
</span><span class="cx"> 
</span><del>-webkit.org/b/215772 platform/ios/ios/fast/coordinates/range-client-rects.html [ Failure ]
-
</del><span class="cx"> webkit.org/b/215783 [ Debug ] imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/moving-between-documents/before-prepare-iframe-fetch-error-external-module.html [ Pass Failure ]
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/209461 imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-item-dynamic-min-contribution-001.html [ Failure ]
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/Source/WebCore/ChangeLog      2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2020-08-25  Darin Adler  <darin@apple.com>
+
+        REGRESSION (r266028): platform/ios/ios/fast/coordinates/range-client-rects.html
+        https://bugs.webkit.org/show_bug.cgi?id=215772
+
+        Reviewed by Anders Carlsson.
+
+        * dom/Range.cpp:
+        (WebCore::Range::getClientRects const): Call updateLayout since it's not safe
+        to start working with the render tree without updating it first. Not required
+        to fix this bug, but an obvious omission. Ideally should make a test to show
+        this is needed.
+        (WebCore::Range::getBoundingClientRect const): Ditto.
+
+        * dom/SimpleRange.cpp:
+        (WebCore::order): Added.
+        (WebCore::documentOrder): Removed bogus special case. Test case proving this is
+        wrong is coming in the next documentOrder-related patch. Not needed to fix this
+        bug, but seems dangerous to leave this in the tree the way it was.
+        (WebCore::firstIntersectingNodeWithDeprecatedZeroOffsetStartQuirk): Added.
+        (WebCore::IntersectingNodeIterator::IntersectingNodeIterator): Added.
+
+        * dom/SimpleRange.h: Added intersectingNodesWithDeprecatedZeroOffsetStartQuirk.
+
+        * rendering/RenderObject.cpp:
+        (WebCore::borderAndTextRects): Use intersectingNodesWithDeprecatedZeroOffsetStartQuirk
+        because this needs to get the set of nodes in a way that works for our incorrectly
+        formed selection ranges and includes the first element even when the range technically
+        starts inside that element. We need to fix those, but that's a big project that affects
+        a lot of editing code. For now, restoring the old quirk is expedient.
+        (WebCore::RenderObject::collectSelectionRectsInternal): Ditto.
+
</ins><span class="cx"> 2020-08-25  Eric Carlson  <eric.carlson@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [macOS] Update audio arbitration manager when audio transport changes
</span></span></pre></div>
<a id="trunkSourceWebCoredomRangecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Range.cpp (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Range.cpp       2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/Source/WebCore/dom/Range.cpp  2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -1358,11 +1358,13 @@
</span><span class="cx"> 
</span><span class="cx"> Ref<DOMRectList> Range::getClientRects() const
</span><span class="cx"> {
</span><ins>+    startContainer().document().updateLayout();
</ins><span class="cx">     return DOMRectList::create(RenderObject::clientBorderAndTextRects(makeSimpleRange(*this)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Ref<DOMRect> Range::getBoundingClientRect() const
</span><span class="cx"> {
</span><ins>+    startContainer().document().updateLayout();
</ins><span class="cx">     return DOMRect::create(unionRectIgnoringZeroRects(RenderObject::clientBorderAndTextRects(makeSimpleRange(*this))));
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomSimpleRangecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/SimpleRange.cpp (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/SimpleRange.cpp 2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/Source/WebCore/dom/SimpleRange.cpp    2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -81,13 +81,22 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // FIXME: Create BoundaryPoint.cpp and move this there.
</span><ins>+// FIXME: Once we move to C++20, replace with the C++20 <=> operator.
+// FIXME: This could return std::strong_ordering if we had that, or the equivalent.
+static PartialOrdering order(unsigned a, unsigned b)
+{
+    if (a < b)
+        return PartialOrdering::less;
+    if (a > b)
+        return PartialOrdering::greater;
+    return PartialOrdering::equivalent;
+}
+
+// FIXME: Create BoundaryPoint.cpp and move this there.
</ins><span class="cx"> PartialOrdering documentOrder(const BoundaryPoint& a, const BoundaryPoint& b)
</span><span class="cx"> {
</span><del>-    if (a.offset == b.offset)
-        return documentOrder(a.container, b.container);
-
</del><span class="cx">     if (a.container.ptr() == b.container.ptr())
</span><del>-        return a.offset < b.offset ? PartialOrdering::less : PartialOrdering::greater;
</del><ins>+        return order(a.offset, b.offset);
</ins><span class="cx"> 
</span><span class="cx">     for (auto ancestor = b.container.ptr(); ancestor; ) {
</span><span class="cx">         auto nextAncestor = ancestor->parentOrShadowHostNode();
</span><span class="lines">@@ -144,6 +153,17 @@
</span><span class="cx">     return NodeTraversal::nextSkippingChildren(range.end.container);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static RefPtr<Node> firstIntersectingNodeWithDeprecatedZeroOffsetStartQuirk(const SimpleRange& range)
+{
+    if (range.start.container->isCharacterDataNode())
+        return range.start.container.ptr();
+    if (auto child = range.start.container->traverseToChildAt(range.start.offset))
+        return child;
+    if (!range.start.offset)
+        return range.start.container.ptr();
+    return NodeTraversal::nextSkippingChildren(range.start.container);
+}
+
</ins><span class="cx"> IntersectingNodeIterator::IntersectingNodeIterator(const SimpleRange& range)
</span><span class="cx">     : m_node(firstIntersectingNode(range))
</span><span class="cx">     , m_pastLastNode(nodePastLastIntersectingNode(range))
</span><span class="lines">@@ -151,6 +171,13 @@
</span><span class="cx">     enforceEndInvariant();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+IntersectingNodeIterator::IntersectingNodeIterator(const SimpleRange& range, QuirkFlag)
+    : m_node(firstIntersectingNodeWithDeprecatedZeroOffsetStartQuirk(range))
+    , m_pastLastNode(nodePastLastIntersectingNode(range))
+{
+    enforceEndInvariant();
+}
+
</ins><span class="cx"> void IntersectingNodeIterator::advance()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_node);
</span></span></pre></div>
<a id="trunkSourceWebCoredomSimpleRangeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/SimpleRange.h (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/SimpleRange.h   2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/Source/WebCore/dom/SimpleRange.h      2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -68,6 +68,9 @@
</span><span class="cx"> class IntersectingNodeRange;
</span><span class="cx"> IntersectingNodeRange intersectingNodes(const SimpleRange&);
</span><span class="cx"> 
</span><ins>+class IntersectingNodeRangeWithQuirk;
+IntersectingNodeRangeWithQuirk intersectingNodesWithDeprecatedZeroOffsetStartQuirk(const SimpleRange&);
+
</ins><span class="cx"> struct OffsetRange {
</span><span class="cx">     unsigned start { 0 };
</span><span class="cx">     unsigned end { 0 };
</span><span class="lines">@@ -78,6 +81,9 @@
</span><span class="cx"> public:
</span><span class="cx">     IntersectingNodeIterator(const SimpleRange&);
</span><span class="cx"> 
</span><ins>+    enum QuirkFlag { DeprecatedZeroOffsetStartQuirk };
+    IntersectingNodeIterator(const SimpleRange&, QuirkFlag);
+
</ins><span class="cx">     Node& operator*() const { return *m_node; }
</span><span class="cx">     Node* operator->() const { ASSERT(m_node); return m_node.get(); }
</span><span class="cx"> 
</span><span class="lines">@@ -107,16 +113,37 @@
</span><span class="cx">     SimpleRange m_range;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class IntersectingNodeRangeWithQuirk {
+public:
+    IntersectingNodeRangeWithQuirk(const SimpleRange&);
+
+    IntersectingNodeIterator begin() const { return { m_range, IntersectingNodeIterator::DeprecatedZeroOffsetStartQuirk }; }
+    static constexpr std::nullptr_t end() { return nullptr; }
+
+private:
+    SimpleRange m_range;
+};
+
</ins><span class="cx"> inline IntersectingNodeRange::IntersectingNodeRange(const SimpleRange& range)
</span><span class="cx">     : m_range(range)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline IntersectingNodeRangeWithQuirk::IntersectingNodeRangeWithQuirk(const SimpleRange& range)
+    : m_range(range)
+{
+}
+
</ins><span class="cx"> inline IntersectingNodeRange intersectingNodes(const SimpleRange& range)
</span><span class="cx"> {
</span><span class="cx">     return { range };
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline IntersectingNodeRangeWithQuirk intersectingNodesWithDeprecatedZeroOffsetStartQuirk(const SimpleRange& range)
+{
+    return { range };
+}
+
</ins><span class="cx"> inline SimpleRange makeSimpleRangeHelper(BoundaryPoint&& start, BoundaryPoint&& end)
</span><span class="cx"> {
</span><span class="cx">     return { WTFMove(start), WTFMove(end) };
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (266122 => 266123)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp  2020-08-25 16:30:51 UTC (rev 266122)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp     2020-08-25 16:32:24 UTC (rev 266123)
</span><span class="lines">@@ -1980,7 +1980,7 @@
</span><span class="cx">     bool useVisibleBounds = behavior.contains(RenderObject::BoundingRectBehavior::UseVisibleBounds);
</span><span class="cx"> 
</span><span class="cx">     HashSet<Element*> selectedElementsSet;
</span><del>-    for (auto& node : intersectingNodes(range)) {
</del><ins>+    for (auto& node : intersectingNodesWithDeprecatedZeroOffsetStartQuirk(range)) {
</ins><span class="cx">         if (is<Element>(node))
</span><span class="cx">             selectedElementsSet.add(&downcast<Element>(node));
</span><span class="cx">     }
</span><span class="lines">@@ -1998,7 +1998,7 @@
</span><span class="cx">         RenderObject::VisibleRectContextOption::ApplyCompositedContainerScrolls
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    for (auto& node : intersectingNodes(range)) {
</del><ins>+    for (auto& node : intersectingNodesWithDeprecatedZeroOffsetStartQuirk(range)) {
</ins><span class="cx">         if (is<Element>(node) && selectedElementsSet.contains(&downcast<Element>(node)) && (useVisibleBounds || !node.parentElement() || !selectedElementsSet.contains(node.parentElement()))) {
</span><span class="cx">             if (auto renderer = downcast<Element>(node).renderBoxModelObject()) {
</span><span class="cx">                 if (useVisibleBounds) {
</span><span class="lines">@@ -2104,7 +2104,7 @@
</span><span class="cx">     Vector<SelectionRect> newRects;
</span><span class="cx">     bool hasFlippedWritingMode = range.start.container->renderer() && range.start.container->renderer()->style().isFlippedBlocksWritingMode();
</span><span class="cx">     bool containsDifferentWritingModes = false;
</span><del>-    for (auto& node : intersectingNodes(range)) {
</del><ins>+    for (auto& node : intersectingNodesWithDeprecatedZeroOffsetStartQuirk(range)) {
</ins><span class="cx">         auto renderer = node.renderer();
</span><span class="cx">         // Only ask leaf render objects for their line box rects.
</span><span class="cx">         if (renderer && !renderer->firstChildSlow() && renderer->style().userSelect() != UserSelect::None) {
</span></span></pre>
</div>
</div>

</body>
</html>