Title: [291545] trunk/Source/WebCore
Revision
291545
Author
[email protected]
Date
2022-03-20 08:04:42 -0700 (Sun, 20 Mar 2022)

Log Message

[IFC][Integration] Remove redundant InlineIterator::Line::contentLogicalTopAdjustedForHitTesting
https://bugs.webkit.org/show_bug.cgi?id=238107

Reviewed by Antti Koivisto.

It looks like contentLogicalTopAdjustedForHitTesting is just the combination of
- containingBlock's border and padding before
- LineSelection::logicalTop (which is either the line's content top or the previous line's content bottom)
- line's content top

* layout/integration/InlineIteratorLine.h:
(WebCore::InlineIterator::contentStartInBlockDirection):
(WebCore::InlineIterator::Line::contentLogicalTopAdjustedForHitTesting const): Deleted.
* layout/integration/InlineIteratorLineModernPath.h:
(WebCore::InlineIterator::LineIteratorModernPath::contentLogicalTopAdjustedForPrecedingLine const):
(WebCore::InlineIterator::LineIteratorModernPath::contentLogicalTopAdjustedForHitTesting const): Deleted.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::positionForPoint): This seems to be missing the contentLogicalTop check.
* rendering/RenderText.cpp:
(WebCore::RenderText::positionForPoint):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291544 => 291545)


--- trunk/Source/WebCore/ChangeLog	2022-03-20 14:18:58 UTC (rev 291544)
+++ trunk/Source/WebCore/ChangeLog	2022-03-20 15:04:42 UTC (rev 291545)
@@ -1,3 +1,28 @@
+2022-03-20  Alan Bujtas  <[email protected]>
+
+        [IFC][Integration] Remove redundant InlineIterator::Line::contentLogicalTopAdjustedForHitTesting
+        https://bugs.webkit.org/show_bug.cgi?id=238107
+
+        Reviewed by Antti Koivisto.
+
+        It looks like contentLogicalTopAdjustedForHitTesting is just the combination of
+        - containingBlock's border and padding before
+        - LineSelection::logicalTop (which is either the line's content top or the previous line's content bottom)
+        - line's content top
+
+        * layout/integration/InlineIteratorLine.h:
+        (WebCore::InlineIterator::contentStartInBlockDirection):
+        (WebCore::InlineIterator::Line::contentLogicalTopAdjustedForHitTesting const): Deleted.
+        * layout/integration/InlineIteratorLineModernPath.h:
+        (WebCore::InlineIterator::LineIteratorModernPath::contentLogicalTopAdjustedForPrecedingLine const):
+        (WebCore::InlineIterator::LineIteratorModernPath::contentLogicalTopAdjustedForHitTesting const): Deleted.
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::positionForPoint): This seems to be missing the contentLogicalTop check.
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::positionForPoint):
+
 2022-03-20  Philippe Normand  <[email protected]>
 
         REGRESSION(r289154) [GSTREAMER] webrtc/vp8-then-h264.html is crashing after SDK update to fdo 21.08 and Gstreamer 1.20

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.h (291544 => 291545)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-20 14:18:58 UTC (rev 291544)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-20 15:04:42 UTC (rev 291545)
@@ -64,7 +64,6 @@
     float contentLogicalRight() const;
     float contentLogicalWidth() const;
 
-    float contentLogicalTopAdjustedForHitTesting() const;
     float contentLogicalTopAdjustedForPrecedingLine() const;
     float contentLogicalBottomAdjustedForFollowingLine() const;
 
@@ -122,10 +121,15 @@
 LeafBoxIterator closestBoxForHorizontalPosition(const Line&, float horizontalPosition, bool editableOnly = false);
 
 // -----------------------------------------------
