Title: [291463] trunk/Source/WebCore
Revision
291463
Author
[email protected]
Date
2022-03-17 19:30:52 -0700 (Thu, 17 Mar 2022)

Log Message

[IFC][Integration] Introduce LineSelection
https://bugs.webkit.org/show_bug.cgi?id=237997

Reviewed by Antti Koivisto.

Use LineSelection to retrieve line based selection information.
This is in preparation for removing selection/hittesting related functions from InlineIterator::Line.

* WebCore.xcodeproj/project.pbxproj:
* editing/VisiblePosition.cpp:
(WebCore::VisiblePosition::absoluteSelectionBoundsForLine const):
* layout/integration/InlineIteratorLine.h:
* layout/integration/InlineIteratorTextBox.cpp:
(WebCore::InlineIterator::TextBox::selectionRect const):
* layout/integration/LineSelection.h: Added.
(WebCore::LineSelection::logicalTop):
(WebCore::LineSelection::logicalBottom):
(WebCore::LineSelection::logicalRect):
(WebCore::LineSelection::physicalRect):
(WebCore::LineSelection::logicalTopAdjustedForPrecedingBlock):
(WebCore::LineSelection::logicalHeightAdjustedForPrecedingBlock):
(WebCore::LineSelection::selectionState):
* rendering/CaretRectComputation.cpp:
(WebCore::computeCaretRectForLinePosition):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::adjustEnclosingTopForPrecedingBlock const):
(WebCore::RenderBlockFlow::inlineSelectionGaps):
(WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::collectSelectionGeometries):
* rendering/RenderLineBreak.cpp:
(WebCore::RenderLineBreak::collectSelectionGeometries):
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::positionForPoint):
* rendering/RenderText.cpp:
(WebCore::RenderText::positionForPoint):
* rendering/TextBoxPainter.cpp:
(WebCore::TextBoxPainter::paintBackground):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291462 => 291463)


