[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):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@291463 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/rendering/RenderBlockFlow.cpp b/Source/WebCore/rendering/RenderBlockFlow.cpp
index 6a9c75b..4046ffb 100644
--- a/Source/WebCore/rendering/RenderBlockFlow.cpp
+++ b/Source/WebCore/rendering/RenderBlockFlow.cpp
@@ -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();