- Revision
- 291532
- Author
- [email protected]
- Date
- 2022-03-19 13:24:01 -0700 (Sat, 19 Mar 2022)
Log Message
[IFC][Integration] Rename InlineIterator::Line::blockDirectionPointInLine to contentStartInBlockDirection
https://bugs.webkit.org/show_bug.cgi?id=238101
Reviewed by Antti Koivisto.
blockDirectionPointInLine returns the position (vertical or horizontal, depending on the writing mode) where the content
starts (which for flipped writing mode is the bottom of the line).
Let's also move this function out of the Line class and have it as a standalone helper function (and move/rename some private Line
functions to public).
* editing/VisibleUnits.cpp:
(WebCore::absoluteLineDirectionPointToLocalPointInBlock):
* layout/integration/InlineIteratorLine.cpp:
(WebCore::InlineIterator::Line::blockDirectionPointInLine const): Deleted.
* layout/integration/InlineIteratorLine.h:
(WebCore::InlineIterator::contentStartInBlockDirection):
(WebCore::InlineIterator::Line::contentLogicalTopAdjustedForHitTesting const):
(WebCore::InlineIterator::Line::contentLogicalTopForHitTesting const): Deleted.
* layout/integration/InlineIteratorLineLegacyPath.h:
(WebCore::InlineIterator::LineIteratorLegacyPath::contentLogicalTopAdjustedForHitTesting const):
(WebCore::InlineIterator::LineIteratorLegacyPath::contentLogicalTopForHitTesting const): Deleted.
* layout/integration/InlineIteratorLineModernPath.h:
(WebCore::InlineIterator::LineIteratorModernPath::contentLogicalTopAdjustedForHitTesting const):
(WebCore::InlineIterator::LineIteratorModernPath::contentLogicalTopForHitTesting const): Deleted.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
* rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::positionForPoint):
* rendering/RenderText.cpp:
(WebCore::RenderText::positionForPoint):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (291531 => 291532)
--- trunk/Source/WebCore/ChangeLog 2022-03-19 20:05:24 UTC (rev 291531)
+++ trunk/Source/WebCore/ChangeLog 2022-03-19 20:24:01 UTC (rev 291532)
@@ -1,5 +1,38 @@
2022-03-19 Alan Bujtas <[email protected]>
+ [IFC][Integration] Rename InlineIterator::Line::blockDirectionPointInLine to contentStartInBlockDirection
+ https://bugs.webkit.org/show_bug.cgi?id=238101
+
+ Reviewed by Antti Koivisto.
+
+ blockDirectionPointInLine returns the position (vertical or horizontal, depending on the writing mode) where the content
+ starts (which for flipped writing mode is the bottom of the line).
+ Let's also move this function out of the Line class and have it as a standalone helper function (and move/rename some private Line
+ functions to public).
+
+ * editing/VisibleUnits.cpp:
+ (WebCore::absoluteLineDirectionPointToLocalPointInBlock):
+ * layout/integration/InlineIteratorLine.cpp:
+ (WebCore::InlineIterator::Line::blockDirectionPointInLine const): Deleted.
+ * layout/integration/InlineIteratorLine.h:
+ (WebCore::InlineIterator::contentStartInBlockDirection):
+ (WebCore::InlineIterator::Line::contentLogicalTopAdjustedForHitTesting const):
+ (WebCore::InlineIterator::Line::contentLogicalTopForHitTesting const): Deleted.
+ * layout/integration/InlineIteratorLineLegacyPath.h:
+ (WebCore::InlineIterator::LineIteratorLegacyPath::contentLogicalTopAdjustedForHitTesting const):
+ (WebCore::InlineIterator::LineIteratorLegacyPath::contentLogicalTopForHitTesting const): Deleted.
+ * layout/integration/InlineIteratorLineModernPath.h:
+ (WebCore::InlineIterator::LineIteratorModernPath::contentLogicalTopAdjustedForHitTesting const):
+ (WebCore::InlineIterator::LineIteratorModernPath::contentLogicalTopForHitTesting const): Deleted.
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::positionForPoint):
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::positionForPoint):
+
+2022-03-19 Alan Bujtas <[email protected]>
+
[IFC][Integration] Use a more descriptive name for InlineIterator::Line::enclosing* functions
https://bugs.webkit.org/show_bug.cgi?id=238094
Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (291531 => 291532)
--- trunk/Source/WebCore/editing/VisibleUnits.cpp 2022-03-19 20:05:24 UTC (rev 291531)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp 2022-03-19 20:24:01 UTC (rev 291532)
@@ -942,9 +942,9 @@
FloatPoint absoluteBlockPoint = containingBlock.localToAbsolute(FloatPoint()) - toFloatSize(containingBlock.scrollPosition());
if (containingBlock.isHorizontalWritingMode())
- return IntPoint(lineDirectionPoint - absoluteBlockPoint.x(), line->blockDirectionPointInLine());
+ return IntPoint(lineDirectionPoint - absoluteBlockPoint.x(), contentStartInBlockDirection(*line));
- return IntPoint(line->blockDirectionPointInLine(), lineDirectionPoint - absoluteBlockPoint.y());
+ return IntPoint(contentStartInBlockDirection(*line), lineDirectionPoint - absoluteBlockPoint.y());
}
static Element* rootEditableOrDocumentElement(Node& node, EditableType editableType)
Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp (291531 => 291532)
--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp 2022-03-19 20:05:24 UTC (rev 291531)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp 2022-03-19 20:24:01 UTC (rev 291532)
@@ -157,11 +157,6 @@
return closestBox;
}
-int Line::blockDirectionPointInLine() const
-{
- return !containingBlock().style().isFlippedBlocksWritingMode() ? std::max(contentLogicalTop(), contentLogicalTopForHitTesting()) : std::min(contentLogicalBottom(), contentLogicalBottomAdjustedForFollowingLine());
}
-
}
-}
Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.h (291531 => 291532)
--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.h 2022-03-19 20:05:24 UTC (rev 291531)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.h 2022-03-19 20:24:01 UTC (rev 291532)
@@ -65,10 +65,10 @@
float contentLogicalRight() const;
float contentLogicalWidth() const;
- LayoutUnit contentLogicalTopForHitTesting() const;
+ LayoutUnit contentLogicalTopAdjustedForHitTesting() const;
+ LayoutUnit contentLogicalTopAdjustedForPrecedingLine() const;
+ LayoutUnit contentLogicalBottomAdjustedForFollowingLine() const;
- int blockDirectionPointInLine() const;
-
bool isHorizontal() const;
FontBaseline baselineType() const;
@@ -92,12 +92,7 @@
private:
friend class LineIterator;
- // FIXME: This is temporary.
- friend class WebCore::LineSelection;
- LayoutUnit contentLogicalTopAdjustedForPrecedingLine() const;
- LayoutUnit contentLogicalBottomAdjustedForFollowingLine() const;
-
PathVariant m_pathVariant;
};
@@ -133,6 +128,12 @@
LineIterator lastLineFor(const RenderBlockFlow&);
// -----------------------------------------------
+inline LayoutUnit contentStartInBlockDirection(const Line& line)
+{
+ if (!line.containingBlock().style().isFlippedBlocksWritingMode())
+ return std::max(line.contentLogicalTop(), line.contentLogicalTopAdjustedForHitTesting());
+ return std::min(line.contentLogicalBottom(), line.contentLogicalBottomAdjustedForFollowingLine());
+}
inline Line::Line(PathVariant&& path)
: m_pathVariant(WTFMove(path))
@@ -160,10 +161,10 @@
});
}
-inline LayoutUnit Line::contentLogicalTopForHitTesting() const
+inline LayoutUnit Line::contentLogicalTopAdjustedForHitTesting() const
{
return WTF::switchOn(m_pathVariant, [](const auto& path) {
- return path.contentLogicalTopForHitTesting();
+ return path.contentLogicalTopAdjustedForHitTesting();
});
}
Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h (291531 => 291532)
--- trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h 2022-03-19 20:05:24 UTC (rev 291531)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h 2022-03-19 20:24:01 UTC (rev 291532)
@@ -46,7 +46,7 @@
LayoutUnit contentLogicalTop() const { return m_rootInlineBox->lineTop(); }
LayoutUnit contentLogicalBottom() const { return m_rootInlineBox->lineBottom(); }
LayoutUnit contentLogicalTopAdjustedForPrecedingLine() const { return m_rootInlineBox->selectionTop(); }
- LayoutUnit contentLogicalTopForHitTesting() const { return m_rootInlineBox->selectionTop(LegacyRootInlineBox::ForHitTesting::Yes); }
+ LayoutUnit contentLogicalTopAdjustedForHitTesting() const { return m_rootInlineBox->selectionTop(LegacyRootInlineBox::ForHitTesting::Yes); }
LayoutUnit contentLogicalBottomAdjustedForFollowingLine() const { return m_rootInlineBox->selectionBottom(); }
LayoutUnit lineBoxTop() const { return m_rootInlineBox->lineBoxTop(); }
LayoutUnit lineBoxBottom() const { return m_rootInlineBox->lineBoxBottom(); }
Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h (291531 => 291532)
--- trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h 2022-03-19 20:05:24 UTC (rev 291531)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h 2022-03-19 20:24:01 UTC (rev 291532)
@@ -58,7 +58,7 @@
// FIXME: Remove the containingBlock().borderAndPaddingBefore() offset after retiring legacy line layout. It also requires changes in RenderText::positionForPoint to find the first line with offset.
// - the "before" value is already factored in to the line offset
// - this logic negates the first line's natural offset (e.g. block has no border/padding but the first line has a computed offset).
- LayoutUnit contentLogicalTopForHitTesting() const { return !m_lineIndex ? containingBlock().borderAndPaddingBefore() : contentLogicalTopAdjustedForPrecedingLine(); };
+ LayoutUnit contentLogicalTopAdjustedForHitTesting() const { return !m_lineIndex ? containingBlock().borderAndPaddingBefore() : contentLogicalTopAdjustedForPrecedingLine(); };
// FIXME: Implement.
LayoutUnit contentLogicalBottomAdjustedForFollowingLine() const { return contentLogicalBottom(); }
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (291531 => 291532)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2022-03-19 20:05:24 UTC (rev 291531)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2022-03-19 20:24:01 UTC (rev 291532)
@@ -3421,7 +3421,7 @@
if (closestBox) {
if (moveCaretToBoundary) {
- LayoutUnit firstLineWithChildrenTop = std::min(firstLineWithChildren->contentLogicalTopForHitTesting(), LayoutUnit(firstLineWithChildren->contentLogicalTop()));
+ LayoutUnit firstLineWithChildrenTop = std::min(firstLineWithChildren->contentLogicalTopAdjustedForHitTesting(), LayoutUnit(firstLineWithChildren->contentLogicalTop()));
if (pointInLogicalContents.y() < firstLineWithChildrenTop
|| (blocksAreFlipped && pointInLogicalContents.y() == firstLineWithChildrenTop)) {
auto box = firstLineWithChildren->firstLeafBox();
@@ -3435,7 +3435,7 @@
}
// pass the box a top position that is inside it
- LayoutPoint point(pointInLogicalContents.x(), closestBox->line()->blockDirectionPointInLine());
+ auto point = LayoutPoint { pointInLogicalContents.x(), contentStartInBlockDirection(*closestBox->line()) };
if (!isHorizontalWritingMode())
point = point.transposedPoint();
if (closestBox->renderer().isReplacedOrInlineBlock())
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (291531 => 291532)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2022-03-19 20:05:24 UTC (rev 291531)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2022-03-19 20:24:01 UTC (rev 291532)
@@ -722,7 +722,7 @@
auto [top, bottom] = [&] {
if (auto run = InlineIterator::boxFor(*this)) {
auto line = run->line();
- return std::make_pair(line->contentLogicalTopForHitTesting(), LineSelection::logicalBottom(*line));
+ return std::make_pair(line->contentLogicalTopAdjustedForHitTesting(), LineSelection::logicalBottom(*line));
}
return std::make_pair(logicalTop(), logicalBottom());
}();
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (291531 => 291532)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2022-03-19 20:05:24 UTC (rev 291531)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2022-03-19 20:24:01 UTC (rev 291532)
@@ -674,7 +674,7 @@
run.traverseNextTextBox();
auto line = run->line();
- auto top = std::min(line->contentLogicalTopForHitTesting(), line->contentLogicalTop());
+ auto top = std::min(line->contentLogicalTopAdjustedForHitTesting(), line->contentLogicalTop());
if (pointBlockDirection > top || (!blocksAreFlipped && pointBlockDirection == top)) {
auto bottom = LineSelection::logicalBottom(*line);
if (auto nextLine = line->next())