Revert "Release assert in Document::updateLayout() via HTMLTextAreaElement::childrenChanged"

This reverts commit 0a91c415adf4e01ff05b2e98934802790e57f276.

Unreviewed revert

Canonical link: https://commits.webkit.org/250803@main


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@294550 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/accessibility/mac/selection-boundary-userinfo.html b/LayoutTests/accessibility/mac/selection-boundary-userinfo.html
index d88f538..8bd9195 100644
--- a/LayoutTests/accessibility/mac/selection-boundary-userinfo.html
+++ b/LayoutTests/accessibility/mac/selection-boundary-userinfo.html
@@ -162,31 +162,20 @@
         var addedNotification = webArea.addNotificationListener(notificationCallback);
         shouldBe("addedNotification", "true");
 
-        function waitForAnimationFrame() {
-            return new Promise(function(resolve, reject) {
-                requestAnimationFrame(resolve);
-            });
-        }
+        textbox = document.getElementById("textbox");
+        textbox.focus();
 
-        function focusElement(elementId) {
-            element = document.getElementById(elementId);
-            element.focus();
-            return waitForAnimationFrame();
-        }
+        move(true);
 
-        function moveAsync(isVertical) {
-            move(isVertical);
-            return waitForAnimationFrame();
-        }
+        textbox = document.getElementById("input");
+        textbox.focus();
 
-        (async function () {
-            await focusElement("textbox");
-            await moveAsync(true);
-            await focusElement("input");
-            await moveAsync(false);
-            await focusElement("textarea");
-            await moveAsync(true);
-        })();
+        move(false);
+
+        textbox = document.getElementById("textarea");
+        textbox.focus();
+
+        move(true);
     }
 
 </script>
diff --git a/LayoutTests/accessibility/mac/selection-change-userinfo.html b/LayoutTests/accessibility/mac/selection-change-userinfo.html
index bb3c86c..e1ebdec 100644
--- a/LayoutTests/accessibility/mac/selection-change-userinfo.html
+++ b/LayoutTests/accessibility/mac/selection-change-userinfo.html
@@ -195,87 +195,19 @@
         shouldBe("addedNotification", "true");
 
         textbox = document.getElementById("textbox");
+        textbox.focus();
 
         // Trigger selection changes.
         var s = window.getSelection();
-
-        function focusTextBox() {
-            return new Promise(function(resolve, reject) {
-                setTimeout(() => {
-                    textbox.focus();
-                    resolve();
-                }, 0);
-            });
+        s.setPosition(textbox, 0);
+        for (var i in gran) {
+            s.modify("move", "forward", gran[i]);
+            s.modify("move", "backward", gran[i]);
         }
-
-        function moveSelection(direction, granularity) {
-            return new Promise(function(resolve, reject) {
-                setTimeout(function() {
-                    s.modify("move", direction, granularity);
-                    resolve();
-                }, 0);
-            });
+        for (var i in gran) {
+            s.setPosition(textbox, 0);
+            s.modify("extend", "forward", gran[i]);
         }
-
-        function extendSelection(granularity) {
-            return new Promise(function(resolve, reject) {
-                setTimeout(function() {
-                    s.modify("extend", "forward", granularity);
-                    resolve();
-                }, 0);
-            });
-        }
-
-        function resetPosition() {
-            return new Promise(function(resolve, reject) {
-                setTimeout(function() {
-                    s = window.getSelection();
-                    s.setPosition(textbox, 0);
-                    resolve();
-                }, 0);
-            });
-        }
-
-        (async function() {
-            await focusTextBox();
-            await resetPosition();
-            await moveSelection("forward", gran[0]);
-            await moveSelection("backward", gran[0]);
-            await moveSelection("forward", gran[1]);
-            await moveSelection("backward", gran[1]);
-            await moveSelection("forward", gran[2]);
-            await moveSelection("backward", gran[2]);
-            await moveSelection("forward", gran[3]);
-            await moveSelection("backward", gran[3]);
-            await moveSelection("forward", gran[4]);
-            await moveSelection("backward", gran[4]);
-            await moveSelection("forward", gran[5]);
-            await moveSelection("backward", gran[5]);
-            await moveSelection("forward", gran[6]);
-            await moveSelection("backward", gran[6]);
-            await moveSelection("forward", gran[7]);
-            await moveSelection("backward", gran[7]);
-            await moveSelection("forward", gran[8]);
-            await moveSelection("backward", gran[8]);
-            await resetPosition();
-            await extendSelection(gran[0]);
-            await resetPosition();
-            await extendSelection(gran[1]);
-            await resetPosition();
-            await extendSelection(gran[2]);
-            await resetPosition();
-            await extendSelection(gran[3]);
-            await resetPosition();
-            await extendSelection(gran[4]);
-            await resetPosition();
-            await extendSelection(gran[5]);
-            await resetPosition();
-            await extendSelection(gran[6]);
-            await resetPosition();
-            await extendSelection(gran[7]);
-            await resetPosition();
-            await extendSelection(gran[8]);
-          })();
     }
 
 </script>
diff --git a/LayoutTests/accessibility/mac/selection-value-changes-for-aria-textbox.html b/LayoutTests/accessibility/mac/selection-value-changes-for-aria-textbox.html
index ae505a2..ee9e0a8 100644
--- a/LayoutTests/accessibility/mac/selection-value-changes-for-aria-textbox.html
+++ b/LayoutTests/accessibility/mac/selection-value-changes-for-aria-textbox.html
@@ -43,17 +43,12 @@
         // Trigger selection changes.
         var s = window.getSelection();
         s.setPosition(textbox, 0);
-        requestAnimationFrame(() => {
+        for (var k = 0; k < 3; k++) {
             s.modify("move", "forward", "character");
-            requestAnimationFrame(() => {
-                s.modify("move", "forward", "character");
-                requestAnimationFrame(() => {
-                    s.modify("move", "forward", "character");
-                    // Trigger value change.
-                    document.execCommand("InsertText", false, "hello ");
-                });
-            });
-        });
+        }
+
+        // Trigger value change.
+        document.execCommand("InsertText", false, "hello ");
     }
 
 </script>