--- trunk/Source/WebCore/ChangeLog	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/ChangeLog	2022-03-18 02:30:52 UTC (rev 291463)
@@ -1,3 +1,44 @@
+2022-03-17  Alan Bujtas  <[email protected]>
+
+        [IFC][Integration] Introduce LineSelection
+        https://bugs.webkit.org/show_bug.cgi?id=237997
+
+        Reviewed by Antti Koivisto.
+
+        Use LineSelection to retrieve line based selection information.
+        This is in preparation for removing selection/hittesting related functions from InlineIterator::Line.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * editing/VisiblePosition.cpp:
+        (WebCore::VisiblePosition::absoluteSelectionBoundsForLine const):
+        * layout/integration/InlineIteratorLine.h:
+        * layout/integration/InlineIteratorTextBox.cpp:
+        (WebCore::InlineIterator::TextBox::selectionRect const):
+        * layout/integration/LineSelection.h: Added.
+        (WebCore::LineSelection::logicalTop):
+        (WebCore::LineSelection::logicalBottom):
+        (WebCore::LineSelection::logicalRect):
+        (WebCore::LineSelection::physicalRect):
+        (WebCore::LineSelection::logicalTopAdjustedForPrecedingBlock):
+        (WebCore::LineSelection::logicalHeightAdjustedForPrecedingBlock):
+        (WebCore::LineSelection::selectionState):
+        * rendering/CaretRectComputation.cpp:
+        (WebCore::computeCaretRectForLinePosition):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::adjustEnclosingTopForPrecedingBlock const):
+        (WebCore::RenderBlockFlow::inlineSelectionGaps):
+        (WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::collectSelectionGeometries):
+        * rendering/RenderLineBreak.cpp:
+        (WebCore::RenderLineBreak::collectSelectionGeometries):
+        * rendering/RenderReplaced.cpp:
+        (WebCore::RenderReplaced::positionForPoint):
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::positionForPoint):
+        * rendering/TextBoxPainter.cpp:
+        (WebCore::TextBoxPainter::paintBackground):
+
 2022-03-17  Devin Rousso  <[email protected]>
 
         [Apple Pay] REGRESSION(r283431): `HAVE_PASSKIT_PAYMENT_METHOD_BILLING_ADDRESS` was removed without also removing where it was used

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (291462 => 291463)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2022-03-18 02:30:52 UTC (rev 291463)
@@ -2212,6 +2212,7 @@
 		6F0CD695229ED32700C5994E /* InlineLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F0CD694229ED32700C5994E /* InlineLine.h */; };
 		6F15522126476B5C00E353C6 /* TableWrapperBlockFormattingQuirks.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F15522026476B5B00E353C6 /* TableWrapperBlockFormattingQuirks.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F17264F2470C60B00518C96 /* TableWrapperBlockFormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F17264E2470C60A00518C96 /* TableWrapperBlockFormattingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		6F1B101427E2D524007178E6 /* LineSelection.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1B101327E2D524007178E6 /* LineSelection.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F1CC1DE225F8B4900720AD2 /* InlineTextItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1CC1DD225F8B4200720AD2 /* InlineTextItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F1E83A22665884C002E9D28 /* TableFormattingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1E83A02665884C002E9D28 /* TableFormattingConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F1E83A62665888C002E9D28 /* FormattingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1E83A52665888C002E9D28 /* FormattingConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10954,6 +10955,7 @@
 		6F15522026476B5B00E353C6 /* TableWrapperBlockFormattingQuirks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableWrapperBlockFormattingQuirks.h; sourceTree = "<group>"; };
 		6F17264C2470C5F700518C96 /* TableWrapperBlockFormattingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableWrapperBlockFormattingContext.cpp; sourceTree = "<group>"; };
 		6F17264E2470C60A00518C96 /* TableWrapperBlockFormattingContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableWrapperBlockFormattingContext.h; sourceTree = "<group>"; };
+		6F1B101327E2D524007178E6 /* LineSelection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineSelection.h; sourceTree = "<group>"; };
 		6F1CC1DC225F8B4100720AD2 /* InlineTextItem.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineTextItem.cpp; sourceTree = "<group>"; };
 		6F1CC1DD225F8B4200720AD2 /* InlineTextItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InlineTextItem.h; sourceTree = "<group>"; };
 		6F1E83A02665884C002E9D28 /* TableFormattingConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableFormattingConstraints.h; sourceTree = "<group>"; };
@@ -31535,6 +31537,7 @@
 				E4ABABDB236088FD00FA4345 /* LayoutIntegrationLineLayout.h */,
 				E4312AB524B3265600678349 /* LayoutIntegrationPagination.cpp */,
 				E4312AB724B3265600678349 /* LayoutIntegrationPagination.h */,
+				6F1B101327E2D524007178E6 /* LineSelection.h */,
 			);
 			path = integration;
 			sourceTree = "<group>";
@@ -36188,6 +36191,7 @@
 				B22279650D00BF220071B782 /* LinearGradientAttributes.h in Headers */,
 				AB31C91E10AE1B8E000C7B92 /* LineClampValue.h in Headers */,
 				FFEFAB2A18380DA000514534 /* LineLayoutState.h in Headers */,
+				6F1B101427E2D524007178E6 /* LineSelection.h in Headers */,
 				FFDBC047183D27B700407109 /* LineWidth.h in Headers */,
 				CBA9DC0B1DF44DF40005675C /* LinkHeader.h in Headers */,
 				5143B2631DDD15200014FAC6 /* LinkIcon.h in Headers */,
@@ -37943,6 +37947,7 @@
 				41EB797E27C3E45E001C3E3E /* VideoFrameLibWebRTC.h in Headers */,
 				41DEEFB62719BA1A00CB8D74 /* VideoFrameMetadata.h in Headers */,
 				41DEEFB02719B29000CB8D74 /* VideoFrameRequestCallback.h in Headers */,
+				416049332743B0E800A86FA0 /* VideoFrameTimeMetadata.h in Headers */,
 				52B0D4C01C57FD660077CE53 /* VideoFullscreenChangeObserver.h in Headers */,
 				3FBC4AF4189881560046EE38 /* VideoFullscreenInterfaceAVKit.h in Headers */,
 				52B0D4C21C57FF910077CE53 /* VideoFullscreenInterfaceMac.h in Headers */,
@@ -37953,7 +37958,6 @@
 				CDE83DB2183C44060031EAA3 /* VideoPlaybackQuality.h in Headers */,
 				075033A8252BD36800F70CE3 /* VideoPlaybackQualityMetrics.h in Headers */,
 				0757B13E214AE79900794B0D /* VideoPreset.h in Headers */,
