Title: [291533] trunk/Source/WebCore
Revision
291533
Author
[email protected]
Date
2022-03-19 13:30:18 -0700 (Sat, 19 Mar 2022)

Log Message

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

Reviewed by Antti Koivisto.

1. Rename closestBoxForLogicalLeftPosition to closestBoxForHorizontalPosition and move it off of the Line class.
2. Replace InlineIterator::Line::closestBoxForPoint calls with closestBoxForHorizontalPosition.
3. Tidy up Line class.

* editing/VisibleUnits.cpp:
(WebCore::previousLinePosition):
(WebCore::nextLinePosition):
* layout/integration/InlineIteratorLine.cpp:
(WebCore::InlineIterator::closestBoxForHorizontalPosition):
(WebCore::InlineIterator::Line::closestBoxForPoint const): Deleted.
(WebCore::InlineIterator::Line::closestBoxForLogicalLeftPosition const): Deleted.
* layout/integration/InlineIteratorLine.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::findClosestTextAtAbsolutePoint):
(WebCore::RenderBlockFlow::positionForPointWithInlineChildren):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291532 => 291533)


--- trunk/Source/WebCore/ChangeLog	2022-03-19 20:24:01 UTC (rev 291532)
+++ trunk/Source/WebCore/ChangeLog	2022-03-19 20:30:18 UTC (rev 291533)
@@ -1,5 +1,28 @@
 2022-03-19  Alan Bujtas  <[email protected]>
 
+        [IFC][Integration] Remove redundant InlineIterator::Line::closestBoxForPoint function
+        https://bugs.webkit.org/show_bug.cgi?id=238103
+
+        Reviewed by Antti Koivisto.
+
+        1. Rename closestBoxForLogicalLeftPosition to closestBoxForHorizontalPosition and move it off of the Line class.
+        2. Replace InlineIterator::Line::closestBoxForPoint calls with closestBoxForHorizontalPosition.
+        3. Tidy up Line class.
+
+        * editing/VisibleUnits.cpp:
+        (WebCore::previousLinePosition):
+        (WebCore::nextLinePosition):
+        * layout/integration/InlineIteratorLine.cpp:
+        (WebCore::InlineIterator::closestBoxForHorizontalPosition):
+        (WebCore::InlineIterator::Line::closestBoxForPoint const): Deleted.
+        (WebCore::InlineIterator::Line::closestBoxForLogicalLeftPosition const): Deleted.
+        * layout/integration/InlineIteratorLine.h:
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::findClosestTextAtAbsolutePoint):
+        (WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
+
+2022-03-19  Alan Bujtas  <[email protected]>
+
         [IFC][Integration] Rename InlineIterator::Line::blockDirectionPointInLine to contentStartInBlockDirection
         https://bugs.webkit.org/show_bug.cgi?id=238101
 

Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (291532 => 291533)


--- trunk/Source/WebCore/editing/VisibleUnits.cpp	2022-03-19 20:24:01 UTC (rev 291532)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp	2022-03-19 20:30:18 UTC (rev 291533)
@@ -990,7 +990,7 @@
     if (line) {
         // FIXME: Can be wrong for multi-column layout and with transforms.
         auto pointInLine = absoluteLineDirectionPointToLocalPointInBlock(line, lineDirectionPoint);
-        auto box = line->closestBoxForPoint(pointInLine, isEditablePosition(p));
+        auto box = closestBoxForHorizontalPosition(*line, line->isHorizontal() ? pointInLine.x() : pointInLine.y(), isEditablePosition(p));
         if (!box)
             return VisiblePosition();
         auto& renderer = box->renderer();
@@ -1046,7 +1046,7 @@
     if (line) {
         // FIXME: Can be wrong for multi-column layout and with transforms.
         auto pointInLine = absoluteLineDirectionPointToLocalPointInBlock(line, lineDirectionPoint);
-        auto box = line->closestBoxForPoint(pointInLine, isEditablePosition(p));
+        auto box = closestBoxForHorizontalPosition(*line, line->isHorizontal() ? pointInLine.x() : pointInLine.y(), isEditablePosition(p));
         if (!box)
             return VisiblePosition();
         auto& renderer = box->renderer();

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp (291532 => 291533)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp	2022-03-19 20:24:01 UTC (rev 291532)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp	2022-03-19 20:30:18 UTC (rev 291533)
@@ -115,19 +115,14 @@
     });
 }
 