diff --git a/LayoutTests/editing/selection-with-absolute-positioned-empty-content.html b/LayoutTests/editing/selection-with-absolute-positioned-empty-content.html
index 09c98ee..9ad64ad 100644
--- a/LayoutTests/editing/selection-with-absolute-positioned-empty-content.html
+++ b/LayoutTests/editing/selection-with-absolute-positioned-empty-content.html
@@ -12,26 +12,15 @@
 <div><a id=foobar style="color: black" href="">select this text<span></span></a> but not this</div>
 <pre id=result></pre>
 <script>
-if (window.testRunner) {
-    testRunner.dumpAsText();
-    testRunner.waitUntilDone();
-}
+if (window.internals)
+  internals.startTrackingRepaints();
+if (window.testRunner)
+  testRunner.dumpAsText();
 
-function timerAfterRAF(callback) {
-    return requestAnimationFrame(() => setTimeout(callback, 0));
-}
+window.getSelection().selectAllChildren(foobar);
 
-timerAfterRAF(() => {
-    if (window.internals)
-        internals.startTrackingRepaints();
-    window.getSelection().selectAllChildren(foobar);
-    timerAfterRAF(() => {
-        if (window.internals) {
-            result.innerText = internals.repaintRectsAsText();
-            internals.stopTrackingRepaints();
-        }
-        if (window.testRunner)
-            testRunner.notifyDone();
-    });
-});
-</script>
+if (window.internals) {
+  result.innerText = internals.repaintRectsAsText();
+  internals.stopTrackingRepaints();
+}
+</script>
\ No newline at end of file
diff --git a/LayoutTests/fast/forms/textarea-scrolled-endline-caret.html b/LayoutTests/fast/forms/textarea-scrolled-endline-caret.html
index e42e43b..734cdcb 100644
--- a/LayoutTests/fast/forms/textarea-scrolled-endline-caret.html
+++ b/LayoutTests/fast/forms/textarea-scrolled-endline-caret.html
@@ -15,17 +15,13 @@
     ta.focus();
     // click
     if (window.eventSender) {
-        testRunner.waitUntilDone();
-        requestAnimationFrame(() => {
-            eventSender.mouseMoveTo(90, 20);
-            eventSender.mouseDown();
-            eventSender.mouseUp();
-            if (ta.selectionEnd == 17)
-                res.innerHTML = "Test Succeeded";
-            else
-                res.innerHTML = "Test Failed: caret is at " + ta.selectionEnd;
-            testRunner.notifyDone();
-        });
+        eventSender.mouseMoveTo(90, 20);
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+        if (ta.selectionEnd == 17)
+            res.innerHTML = "Test Succeeded";
+        else
+            res.innerHTML = "Test Failed: caret is at " + ta.selectionEnd;
     } else {
         res.innerHTML = "Test can't run without event sender (part of DumpRenderTree). "
             + "To test manually, click at the middle of the line marked 9 and check that the caret appears after the 9.";
diff --git a/LayoutTests/fast/repaint/selection-gap-absolute-child-expected.txt b/LayoutTests/fast/repaint/selection-gap-absolute-child-expected.txt
index acea54e..3abb0f70 100644
--- a/LayoutTests/fast/repaint/selection-gap-absolute-child-expected.txt
+++ b/LayoutTests/fast/repaint/selection-gap-absolute-child-expected.txt
@@ -2,4 +2,7 @@
 This tests that absolute elements are invalidated correctly. The box will be competely green if the selected area was invalidated correctly.
 
 
-(repaint rects (rect 0 0 100 100) )
+(repaint rects
+  (rect 0 0 100 100)
+)
+
diff --git a/LayoutTests/fast/repaint/selection-gap-absolute-child.html b/LayoutTests/fast/repaint/selection-gap-absolute-child.html
index a10b9b5..7d47d12 100644
--- a/LayoutTests/fast/repaint/selection-gap-absolute-child.html
+++ b/LayoutTests/fast/repaint/selection-gap-absolute-child.html
@@ -1,27 +1,11 @@
 <!doctype html>
 <head>
+    <script src="resources/text-based-repaint.js"></script>
     <script>
-    if (window.testRunner) {
-        testRunner.dumpAsText(false);
-        testRunner.waitUntilDone();
-    }
-    function runRepaintTest()
+    function repaintTest()
     {
-        if (window.internals)
-            internals.startTrackingRepaints();
-
         var target = document.getElementById("target");
         getSelection().setBaseAndExtent(target, 0, target.nextSibling, 0);
-
-        setTimeout(function() {
-            if (window.internals) {
-                document.querySelector('#repaints').innerHTML = window.internals.repaintRectsAsText();
-                internals.stopTrackingRepaints();
-            }
-
-            if (window.testRunner)
-                testRunner.notifyDone();
-        }, 0);
     }
     </script>
     <style>
@@ -37,5 +21,4 @@
     <div>
         <div id="target" style="background-color: red; width: 100px; height: 100px; position: absolute;"><br/></div><br/>
     </div>
-    <div id="repaints"></div>
 </body>
diff --git a/LayoutTests/fast/repaint/selection-gap-fixed-child-expected.txt b/LayoutTests/fast/repaint/selection-gap-fixed-child-expected.txt
index cc985ae..9b6be5a 100644
--- a/LayoutTests/fast/repaint/selection-gap-fixed-child-expected.txt
+++ b/LayoutTests/fast/repaint/selection-gap-fixed-child-expected.txt
@@ -2,4 +2,7 @@
 This tests that fixed elements are invalidated correctly. The box will be competely green if the selected area was invalidated correctly.
 
 
-(repaint rects (rect 0 0 100 100) )
+(repaint rects
+  (rect 0 0 100 100)
+)
+
diff --git a/LayoutTests/fast/repaint/selection-gap-fixed-child.html b/LayoutTests/fast/repaint/selection-gap-fixed-child.html
index c40ddff..6931c82 100644
--- a/LayoutTests/fast/repaint/selection-gap-fixed-child.html
+++ b/LayoutTests/fast/repaint/selection-gap-fixed-child.html
@@ -1,26 +1,11 @@
 <!doctype html>
 <head>
+    <script src="resources/text-based-repaint.js"></script>
     <script>
-    if (window.testRunner) {
-        testRunner.dumpAsText(false);
-        testRunner.waitUntilDone();
-    }
-    function runRepaintTest()
+    function repaintTest()
     {
-        if (window.internals)
-            internals.startTrackingRepaints();
-
         var target = document.getElementById("target");
         getSelection().setBaseAndExtent(target, 0, target.nextSibling, 0);
-
-        setTimeout(function() {
-            if (window.internals) {
-                document.querySelector('#repaints').innerHTML = window.internals.repaintRectsAsText();
-                internals.stopTrackingRepaints();
-            }
-            if (window.testRunner)
-                testRunner.notifyDone();
-        });
     }
     </script>
     <style>
@@ -36,5 +21,4 @@
     <div>
         <div id="target" style="background-color: red; width: 100px; height: 100px; position: fixed;"><br/></div><br/>
     </div>
-    <div id="repaints"></div>
 </body>
diff --git a/LayoutTests/fast/repaint/selection-gap-flipped-absolute-child-expected.txt b/LayoutTests/fast/repaint/selection-gap-flipped-absolute-child-expected.txt
index 979efa3..db3c374 100644
--- a/LayoutTests/fast/repaint/selection-gap-flipped-absolute-child-expected.txt
+++ b/LayoutTests/fast/repaint/selection-gap-flipped-absolute-child-expected.txt
@@ -2,4 +2,7 @@
 This tests that absolute elements that get flipped are invalidated correctly. The box will be competely green if the selected area was invalidated correctly.
 
 
-(repaint rects (rect 0 0 100 100) )
+(repaint rects
+  (rect 0 0 100 100)
+)
+
diff --git a/LayoutTests/fast/repaint/selection-gap-flipped-absolute-child.html b/LayoutTests/fast/repaint/selection-gap-flipped-absolute-child.html
index 38ff92e..1b61ebf 100644
--- a/LayoutTests/fast/repaint/selection-gap-flipped-absolute-child.html
+++ b/LayoutTests/fast/repaint/selection-gap-flipped-absolute-child.html
@@ -1,27 +1,11 @@
 <!doctype html>
 <head>
+    <script src="resources/text-based-repaint.js"></script>
     <script>
-    if (window.testRunner) {
-        testRunner.dumpAsText(false);
-        testRunner.waitUntilDone();
-    }
-    function runRepaintTest()
+    function repaintTest()
     {
-        if (window.internals)
-            internals.startTrackingRepaints();
-
         var target = document.getElementById("target");
         getSelection().setBaseAndExtent(target, 0, target.nextSibling, 0);
-
-        setTimeout(function() {
-            if (window.internals) {
-                document.querySelector('#repaints').innerHTML = window.internals.repaintRectsAsText();
-                internals.stopTrackingRepaints();
-            }
-
-            if (window.testRunner)
-                testRunner.notifyDone();
-        }, 0);
     }
     </script>
     <style>
@@ -37,5 +21,4 @@
     <div style="-webkit-writing-mode: vertical-rl">
         <div id="target" style="background-color: red; width: 100px; height: 100px; position: absolute;"><br/></div><br/>
     </div>
-    <div id="repaints"></div>
 </body>
diff --git a/LayoutTests/fast/repaint/selection-gap-transformed-absolute-child-expected.txt b/LayoutTests/fast/repaint/selection-gap-transformed-absolute-child-expected.txt
index 5cc9615..b7c3097 100644
--- a/LayoutTests/fast/repaint/selection-gap-transformed-absolute-child-expected.txt
+++ b/LayoutTests/fast/repaint/selection-gap-transformed-absolute-child-expected.txt
@@ -2,4 +2,7 @@
 This tests that absolute elements that get transformed are invalidated correctly. The box will be completely green if the selected area was invalidated correctly.
 
 
-(repaint rects (rect 50 50 100 100) )
+(repaint rects
+  (rect 50 50 100 100)
+)
+
diff --git a/LayoutTests/fast/repaint/selection-gap-transformed-absolute-child.html b/LayoutTests/fast/repaint/selection-gap-transformed-absolute-child.html
index 431ac35..17ed35b 100644
--- a/LayoutTests/fast/repaint/selection-gap-transformed-absolute-child.html
+++ b/LayoutTests/fast/repaint/selection-gap-transformed-absolute-child.html
@@ -1,27 +1,11 @@
 <!doctype html>
 <head>
+    <script src="resources/text-based-repaint.js"></script>
     <script>
-    if (window.testRunner) {
-        testRunner.dumpAsText(false);
-        testRunner.waitUntilDone();
-    }
-    function runRepaintTest()
+    function repaintTest()
     {
-        if (window.internals)
-            internals.startTrackingRepaints();
-
         var target = document.getElementById("target");
         getSelection().setBaseAndExtent(target, 0, target.nextSibling, 0);
-
-        setTimeout(function() {
-            if (window.internals) {
-                document.querySelector('#repaints').innerHTML = window.internals.repaintRectsAsText();
-                internals.stopTrackingRepaints();
-            }
-
-            if (window.testRunner)
-                testRunner.notifyDone();
-        }, 0);
     }
     </script>
     <style>
@@ -37,5 +21,4 @@
     <div style="-webkit-transform: translate(50px, 50px);">
         <div id="target" style="background-color: red; width: 100px; height: 100px; position: absolute;"><br/></div><br/>
     </div>
-    <div id="repaints"></div>
 </body>
diff --git a/LayoutTests/fast/repaint/selection-gap-transformed-fixed-child-expected.txt b/LayoutTests/fast/repaint/selection-gap-transformed-fixed-child-expected.txt
index c5a3128..8dbed44 100644
--- a/LayoutTests/fast/repaint/selection-gap-transformed-fixed-child-expected.txt
+++ b/LayoutTests/fast/repaint/selection-gap-transformed-fixed-child-expected.txt
@@ -2,4 +2,7 @@
 This tests that fixed elements that get transformed are invalidated correctly. The box will be competely green if the selected area was invalidated correctly.
 
 
-(repaint rects (rect 50 50 100 100) )
+(repaint rects
+  (rect 50 50 100 100)
+)
+
diff --git a/LayoutTests/fast/repaint/selection-gap-transformed-fixed-child.html b/LayoutTests/fast/repaint/selection-gap-transformed-fixed-child.html
index 359f9f57..745c55e 100644
--- a/LayoutTests/fast/repaint/selection-gap-transformed-fixed-child.html
+++ b/LayoutTests/fast/repaint/selection-gap-transformed-fixed-child.html
@@ -1,27 +1,11 @@
 <!doctype html>
 <head>
+    <script src="resources/text-based-repaint.js"></script>
     <script>
-    if (window.testRunner) {
-        testRunner.dumpAsText(false);
-        testRunner.waitUntilDone();
-    }
-    function runRepaintTest()
+    function repaintTest()
     {
-        if (window.internals)
-            internals.startTrackingRepaints();
-
         var target = document.getElementById("target");
         getSelection().setBaseAndExtent(target, 0, target.nextSibling, 0);
-
-        setTimeout(function() {
-            if (window.internals) {
-                document.querySelector('#repaints').innerHTML = window.internals.repaintRectsAsText();
-                internals.stopTrackingRepaints();
-            }
-
-            if (window.testRunner)
-                testRunner.notifyDone();
-        }, 0);
     }
     </script>
     <style>
@@ -37,5 +21,4 @@
     <div style="-webkit-transform: translate(50px, 50px);">
         <div id="target" style="background-color: red; width: 100px; height: 100px; position: fixed;"><br/></div><br/>
     </div>
-    <div id="repaints"></div>
 </body>
diff --git a/LayoutTests/fast/repaint/selection-paint-invalidation-expected.txt b/LayoutTests/fast/repaint/selection-paint-invalidation-expected.txt
index b1992a9..8612326 100644
--- a/LayoutTests/fast/repaint/selection-paint-invalidation-expected.txt
+++ b/LayoutTests/fast/repaint/selection-paint-invalidation-expected.txt
@@ -2,5 +2,6 @@
 A
 (repaint rects
   (rect 8 68 20 100)
+  (rect 8 68 20 100)
 )
 
diff --git a/LayoutTests/fast/repaint/selection-ruby-rl-expected.txt b/LayoutTests/fast/repaint/selection-ruby-rl-expected.txt
index 4e7c092..95915e6 100644
--- a/LayoutTests/fast/repaint/selection-ruby-rl-expected.txt
+++ b/LayoutTests/fast/repaint/selection-ruby-rl-expected.txt
@@ -8,4 +8,7 @@
 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 38 18 79) )
