Title: [291207] trunk/Source/WebCore
Revision
291207
Author
za...@apple.com
Date
2022-03-12 06:30:45 -0800 (Sat, 12 Mar 2022)

Log Message

[IFC][Integration] RenderBlockFlow::findClosestTextAtAbsolutePoint should use root inline box iterator
https://bugs.webkit.org/show_bug.cgi?id=237786

Reviewed by Antti Koivisto.

Let's remove root inline box APIs from the line iterator interface.

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::findClosestTextAtAbsolutePoint): Replace line iterator with root inline box iterator
and check whether the local point is in between these root inline boxes.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291206 => 291207)


--- trunk/Source/WebCore/ChangeLog	2022-03-12 05:01:28 UTC (rev 291206)
+++ trunk/Source/WebCore/ChangeLog	2022-03-12 14:30:45 UTC (rev 291207)
@@ -1,3 +1,16 @@
+2022-03-12  Alan Bujtas  <za...@apple.com>
+
+        [IFC][Integration] RenderBlockFlow::findClosestTextAtAbsolutePoint should use root inline box iterator
+        https://bugs.webkit.org/show_bug.cgi?id=237786
+
+        Reviewed by Antti Koivisto.
+
+        Let's remove root inline box APIs from the line iterator interface.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::findClosestTextAtAbsolutePoint): Replace line iterator with root inline box iterator
+        and check whether the local point is in between these root inline boxes.
+
 2022-03-11  Per Arne Vollan  <pvol...@apple.com>
 
         [macOS] Image decoders should be restricted for Mail

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.h (291206 => 291207)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-12 05:01:28 UTC (rev 291206)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-12 14:30:45 UTC (rev 291207)
@@ -64,7 +64,6 @@
     LayoutRect selectionRect() const;
     RenderObject::HighlightState selectionState() const;
 
-    float y() const;
     float contentLogicalLeft() const;
     float contentLogicalRight() const;
     float contentLogicalWidth() const;
@@ -196,13 +195,6 @@
     return { LayoutPoint { contentLogicalLeft(), selectionTop() }, LayoutPoint { contentLogicalRight(), selectionBottom() } };
 }
 
-inline float Line::y() const
-{
-    return WTF::switchOn(m_pathVariant, [](const auto& path) {
-        return path.y();
-    });
-}
-
 inline float Line::contentLogicalLeft() const
 {
     return WTF::switchOn(m_pathVariant, [](const auto& path) {

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h (291206 => 291207)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h	2022-03-12 05:01:28 UTC (rev 291206)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h	2022-03-12 14:30:45 UTC (rev 291207)
@@ -51,7 +51,6 @@
     LayoutUnit lineBoxTop() const { return m_rootInlineBox->lineBoxTop(); }
     LayoutUnit lineBoxBottom() const { return m_rootInlineBox->lineBoxBottom(); }
 
-    float y() const { return m_rootInlineBox->y(); }
     float contentLogicalLeft() const { return m_rootInlineBox->logicalLeft(); }
     float contentLogicalRight() const { return m_rootInlineBox->logicalRight(); }
     float logicalHeight() const { return m_rootInlineBox->logicalHeight(); }

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h (291206 => 291207)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h	2022-03-12 05:01:28 UTC (rev 291206)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h	2022-03-12 14:30:45 UTC (rev 291207)
@@ -64,7 +64,6 @@
 
     float contentLogicalLeft() const { return line().lineBoxLeft() + line().contentLogicalOffset(); }
     float contentLogicalRight() const { return contentLogicalLeft() + line().contentLogicalWidth(); }
-    float y() const { return lineBoxTop(); }
     float logicalHeight() const { return lineBoxBottom() - lineBoxTop(); }
     bool isHorizontal() const { return line().isHorizontal(); }
     FontBaseline baselineType() const { return line().baselineType(); }

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (291206 => 291207)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-12 05:01:28 UTC (rev 291206)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-12 14:30:45 UTC (rev 291207)
@@ -3331,18 +3331,19 @@
     // Only check the gaps between the root line boxes. We deliberately ignore overflow because
     // experience has shown that hit tests on an exploded text node can fail when within the
     // overflow fragment.
-    for (auto current = InlineIterator::firstLineFor(blockFlow), last = InlineIterator::lastLineFor(blockFlow); current && current != last; current.traverseNext()) {
-        float currentBottom = current->y() + current->logicalHeight();
-        if (localPoint.y() < currentBottom)
-            return nullptr;
-        
-        auto next = current->next();
-        float nextTop = next->y();
-        if (localPoint.y() < nextTop) {
-            auto run = current->closestRunForLogicalLeftPosition(localPoint.x());
-            if (run && is<RenderText>(run->renderer()))
-                return const_cast<RenderText*>(&downcast<RenderText>(run->renderer()));
+    auto previousRootInlineBoxBottom = std::optional<float> { };
+    for (auto box = InlineIterator::firstRootInlineBoxFor(blockFlow); box; box.traverseNextInlineBox()) {
+        if (previousRootInlineBoxBottom) {
+            if (localPoint.y() < *previousRootInlineBoxBottom)
+                return nullptr;
+
+            if (localPoint.y() > *previousRootInlineBoxBottom && localPoint.y() < box->logicalTop()) {
+                auto run = box->line()->closestRunForLogicalLeftPosition(localPoint.x());
+                if (run && is<RenderText>(run->renderer()))
+                    return const_cast<RenderText*>(&downcast<RenderText>(run->renderer()));
+            }
         }
+        previousRootInlineBoxBottom = box->logicalBottom();
     }
     return nullptr;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to