Title: [291409] trunk/Source/WebCore
Revision
291409
Author
[email protected]
Date
2022-03-17 08:24:31 -0700 (Thu, 17 Mar 2022)

Log Message

[IFC][Integration] Replace enclosingTop/Bottom/height calls with Line::enclosingLogicalRect when applicable
https://bugs.webkit.org/show_bug.cgi?id=237996

Reviewed by Antti Koivisto.

This is in preparation for removing selection/hittesting related functions from InlineIterator::Line.

* layout/integration/InlineIteratorLine.h:
(WebCore::InlineIterator::Line::enclosingHeight const): Deleted.
* layout/integration/InlineIteratorTextBox.cpp:
(WebCore::InlineIterator::TextBox::selectionRect const):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::inlineSelectionGaps):
(WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::collectSelectionGeometries):
* rendering/TextBoxPainter.cpp:
(WebCore::TextBoxPainter::paintBackground):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291408 => 291409)


--- trunk/Source/WebCore/ChangeLog	2022-03-17 15:19:03 UTC (rev 291408)
+++ trunk/Source/WebCore/ChangeLog	2022-03-17 15:24:31 UTC (rev 291409)
@@ -1,3 +1,24 @@
+2022-03-17  Alan Bujtas  <[email protected]>
+
+        [IFC][Integration] Replace enclosingTop/Bottom/height calls with Line::enclosingLogicalRect when applicable
+        https://bugs.webkit.org/show_bug.cgi?id=237996
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for removing selection/hittesting related functions from InlineIterator::Line.
+
+        * layout/integration/InlineIteratorLine.h:
+        (WebCore::InlineIterator::Line::enclosingHeight const): Deleted.
+        * layout/integration/InlineIteratorTextBox.cpp:
+        (WebCore::InlineIterator::TextBox::selectionRect const):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::inlineSelectionGaps):
+        (WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::collectSelectionGeometries):
+        * rendering/TextBoxPainter.cpp:
+        (WebCore::TextBoxPainter::paintBackground):
+
 2022-03-17  Diego Pino Garcia  <[email protected]>
 
         Unreviewed, fix non-unified build after r291396

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.h (291408 => 291409)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-17 15:19:03 UTC (rev 291408)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-17 15:24:31 UTC (rev 291409)
@@ -60,7 +60,6 @@
 
     LayoutUnit enclosingTop() const;
     LayoutUnit enclosingBottom() const;
-    LayoutUnit enclosingHeight() const;
 
     LayoutRect enclosingLogicalRect() const;
     LayoutRect enclosingPhysicalRect() const;
@@ -177,11 +176,6 @@
     });
 }
 
-inline LayoutUnit Line::enclosingHeight() const
-{
-    return enclosingBottom() - enclosingTop();
-}
-
 inline LayoutUnit Line::lineBoxTop() const
 {
     return WTF::switchOn(m_pathVariant, [](const auto& path) {

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorTextBox.cpp (291408 => 291409)


--- trunk/Source/WebCore/layout/integration/InlineIteratorTextBox.cpp	2022-03-17 15:19:03 UTC (rev 291408)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorTextBox.cpp	2022-03-17 15:24:31 UTC (rev 291409)
@@ -45,16 +45,14 @@
     if (clampedStart >= clampedEnd && !(rangeStart == rangeEnd && rangeStart >= start() && rangeStart <= end()))
         return { };
 
-    auto selectionTop = line()->enclosingTop();
-    auto selectionHeight = line()->enclosingHeight();
+    auto lineSelectionRect = line()->enclosingLogicalRect();
+    auto selectionRect = LayoutRect { logicalLeft(), lineSelectionRect.y(), logicalWidth(), lineSelectionRect.height() };
 
-    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());
+    return snappedSelectionRect(selectionRect, logicalRight(), lineSelectionRect.y(), lineSelectionRect.height(), isHorizontal());
 }
 
 unsigned TextBox::offsetForPosition(float x, bool includePartialGlyphs) const

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (291408 => 291409)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-17 15:19:03 UTC (rev 291408)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-17 15:24:31 UTC (rev 291409)
@@ -3187,9 +3187,10 @@
 
     if (lastSelectedLine && selectionState() != HighlightState::End && selectionState() != HighlightState::Both) {
         // Update our lastY to be the bottom of the last selected line.
-        lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + lastSelectedLine->enclosingBottom();
-        lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastSelectedLine->enclosingBottom(), cache);
-        lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastSelectedLine->enclosingBottom(), cache);
+        auto lastLineSelectionBottom = lastSelectedLine->enclosingBottom();
+        lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + lastLineSelectionBottom;
+        lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastLineSelectionBottom, cache);
+        lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastLineSelectionBottom, cache);
     }
     return result;
 }
