<!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>[282764] 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/282764">282764</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2021-09-20 11:20:29 -0700 (Mon, 20 Sep 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[LFC][Integration] Enable selections
https://bugs.webkit.org/show_bug.cgi?id=230463

Reviewed by Alan Bujtas.

Source/WebCore:

Don't switch to legacy inline boxes on selection.

Test: fast/repaint/selection-paint-invalidation.html

* layout/integration/LayoutIntegrationCoverage.cpp:
(WebCore::LayoutIntegration::printReason):
(WebCore::LayoutIntegration::canUseForChild):
* layout/integration/LayoutIntegrationCoverage.h:
* layout/integration/LayoutIntegrationRunIterator.cpp:
(WebCore::LayoutIntegration::PathTextRun::selectionRect const):

Move this to path independent code and fix it to compute selectionTop/Bottom correctly.

(WebCore::LayoutIntegration::PathTextRun::isCombinedText const):
(WebCore::LayoutIntegration::PathTextRun::fontCascade const):

Add some helpful functions.

* layout/integration/LayoutIntegrationRunIterator.h:
(WebCore::LayoutIntegration::PathTextRun::selectionRect const): Deleted.
* layout/integration/LayoutIntegrationRunIteratorLegacyPath.h:
(WebCore::LayoutIntegration::RunIteratorLegacyPath::selectableRange const):
(WebCore::LayoutIntegration::RunIteratorLegacyPath::selectionRect const): Deleted.
* layout/integration/LayoutIntegrationRunIteratorModernPath.h:
(WebCore::LayoutIntegration::RunIteratorModernPath::selectionRect const): Deleted.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::setSelectionState): Deleted.
* rendering/RenderBlockFlow.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::setSelectionState):

* layout/integration/LayoutIntegrationCoverage.cpp:
(WebCore::LayoutIntegration::printReason):
(WebCore::LayoutIntegration::canUseForChild):
* layout/integration/LayoutIntegrationCoverage.h:
* layout/integration/LayoutIntegrationRunIterator.cpp:
(WebCore::LayoutIntegration::PathTextRun::selectionRect const):
(WebCore::LayoutIntegration::PathTextRun::fontCascade const):
* layout/integration/LayoutIntegrationRunIterator.h:
(WebCore::LayoutIntegration::PathTextRun::selectionRect const): Deleted.
* layout/integration/LayoutIntegrationRunIteratorLegacyPath.h:
(WebCore::LayoutIntegration::RunIteratorLegacyPath::selectableRange const):
(WebCore::LayoutIntegration::RunIteratorLegacyPath::selectionRect const): Deleted.
* layout/integration/LayoutIntegrationRunIteratorModernPath.h:
(WebCore::LayoutIntegration::RunIteratorModernPath::selectionRect const): Deleted.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::setSelectionState): Deleted.
* rendering/RenderBlockFlow.h:
* rendering/RenderObject.cpp:
(WebCore::RenderObject::setSelectionState):
* rendering/TextBoxPainter.cpp:
(WebCore::TextBoxPainter::paint):
(WebCore::TextBoxPainter::paintForeground):
(WebCore::TextBoxPainter::paintDecoration):
(WebCore::TextBoxPainter::calculateDocumentMarkerBounds):
(WebCore::TextBoxPainter::fontCascade const):

Use iterator functions.

(WebCore::TextBoxPainter::textOriginFromPaintRect const):
(WebCore::fontCascadeFor): Deleted.
(WebCore::TextBoxPainter::combinedText const): Deleted.
* rendering/TextBoxPainter.h:

Tools:

* TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm:
(TestWebKitAPI::TEST):

LayoutTests:

