Diff
Modified: trunk/Source/WebCore/ChangeLog (291534 => 291535)
--- trunk/Source/WebCore/ChangeLog 2022-03-19 23:22:30 UTC (rev 291534)
+++ trunk/Source/WebCore/ChangeLog 2022-03-20 00:45:31 UTC (rev 291535)
@@ -1,5 +1,58 @@
2022-03-19 Alan Bujtas <[email protected]>
+ [IFC][Integration] InlineIterator::Line functions should all return float values
+ https://bugs.webkit.org/show_bug.cgi?id=238106
+
+ Reviewed by Antti Koivisto.
+
+ Display structures are supposed to be all float based.
+
+ * layout/integration/InlineIteratorLine.h:
+ (WebCore::InlineIterator::Line::lineBoxHeight const):
+ (WebCore::InlineIterator::contentStartInBlockDirection):
+ (WebCore::InlineIterator::Line::contentLogicalTop const):
+ (WebCore::InlineIterator::Line::contentLogicalBottom const):
+ (WebCore::InlineIterator::Line::contentLogicalTopAdjustedForPrecedingLine const):
+ (WebCore::InlineIterator::Line::contentLogicalTopAdjustedForHitTesting const):
+ (WebCore::InlineIterator::Line::contentLogicalBottomAdjustedForFollowingLine const):
+ (WebCore::InlineIterator::Line::lineBoxTop const):
+ (WebCore::InlineIterator::Line::lineBoxBottom const):
+ * layout/integration/InlineIteratorLineLegacyPath.h:
+ (WebCore::InlineIterator::LineIteratorLegacyPath::contentLogicalTop const):
+ (WebCore::InlineIterator::LineIteratorLegacyPath::contentLogicalBottom const):
+ (WebCore::InlineIterator::LineIteratorLegacyPath::contentLogicalTopAdjustedForPrecedingLine const):
+ (WebCore::InlineIterator::LineIteratorLegacyPath::contentLogicalTopAdjustedForHitTesting const):
+ (WebCore::InlineIterator::LineIteratorLegacyPath::contentLogicalBottomAdjustedForFollowingLine const):
+ (WebCore::InlineIterator::LineIteratorLegacyPath::lineBoxTop const):
+ (WebCore::InlineIterator::LineIteratorLegacyPath::lineBoxBottom const):
+ * layout/integration/InlineIteratorLineModernPath.h:
+ (WebCore::InlineIterator::LineIteratorModernPath::contentLogicalTop const):
+ (WebCore::InlineIterator::LineIteratorModernPath::contentLogicalBottom const):
+ (WebCore::InlineIterator::LineIteratorModernPath::lineBoxTop const):
+ (WebCore::InlineIterator::LineIteratorModernPath::lineBoxBottom const):
+ (WebCore::InlineIterator::LineIteratorModernPath::contentLogicalTopAdjustedForPrecedingLine const):
+ (WebCore::InlineIterator::LineIteratorModernPath::contentLogicalTopAdjustedForHitTesting const):
+ (WebCore::InlineIterator::LineIteratorModernPath::contentLogicalBottomAdjustedForFollowingLine const):
+ * layout/integration/LineSelection.h:
+ (WebCore::LineSelection::logicalTop):
+ (WebCore::LineSelection::logicalBottom):
+ (WebCore::LineSelection::logicalRect):
+ (WebCore::LineSelection::physicalRect):
+ (WebCore::LineSelection::logicalTopAdjustedForPrecedingBlock):
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::adjustEnclosingTopForPrecedingBlock const):
+ (WebCore::RenderBlockFlow::inlineSelectionGaps):
+ (WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
+ (WebCore::RenderBlockFlow::addFocusRingRectsForInlineChildren):
+ * rendering/RenderInline.cpp:
+ (WebCore::RenderInline::paintOutline):
+ * rendering/RenderReplaced.cpp:
+ (WebCore::RenderReplaced::positionForPoint):
+ * rendering/TextBoxPainter.cpp:
+ (WebCore::TextBoxPainter::paintBackground):
+
+2022-03-19 Alan Bujtas <[email protected]>
+
[IFC][Integration] Remove redundant InlineIterator::Line::closestBoxForPoint function
https://bugs.webkit.org/show_bug.cgi?id=238103
Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.h (291534 => 291535)
--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.h 2022-03-19 23:22:30 UTC (rev 291534)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.h 2022-03-20 00:45:31 UTC (rev 291535)
@@ -54,20 +54,19 @@
Line(PathVariant&&);
- LayoutUnit lineBoxTop() const;
- LayoutUnit lineBoxBottom() const;
- LayoutUnit lineBoxHeight() const { return lineBoxBottom() - lineBoxTop(); }
+ float lineBoxTop() const;
+ float lineBoxBottom() const;
+ float lineBoxHeight() const { return lineBoxBottom() - lineBoxTop(); }
- // FIXME: Make sure we use the same type for content geometry.
- LayoutUnit contentLogicalTop() const;
- LayoutUnit contentLogicalBottom() const;
+ float contentLogicalTop() const;
+ float contentLogicalBottom() const;
float contentLogicalLeft() const;
float contentLogicalRight() const;
float contentLogicalWidth() const;
- LayoutUnit contentLogicalTopAdjustedForHitTesting() const;
- LayoutUnit contentLogicalTopAdjustedForPrecedingLine() const;
- LayoutUnit contentLogicalBottomAdjustedForFollowingLine() const;
+ float contentLogicalTopAdjustedForHitTesting() const;
+ float contentLogicalTopAdjustedForPrecedingLine() const;
+ float contentLogicalBottomAdjustedForFollowingLine() const;
const RenderBlockFlow& containingBlock() const;
RenderFragmentContainer* containingFragment() const;
@@ -123,7 +122,7 @@
LeafBoxIterator closestBoxForHorizontalPosition(const Line&, float horizontalPosition, bool editableOnly = false);
// -----------------------------------------------
-inline LayoutUnit contentStartInBlockDirection(const Line& line)
+inline float contentStartInBlockDirection(const Line& line)
{
if (!line.containingBlock().style().isFlippedBlocksWritingMode())
return std::max(line.contentLogicalTop(), line.contentLogicalTopAdjustedForHitTesting());
@@ -135,7 +134,7 @@
{
}
-inline LayoutUnit Line::contentLogicalTop() const
+inline float Line::contentLogicalTop() const
{
return WTF::switchOn(m_pathVariant, [](const auto& path) {
return path.contentLogicalTop();
@@ -142,7 +141,7 @@
});
}
-inline LayoutUnit Line::contentLogicalBottom() const
+inline float Line::contentLogicalBottom() const
{
return WTF::switchOn(m_pathVariant, [](const auto& path) {
return path.contentLogicalBottom();
@@ -149,7 +148,7 @@
});
}
-inline LayoutUnit Line::contentLogicalTopAdjustedForPrecedingLine() const
+inline float Line::contentLogicalTopAdjustedForPrecedingLine() const
{
return WTF::switchOn(m_pathVariant, [](const auto& path) {
return path.contentLogicalTopAdjustedForPrecedingLine();
@@ -156,7 +155,7 @@
});
}
-inline LayoutUnit Line::contentLogicalTopAdjustedForHitTesting() const
+inline float Line::contentLogicalTopAdjustedForHitTesting() const
{
return WTF::switchOn(m_pathVariant, [](const auto& path) {
return path.contentLogicalTopAdjustedForHitTesting();
@@ -163,7 +162,7 @@
});
}
-inline LayoutUnit Line::contentLogicalBottomAdjustedForFollowingLine() const
+inline float Line::contentLogicalBottomAdjustedForFollowingLine() const
{
return WTF::switchOn(m_pathVariant, [](const auto& path) {
return path.contentLogicalBottomAdjustedForFollowingLine();
@@ -170,7 +169,7 @@
});
}
-inline LayoutUnit Line::lineBoxTop() const
+inline float Line::lineBoxTop() const
{
return WTF::switchOn(m_pathVariant, [](const auto& path) {
return path.lineBoxTop();
@@ -177,7 +176,7 @@
});
}
-inline LayoutUnit Line::lineBoxBottom() const
+inline float Line::lineBoxBottom() const
{
return WTF::switchOn(m_pathVariant, [](const auto& path) {
return path.lineBoxBottom();
Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h (291534 => 291535)
--- trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h 2022-03-19 23:22:30 UTC (rev 291534)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h 2022-03-20 00:45:31 UTC (rev 291535)
@@ -43,13 +43,13 @@
LineIteratorLegacyPath& operator=(const LineIteratorLegacyPath&) = default;
LineIteratorLegacyPath& operator=(LineIteratorLegacyPath&&) = default;
- LayoutUnit contentLogicalTop() const { return m_rootInlineBox->lineTop(); }
- LayoutUnit contentLogicalBottom() const { return m_rootInlineBox->lineBottom(); }
- LayoutUnit contentLogicalTopAdjustedForPrecedingLine() const { return m_rootInlineBox->selectionTop(); }
- 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(); }
+ float contentLogicalTop() const { return m_rootInlineBox->lineTop().toFloat(); }
+ float contentLogicalBottom() const { return m_rootInlineBox->lineBottom().toFloat(); }
+ float contentLogicalTopAdjustedForPrecedingLine() const { return m_rootInlineBox->selectionTop().toFloat(); }
+ float contentLogicalTopAdjustedForHitTesting() const { return m_rootInlineBox->selectionTop(LegacyRootInlineBox::ForHitTesting::Yes).toFloat(); }
+ float contentLogicalBottomAdjustedForFollowingLine() const { return m_rootInlineBox->selectionBottom().toFloat(); }
+ float lineBoxTop() const { return m_rootInlineBox->lineBoxTop().toFloat(); }
+ float lineBoxBottom() const { return m_rootInlineBox->lineBoxBottom().toFloat(); }
float contentLogicalLeft() const { return m_rootInlineBox->logicalLeft(); }
float contentLogicalRight() const { return m_rootInlineBox->logicalRight(); }
Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h (291534 => 291535)
--- trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h 2022-03-19 23:22:30 UTC (rev 291534)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h 2022-03-20 00:45:31 UTC (rev 291535)
@@ -49,18 +49,18 @@
LineIteratorModernPath& operator=(const LineIteratorModernPath&) = default;
LineIteratorModernPath& operator=(LineIteratorModernPath&&) = default;
- LayoutUnit contentLogicalTop() const { return LayoutUnit::fromFloatRound(line().enclosingContentTop()); }
- LayoutUnit contentLogicalBottom() const { return LayoutUnit::fromFloatRound(line().enclosingContentBottom()); }
- LayoutUnit lineBoxTop() const { return LayoutUnit::fromFloatRound(line().lineBoxTop()); }
- LayoutUnit lineBoxBottom() const { return LayoutUnit::fromFloatRound(line().lineBoxBottom()); }
+ float contentLogicalTop() const { return line().enclosingContentTop(); }
+ float contentLogicalBottom() const { return line().enclosingContentBottom(); }
+ float lineBoxTop() const { return line().lineBoxTop(); }
+ float lineBoxBottom() const { return line().lineBoxBottom(); }
- LayoutUnit contentLogicalTopAdjustedForPrecedingLine() const { return !m_lineIndex ? contentLogicalTop() : LineIteratorModernPath(*m_inlineContent, m_lineIndex - 1).contentLogicalBottomAdjustedForFollowingLine(); }
+ float contentLogicalTopAdjustedForPrecedingLine() const { return !m_lineIndex ? contentLogicalTop() : LineIteratorModernPath(*m_inlineContent, m_lineIndex - 1).contentLogicalBottomAdjustedForFollowingLine(); }
// 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 contentLogicalTopAdjustedForHitTesting() const { return !m_lineIndex ? containingBlock().borderAndPaddingBefore() : contentLogicalTopAdjustedForPrecedingLine(); };
+ float contentLogicalTopAdjustedForHitTesting() const { return !m_lineIndex ? containingBlock().borderAndPaddingBefore().toFloat() : contentLogicalTopAdjustedForPrecedingLine(); };
// FIXME: Implement.
- LayoutUnit contentLogicalBottomAdjustedForFollowingLine() const { return contentLogicalBottom(); }
+ float contentLogicalBottomAdjustedForFollowingLine() const { return contentLogicalBottom(); }
float contentLogicalLeft() const { return line().lineBoxLeft() + line().contentLogicalOffset(); }
float contentLogicalRight() const { return contentLogicalLeft() + line().contentLogicalWidth(); }
Modified: trunk/Source/WebCore/layout/integration/LineSelection.h (291534 => 291535)
--- trunk/Source/WebCore/layout/integration/LineSelection.h 2022-03-19 23:22:30 UTC (rev 291534)
+++ trunk/Source/WebCore/layout/integration/LineSelection.h 2022-03-20 00:45:31 UTC (rev 291535)
@@ -32,15 +32,15 @@
class LineSelection {
public:
- static LayoutUnit logicalTop(const InlineIterator::Line& line) { return line.contentLogicalTopAdjustedForPrecedingLine(); }
- static LayoutUnit logicalBottom(const InlineIterator::Line& line) { return line.contentLogicalBottomAdjustedForFollowingLine(); }
+ static float logicalTop(const InlineIterator::Line& line) { return line.contentLogicalTopAdjustedForPrecedingLine(); }
+ static float logicalBottom(const InlineIterator::Line& line) { return line.contentLogicalBottomAdjustedForFollowingLine(); }
- static LayoutRect logicalRect(const InlineIterator::Line& line)
+ static FloatRect logicalRect(const InlineIterator::Line& line)
{
- return { LayoutPoint { line.contentLogicalLeft(), line.contentLogicalTopAdjustedForPrecedingLine() }, LayoutPoint { line.contentLogicalRight(), line.contentLogicalBottomAdjustedForFollowingLine() } };
+ return { FloatPoint { line.contentLogicalLeft(), line.contentLogicalTopAdjustedForPrecedingLine() }, FloatPoint { line.contentLogicalRight(), line.contentLogicalBottomAdjustedForFollowingLine() } };
}
- static LayoutRect physicalRect(const InlineIterator::Line& line)
+ static FloatRect physicalRect(const InlineIterator::Line& line)
{
auto physicalRect = logicalRect(line);
if (!line.isHorizontal())
@@ -49,10 +49,10 @@
return physicalRect;
}
- static LayoutUnit logicalTopAdjustedForPrecedingBlock(const InlineIterator::Line& line)
+ static float logicalTopAdjustedForPrecedingBlock(const InlineIterator::Line& line)
{
// FIXME: Move adjustEnclosingTopForPrecedingBlock from RenderBlockFlow to here.
- return line.containingBlock().adjustEnclosingTopForPrecedingBlock(line.contentLogicalTopAdjustedForPrecedingLine());
+ return line.containingBlock().adjustEnclosingTopForPrecedingBlock(LayoutUnit { line.contentLogicalTopAdjustedForPrecedingLine() });
}
static RenderObject::HighlightState selectionState(const InlineIterator::Line& line)
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (291534 => 291535)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2022-03-19 23:22:30 UTC (rev 291534)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2022-03-20 00:45:31 UTC (rev 291535)
@@ -3067,7 +3067,7 @@
return top;
auto lastLineSelectionBottom = LineSelection::logicalBottom(*lastLine) + offsetToBlockBefore.height();
- top = std::max(top, lastLineSelectionBottom);
+ top = std::max(top, LayoutUnit { lastLineSelectionBottom });
}
return top;
}
@@ -3165,8 +3165,8 @@
// Now paint the gaps for the lines.
for (; line && hasSelectedChildren(line); line.traverseNext()) {
- auto selectionTop = LineSelection::logicalTopAdjustedForPrecedingBlock(*line);
- auto selectionHeight = std::max(0_lu, LineSelection::logicalBottom(*line) - selectionTop);
+ auto selectionTop = LayoutUnit { LineSelection::logicalTopAdjustedForPrecedingBlock(*line) };
+ auto selectionHeight = LayoutUnit { std::max(0.f, LineSelection::logicalBottom(*line) - selectionTop) };
if (!containsStart && !lastSelectedLine &&
selectionState() != HighlightState::Start && selectionState() != HighlightState::Both && !isRubyBase())
@@ -3188,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 = LineSelection::logicalBottom(*lastSelectedLine);
+ auto lastLineSelectionBottom = LayoutUnit { LineSelection::logicalBottom(*lastSelectedLine) };
lastLogicalTop = blockDirectionOffset(rootBlock, offsetFromRootBlock) + lastLineSelectionBottom;
lastLogicalLeft = logicalLeftSelectionOffset(rootBlock, lastLineSelectionBottom, cache);
lastLogicalRight = logicalRightSelectionOffset(rootBlock, lastLineSelectionBottom, cache);
@@ -3421,7 +3421,7 @@
if (closestBox) {
if (moveCaretToBoundary) {
- LayoutUnit firstLineWithChildrenTop = std::min(firstLineWithChildren->contentLogicalTopAdjustedForHitTesting(), LayoutUnit(firstLineWithChildren->contentLogicalTop()));
+ auto firstLineWithChildrenTop = LayoutUnit { std::min(firstLineWithChildren->contentLogicalTopAdjustedForHitTesting(), firstLineWithChildren->contentLogicalTop()) };
if (pointInLogicalContents.y() < firstLineWithChildrenTop
|| (blocksAreFlipped && pointInLogicalContents.y() == firstLineWithChildrenTop)) {
auto box = firstLineWithChildren->firstLeafBox();
@@ -3474,8 +3474,8 @@
auto line = box->line();
// FIXME: This is mixing physical and logical coordinates.
auto unflippedVisualRect = box->visualRectIgnoringBlockDirection();
- auto top = std::max(line->contentLogicalTop(), LayoutUnit { unflippedVisualRect.y() });
- auto bottom = std::min(line->contentLogicalBottom(), LayoutUnit { unflippedVisualRect.maxY() });
+ auto top = std::max(line->contentLogicalTop(), unflippedVisualRect.y());
+ auto bottom = std::min(line->contentLogicalBottom(), unflippedVisualRect.maxY());
auto rect = LayoutRect { LayoutUnit { additionalOffset.x() + unflippedVisualRect.x() }
, additionalOffset.y() + top
, LayoutUnit { unflippedVisualRect.width() }
Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (291534 => 291535)
--- trunk/Source/WebCore/rendering/RenderImage.cpp 2022-03-19 23:22:30 UTC (rev 291534)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp 2022-03-20 00:45:31 UTC (rev 291535)
@@ -111,8 +111,9 @@
}
} else {
auto selectionLogicalRect = LineSelection::logicalRect(*run->line());
- auto selectionTop = !containingBlock->style().isFlippedBlocksWritingMode() ? selectionLogicalRect.y() - logicalTop() : logicalBottom() - selectionLogicalRect.maxY();
- imageRect = IntRect { 0, selectionTop, logicalWidth(), selectionLogicalRect.height() };
+ int selectionTop = !containingBlock->style().isFlippedBlocksWritingMode() ? selectionLogicalRect.y() - logicalTop() : logicalBottom() - selectionLogicalRect.maxY();
+ int selectionHeight = selectionLogicalRect.height();
+ imageRect = IntRect { 0, selectionTop, logicalWidth(), selectionHeight };
isFirstOnLine = !run->previousOnLine();
isLastOnLine = !run->nextOnLine();
LogicalSelectionOffsetCaches cache(*containingBlock);
Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (291534 => 291535)
--- trunk/Source/WebCore/rendering/RenderInline.cpp 2022-03-19 23:22:30 UTC (rev 291534)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp 2022-03-20 00:45:31 UTC (rev 291535)
@@ -974,8 +974,8 @@
for (auto box = InlineIterator::firstInlineBoxFor(*this); box; box.traverseNextInlineBox()) {
auto line = box->line();
- auto top = std::max(line->contentLogicalTop(), LayoutUnit(box->logicalTop()));
- auto bottom = std::min(line->contentLogicalBottom(), LayoutUnit(box->logicalBottom()));
+ auto top = LayoutUnit { std::max(line->contentLogicalTop(), box->logicalTop()) };
+ auto bottom = LayoutUnit { std::min(line->contentLogicalBottom(), box->logicalBottom()) };
// FIXME: This is mixing physical and logical coordinates.
rects.append({ LayoutUnit(box->visualRectIgnoringBlockDirection().x()), top, LayoutUnit(box->logicalWidth()), bottom - top });
}
Modified: trunk/Source/WebCore/rendering/RenderReplaced.cpp (291534 => 291535)
--- trunk/Source/WebCore/rendering/RenderReplaced.cpp 2022-03-19 23:22:30 UTC (rev 291534)
+++ trunk/Source/WebCore/rendering/RenderReplaced.cpp 2022-03-20 00:45:31 UTC (rev 291535)
@@ -719,7 +719,7 @@
VisiblePosition RenderReplaced::positionForPoint(const LayoutPoint& point, const RenderFragmentContainer* fragment)
{
- auto [top, bottom] = [&] {
+ auto [top, bottom] = [&]() -> std::pair<float, float> {
if (auto run = InlineIterator::boxFor(*this)) {
auto line = run->line();
return std::make_pair(line->contentLogicalTopAdjustedForHitTesting(), LineSelection::logicalBottom(*line));
Modified: trunk/Source/WebCore/rendering/TextBoxPainter.cpp (291534 => 291535)
--- trunk/Source/WebCore/rendering/TextBoxPainter.cpp 2022-03-19 23:22:30 UTC (rev 291534)
+++ trunk/Source/WebCore/rendering/TextBoxPainter.cpp 2022-03-20 00:45:31 UTC (rev 291535)
@@ -295,7 +295,7 @@
// 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 };
- auto selectionHeight = LayoutUnit { std::max(0_lu, selectionBottom - selectionTop) };
+ auto selectionHeight = LayoutUnit { std::max(0.f, selectionBottom - selectionTop) };
auto selectionRect = LayoutRect { LayoutUnit(m_paintRect.x()), LayoutUnit(m_paintRect.y() - deltaY), LayoutUnit(textBox().logicalWidth()), selectionHeight };
fontCascade().adjustSelectionRectForText(m_paintTextRun, selectionRect, startOffset, endOffset);