+(repaint rects
+  (rect 774 38 18 79)
+)
+
diff --git a/LayoutTests/fast/repaint/selection-ruby-rl.html b/LayoutTests/fast/repaint/selection-ruby-rl.html
index ea42516..0278440 100644
--- a/LayoutTests/fast/repaint/selection-ruby-rl.html
+++ b/LayoutTests/fast/repaint/selection-ruby-rl.html
@@ -3,15 +3,7 @@
 <head>
 <script src="resources/text-based-repaint.js"></script>
 <script>
-if (window.testRunner) {
-    testRunner.dumpAsText(false);
-    testRunner.waitUntilDone();
-}
-
-function runRepaintTest() {
-    if (window.internals)
-        internals.startTrackingRepaints();
-
+function repaintTest() {
     if (eventSender) {
         eventSender.mouseMoveTo(790, 40);
         eventSender.mouseDown();
@@ -19,16 +11,6 @@
         eventSender.mouseMoveTo(790, 120);
         eventSender.mouseUp();
     }
-
-    setTimeout(function() {
-        if (window.internals) {
-            document.querySelector('#repaints').innerHTML = window.internals.repaintRectsAsText();
-            internals.stopTrackingRepaints();
-        }
-
-        if (window.testRunner)
-            testRunner.notifyDone();
-    }, 0);
 }
 </script>
 
@@ -44,5 +26,4 @@
 Testing both hit testing and painting of selection.<br>
 Testing both hit testing and painting of selection.<br>
 Testing both hit testing and painting of selection.<br>
-<div id="repaints"></div>
 </body>
diff --git a/LayoutTests/fast/repaint/text-selection-overflow-hidden-expected.txt b/LayoutTests/fast/repaint/text-selection-overflow-hidden-expected.txt
index e2d3e59..bd9f589 100644
--- a/LayoutTests/fast/repaint/text-selection-overflow-hidden-expected.txt
+++ b/LayoutTests/fast/repaint/text-selection-overflow-hidden-expected.txt
@@ -1,3 +1,6 @@
 Should have green background
 
-(repaint rects (rect 8 16 199 18) )
+(repaint rects
+  (rect 8 16 199 18)
+)
+
diff --git a/LayoutTests/fast/repaint/text-selection-overflow-hidden.html b/LayoutTests/fast/repaint/text-selection-overflow-hidden.html
index 8a43f9b..bcc9e34 100644
--- a/LayoutTests/fast/repaint/text-selection-overflow-hidden.html
+++ b/LayoutTests/fast/repaint/text-selection-overflow-hidden.html
@@ -1,4 +1,5 @@
 <!DOCTYPE html>
+<script src="resources/text-based-repaint.js" type="text/javascript"></script>
 <style>
 #test {
     background-color: red;
@@ -11,30 +12,11 @@
 }
 </style>
 <script>
