Title: [282764] trunk
Revision
282764
Author
[email protected]
Date
2021-09-20 11:20:29 -0700 (Mon, 20 Sep 2021)

Log Message

[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:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (282763 => 282764)


--- trunk/LayoutTests/ChangeLog	2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/LayoutTests/ChangeLog	2021-09-20 18:20:29 UTC (rev 282764)
@@ -1,3 +1,14 @@
+2021-09-20  Antti Koivisto  <[email protected]>
+
+        [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:
+
 2021-09-20  Eric Hutchison  <[email protected]>
 
         Update test expectations for http/tests/misc/iframe-reparenting-id-collision.html.

Added: trunk/LayoutTests/fast/repaint/selection-paint-invalidation-expected.txt (0 => 282764)


--- 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)
@@ -0,0 +1,7 @@
+A
+A
+(repaint rects
+  (rect 8 68 20 100)
+  (rect 8 68 20 100)
+)
+

Added: trunk/LayoutTests/fast/repaint/selection-paint-invalidation.html (0 => 282764)


--- 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)
@@ -0,0 +1,54 @@
+<!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>

Modified: trunk/LayoutTests/platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt (282763 => 282764)


--- 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)
@@ -22,12 +22,10 @@
       RenderBlock {HR} at (0,197) size 784x2 [border: (1px inset #000000)]
       RenderBlock {PRE} at (0,212) size 108x83 [border: (4px solid #0000FF)]
         RenderText {#text} at (4,4) size 100x75
-          text run at (4,4) width 86: "This   text"
-          text run at (89,4) width 15: "     "
+          text run at (4,4) width 100: "This   text     "
           text run at (4,19) width 71: "will wrap"
           text run at (74,19) width 1: " "
-          text run at (4,34) width 71: "and   fit"
-          text run at (74,34) width 24: "   "
+          text run at (4,34) width 94: "and   fit   "
           text run at (4,49) width 79: "within the"
           text run at (82,49) width 1: " "
           text run at (4,64) width 32: "box."

Modified: trunk/Source/WebCore/ChangeLog (282763 => 282764)


--- 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)
@@ -1,3 +1,74 @@
+2021-09-20  Antti Koivisto  <[email protected]>
+
+        [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:
+
 2021-09-20  Chris Dumez  <[email protected]>
 
         Unreviewed iOS debug build fix after r282755.

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp (282763 => 282764)


--- 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)
@@ -189,9 +189,6 @@
     case AvoidanceReason::FlowHasComplexFontCodePath:
         stream << "text with complex font codepath";
         break;
-    case AvoidanceReason::FlowChildIsSelected:
-        stream << "selected content";
-        break;
     case AvoidanceReason::FlowHasLineBoxContainGlyphs:
         stream << "-webkit-line-box-contain: glyphs";
         break;
@@ -527,8 +524,6 @@
 static OptionSet<AvoidanceReason> canUseForChild(const RenderBlockFlow& flow, const RenderObject& child, IncludeReasons includeReasons)
 {
     OptionSet<AvoidanceReason> reasons;
-    if (child.selectionState() != RenderObject::HighlightState::None)
-        SET_REASON_AND_RETURN_IF_NEEDED(FlowChildIsSelected, reasons, includeReasons);
     if (is<RenderCounter>(child))
         SET_REASON_AND_RETURN_IF_NEEDED(FlowTextIsRenderCounter, reasons, includeReasons);
     if (is<RenderText>(child)) {

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h (282763 => 282764)


--- 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)
@@ -80,7 +80,7 @@
     FlowHasComplexFontCodePath                   = 1LLU  << 40,
     FeatureIsDisabled                            = 1LLU  << 41,
     FlowDoesNotEstablishInlineFormattingContext  = 1LLU  << 42,
-    FlowChildIsSelected                          = 1LLU  << 43,
+    // Unused                                    = 1LLU  << 43,
     FlowHasHangingPunctuation                    = 1LLU  << 44,
     FlowHasLineBoxContainGlyphs                  = 1LLU  << 45,
     FlowTextHasSurrogatePair                     = 1LLU  << 46,

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp (282763 => 282764)


--- 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)
@@ -30,6 +30,7 @@
 #include "LayoutIntegrationLineIterator.h"
 #include "LayoutIntegrationLineLayout.h"
 #include "RenderBlockFlow.h"
+#include "RenderCombineText.h"
 #include "RenderLineBreak.h"
 #include "RenderView.h"
 
@@ -106,6 +107,39 @@
     return TextRunIterator(*this).traverseNextTextRunInTextOrder();
 }
 
+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();
+}
+
 RenderObject::HighlightState PathRun::selectionState() const
 {
     if (isText()) {

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h (282763 => 282764)


--- 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)
@@ -127,6 +127,9 @@
     TextBoxSelectableRange selectableRange() const;
     LayoutRect selectionRect(unsigned start, unsigned end) const;
 
+    bool isCombinedText() const;
+    const FontCascade& fontCascade() const;
+
     TextRun createTextRun() const;
 
     const RenderText& renderer() const { return downcast<RenderText>(PathRun::renderer()); }
@@ -366,13 +369,6 @@
     });
 }
 