-LeafBoxIterator Line::closestBoxForPoint(const IntPoint& pointInContents, bool editableOnly) const
+LeafBoxIterator closestBoxForHorizontalPosition(const Line& line, float horizontalPosition, bool editableOnly)
 {
-    return closestBoxForLogicalLeftPosition(isHorizontal() ? pointInContents.x() : pointInContents.y(), editableOnly);
-}
-
-LeafBoxIterator Line::closestBoxForLogicalLeftPosition(int leftPosition, bool editableOnly) const
-{
     auto isEditable = [&](auto box) {
         return box && box->renderer().node() && box->renderer().node()->hasEditableStyle();
     };
 
-    auto firstBox = this->firstLeafBox();
-    auto lastBox = this->lastLeafBox();
+    auto firstBox = line.firstLeafBox();
+    auto lastBox = line.lastLeafBox();
 
     if (firstBox != lastBox) {
         if (firstBox->isLineBreak())
@@ -139,16 +134,16 @@
     if (firstBox == lastBox && (!editableOnly || isEditable(firstBox)))
         return firstBox;
 
-    if (firstBox && leftPosition <= firstBox->logicalLeft() && !firstBox->renderer().isListMarker() && (!editableOnly || isEditable(firstBox)))
+    if (firstBox && horizontalPosition <= firstBox->logicalLeft() && !firstBox->renderer().isListMarker() && (!editableOnly || isEditable(firstBox)))
         return firstBox;
 
-    if (lastBox && leftPosition >= lastBox->logicalRight() && !lastBox->renderer().isListMarker() && (!editableOnly || isEditable(lastBox)))
+    if (lastBox && horizontalPosition >= lastBox->logicalRight() && !lastBox->renderer().isListMarker() && (!editableOnly || isEditable(lastBox)))
         return lastBox;
 
     auto closestBox = lastBox;
     for (auto box = firstBox; box; box = box.traverseNextOnLineIgnoringLineBreak()) {
         if (!box->renderer().isListMarker() && (!editableOnly || isEditable(box))) {
-            if (leftPosition < box->logicalRight())
+            if (horizontalPosition < box->logicalRight())
                 return box;
             closestBox = box;
         }

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.h (291532 => 291533)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-19 20:24:01 UTC (rev 291532)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-19 20:30:18 UTC (rev 291533)
@@ -69,18 +69,15 @@
     LayoutUnit contentLogicalTopAdjustedForPrecedingLine() const;
     LayoutUnit contentLogicalBottomAdjustedForFollowingLine() const;
 
+    const RenderBlockFlow& containingBlock() const;
+    RenderFragmentContainer* containingFragment() const;
+
     bool isHorizontal() const;
-
     FontBaseline baselineType() const;
 
-    const RenderBlockFlow& containingBlock() const;
-
-    // FIXME: We may move these multi-column bits to some dedicated structures.
-    RenderFragmentContainer* containingFragment() const;
+    bool isFirst() const;
     bool isFirstAfterPageBreak() const;
 
-    bool isFirst() const;
-
     LeafBoxIterator firstLeafBox() const;
     LeafBoxIterator lastLeafBox() const;
 
@@ -87,9 +84,6 @@
     LineIterator next() const;
     LineIterator previous() const;
 
-    LeafBoxIterator closestBoxForPoint(const IntPoint& pointInContents, bool editableOnly) const;
-    LeafBoxIterator closestBoxForLogicalLeftPosition(int position, bool editableOnly = false) const;
-    
 private:
     friend class LineIterator;
 
@@ -126,6 +120,7 @@
 
 LineIterator firstLineFor(const RenderBlockFlow&);
 LineIterator lastLineFor(const RenderBlockFlow&);
+LeafBoxIterator closestBoxForHorizontalPosition(const Line&, float horizontalPosition, bool editableOnly = false);
 
 // -----------------------------------------------
 inline LayoutUnit contentStartInBlockDirection(const Line& line)

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (291532 => 291533)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-19 20:24:01 UTC (rev 291532)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-19 20:30:18 UTC (rev 291533)
@@ -3353,7 +3353,7 @@
                 return nullptr;
 
             if (localPoint.y() > *previousRootInlineBoxBottom && localPoint.y() < box->logicalTop()) {
-                auto closestBox = box->line()->closestBoxForLogicalLeftPosition(localPoint.x());
+                auto closestBox = closestBoxForHorizontalPosition(*box->line(), localPoint.x());
                 if (closestBox && is<RenderText>(closestBox->renderer()))
                     return const_cast<RenderText*>(&downcast<RenderText>(closestBox->renderer()));
             }
@@ -3406,7 +3406,7 @@
                     && (pointInLogicalContents.y() > nextLineWithChildren->lineBoxTop() || (!blocksAreFlipped && pointInLogicalContents.y() == nextLineWithChildren->lineBoxTop())))
                     continue;
             }
-            closestBox = line->closestBoxForLogicalLeftPosition(pointInLogicalContents.x());
+            closestBox = closestBoxForHorizontalPosition(*line, pointInLogicalContents.x());
             if (closestBox)
                 break;
         }
@@ -3416,7 +3416,7 @@
 
     if (!moveCaretToBoundary && !closestBox && lastLineWithChildren) {
         // y coordinate is below last root line box, pretend we hit it
-        closestBox = lastLineWithChildren->closestBoxForLogicalLeftPosition(pointInLogicalContents.x());
+        closestBox = closestBoxForHorizontalPosition(*lastLineWithChildren, pointInLogicalContents.x());
     }
 
     if (closestBox) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to