-    if (window.testRunner) {
-        testRunner.dumpAsText(false);
-        testRunner.waitUntilDone();
-    }
-
-    function runRepaintTest() {
-        if (window.internals)
-            internals.startTrackingRepaints();
-
+    function repaintTest() {
         getSelection().setBaseAndExtent(test, 0, test, 1);
-
-        setTimeout(function() {
-            if (window.internals) {
-                document.querySelector('#repaints').innerHTML = window.internals.repaintRectsAsText();
-                internals.stopTrackingRepaints();
-            }
-
-            if (window.testRunner)
-                testRunner.notifyDone();
-        }, 0);
     };
 </script>
 
 <body onload="runRepaintTest()">
     <p id="test">Should have green background</p>
-    <div id="repaints"></div>
 </body>
diff --git a/LayoutTests/fast/text/incorrect-deselection-across-multiple-elements.html b/LayoutTests/fast/text/incorrect-deselection-across-multiple-elements.html
index efe964e..e08b1b7 100644
--- a/LayoutTests/fast/text/incorrect-deselection-across-multiple-elements.html
+++ b/LayoutTests/fast/text/incorrect-deselection-across-multiple-elements.html
@@ -20,13 +20,11 @@
   if (window.internals)
     internals.startTrackingRepaints();
   window.getSelection().selectAllChildren(second);
-  setTimeout(function() {
-    if (window.internals) {
-      result.innerText = internals.repaintRectsAsText().indexOf("784 70") == -1 ? "FAIL" : "PASS";
-      internals.stopTrackingRepaints();
-    }
-    if (window.testRunner)
-      testRunner.notifyDone();
-  }, 0);
+  if (window.internals) {
+    result.innerText = internals.repaintRectsAsText().indexOf("784 70") == -1 ? "FAIL" : "PASS";
+    internals.stopTrackingRepaints();
+  }
+  if (window.testRunner)
+    testRunner.notifyDone();
 }, 0);
 </script>