* fast/repaint/selection-paint-invalidation-expected.txt: Added.
* fast/repaint/selection-paint-invalidation.html: Added.
* platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacfasttextwhitespaceprewrapoverflowselectionexpectedtxt">trunk/LayoutTests/platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationCoveragecpp">trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationCoverageh">trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationRunIteratorcpp">trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationRunIteratorh">trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationRunIteratorLegacyPathh">trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationRunIteratorModernPathh">trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowh">trunk/Source/WebCore/rendering/RenderBlockFlow.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingTextBoxPaintercpp">trunk/Source/WebCore/rendering/TextBoxPainter.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingTextBoxPainterh">trunk/Source/WebCore/rendering/TextBoxPainter.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsiosAccessibilityTestsIOSmm">trunk/Tools/TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastrepaintselectionpaintinvalidationexpectedtxt">trunk/LayoutTests/fast/repaint/selection-paint-invalidation-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastrepaintselectionpaintinvalidationhtml">trunk/LayoutTests/fast/repaint/selection-paint-invalidation.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/LayoutTests/ChangeLog 2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2021-09-20  Antti Koivisto  <antti@apple.com>
+
+        [LFC][Integration] Enable selections
+        https://bugs.webkit.org/show_bug.cgi?id=230463
+
+        Reviewed by Alan Bujtas.
+
+        * fast/repaint/selection-paint-invalidation-expected.txt: Added.
+        * fast/repaint/selection-paint-invalidation.html: Added.
+        * platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt:
+
</ins><span class="cx"> 2021-09-20  Eric Hutchison  <ehutchison@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Update test expectations for http/tests/misc/iframe-reparenting-id-collision.html.
</span></span></pre></div>
<a id="trunkLayoutTestsfastrepaintselectionpaintinvalidationexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/repaint/selection-paint-invalidation-expected.txt (0 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/repaint/selection-paint-invalidation-expected.txt                         (rev 0)
+++ trunk/LayoutTests/fast/repaint/selection-paint-invalidation-expected.txt    2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+A
+A
+(repaint rects
+  (rect 8 68 20 100)
+  (rect 8 68 20 100)
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastrepaintselectionpaintinvalidationhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/repaint/selection-paint-invalidation.html (0 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/repaint/selection-paint-invalidation.html                         (rev 0)
+++ trunk/LayoutTests/fast/repaint/selection-paint-invalidation.html    2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<title>Test that selection gets cleared properly with line-height set.</title>
+<style>
+::selection {
+    background: rgba(255, 0, 0, 0.9);
+}
+
+div {
+    font-size: 20px;
+    font-family: 'Ahem';
+    line-height: 100px;
+}
+</style>
+</head>
+<body>
+<div id="container">A<br><span>A</span></div>
+<pre id="result"></pre>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+async function test() {
+    await new Promise(requestAnimationFrame);
+
+    if (window.internals)
+        internals.startTrackingRepaints();
+
+    const range = document.createRange();
+    range.selectNode(document.querySelector("#container > span"));
+    window.getSelection().addRange(range);
+
+    await new Promise(requestAnimationFrame);
+
+    window.getSelection().removeAllRanges();
+
+    if (window.internals) {
+        let repaintRects = internals.repaintRectsAsText();
+        internals.stopTrackingRepaints();
+        result.textContent = repaintRects;
+    }
+
+    await new Promise(requestAnimationFrame);
+    
+    if (window.testRunner)
+        testRunner.notifyDone();
+};
+test();
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacfasttextwhitespaceprewrapoverflowselectionexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt     2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/LayoutTests/platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt        2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -22,12 +22,10 @@
</span><span class="cx">       RenderBlock {HR} at (0,197) size 784x2 [border: (1px inset #000000)]
</span><span class="cx">       RenderBlock {PRE} at (0,212) size 108x83 [border: (4px solid #0000FF)]
</span><span class="cx">         RenderText {#text} at (4,4) size 100x75
</span><del>-          text run at (4,4) width 86: "This   text"
-          text run at (89,4) width 15: "     "
</del><ins>+          text run at (4,4) width 100: "This   text     "
</ins><span class="cx">           text run at (4,19) width 71: "will wrap"
</span><span class="cx">           text run at (74,19) width 1: " "
</span><del>-          text run at (4,34) width 71: "and   fit"
-          text run at (74,34) width 24: "   "
</del><ins>+          text run at (4,34) width 94: "and   fit   "
</ins><span class="cx">           text run at (4,49) width 79: "within the"
</span><span class="cx">           text run at (82,49) width 1: " "
</span><span class="cx">           text run at (4,64) width 32: "box."
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/ChangeLog      2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -1,3 +1,74 @@
</span><ins>+2021-09-20  Antti Koivisto  <antti@apple.com>
+
+        [LFC][Integration] Enable selections
+        https://bugs.webkit.org/show_bug.cgi?id=230463
+
+        Reviewed by Alan Bujtas.
+
+        Don't switch to legacy inline boxes on selection.
+
+        Test: fast/repaint/selection-paint-invalidation.html
+
+        * layout/integration/LayoutIntegrationCoverage.cpp:
+        (WebCore::LayoutIntegration::printReason):
+        (WebCore::LayoutIntegration::canUseForChild):
+        * layout/integration/LayoutIntegrationCoverage.h:
+        * layout/integration/LayoutIntegrationRunIterator.cpp:
+        (WebCore::LayoutIntegration::PathTextRun::selectionRect const):
+
+        Move this to path independent code and fix it to compute selectionTop/Bottom correctly.
+
+        (WebCore::LayoutIntegration::PathTextRun::isCombinedText const):
+        (WebCore::LayoutIntegration::PathTextRun::fontCascade const):
+
+        Add some helpful functions.
+
+        * layout/integration/LayoutIntegrationRunIterator.h:
+        (WebCore::LayoutIntegration::PathTextRun::selectionRect const): Deleted.
+        * layout/integration/LayoutIntegrationRunIteratorLegacyPath.h:
+        (WebCore::LayoutIntegration::RunIteratorLegacyPath::selectableRange const):
+        (WebCore::LayoutIntegration::RunIteratorLegacyPath::selectionRect const): Deleted.
+        * layout/integration/LayoutIntegrationRunIteratorModernPath.h:
+        (WebCore::LayoutIntegration::RunIteratorModernPath::selectionRect const): Deleted.
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::setSelectionState): Deleted.
+        * rendering/RenderBlockFlow.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::setSelectionState):
+
+        * layout/integration/LayoutIntegrationCoverage.cpp:
+        (WebCore::LayoutIntegration::printReason):
+        (WebCore::LayoutIntegration::canUseForChild):
+        * layout/integration/LayoutIntegrationCoverage.h:
+        * layout/integration/LayoutIntegrationRunIterator.cpp:
+        (WebCore::LayoutIntegration::PathTextRun::selectionRect const):
+        (WebCore::LayoutIntegration::PathTextRun::fontCascade const):
+        * layout/integration/LayoutIntegrationRunIterator.h:
+        (WebCore::LayoutIntegration::PathTextRun::selectionRect const): Deleted.
+        * layout/integration/LayoutIntegrationRunIteratorLegacyPath.h:
+        (WebCore::LayoutIntegration::RunIteratorLegacyPath::selectableRange const):
+        (WebCore::LayoutIntegration::RunIteratorLegacyPath::selectionRect const): Deleted.
+        * layout/integration/LayoutIntegrationRunIteratorModernPath.h:
+        (WebCore::LayoutIntegration::RunIteratorModernPath::selectionRect const): Deleted.
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::setSelectionState): Deleted.
+        * rendering/RenderBlockFlow.h:
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::setSelectionState):
+        * rendering/TextBoxPainter.cpp:
+        (WebCore::TextBoxPainter::paint):
+        (WebCore::TextBoxPainter::paintForeground):
+        (WebCore::TextBoxPainter::paintDecoration):
+        (WebCore::TextBoxPainter::calculateDocumentMarkerBounds):
+        (WebCore::TextBoxPainter::fontCascade const):
+
+        Use iterator functions.
+
+        (WebCore::TextBoxPainter::textOriginFromPaintRect const):
+        (WebCore::fontCascadeFor): Deleted.
+        (WebCore::TextBoxPainter::combinedText const): Deleted.
+        * rendering/TextBoxPainter.h:
+
</ins><span class="cx"> 2021-09-20  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed iOS debug build fix after r282755.
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationCoveragecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp    2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp       2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -189,9 +189,6 @@
</span><span class="cx">     case AvoidanceReason::FlowHasComplexFontCodePath:
</span><span class="cx">         stream << "text with complex font codepath";
</span><span class="cx">         break;
</span><del>-    case AvoidanceReason::FlowChildIsSelected:
-        stream << "selected content";
-        break;
</del><span class="cx">     case AvoidanceReason::FlowHasLineBoxContainGlyphs:
</span><span class="cx">         stream << "-webkit-line-box-contain: glyphs";
</span><span class="cx">         break;
</span><span class="lines">@@ -527,8 +524,6 @@
</span><span class="cx"> static OptionSet<AvoidanceReason> canUseForChild(const RenderBlockFlow& flow, const RenderObject& child, IncludeReasons includeReasons)
</span><span class="cx"> {
</span><span class="cx">     OptionSet<AvoidanceReason> reasons;
</span><del>-    if (child.selectionState() != RenderObject::HighlightState::None)
-        SET_REASON_AND_RETURN_IF_NEEDED(FlowChildIsSelected, reasons, includeReasons);
</del><span class="cx">     if (is<RenderCounter>(child))
</span><span class="cx">         SET_REASON_AND_RETURN_IF_NEEDED(FlowTextIsRenderCounter, reasons, includeReasons);
</span><span class="cx">     if (is<RenderText>(child)) {
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationCoverageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h      2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h 2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx">     FlowHasComplexFontCodePath                   = 1LLU  << 40,
</span><span class="cx">     FeatureIsDisabled                            = 1LLU  << 41,
</span><span class="cx">     FlowDoesNotEstablishInlineFormattingContext  = 1LLU  << 42,
</span><del>-    FlowChildIsSelected                          = 1LLU  << 43,
</del><ins>+    // Unused                                    = 1LLU  << 43,
</ins><span class="cx">     FlowHasHangingPunctuation                    = 1LLU  << 44,
</span><span class="cx">     FlowHasLineBoxContainGlyphs                  = 1LLU  << 45,
</span><span class="cx">     FlowTextHasSurrogatePair                     = 1LLU  << 46,
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationRunIteratorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp 2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp    2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include "LayoutIntegrationLineIterator.h"
</span><span class="cx"> #include "LayoutIntegrationLineLayout.h"
</span><span class="cx"> #include "RenderBlockFlow.h"
</span><ins>+#include "RenderCombineText.h"
</ins><span class="cx"> #include "RenderLineBreak.h"
</span><span class="cx"> #include "RenderView.h"
</span><span class="cx"> 
</span><span class="lines">@@ -106,6 +107,39 @@
</span><span class="cx">     return TextRunIterator(*this).traverseNextTextRunInTextOrder();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+LayoutRect PathTextRun::selectionRect(unsigned rangeStart, unsigned rangeEnd) const
+{
+    auto [clampedStart, clampedEnd] = selectableRange().clamp(rangeStart, rangeEnd);
+
+    if (clampedStart >= clampedEnd && !(rangeStart == rangeEnd && rangeStart >= start() && rangeStart <= end()))
+        return { };
+
+    auto selectionTop = line()->selectionTop();
+    auto selectionHeight = line()->selectionHeight();
+
+    LayoutRect selectionRect { logicalLeft(), selectionTop, logicalWidth(), selectionHeight };
+
+    TextRun textRun = createTextRun();
+    if (clampedStart || clampedEnd != textRun.length())
+        fontCascade().adjustSelectionRectForText(textRun, selectionRect, clampedStart, clampedEnd);
+
+    return snappedSelectionRect(selectionRect, logicalRight(), selectionTop, selectionHeight, isHorizontal());
+}
+
+bool PathTextRun::isCombinedText() const
+{
+    auto& renderer = this->renderer();
+    return is<RenderCombineText>(renderer) && downcast<RenderCombineText>(renderer).isCombined();
+}
+
+const FontCascade& PathTextRun::fontCascade() const
+{
+    if (isCombinedText())
+        return downcast<RenderCombineText>(renderer()).textCombineFont();
+
+    return style().fontCascade();
+}
+
</ins><span class="cx"> RenderObject::HighlightState PathRun::selectionState() const
</span><span class="cx"> {
</span><span class="cx">     if (isText()) {
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationRunIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h   2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h      2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -127,6 +127,9 @@
</span><span class="cx">     TextBoxSelectableRange selectableRange() const;
</span><span class="cx">     LayoutRect selectionRect(unsigned start, unsigned end) const;
</span><span class="cx"> 
</span><ins>+    bool isCombinedText() const;
+    const FontCascade& fontCascade() const;
+
</ins><span class="cx">     TextRun createTextRun() const;
</span><span class="cx"> 
</span><span class="cx">     const RenderText& renderer() const { return downcast<RenderText>(PathRun::renderer()); }
</span><span class="lines">@@ -366,13 +369,6 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline LayoutRect PathTextRun::selectionRect(unsigned start, unsigned end) const
-{
-    return WTF::switchOn(m_pathVariant, [&](auto& path) {
-        return path.selectionRect(start, end);
-    });
-}
-
</del><span class="cx"> inline TextRun PathTextRun::createTextRun() const
</span><span class="cx"> {
</span><span class="cx">     return WTF::switchOn(m_pathVariant, [&](auto& path) {
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationRunIteratorLegacyPathh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h 2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h    2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -76,7 +76,6 @@
</span><span class="cx">     float positionForOffset(unsigned offset) const { return inlineTextBox()->positionForOffset(offset); }
</span><span class="cx"> 
</span><span class="cx">     TextBoxSelectableRange selectableRange() const { return inlineTextBox()->selectableRange(); }
</span><del>-    LayoutRect selectionRect(unsigned start, unsigned end) const { return inlineTextBox()->localSelectionRect(start, end); }
</del><span class="cx"> 
</span><span class="cx">     TextRun createTextRun() const { return inlineTextBox()->createTextRun(); }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationRunIteratorModernPathh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h 2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h    2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -110,30 +110,6 @@
</span><span class="cx">         };
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    LayoutRect selectionRect(unsigned rangeStart, unsigned rangeEnd) const
-    {
-        auto [clampedStart, clampedEnd] = selectableRange().clamp(rangeStart, rangeEnd);
-
-        if (clampedStart >= clampedEnd && !(rangeStart == rangeEnd && rangeStart >= start() && rangeStart <= end()))
-            return { };
-
-        auto logicalLeft = LayoutUnit(isHorizontal() ? rect().x() : rect().y());
-        auto logicalRight = LayoutUnit(isHorizontal() ? rect().maxX() : rect().maxY());
-        auto logicalWidth = logicalRight - logicalLeft;
-
-        // FIXME: These should share implementation with the line iterator.
-        auto selectionTop = LayoutUnit::fromFloatRound(line().enclosingContentTop());
-        auto selectionHeight = LayoutUnit::fromFloatRound(line().enclosingContentBottom() - line().enclosingContentTop());
-
-        LayoutRect selectionRect { logicalLeft, selectionTop, logicalWidth, selectionHeight };
-
-        TextRun textRun = createTextRun(HyphenMode::Include);
-        if (clampedStart || clampedEnd != textRun.length())
-            run().style().fontCascade().adjustSelectionRectForText(textRun, selectionRect, clampedStart, clampedEnd);
-
-        return snappedSelectionRect(selectionRect, logicalRight, selectionTop, selectionHeight, isHorizontal());
-    }
-
</del><span class="cx">     TextRun createTextRun() const
</span><span class="cx">     {
</span><span class="cx">         return createTextRun(HyphenMode::Include);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp       2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp  2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -3207,13 +3207,6 @@
</span><span class="cx">     return LayoutUnit { style().overflowY() == Overflow::Visible ? lastBaseline : std::min(boxHeight, lastBaseline) };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RenderBlockFlow::setSelectionState(HighlightState state)
-{
-    if (state != HighlightState::None)
-        ensureLineBoxes();
-    RenderBoxModelObject::setSelectionState(state);
-}
-
</del><span class="cx"> LayoutUnit RenderBlockFlow::adjustSelectionTopForPrecedingBlock(LayoutUnit top) const
</span><span class="cx"> {
</span><span class="cx">     if (selectionState() != RenderObject::HighlightState::Inside && selectionState() != RenderObject::HighlightState::End)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.h 2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.h    2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -558,7 +558,6 @@
</span><span class="cx">     int m_widthForTextAutosizing;
</span><span class="cx">     unsigned m_lineCountForTextAutosizing : 2;
</span><span class="cx"> #endif
</span><del>-    void setSelectionState(HighlightState) final;
</del><span class="cx"> 
</span><span class="cx"> public:
</span><span class="cx">     // FIXME-BLOCKFLOW: These can be made protected again once all callers have been moved here.
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp  2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp     2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -1800,13 +1800,6 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderObject::setSelectionState(HighlightState state)
</span><span class="cx"> {
</span><del>-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-    if (state != HighlightState::None) {
-        if (auto* lineLayout = LayoutIntegration::LineLayout::containing(*this))
-            lineLayout->flow().ensureLineBoxes();
-    }
-#endif
-
</del><span class="cx">     m_bitfields.setSelectionState(state);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingTextBoxPaintercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/TextBoxPainter.cpp (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/TextBoxPainter.cpp        2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/rendering/TextBoxPainter.cpp   2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool shouldRotate = !textBox().isHorizontal() && !combinedText();
</del><ins>+    bool shouldRotate = !textBox().isHorizontal() && !textBox().isCombinedText();
</ins><span class="cx">     if (shouldRotate)
</span><span class="cx">         m_paintInfo.context().concatCTM(rotation(m_paintRect, Clockwise));
</span><span class="cx"> 
</span><span class="lines">@@ -317,7 +317,7 @@
</span><span class="cx">         if (m_style.hasAppleColorFilter())
</span><span class="cx">             textPainter.setShadowColorFilter(&m_style.appleColorFilter());
</span><span class="cx">     }
</span><del>-    textPainter.setEmphasisMark(emphasisMark, emphasisMarkOffset, combinedText());
</del><ins>+    textPainter.setEmphasisMark(emphasisMark, emphasisMarkOffset, textBox().isCombinedText() ? &downcast<RenderCombineText>(m_renderer) : nullptr);
</ins><span class="cx">     if (auto* debugShadow = debugTextShadow())
</span><span class="cx">         textPainter.setShadow(debugShadow);
</span><span class="cx"> 
</span><span class="lines">@@ -348,7 +348,7 @@
</span><span class="cx"> 
</span><span class="cx">     updateGraphicsContext(context, markedText.style.textStyles);
</span><span class="cx"> 
</span><del>-    bool isCombinedText = combinedText();
</del><ins>+    bool isCombinedText = textBox().isCombinedText();
</ins><span class="cx">     if (isCombinedText)
</span><span class="cx">         context.concatCTM(rotation(m_paintRect, Clockwise));
</span><span class="cx"> 
</span><span class="lines">@@ -566,17 +566,9 @@
</span><span class="cx">     return { boxOrigin, FloatSize(textBox().logicalWidth(), textBox().logicalHeight()) };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static const FontCascade& fontCascadeFor(const RenderText& renderer, const RenderStyle& textBoxStyle)
-{
-    if (is<RenderCombineText>(renderer))
-        return downcast<RenderCombineText>(renderer).textCombineFont();
-
-    return textBoxStyle.fontCascade();
-}
-
</del><span class="cx"> FloatRect TextBoxPainter::calculateDocumentMarkerBounds(const LayoutIntegration::TextRunIterator& textBox, const MarkedText& markedText)
</span><span class="cx"> {
</span><del>-    auto& font = fontCascadeFor(textBox->renderer(), textBox->style());
</del><ins>+    auto& font = textBox->fontCascade();
</ins><span class="cx">     auto ascent = font.fontMetrics().ascent();
</span><span class="cx">     auto fontSize = std::min(std::max(font.size(), 10.0f), 40.0f);
</span><span class="cx">     auto y = ascent + 0.11035 * fontSize;
</span><span class="lines">@@ -601,21 +593,16 @@
</span><span class="cx">     return m_renderer.view().selection().highlightStateForTextBox(m_renderer, m_selectableRange) != RenderObject::HighlightState::None;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-const RenderCombineText* TextBoxPainter::combinedText() const
-{
-    return is<RenderCombineText>(m_renderer) ? &downcast<RenderCombineText>(m_renderer) : nullptr;
-}
-
</del><span class="cx"> const FontCascade& TextBoxPainter::fontCascade() const
</span><span class="cx"> {
</span><del>-    return fontCascadeFor(m_renderer, m_style);
</del><ins>+    return m_textBox->fontCascade();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> FloatPoint TextBoxPainter::textOriginFromPaintRect(const FloatRect& paintRect) const
</span><span class="cx"> {
</span><span class="cx">     FloatPoint textOrigin { paintRect.x(), paintRect.y() + fontCascade().fontMetrics().ascent() };
</span><del>-    if (auto* combinedText = this->combinedText()) {
-        if (auto newOrigin = combinedText->computeTextOrigin(paintRect))
</del><ins>+    if (textBox().isCombinedText()) {
+        if (auto newOrigin = downcast<RenderCombineText>(m_renderer).computeTextOrigin(paintRect))
</ins><span class="cx">             textOrigin = newOrigin.value();
</span><span class="cx">     }
</span><span class="cx">     if (textBox().isHorizontal())
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingTextBoxPainterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/TextBoxPainter.h (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/TextBoxPainter.h  2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Source/WebCore/rendering/TextBoxPainter.h     2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -78,7 +78,6 @@
</span><span class="cx">     FloatRect computePaintRect(const LayoutPoint& paintOffset);
</span><span class="cx">     bool computeHaveSelection() const;
</span><span class="cx">     MarkedText createMarkedTextFromSelectionInBox();
</span><del>-    const RenderCombineText* combinedText() const;
</del><span class="cx">     const FontCascade& fontCascade() const;
</span><span class="cx">     FloatPoint textOriginFromPaintRect(const FloatRect&) const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Tools/ChangeLog       2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2021-09-20  Antti Koivisto  <antti@apple.com>
+
+        [LFC][Integration] Enable selections
+        https://bugs.webkit.org/show_bug.cgi?id=230463
+
+        Reviewed by Alan Bujtas.
+
+        * TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm:
+        (TestWebKitAPI::TEST):
+
</ins><span class="cx"> 2021-09-20  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Stop using makeRef(*this) / makeRefPtr(this)
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsiosAccessibilityTestsIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm (282763 => 282764)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm     2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm        2021-09-20 18:20:29 UTC (rev 282764)
</span><span class="lines">@@ -77,11 +77,11 @@
</span><span class="cx"> #if PLATFORM(MACCATALYST)
</span><span class="cx">     checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 8, 25, 19), 0);
</span><span class="cx">     checkCGRectValueAtIndex([webView rectsAtSelectionOffset:6 withText:@"second"], CGRectMake(36, 8, 46, 19), 0);
</span><del>-    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:13 withText:@"third"], CGRectMake(8, 28, 31, 19), 0);
</del><ins>+    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:13 withText:@"third"], CGRectMake(8, 27, 31, 20), 0);
</ins><span class="cx"> #else
</span><span class="cx">     checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 8, 26, 19), 0);
</span><span class="cx">     checkCGRectValueAtIndex([webView rectsAtSelectionOffset:6 withText:@"second"], CGRectMake(37, 8, 46, 19), 0);
</span><del>-    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:13 withText:@"third"], CGRectMake(8, 28, 31, 19), 0);
</del><ins>+    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:13 withText:@"third"], CGRectMake(8, 27, 31, 20), 0);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -146,9 +146,9 @@
</span><span class="cx">     // Clear the stored selection, we should use the current selection to retrieve rects
</span><span class="cx">     [webView _accessibilityClearSelection];
</span><span class="cx"> #if PLATFORM(MACCATALYST)
</span><del>-    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 28, 25, 19), 0);
</del><ins>+    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 27, 25, 20), 0);
</ins><span class="cx"> #else
</span><del>-    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 28, 26, 19), 0);
</del><ins>+    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 27, 26, 20), 0);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>