+inline float previousLineContentBottomOrBorderAndPadding(const Line& line)
+{
+    return line.isFirst() ? line.containingBlock().borderAndPaddingBefore().toFloat() : line.contentLogicalTopAdjustedForPrecedingLine(); 
+}
+
 inline float contentStartInBlockDirection(const Line& line)
 {
     if (!line.containingBlock().style().isFlippedBlocksWritingMode())
-        return std::max(line.contentLogicalTop(), line.contentLogicalTopAdjustedForHitTesting());
+        return std::max(line.contentLogicalTop(), previousLineContentBottomOrBorderAndPadding(line));
     return std::min(line.contentLogicalBottom(), line.contentLogicalBottomAdjustedForFollowingLine());
 }
 
@@ -155,13 +159,6 @@
     });
 }
 
-inline float Line::contentLogicalTopAdjustedForHitTesting() const
-{
-    return WTF::switchOn(m_pathVariant, [](const auto& path) {
-        return path.contentLogicalTopAdjustedForHitTesting();
-    });
-}
-
 inline float Line::contentLogicalBottomAdjustedForFollowingLine() const
 {
     return WTF::switchOn(m_pathVariant, [](const auto& path) {

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h (291544 => 291545)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h	2022-03-20 14:18:58 UTC (rev 291544)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h	2022-03-20 15:04:42 UTC (rev 291545)
@@ -46,7 +46,6 @@
     float contentLogicalTop() const { return m_rootInlineBox->lineTop().toFloat(); }
     float contentLogicalBottom() const { return m_rootInlineBox->lineBottom().toFloat(); }
     float contentLogicalTopAdjustedForPrecedingLine() const { return m_rootInlineBox->selectionTop().toFloat(); }
-    float contentLogicalTopAdjustedForHitTesting() const { return m_rootInlineBox->selectionTop(LegacyRootInlineBox::ForHitTesting::Yes).toFloat(); }
     float contentLogicalBottomAdjustedForFollowingLine() const { return m_rootInlineBox->selectionBottom().toFloat(); }
     float lineBoxTop() const { return m_rootInlineBox->lineBoxTop().toFloat(); }
     float lineBoxBottom() const { return m_rootInlineBox->lineBoxBottom().toFloat(); }

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h (291544 => 291545)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h	2022-03-20 14:18:58 UTC (rev 291544)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h	2022-03-20 15:04:42 UTC (rev 291545)
@@ -55,10 +55,6 @@
     float lineBoxBottom() const { return line().lineBoxBottom(); }
 
     float contentLogicalTopAdjustedForPrecedingLine() const { return !m_lineIndex ? contentLogicalTop() : LineIteratorModernPath(*m_inlineContent, m_lineIndex - 1).contentLogicalBottomAdjustedForFollowingLine(); }
-    // FIXME: Remove the containingBlock().borderAndPaddingBefore() offset after retiring legacy line layout. It also requires changes in RenderText::positionForPoint to find the first line with offset.
-    // - the "before" value is already factored in to the line offset
-    // - this logic negates the first line's natural offset (e.g. block has no border/padding but the first line has a computed offset).
-    float contentLogicalTopAdjustedForHitTesting() const { return !m_lineIndex ? containingBlock().borderAndPaddingBefore().toFloat() : contentLogicalTopAdjustedForPrecedingLine(); };
     // FIXME: Implement.
     float contentLogicalBottomAdjustedForFollowingLine() const { return contentLogicalBottom(); }
 

Modified: trunk/Source/WebCore/rendering/LegacyRootInlineBox.cpp (291544 => 291545)


--- trunk/Source/WebCore/rendering/LegacyRootInlineBox.cpp	2022-03-20 14:18:58 UTC (rev 291544)
+++ trunk/Source/WebCore/rendering/LegacyRootInlineBox.cpp	2022-03-20 15:04:42 UTC (rev 291545)
@@ -469,7 +469,7 @@
     return nullptr;
 }
 
-LayoutUnit LegacyRootInlineBox::selectionTop(ForHitTesting forHitTesting) const
+LayoutUnit LegacyRootInlineBox::selectionTop() const
 {
     LayoutUnit selectionTop = m_lineTop;
     
@@ -514,7 +514,7 @@
     if (auto* previousBox = prevRootBox())
         prevBottom = previousBox->selectionBottom();
     else
-        prevBottom = forHitTesting == ForHitTesting::Yes ? blockFlow().borderAndPaddingBefore() : selectionTop;
+        prevBottom = selectionTop;
 
     if (prevBottom < selectionTop && blockFlow().containsFloats()) {
         // This line has actually been moved further down, probably from a large line-height, but possibly because the

Modified: trunk/Source/WebCore/rendering/LegacyRootInlineBox.h (291544 => 291545)


--- trunk/Source/WebCore/rendering/LegacyRootInlineBox.h	2022-03-20 14:18:58 UTC (rev 291544)
+++ trunk/Source/WebCore/rendering/LegacyRootInlineBox.h	2022-03-20 15:04:42 UTC (rev 291545)
@@ -73,8 +73,7 @@
     void setContainingFragment(RenderFragmentContainer&);
     void clearContainingFragment();
 
-    enum class ForHitTesting : bool { No, Yes };
-    LayoutUnit selectionTop(ForHitTesting = ForHitTesting::No) const;
+    LayoutUnit selectionTop() const;
     LayoutUnit selectionBottom() const;
     LayoutUnit selectionHeight() const { return std::max<LayoutUnit>(0, selectionBottom() - selectionTop()); }
 

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (291544 => 291545)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-20 14:18:58 UTC (rev 291544)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-20 15:04:42 UTC (rev 291545)
@@ -3421,7 +3421,7 @@
 
     if (closestBox) {
         if (moveCaretToBoundary) {
-            auto firstLineWithChildrenTop = LayoutUnit { std::min(firstLineWithChildren->contentLogicalTopAdjustedForHitTesting(), firstLineWithChildren->contentLogicalTop()) };
+            auto firstLineWithChildrenTop = LayoutUnit { std::min(previousLineContentBottomOrBorderAndPadding(*firstLineWithChildren), firstLineWithChildren->contentLogicalTop()) };
             if (pointInLogicalContents.y() < firstLineWithChildrenTop
                 || (blocksAreFlipped && pointInLogicalContents.y() == firstLineWithChildrenTop)) {
                 auto box = firstLineWithChildren->firstLeafBox();

Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (291544 => 291545)


--- trunk/Source/WebCore/rendering/RenderReplaced.cpp	2022-03-20 14:18:58 UTC (rev 291544)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp	2022-03-20 15:04:42 UTC (rev 291545)
@@ -722,7 +722,8 @@
     auto [top, bottom] = [&]() -> std::pair<float, float> {
         if (auto run = InlineIterator::boxFor(*this)) {
             auto line = run->line();
-            return std::make_pair(line->contentLogicalTopAdjustedForHitTesting(), LineSelection::logicalBottom(*line));
+            auto lineContentTop = LayoutUnit { std::min(previousLineContentBottomOrBorderAndPadding(*line), line->contentLogicalTop()) };
+            return std::make_pair(lineContentTop, LineSelection::logicalBottom(*line));
         }
         return std::make_pair(logicalTop(), logicalBottom());
     }();

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (291544 => 291545)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2022-03-20 14:18:58 UTC (rev 291544)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2022-03-20 15:04:42 UTC (rev 291545)
@@ -674,7 +674,7 @@
             run.traverseNextTextBox();
 
         auto line = run->line();
-        auto top = std::min(line->contentLogicalTopAdjustedForHitTesting(), line->contentLogicalTop());
+        auto top = LayoutUnit { std::min(previousLineContentBottomOrBorderAndPadding(*line), line->contentLogicalTop()) };
         if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirection == top)) {
             auto bottom = LineSelection::logicalBottom(*line);
             if (auto nextLine = line->next())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to