-inline LayoutRect PathTextRun::selectionRect(unsigned start, unsigned end) const
-{
-    return WTF::switchOn(m_pathVariant, [&](auto& path) {
-        return path.selectionRect(start, end);
-    });
-}
-
 inline TextRun PathTextRun::createTextRun() const
 {
     return WTF::switchOn(m_pathVariant, [&](auto& path) {

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h (282763 => 282764)


--- 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)
@@ -76,7 +76,6 @@
     float positionForOffset(unsigned offset) const { return inlineTextBox()->positionForOffset(offset); }
 
     TextBoxSelectableRange selectableRange() const { return inlineTextBox()->selectableRange(); }
-    LayoutRect selectionRect(unsigned start, unsigned end) const { return inlineTextBox()->localSelectionRect(start, end); }
 
     TextRun createTextRun() const { return inlineTextBox()->createTextRun(); }
 

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h (282763 => 282764)


--- 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)
@@ -110,30 +110,6 @@
         };
     }
 
-    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());
-    }
-
     TextRun createTextRun() const
     {
         return createTextRun(HyphenMode::Include);

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (282763 => 282764)


--- 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)
@@ -3207,13 +3207,6 @@
     return LayoutUnit { style().overflowY() == Overflow::Visible ? lastBaseline : std::min(boxHeight, lastBaseline) };
 }
 
-void RenderBlockFlow::setSelectionState(HighlightState state)
-{
-    if (state != HighlightState::None)
-        ensureLineBoxes();
-    RenderBoxModelObject::setSelectionState(state);
-}
-
 LayoutUnit RenderBlockFlow::adjustSelectionTopForPrecedingBlock(LayoutUnit top) const
 {
     if (selectionState() != RenderObject::HighlightState::Inside && selectionState() != RenderObject::HighlightState::End)

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.h (282763 => 282764)


--- 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)
@@ -558,7 +558,6 @@
     int m_widthForTextAutosizing;
     unsigned m_lineCountForTextAutosizing : 2;
 #endif
-    void setSelectionState(HighlightState) final;
 
 public:
     // FIXME-BLOCKFLOW: These can be made protected again once all callers have been moved here.

Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (282763 => 282764)


--- 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)
@@ -1800,13 +1800,6 @@
 
 void RenderObject::setSelectionState(HighlightState state)
 {
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-    if (state != HighlightState::None) {
-        if (auto* lineLayout = LayoutIntegration::LineLayout::containing(*this))
-            lineLayout->flow().ensureLineBoxes();
-    }
-#endif
-
     m_bitfields.setSelectionState(state);
 }
 

Modified: trunk/Source/WebCore/rendering/TextBoxPainter.cpp (282763 => 282764)


--- 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)
@@ -87,7 +87,7 @@
         return;
     }
 
-    bool shouldRotate = !textBox().isHorizontal() && !combinedText();
+    bool shouldRotate = !textBox().isHorizontal() && !textBox().isCombinedText();
     if (shouldRotate)
         m_paintInfo.context().concatCTM(rotation(m_paintRect, Clockwise));
 
@@ -317,7 +317,7 @@
         if (m_style.hasAppleColorFilter())
             textPainter.setShadowColorFilter(&m_style.appleColorFilter());
     }
-    textPainter.setEmphasisMark(emphasisMark, emphasisMarkOffset, combinedText());
+    textPainter.setEmphasisMark(emphasisMark, emphasisMarkOffset, textBox().isCombinedText() ? &downcast<RenderCombineText>(m_renderer) : nullptr);
     if (auto* debugShadow = debugTextShadow())
         textPainter.setShadow(debugShadow);
 
@@ -348,7 +348,7 @@
 
     updateGraphicsContext(context, markedText.style.textStyles);
 
-    bool isCombinedText = combinedText();
+    bool isCombinedText = textBox().isCombinedText();
     if (isCombinedText)
         context.concatCTM(rotation(m_paintRect, Clockwise));
 
@@ -566,17 +566,9 @@
     return { boxOrigin, FloatSize(textBox().logicalWidth(), textBox().logicalHeight()) };
 }
 