\ No newline at end of file
diff --git a/LayoutTests/platform/gtk/TestExpectations b/LayoutTests/platform/gtk/TestExpectations
index f945c8c..aee26d0 100644
--- a/LayoutTests/platform/gtk/TestExpectations
+++ b/LayoutTests/platform/gtk/TestExpectations
@@ -1531,6 +1531,8 @@
 # Incomplete implementation of eventSender causes this test to fail
 webkit.org/b/42194 fast/scrolling/scroll-select-list.html [ ImageOnlyFailure ]
 
+webkit.org/b/139354 fast/repaint/selection-ruby-rl.html [ Failure ]
+
 # Missing glyph symbol is not rendered properly.
 webkit.org/b/140252 fast/css/line-height-determined-by-primary-font.html [ Failure ]
 webkit.org/b/140252 fast/text/decorations-with-text-combine.html [ Failure ]
diff --git a/LayoutTests/platform/gtk/fast/repaint/selection-ruby-rl-expected.txt b/LayoutTests/platform/gtk/fast/repaint/selection-ruby-rl-expected.txt
deleted file mode 100644
index e858098..0000000
--- a/LayoutTests/platform/gtk/fast/repaint/selection-ruby-rl-expected.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-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 775 37 17 84) )
diff --git a/LayoutTests/platform/gtk/fast/repaint/text-selection-overflow-hidden-expected.txt b/LayoutTests/platform/gtk/fast/repaint/text-selection-overflow-hidden-expected.txt
index 0fa5dda..a0ae456 100644
--- a/LayoutTests/platform/gtk/fast/repaint/text-selection-overflow-hidden-expected.txt
+++ b/LayoutTests/platform/gtk/fast/repaint/text-selection-overflow-hidden-expected.txt
@@ -1,3 +1,6 @@
 Should have green background
 