@@ -3393,7 +3394,8 @@
         lastLineWithChildren = line;
 
         // check if this root line box is located at this y coordinate
-        if (pointInLogicalContents.y() < line->enclosingBottom() || (blocksAreFlipped && pointInLogicalContents.y() == line->enclosingBottom())) {
+        auto selectionBottom = line->enclosingBottom();
+        if (pointInLogicalContents.y() < selectionBottom || (blocksAreFlipped && pointInLogicalContents.y() == selectionBottom)) {
             if (linesAreFlipped) {
                 auto nextLineWithChildren = line->next();
                 while (nextLineWithChildren && !nextLineWithChildren->firstLeafBox())

Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (291408 => 291409)


--- trunk/Source/WebCore/rendering/RenderImage.cpp	2022-03-17 15:19:03 UTC (rev 291408)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp	2022-03-17 15:24:31 UTC (rev 291409)
@@ -109,9 +109,9 @@
             lineExtentRect.setHeight(containingBlock->height());
         }
     } else {
-        auto line = run->line();
-        LayoutUnit selectionTop = !containingBlock->style().isFlippedBlocksWritingMode() ? line->enclosingTop() - logicalTop() : logicalBottom() - line->enclosingBottom();
-        imageRect = IntRect(0,  selectionTop, logicalWidth(), line->enclosingHeight());
+        auto selectionLogicalRect = run->line()->enclosingLogicalRect();
+        auto selectionTop = !containingBlock->style().isFlippedBlocksWritingMode() ? selectionLogicalRect.y() - logicalTop() : logicalBottom() - selectionLogicalRect.maxY();
+        imageRect = IntRect { 0,  selectionTop, logicalWidth(), selectionLogicalRect.height() };
         isFirstOnLine = !run->previousOnLine();
         isLastOnLine = !run->nextOnLine();
         LogicalSelectionOffsetCaches cache(*containingBlock);

Modified: trunk/Source/WebCore/rendering/TextBoxPainter.cpp (291408 => 291409)


--- trunk/Source/WebCore/rendering/TextBoxPainter.cpp	2022-03-17 15:19:03 UTC (rev 291408)
+++ trunk/Source/WebCore/rendering/TextBoxPainter.cpp	2022-03-17 15:24:31 UTC (rev 291409)
@@ -288,17 +288,14 @@
 
     // Note that if the text is truncated, we let the thing being painted in the truncation
     // draw its own highlight.
-
-    const auto line = textBox().line();
-    LayoutUnit selectionBottom = line->enclosingBottom();
-    LayoutUnit selectionTop = line->enclosingTopAdjustedForPrecedingBlock();
-
+    auto line = textBox().line();
+    auto selectionBottom = line->enclosingBottom();
+    auto selectionTop = line->enclosingTopAdjustedForPrecedingBlock();
     // Use same y positioning and height as for selection, so that when the selection and this subrange are on
     // the same word there are no pieces sticking out.
-    LayoutUnit deltaY { m_style.isFlippedLinesWritingMode() ? selectionBottom - textBox().logicalBottom() : textBox().logicalTop() - selectionTop };
-    LayoutUnit selectionHeight = std::max<LayoutUnit>(0, selectionBottom - selectionTop);
-
-    LayoutRect selectionRect { LayoutUnit(m_paintRect.x()), LayoutUnit(m_paintRect.y() - deltaY), LayoutUnit(textBox().logicalWidth()), selectionHeight };
+    auto deltaY = LayoutUnit { m_style.isFlippedLinesWritingMode() ? selectionBottom - textBox().logicalBottom() : textBox().logicalTop() - selectionTop };
+    auto selectionHeight = LayoutUnit { std::max(0_lu, selectionBottom - selectionTop) };
+    auto selectionRect = LayoutRect { LayoutUnit(m_paintRect.x()), LayoutUnit(m_paintRect.y() - deltaY), LayoutUnit(textBox().logicalWidth()), selectionHeight };
     fontCascade().adjustSelectionRectForText(m_paintTextRun, selectionRect, startOffset, endOffset);
 
     // FIXME: Support painting combined text. See <https://bugs.webkit.org/show_bug.cgi?id=180993>.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to