Title: [291346] trunk/Source/WebCore
Revision
291346
Author
[email protected]
Date
2022-03-16 07:41:56 -0700 (Wed, 16 Mar 2022)

Log Message

[IFC][Integration] Move firstSelectedBox/lastSelectedBox out of InlineIterator::Line
https://bugs.webkit.org/show_bug.cgi?id=237941

Reviewed by Simon Fraser.

These functions don't belong in InlineIterator::Line (they are standalone functions with only one callsite).

* layout/integration/InlineIteratorLine.cpp:
(WebCore::InlineIterator::Line::firstSelectedBox const): Deleted.
(WebCore::InlineIterator::Line::lastSelectedBox const): Deleted.
* layout/integration/InlineIteratorLine.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::inlineSelectionGaps):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (291345 => 291346)


--- trunk/Source/WebCore/ChangeLog	2022-03-16 14:28:59 UTC (rev 291345)
+++ trunk/Source/WebCore/ChangeLog	2022-03-16 14:41:56 UTC (rev 291346)
@@ -1,3 +1,19 @@
+2022-03-16  Alan Bujtas  <[email protected]>
+
+        [IFC][Integration] Move firstSelectedBox/lastSelectedBox out of InlineIterator::Line
+        https://bugs.webkit.org/show_bug.cgi?id=237941
+
+        Reviewed by Simon Fraser.
+
+        These functions don't belong in InlineIterator::Line (they are standalone functions with only one callsite).
+
+        * layout/integration/InlineIteratorLine.cpp:
+        (WebCore::InlineIterator::Line::firstSelectedBox const): Deleted.
+        (WebCore::InlineIterator::Line::lastSelectedBox const): Deleted.
+        * layout/integration/InlineIteratorLine.h:
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::inlineSelectionGaps):
+
 2022-03-16  Chris Fleizach  <[email protected]>
 
         AX: imported/w3c/web-platform-tests/speech-api/SpeechSynthesis (layout-tests) are constant text failures

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp (291345 => 291346)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp	2022-03-16 14:28:59 UTC (rev 291345)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp	2022-03-16 14:41:56 UTC (rev 291346)
@@ -202,24 +202,6 @@
     return lineState;
 }
 
-LeafBoxIterator Line::firstSelectedBox() const
-{
-    for (auto box = firstLeafBox(); box; box.traverseNextOnLine()) {
-        if (box->selectionState() != RenderObject::HighlightState::None)
-            return box;
-    }
-    return { };
 }
-
-LeafBoxIterator Line::lastSelectedBox() const
-{
-    for (auto box = lastLeafBox(); box; box.traversePreviousOnLine()) {
-        if (box->selectionState() != RenderObject::HighlightState::None)
-            return box;
-    }
-    return { };
 }
 
-}
-}
-

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.h (291345 => 291346)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-16 14:28:59 UTC (rev 291345)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-03-16 14:41:56 UTC (rev 291346)
@@ -98,9 +98,6 @@
     LeafBoxIterator closestRunForPoint(const IntPoint& pointInContents, bool editableOnly) const;
     LeafBoxIterator closestRunForLogicalLeftPosition(int position, bool editableOnly = false) const;
     
-    LeafBoxIterator firstSelectedBox() const;
-    LeafBoxIterator lastSelectedBox() const;
-
 private:
     friend class LineIterator;
 

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (291345 => 291346)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-16 14:28:59 UTC (rev 291345)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-03-16 14:41:56 UTC (rev 291346)
@@ -3098,15 +3098,28 @@
 
         GapRects result;
 
-        auto firstBox = line->firstSelectedBox();
-        auto lastBox = line->lastSelectedBox();
+        auto firstSelectedBox = [&]() -> InlineIterator::LeafBoxIterator {
+            for (auto box = line->firstLeafBox(); box; box.traverseNextOnLine()) {
+                if (box->selectionState() != RenderObject::HighlightState::None)
+                    return box;
+            }
+            return { };
+        }();
 
+        auto lastSelectedBox = [&]() -> InlineIterator::LeafBoxIterator {
+            for (auto box = line->lastLeafBox(); box; box.traversePreviousOnLine()) {
+                if (box->selectionState() != RenderObject::HighlightState::None)
+                    return box;
+            }
+            return { };
+        }();
+
         if (leftGap) {
-            result.uniteLeft(logicalLeftSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, firstBox->renderer().parent(), LayoutUnit(firstBox->logicalLeft()),
+            result.uniteLeft(logicalLeftSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, firstSelectedBox->renderer().parent(), LayoutUnit(firstSelectedBox->logicalLeft()),
                 selTop, selHeight, cache, paintInfo));
         }
         if (rightGap) {
-            result.uniteRight(logicalRightSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, lastBox->renderer().parent(), LayoutUnit(lastBox->logicalRight()),
+            result.uniteRight(logicalRightSelectionGap(rootBlock, rootBlockPhysicalPosition, offsetFromRootBlock, lastSelectedBox->renderer().parent(), LayoutUnit(lastSelectedBox->logicalRight()),
                 selTop, selHeight, cache, paintInfo));
         }
 
@@ -3117,11 +3130,11 @@
         // |aaa|bbb|AAA|
         //  ___       _
         // We can see that the |bbb| run is not part of the selection while the runs around it are.
-        if (firstBox && firstBox != lastBox) {
+        if (firstSelectedBox && firstSelectedBox != lastSelectedBox) {
             // Now fill in any gaps on the line that occurred between two selected elements.
-            LayoutUnit lastLogicalLeft { firstBox->logicalRight() };
-            bool isPreviousBoxSelected = firstBox->selectionState() != RenderObject::HighlightState::None;
-            for (auto box = firstBox; box; box.traverseNextOnLine()) {
+            LayoutUnit lastLogicalLeft { firstSelectedBox->logicalRight() };
+            bool isPreviousBoxSelected = firstSelectedBox->selectionState() != RenderObject::HighlightState::None;
+            for (auto box = firstSelectedBox; box; box.traverseNextOnLine()) {
                 if (box->selectionState() != RenderObject::HighlightState::None) {
                     LayoutRect logicalRect { lastLogicalLeft, selTop, LayoutUnit(box->logicalLeft() - lastLogicalLeft), selHeight };
                     logicalRect.move(isHorizontalWritingMode() ? offsetFromRootBlock : LayoutSize(offsetFromRootBlock.height(), offsetFromRootBlock.width()));
@@ -3134,7 +3147,7 @@
                     }
                     lastLogicalLeft = box->logicalRight();
                 }
-                if (box == lastBox)
+                if (box == lastSelectedBox)
                     break;
                 isPreviousBoxSelected = box->selectionState() != RenderObject::HighlightState::None;
             }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to