-(repaint rects (rect 8 16 197 17) )
+(repaint rects
+  (rect 8 16 197 17)
+)
+
diff --git a/LayoutTests/platform/mac-wk1/TestExpectations b/LayoutTests/platform/mac-wk1/TestExpectations
index ed94091..468de81 100644
--- a/LayoutTests/platform/mac-wk1/TestExpectations
+++ b/LayoutTests/platform/mac-wk1/TestExpectations
@@ -1841,6 +1841,3 @@
 
 # rdar://82399990 ([ Catalina EWS ] webgl/2.0.0/* tests are flaky crashing ASSERTION FAILED: !needsLayout() (229580)) Disable webgl tests for mac-wk1
 webgl [ Skip ]
-
-webkit.org/b/231298 accessibility/mac/selection-boundary-userinfo.html [ Failure ]
-webkit.org/b/232630 fast/forms/autofocus-opera-003.html [ Failure ]
diff --git a/LayoutTests/platform/mac-wk1/accessibility/mac/focus-setting-selection-syncronizing-not-clearing-expected.txt b/LayoutTests/platform/mac-wk1/accessibility/mac/focus-setting-selection-syncronizing-not-clearing-expected.txt
deleted file mode 100644
index c68379c..0000000
--- a/LayoutTests/platform/mac-wk1/accessibility/mac/focus-setting-selection-syncronizing-not-clearing-expected.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-
- 1
- 2
-This tests that calling focus on a render object when it doesn't result in a selection change won't leave isSynchronizingSelection set to true.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS addedNotification is true
-PASS accessibilityController.focusedElement.isEqual(accessibilityController.accessibleElementById("1")) is true
-PASS axTextStateSyncOne is undefined
-PASS accessibilityController.accessibleElementById("1").isFocusable is true
-PASS axTextStateSyncTwo is undefined
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
diff --git a/LayoutTests/platform/mac-wk1/fast/repaint/4776765-expected.txt b/LayoutTests/platform/mac-wk1/fast/repaint/4776765-expected.txt
deleted file mode 100644
index 5bf010f..0000000
--- a/LayoutTests/platform/mac-wk1/fast/repaint/4776765-expected.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-(repaint rects
-  (rect 1 19 15 32)
-  (rect 8 26 1 18)
-  (rect 1 19 15 32)
-  (rect 8 26 1 18)
-  (rect 1 37 798 32)
-  (rect 8 44 784 18)
-  (rect 1 51 798 18)
-  (rect 1 44 798 7)
-)
-
diff --git a/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-005-expected.txt b/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-005-expected.txt
index 6b495d3..4800280 100644
--- a/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-005-expected.txt
+++ b/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-scroll-snap/scroll-target-margin-005-expected.txt
@@ -1,4 +1,4 @@
 
 
-FAIL scroll-margin on input widget assert_between_exclusive: Should honor date input scroll-margin expected a number greater than 4750 and less than 4850 but got 9439
+FAIL scroll-margin on input widget assert_between_exclusive: Should honor date input scroll-margin expected a number greater than 4750 and less than 4850 but got 4720
 
diff --git a/LayoutTests/platform/mac/TestExpectations b/LayoutTests/platform/mac/TestExpectations
index cfd69d8..d417480 100644
--- a/LayoutTests/platform/mac/TestExpectations
+++ b/LayoutTests/platform/mac/TestExpectations
@@ -2305,4 +2305,3 @@
 
 webkit.org/b/240074 imported/w3c/web-platform-tests/service-workers/service-worker/registration-updateviacache.https.html [ Pass Failure ]
 