-static const FontCascade& fontCascadeFor(const RenderText& renderer, const RenderStyle& textBoxStyle)
-{
-    if (is<RenderCombineText>(renderer))
-        return downcast<RenderCombineText>(renderer).textCombineFont();
-
-    return textBoxStyle.fontCascade();
-}
-
 FloatRect TextBoxPainter::calculateDocumentMarkerBounds(const LayoutIntegration::TextRunIterator& textBox, const MarkedText& markedText)
 {
-    auto& font = fontCascadeFor(textBox->renderer(), textBox->style());
+    auto& font = textBox->fontCascade();
     auto ascent = font.fontMetrics().ascent();
     auto fontSize = std::min(std::max(font.size(), 10.0f), 40.0f);
     auto y = ascent + 0.11035 * fontSize;
@@ -601,21 +593,16 @@
     return m_renderer.view().selection().highlightStateForTextBox(m_renderer, m_selectableRange) != RenderObject::HighlightState::None;
 }
 
-const RenderCombineText* TextBoxPainter::combinedText() const
-{
-    return is<RenderCombineText>(m_renderer) ? &downcast<RenderCombineText>(m_renderer) : nullptr;
-}
-
 const FontCascade& TextBoxPainter::fontCascade() const
 {
-    return fontCascadeFor(m_renderer, m_style);
+    return m_textBox->fontCascade();
 }
 
 FloatPoint TextBoxPainter::textOriginFromPaintRect(const FloatRect& paintRect) const
 {
     FloatPoint textOrigin { paintRect.x(), paintRect.y() + fontCascade().fontMetrics().ascent() };
-    if (auto* combinedText = this->combinedText()) {
-        if (auto newOrigin = combinedText->computeTextOrigin(paintRect))
+    if (textBox().isCombinedText()) {
+        if (auto newOrigin = downcast<RenderCombineText>(m_renderer).computeTextOrigin(paintRect))
             textOrigin = newOrigin.value();
     }
     if (textBox().isHorizontal())

Modified: trunk/Source/WebCore/rendering/TextBoxPainter.h (282763 => 282764)


--- 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)
@@ -78,7 +78,6 @@
     FloatRect computePaintRect(const LayoutPoint& paintOffset);
     bool computeHaveSelection() const;
     MarkedText createMarkedTextFromSelectionInBox();
-    const RenderCombineText* combinedText() const;
     const FontCascade& fontCascade() const;
     FloatPoint textOriginFromPaintRect(const FloatRect&) const;
 

Modified: trunk/Tools/ChangeLog (282763 => 282764)


--- trunk/Tools/ChangeLog	2021-09-20 18:07:41 UTC (rev 282763)
+++ trunk/Tools/ChangeLog	2021-09-20 18:20:29 UTC (rev 282764)
@@ -1,3 +1,13 @@
+2021-09-20  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] Enable selections
+        https://bugs.webkit.org/show_bug.cgi?id=230463
+
+        Reviewed by Alan Bujtas.
+
+        * TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm:
+        (TestWebKitAPI::TEST):
+
 2021-09-20  Chris Dumez  <[email protected]>
 
         Stop using makeRef(*this) / makeRefPtr(this)

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/AccessibilityTestsIOS.mm (282763 => 282764)


--- 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)
@@ -77,11 +77,11 @@
 #if PLATFORM(MACCATALYST)
     checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 8, 25, 19), 0);
     checkCGRectValueAtIndex([webView rectsAtSelectionOffset:6 withText:@"second"], CGRectMake(36, 8, 46, 19), 0);
-    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:13 withText:@"third"], CGRectMake(8, 28, 31, 19), 0);
+    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:13 withText:@"third"], CGRectMake(8, 27, 31, 20), 0);
 #else
     checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 8, 26, 19), 0);
     checkCGRectValueAtIndex([webView rectsAtSelectionOffset:6 withText:@"second"], CGRectMake(37, 8, 46, 19), 0);
-    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:13 withText:@"third"], CGRectMake(8, 28, 31, 19), 0);
+    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:13 withText:@"third"], CGRectMake(8, 27, 31, 20), 0);
 #endif
 }
 
@@ -146,9 +146,9 @@
     // Clear the stored selection, we should use the current selection to retrieve rects
     [webView _accessibilityClearSelection];
 #if PLATFORM(MACCATALYST)
-    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 28, 25, 19), 0);
+    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 27, 25, 20), 0);
 #else
-    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 28, 26, 19), 0);
+    checkCGRectValueAtIndex([webView rectsAtSelectionOffset:0 withText:@"first"], CGRectMake(8, 27, 26, 20), 0);
 #endif
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to