-				416049332743B0E800A86FA0 /* VideoFrameTimeMetadata.h in Headers */,
 				CDC939A81E9BDFB100BB768D /* VideoToolboxSoftLink.h in Headers */,
 				BE88E0DF1715D2A200658D98 /* VideoTrack.h in Headers */,
 				CD1F9B1827023A2A00617EB6 /* VideoTrackClient.h in Headers */,

Modified: trunk/Source/WebCore/editing/VisiblePosition.cpp (291462 => 291463)


--- trunk/Source/WebCore/editing/VisiblePosition.cpp	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/editing/VisiblePosition.cpp	2022-03-18 02:30:52 UTC (rev 291463)
@@ -38,6 +38,7 @@
 #include "InlineIteratorBox.h"
 #include "InlineIteratorLine.h"
 #include "InlineRunAndOffset.h"
+#include "LineSelection.h"
 #include "Logging.h"
 #include "Range.h"
 #include "RenderBlockFlow.h"
@@ -669,7 +670,7 @@
         return { };
 
     auto line = run->line();
-    return line->containingBlock().localToAbsoluteQuad(FloatRect { line->enclosingPhysicalRect() }).boundingBox();
+    return line->containingBlock().localToAbsoluteQuad(FloatRect { LineSelection::physicalRect(*line) }).boundingBox();
 }
 
 int VisiblePosition::lineDirectionPointForBlockDirectionNavigation() const

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.h (291462 => 291463)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-18 02:30:52 UTC (rev 291463)
@@ -32,6 +32,9 @@
 #include <variant>
 
 namespace WebCore {
+
+class LineSelection;
+
 namespace InlineIterator {
 
 class LineIterator;
@@ -58,22 +61,12 @@
     LayoutUnit lineBoxBottom() const;
     LayoutUnit lineBoxHeight() const { return lineBoxBottom() - lineBoxTop(); }
 
-    LayoutUnit enclosingTop() const;
-    LayoutUnit enclosingBottom() const;
-
-    LayoutRect enclosingLogicalRect() const;
-    LayoutRect enclosingPhysicalRect() const;
-
-    LayoutUnit enclosingTopForHitTesting() const;
-    LayoutUnit enclosingTopAdjustedForPrecedingBlock() const;
-    LayoutUnit enclosingHeightAdjustedForPrecedingBlock() const;
-
-    RenderObject::HighlightState selectionState() const;
-
     float contentLogicalLeft() const;
     float contentLogicalRight() const;
     float contentLogicalWidth() const;
 
+    LayoutUnit enclosingTopForHitTesting() const;
+
     int blockDirectionPointInLine() const;
 
     bool isHorizontal() const;
@@ -99,7 +92,20 @@
     
 private:
     friend class LineIterator;
+    // FIXME: This is temporary.
+    friend class WebCore::LineSelection;
 
+    LayoutUnit enclosingTop() const;
+    LayoutUnit enclosingBottom() const;
+
+    LayoutRect enclosingLogicalRect() const;
+    LayoutRect enclosingPhysicalRect() const;
+
+    LayoutUnit enclosingTopAdjustedForPrecedingBlock() const;
+    LayoutUnit enclosingHeightAdjustedForPrecedingBlock() const;
+
+    RenderObject::HighlightState selectionState() const;
+
     PathVariant m_pathVariant;
 };
 

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorTextBox.cpp (291462 => 291463)


--- trunk/Source/WebCore/layout/integration/InlineIteratorTextBox.cpp	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorTextBox.cpp	2022-03-18 02:30:52 UTC (rev 291463)
@@ -28,6 +28,7 @@
 
 #include "InlineIteratorLine.h"
 #include "LayoutIntegrationLineLayout.h"
+#include "LineSelection.h"
 #include "RenderCombineText.h"
 
 namespace WebCore {
@@ -45,7 +46,7 @@
     if (clampedStart >= clampedEnd && !(rangeStart == rangeEnd && rangeStart >= start() && rangeStart <= end()))
         return { };
 
-    auto lineSelectionRect = line()->enclosingLogicalRect();
+    auto lineSelectionRect = LineSelection::logicalRect(*line());
     auto selectionRect = LayoutRect { logicalLeft(), lineSelectionRect.y(), logicalWidth(), lineSelectionRect.height() };
 
     TextRun textRun = createTextRun();

Added: trunk/Source/WebCore/layout/integration/LineSelection.h (0 => 291463)


--- trunk/Source/WebCore/layout/integration/LineSelection.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/integration/LineSelection.h	2022-03-18 02:30:52 UTC (rev 291463)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "InlineIteratorLine.h"
+
+namespace WebCore {
+
+class LineSelection {
+public:
+    static LayoutUnit logicalTop(const InlineIterator::Line& line) { return line.enclosingTop(); }
+    static LayoutUnit logicalBottom(const InlineIterator::Line& line) { return line.enclosingBottom(); }
+
+    static LayoutRect logicalRect(const InlineIterator::Line& line) { return line.enclosingLogicalRect(); }
+    static LayoutRect physicalRect(const InlineIterator::Line& line) { return line.enclosingPhysicalRect(); }
+
+    static LayoutUnit logicalTopAdjustedForPrecedingBlock(const InlineIterator::Line& line) { return line.enclosingTopAdjustedForPrecedingBlock(); }
+    static LayoutUnit logicalHeightAdjustedForPrecedingBlock(const InlineIterator::Line& line) { return line.enclosingHeightAdjustedForPrecedingBlock(); }
+
+    static RenderObject::HighlightState selectionState(const InlineIterator::Line& line) { return line.selectionState(); }
+};
+
+}
+

Modified: trunk/Source/WebCore/rendering/CaretRectComputation.cpp (291462 => 291463)


--- trunk/Source/WebCore/rendering/CaretRectComputation.cpp	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/rendering/CaretRectComputation.cpp	2022-03-18 02:30:52 UTC (rev 291463)
@@ -29,6 +29,7 @@
 #include "Editing.h"
 #include "InlineIteratorLine.h"
 #include "InlineIteratorTextBox.h"
+#include "LineSelection.h"
 #include "RenderBlockFlow.h"
 #include "RenderInline.h"
 #include "RenderLineBreak.h"
@@ -112,7 +113,7 @@
 static LayoutRect computeCaretRectForLinePosition(const InlineIterator::LineIterator& line, float logicalLeftPosition, CaretRectMode caretRectMode)
 {
     auto& containingBlock = line->containingBlock();
-    auto lineSelectionRect = line->enclosingLogicalRect();
+    auto lineSelectionRect = LineSelection::logicalRect(*line);
 
     int height = lineSelectionRect.height();
     int top = lineSelectionRect.y();

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (291462 => 291463)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-18 02:30:52 UTC (rev 291463)
@@ -44,6 +44,7 @@
 #include "LayoutRepainter.h"
 #include "LegacyInlineTextBox.h"
 #include "LegacyLineLayout.h"
+#include "LineSelection.h"
 #include "Logging.h"
 #include "RenderCombineText.h"
 #include "RenderDeprecatedFlexibleBox.h"
@@ -3061,11 +3062,11 @@
         return top;
 
     if (auto lastLine = InlineIterator::lastLineFor(*blockBefore)) {
-        RenderObject::HighlightState lastLineSelectionState = lastLine->selectionState();
+        auto lastLineSelectionState = LineSelection::selectionState(*lastLine);
         if (lastLineSelectionState != RenderObject::HighlightState::Inside && lastLineSelectionState != RenderObject::HighlightState::Start)
             return top;
 
-        LayoutUnit lastLineSelectionBottom = lastLine->enclosingBottom() + offsetToBlockBefore.height();
+        auto lastLineSelectionBottom = LineSelection::logicalBottom(*lastLine) + offsetToBlockBefore.height();
         top = std::max(top, lastLineSelectionBottom);
     }
     return top;
@@ -3087,11 +3088,11 @@
     }
 
     auto hasSelectedChildren = [&](const InlineIterator::LineIterator& line) {
-        return line->selectionState() != RenderObject::HighlightState::None;
+        return LineSelection::selectionState(*line) != RenderObject::HighlightState::None;
     };
 
     auto lineSelectionGap = [&](const InlineIterator::LineIterator& line, LayoutUnit selTop, LayoutUnit selHeight) -> GapRects {
-        RenderObject::HighlightState lineState = line->selectionState();
+        auto lineState = LineSelection::selectionState(*line);
 
         bool leftGap, rightGap;
         getSelectionGapInfo(lineState, leftGap, rightGap);
@@ -3164,19 +3165,19 @@
 
     // Now paint the gaps for the lines.
     for (; line && hasSelectedChildren(line); line.traverseNext()) {
-        LayoutUnit selTop =  line->enclosingTopAdjustedForPrecedingBlock();
-        LayoutUnit selHeight = line->enclosingHeightAdjustedForPrecedingBlock();
+        auto selectionTop =  LineSelection::logicalTopAdjustedForPrecedingBlock(*line);
+        auto selectionHeight = LineSelection::logicalHeightAdjustedForPrecedingBlock(*line);
 
         if (!containsStart && !lastSelectedLine &&
             selectionState() != HighlightState::Start && selectionState() != HighlightState::Both && !isRubyBase())
-            result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, selTop, cache, paintInfo));
+            result.uniteCenter(blockSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, lastLogicalTop, lastLogicalLeft, lastLogicalRight, selectionTop, cache, paintInfo));
 
-        LayoutRect logicalRect { LayoutUnit(line->contentLogicalLeft()), selTop, LayoutUnit(line->contentLogicalWidth()), selTop + selHeight };
+        LayoutRect logicalRect { LayoutUnit(line->contentLogicalLeft()), selectionTop, LayoutUnit(line->contentLogicalWidth()), selectionTop + selectionHeight };
         logicalRect.move(isHorizontalWritingMode() ? offsetFromRootBlock : offsetFromRootBlock.transposedSize());
         LayoutRect physicalRect = rootBlock.logicalRectToPhysicalRect(rootBlockPhysicalPosition, logicalRect);
         if (!paintInfo || (isHorizontalWritingMode() && physicalRect.y() < paintInfo->rect.maxY() && physicalRect.maxY() > paintInfo->rect.y())
             || (!isHorizontalWritingMode() && physicalRect.x() < paintInfo->rect.maxX() && physicalRect.maxX() > paintInfo->rect.x()))
-            result.unite(lineSelectionGap(line, selTop, selHeight));
+            result.unite(lineSelectionGap(line, selectionTop, selectionHeight));
 
         lastSelectedLine = line;
     }