-webkit.org/b/231298 accessibility/mac/selection-sync.html [ Skip ] # Timeout
diff --git a/LayoutTests/platform/win/fast/repaint/4776765-expected.txt b/LayoutTests/platform/win/fast/repaint/4776765-expected.txt
deleted file mode 100644
index d9ca7dc..0000000
--- a/LayoutTests/platform/win/fast/repaint/4776765-expected.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-(repaint rects
-  (rect 1 37 798 32)
-  (rect 8 44 784 18)
-  (rect 1 51 798 18)
-  (rect 1 44 798 7)
-)
-
diff --git a/LayoutTests/platform/win/fast/repaint/selection-gap-fixed-child-expected.txt b/LayoutTests/platform/win/fast/repaint/selection-gap-fixed-child-expected.txt
index 387aace..e02c092 100644
--- a/LayoutTests/platform/win/fast/repaint/selection-gap-fixed-child-expected.txt
+++ b/LayoutTests/platform/win/fast/repaint/selection-gap-fixed-child-expected.txt
@@ -2,4 +2,7 @@
 This tests that fixed elements are invalidated correctly. The box will be competely green if the selected area was invalidated correctly.

 

 

-(repaint rects (rect 0 0 100 100) )

+(repaint rects

+  (rect 0 0 100 100)

+)

+

diff --git a/LayoutTests/platform/win/fast/repaint/selection-ruby-rl-expected.txt b/LayoutTests/platform/win/fast/repaint/selection-ruby-rl-expected.txt
index fc55959..5a934f4 100644
--- a/LayoutTests/platform/win/fast/repaint/selection-ruby-rl-expected.txt
+++ b/LayoutTests/platform/win/fast/repaint/selection-ruby-rl-expected.txt
@@ -8,4 +8,7 @@
 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) )
+(repaint rects
+  (rect 774 39 18 83)
+)
+
diff --git a/LayoutTests/platform/win/fast/repaint/text-selection-overflow-hidden-expected.txt b/LayoutTests/platform/win/fast/repaint/text-selection-overflow-hidden-expected.txt
index 4190403..0a771d4 100644
--- a/LayoutTests/platform/win/fast/repaint/text-selection-overflow-hidden-expected.txt
+++ b/LayoutTests/platform/win/fast/repaint/text-selection-overflow-hidden-expected.txt
@@ -1,3 +1,6 @@
 Should have green background
 
-(repaint rects (rect 8 16 197 18) )
+(repaint rects
+  (rect 8 16 197 18)
+)
+
diff --git a/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp b/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp
index 954b2e1..24f6552 100644
--- a/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp
+++ b/Source/WebCore/Modules/highlight/AppHighlightStorage.cpp
@@ -271,7 +271,7 @@
         if (textIndicator)
             m_document->page()->chrome().client().setTextIndicator(textIndicator->data());
 
-        TemporarySelectionChange selectionChange(*strongDocument, { *range }, { TemporarySelectionOption::DelegateMainFrameScroll, TemporarySelectionOption::SmoothScroll, TemporarySelectionOption::RevealSelectionBounds, TemporarySelectionOption::UserTriggered });
+        TemporarySelectionChange selectionChange(*strongDocument, { range.value() }, { TemporarySelectionOption::DelegateMainFrameScroll, TemporarySelectionOption::SmoothScroll, TemporarySelectionOption::RevealSelectionBounds });
     }
 
     return true;
diff --git a/Source/WebCore/editing/Editor.cpp b/Source/WebCore/editing/Editor.cpp
index 1b79213..3753d29 100644
--- a/Source/WebCore/editing/Editor.cpp
+++ b/Source/WebCore/editing/Editor.cpp
@@ -264,7 +264,7 @@
 
 void TemporarySelectionChange::setSelection(const VisibleSelection& selection, IsTemporarySelection isTemporarySelection)
 {
-    auto options = FrameSelection::defaultSetSelectionOptions(m_options.contains(TemporarySelectionOption::UserTriggered) ? UserTriggered : NotUserTriggered);
+    auto options = FrameSelection::defaultSetSelectionOptions();
     if (m_options & TemporarySelectionOption::DoNotSetFocus)
         options.add(FrameSelection::DoNotSetFocus);
 
diff --git a/Source/WebCore/editing/Editor.h b/Source/WebCore/editing/Editor.h
index 3b16dd6..24a17f4 100644
--- a/Source/WebCore/editing/Editor.h
+++ b/Source/WebCore/editing/Editor.h
@@ -126,8 +126,6 @@
     DelegateMainFrameScroll = 1 << 5,
     
     RevealSelectionBounds = 1 << 6,
-
-    UserTriggered = 1 << 7,
 };
 
 class TemporarySelectionChange {
diff --git a/Source/WebCore/editing/FrameSelection.cpp b/Source/WebCore/editing/FrameSelection.cpp
index e85497b..1cfb24c 100644
--- a/Source/WebCore/editing/FrameSelection.cpp
+++ b/Source/WebCore/editing/FrameSelection.cpp
@@ -454,11 +454,6 @@
     if (frameView && frameView->layoutContext().isLayoutPending())
         return;
 
-    if (!(options & IsUserTriggered)) {
-        scheduleAppearanceUpdateAfterStyleChange();
-        return;
-    }
-
     updateAndRevealSelection(intent, options.contains(SmoothScroll) ? ScrollBehavior::Smooth : ScrollBehavior::Instant, options.contains(RevealSelectionBounds) ? RevealExtentOption::DoNotRevealExtent : RevealExtentOption::RevealExtent);
 
     if (options & IsUserTriggered) {
@@ -467,19 +462,13 @@
     }
 }
 
-void FrameSelection::updateSelectionAppearanceNow()
+static void updateSelectionByUpdatingLayoutOrStyle(Document& document)
 {
-    if (!m_document)
-        return;
-
-    Ref document = *m_document;
 #if ENABLE(TEXT_CARET)
-    document->updateLayoutIgnorePendingStylesheets();
+    document.updateLayoutIgnorePendingStylesheets();
 #else
-    document->updateStyleIfNeeded();
+    document.updateStyleIfNeeded();
 #endif
-    if (m_pendingSelectionUpdate)
-        updateAppearance();
 }
 
 void FrameSelection::setNeedsSelectionUpdate(RevealSelectionAfterUpdate revealMode)
@@ -1711,7 +1700,7 @@
 {
     if (!m_document)
         return IntRect();
-    updateSelectionAppearanceNow();
+    updateSelectionByUpdatingLayoutOrStyle(*m_document);
     recomputeCaretRect();
     if (insideFixed)
         *insideFixed = m_caretInsidePositionFixed;
@@ -2269,7 +2258,7 @@
 
     // FIXME: We shouldn't trigger a synchronous layout here.
     if (doAppearanceUpdate == ShouldUpdateAppearance::Yes && m_document)
-        updateSelectionAppearanceNow();
+        updateSelectionByUpdatingLayoutOrStyle(*m_document);
 
 #if ENABLE(TEXT_CARET)
     if (m_caretPaint) {
@@ -2372,12 +2361,12 @@
     return m_document->editor().client()->shouldDeleteRange(selection.toNormalizedRange());
 }
 
-FloatRect FrameSelection::selectionBounds(ClipToVisibleContent clipToVisibleContent)
+FloatRect FrameSelection::selectionBounds(ClipToVisibleContent clipToVisibleContent) const
 {
     if (!m_document)
         return LayoutRect();
 
-    updateSelectionAppearanceNow();
+    updateSelectionByUpdatingLayoutOrStyle(*m_document);
     auto* renderView = m_document->renderView();
     if (!renderView)
         return LayoutRect();
@@ -2473,8 +2462,6 @@
     if (isNone())
         return;
 
-    updateSelectionAppearanceNow();
-
     LayoutRect rect;
     bool insideFixed = false;
     if (isCaret())
diff --git a/Source/WebCore/editing/FrameSelection.h b/Source/WebCore/editing/FrameSelection.h
index fa04b28..a3d7434 100644
--- a/Source/WebCore/editing/FrameSelection.h
+++ b/Source/WebCore/editing/FrameSelection.h
@@ -245,7 +245,7 @@
     void clearTypingStyle();
 
     enum class ClipToVisibleContent : uint8_t { No, Yes };
-    WEBCORE_EXPORT FloatRect selectionBounds(ClipToVisibleContent = ClipToVisibleContent::Yes);
+    WEBCORE_EXPORT FloatRect selectionBounds(ClipToVisibleContent = ClipToVisibleContent::Yes) const;
 
     enum class TextRectangleHeight { TextHeight, SelectionHeight };
     WEBCORE_EXPORT void getClippedVisibleTextRectangles(Vector<FloatRect>&, TextRectangleHeight = TextRectangleHeight::SelectionHeight) const;
@@ -267,7 +267,6 @@
     void updateFromAssociatedLiveRange();
 
 private:
-    void updateSelectionAppearanceNow();
     void updateAndRevealSelection(const AXTextStateChangeIntent&, ScrollBehavior = ScrollBehavior::Instant, RevealExtentOption = RevealExtentOption::RevealExtent);
     void updateDataDetectorsForSelection();
 
diff --git a/Source/WebCore/page/EventHandler.cpp b/Source/WebCore/page/EventHandler.cpp
index ac725d4..0c66410 100644
--- a/Source/WebCore/page/EventHandler.cpp
+++ b/Source/WebCore/page/EventHandler.cpp
@@ -444,7 +444,7 @@
 static void setSelectionIfNeeded(FrameSelection& selection, const VisibleSelection& newSelection)
 {
     if (selection.selection() != newSelection && selection.shouldChangeSelection(newSelection))
-        selection.setSelection(newSelection, FrameSelection::defaultSetSelectionOptions(UserTriggered));
+        selection.setSelection(newSelection);
 }
 
 static inline bool dispatchSelectStart(Node* node)
diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp
index 22737c5..4c9b6bb 100644
--- a/Source/WebCore/page/Page.cpp
+++ b/Source/WebCore/page/Page.cpp
@@ -1742,10 +1742,6 @@
     });
 
     forEachDocument([] (Document& document) {
-        document.selection().updateAppearanceAfterLayout();
-    });
-
-    forEachDocument([] (Document& document) {
         document.updateHighlightPositions();
     });
 #if ENABLE(APP_HIGHLIGHTS)