@@ -3187,7 +3188,7 @@
 
     if (lastSelectedLine && selectionState() != HighlightState::End && selectionState() != HighlightState::Both) {
         // Update our lastY to be the bottom of the last selected line.
-        auto lastLineSelectionBottom = lastSelectedLine->enclosingBottom();
+        auto lastLineSelectionBottom = LineSelection::logicalBottom(*lastSelectedLine);
         lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + lastLineSelectionBottom;
         lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastLineSelectionBottom, cache);
         lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastLineSelectionBottom, cache);
@@ -3394,7 +3395,7 @@
         lastLineWithChildren = line;
 
         // check if this root line box is located at this y coordinate
-        auto selectionBottom = line->enclosingBottom();
+        auto selectionBottom = LineSelection::logicalBottom(*line);
         if (pointInLogicalContents.y() < selectionBottom || (blocksAreFlipped && pointInLogicalContents.y() == selectionBottom)) {
             if (linesAreFlipped) {
                 auto nextLineWithChildren = line->next();

Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (291462 => 291463)


--- trunk/Source/WebCore/rendering/RenderImage.cpp	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp	2022-03-18 02:30:52 UTC (rev 291463)
@@ -48,6 +48,7 @@
 #include "ImageOverlay.h"
 #include "InlineIteratorInlineBox.h"
 #include "InlineIteratorLine.h"
+#include "LineSelection.h"
 #include "Page.h"
 #include "PaintInfo.h"
 #include "RenderChildIterator.h"
@@ -109,7 +110,7 @@
             lineExtentRect.setHeight(containingBlock->height());
         }
     } else {
-        auto selectionLogicalRect = run->line()->enclosingLogicalRect();
+        auto selectionLogicalRect = LineSelection::logicalRect(*run->line());
         auto selectionTop = !containingBlock->style().isFlippedBlocksWritingMode() ? selectionLogicalRect.y() - logicalTop() : logicalBottom() - selectionLogicalRect.maxY();
         imageRect = IntRect { 0,  selectionTop, logicalWidth(), selectionLogicalRect.height() };
         isFirstOnLine = !run->previousOnLine();

Modified: trunk/Source/WebCore/rendering/RenderLineBreak.cpp (291462 => 291463)


--- trunk/Source/WebCore/rendering/RenderLineBreak.cpp	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/rendering/RenderLineBreak.cpp	2022-03-18 02:30:52 UTC (rev 291463)
@@ -31,6 +31,7 @@
 #include "InlineRunAndOffset.h"
 #include "LegacyInlineElementBox.h"
 #include "LegacyRootInlineBox.h"
+#include "LineSelection.h"
 #include "LogicalSelectionOffsetCaches.h"
 #include "RenderBlock.h"
 #include "RenderView.h"
@@ -187,7 +188,7 @@
         return;
     auto line = run->line();
 
-    auto lineSelectionRect = line->enclosingLogicalRect();
+    auto lineSelectionRect = LineSelection::logicalRect(*line);
     LayoutRect rect = IntRect(run->logicalLeft(), lineSelectionRect.y(), 0, lineSelectionRect.height());
     if (!line->isHorizontal())
         rect = rect.transposedRect();

Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (291462 => 291463)


--- trunk/Source/WebCore/rendering/RenderReplaced.cpp	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp	2022-03-18 02:30:52 UTC (rev 291463)
@@ -37,6 +37,7 @@
 #include "InlineIteratorBox.h"
 #include "InlineIteratorLine.h"
 #include "LayoutRepainter.h"
+#include "LineSelection.h"
 #include "RenderBlock.h"
 #include "RenderFragmentedFlow.h"
 #include "RenderImage.h"
@@ -721,7 +722,7 @@
     auto [top, bottom] = [&] {
         if (auto run = InlineIterator::boxFor(*this)) {
             auto line = run->line();
-            return std::make_pair(line->enclosingTopForHitTesting(), line->enclosingBottom());
+            return std::make_pair(line->enclosingTopForHitTesting(), LineSelection::logicalBottom(*line));
         }
         return std::make_pair(logicalTop(), logicalBottom());
     }();

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (291462 => 291463)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2022-03-18 02:30:52 UTC (rev 291463)
@@ -42,6 +42,7 @@
 #include "InlineRunAndOffset.h"
 #include "LayoutIntegrationLineLayout.h"
 #include "LegacyEllipsisBox.h"
+#include "LineSelection.h"
 #include "Range.h"
 #include "RenderBlock.h"
 #include "RenderCombineText.h"
@@ -675,7 +676,7 @@
         auto line = run->line();
         LayoutUnit top = std::min(line->enclosingTopForHitTesting(), line->top());
         if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirection == top)) {
-            LayoutUnit bottom = line->enclosingBottom();
+            auto bottom = LineSelection::logicalBottom(*line);
             if (auto nextLine = line->next())
                 bottom = std::min(bottom, nextLine->top());
 

Modified: trunk/Source/WebCore/rendering/TextBoxPainter.cpp (291462 => 291463)


--- trunk/Source/WebCore/rendering/TextBoxPainter.cpp	2022-03-18 01:39:42 UTC (rev 291462)
+++ trunk/Source/WebCore/rendering/TextBoxPainter.cpp	2022-03-18 02:30:52 UTC (rev 291463)
@@ -31,6 +31,7 @@
 #include "GraphicsContext.h"
 #include "InlineIteratorLine.h"
 #include "LegacyInlineTextBox.h"
+#include "LineSelection.h"
 #include "PaintInfo.h"
 #include "RenderBlock.h"
 #include "RenderCombineText.h"
@@ -289,8 +290,8 @@
     // Note that if the text is truncated, we let the thing being painted in the truncation
     // draw its own highlight.
     auto line = textBox().line();
-    auto selectionBottom = line->enclosingBottom();
-    auto selectionTop = line->enclosingTopAdjustedForPrecedingBlock();
+    auto selectionBottom = LineSelection::logicalBottom(*line);
+    auto selectionTop = LineSelection::logicalTopAdjustedForPrecedingBlock(*line);
     // 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.
     auto deltaY = LayoutUnit { m_style.isFlippedLinesWritingMode() ? selectionBottom - textBox().logicalBottom() : textBox().logicalTop() - selectionTop };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to