- Revision
- 270144
- Author
- [email protected]
- Date
- 2020-11-21 05:13:29 -0800 (Sat, 21 Nov 2020)
Log Message
[LFC][IFC] Remove InlineLineGeometry::logicalLeft/top/bottom/right/width/height helper functions
https://bugs.webkit.org/show_bug.cgi?id=219226
Reviewed by Antti Koivisto.
This is in preparation for having lineBoxLogicalRect() on InlineLineGeometry. It makes it absolutely clear
of what type of logical rect we have here.
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedContentHeightAndMargin):
* layout/inlineformatting/InlineFormattingContextGeometry.cpp:
(WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):
* layout/inlineformatting/InlineLineGeometry.h:
(WebCore::Layout::InlineLineGeometry::logicalLeft const): Deleted.
(WebCore::Layout::InlineLineGeometry::logicalRight const): Deleted.
(WebCore::Layout::InlineLineGeometry::logicalTop const): Deleted.
(WebCore::Layout::InlineLineGeometry::logicalBottom const): Deleted.
(WebCore::Layout::InlineLineGeometry::logicalWidth const): Deleted.
(WebCore::Layout::InlineLineGeometry::logicalHeight const): Deleted.
* layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
(WebCore::LayoutIntegration::InlineContentBuilder::computeLineLevelVisualAdjustmentsForRuns const):
(WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLineRuns const):
(WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const):
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::showInlineTreeAndRuns):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (270143 => 270144)
--- trunk/Source/WebCore/ChangeLog 2020-11-21 12:56:46 UTC (rev 270143)
+++ trunk/Source/WebCore/ChangeLog 2020-11-21 13:13:29 UTC (rev 270144)
@@ -1,5 +1,35 @@
2020-11-21 Zalan Bujtas <[email protected]>
+ [LFC][IFC] Remove InlineLineGeometry::logicalLeft/top/bottom/right/width/height helper functions
+ https://bugs.webkit.org/show_bug.cgi?id=219226
+
+ Reviewed by Antti Koivisto.
+
+ This is in preparation for having lineBoxLogicalRect() on InlineLineGeometry. It makes it absolutely clear
+ of what type of logical rect we have here.
+
+ * layout/FormattingContextGeometry.cpp:
+ (WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const):
+ * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedContentHeightAndMargin):
+ * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+ (WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):
+ * layout/inlineformatting/InlineLineGeometry.h:
+ (WebCore::Layout::InlineLineGeometry::logicalLeft const): Deleted.
+ (WebCore::Layout::InlineLineGeometry::logicalRight const): Deleted.
+ (WebCore::Layout::InlineLineGeometry::logicalTop const): Deleted.
+ (WebCore::Layout::InlineLineGeometry::logicalBottom const): Deleted.
+ (WebCore::Layout::InlineLineGeometry::logicalWidth const): Deleted.
+ (WebCore::Layout::InlineLineGeometry::logicalHeight const): Deleted.
+ * layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
+ (WebCore::LayoutIntegration::InlineContentBuilder::computeLineLevelVisualAdjustmentsForRuns const):
+ (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLineRuns const):
+ (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const):
+ * layout/layouttree/LayoutTreeBuilder.cpp:
+ (WebCore::Layout::showInlineTreeAndRuns):
+
+2020-11-21 Zalan Bujtas <[email protected]>
+
[LFC][Integration] Add contentLogicalOffset and contentLogicalWidth to InlineLineGeometry(Line)
https://bugs.webkit.org/show_bug.cgi?id=219220
Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (270143 => 270144)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2020-11-21 12:56:46 UTC (rev 270143)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2020-11-21 13:13:29 UTC (rev 270144)
@@ -197,8 +197,8 @@
auto& lines = inlineFormattingState.lines();
// Even empty containers generate one line.
ASSERT(!lines.isEmpty());
- top = lines.first().logicalTop();
- bottom = lines.last().logicalBottom() + inlineFormattingState.clearGapAfterLastLine();
+ top = lines.first().logicalRect().top();
+ bottom = lines.last().logicalRect().bottom() + inlineFormattingState.clearGapAfterLastLine();
} else if (formattingContextRoot.establishesFlexFormattingContext()) {
auto& lines = layoutState.establishedFlexFormattingState(formattingContextRoot).lines();
ASSERT(!lines.isEmpty());
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (270143 => 270144)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2020-11-21 12:56:46 UTC (rev 270143)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2020-11-21 13:13:29 UTC (rev 270144)
@@ -81,7 +81,7 @@
auto& lines = inlineFormattingState.lines();
// Even empty containers generate one line.
ASSERT(!lines.isEmpty());
- return { toLayoutUnit(lines.last().logicalBottom() + inlineFormattingState.clearGapAfterLastLine()) - borderAndPaddingTop, nonCollapsedMargin };
+ return { toLayoutUnit(lines.last().logicalRect().bottom() + inlineFormattingState.clearGapAfterLastLine()) - borderAndPaddingTop, nonCollapsedMargin };
}
// 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin...
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (270143 => 270144)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2020-11-21 12:56:46 UTC (rev 270143)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp 2020-11-21 13:13:29 UTC (rev 270144)
@@ -259,7 +259,7 @@
if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) {
auto& formattingState = layoutState().establishedInlineFormattingState(downcast<ContainerBox>(layoutBox));
auto& lastLine = formattingState.lines().last();
- auto inlineBlockBaseline = lastLine.logicalTop() + lastLine.baseline();
+ auto inlineBlockBaseline = lastLine.logicalRect().top() + lastLine.baseline();
ascent = inlineLevelBoxGeometry.marginBefore() + inlineLevelBoxGeometry.borderTop() + inlineLevelBoxGeometry.paddingTop().valueOr(0) + inlineBlockBaseline;
} else if (layoutBox.isReplacedBox())
ascent = downcast<ReplacedBox>(layoutBox).baseline().valueOr(marginBoxHeight);
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineGeometry.h (270143 => 270144)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineGeometry.h 2020-11-21 12:56:46 UTC (rev 270143)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineGeometry.h 2020-11-21 13:13:29 UTC (rev 270144)
@@ -37,15 +37,6 @@
public:
InlineLineGeometry(const InlineRect& lineLogicalRect, const InlineLayoutSize& lineBoxLogicalSize, InlineLayoutUnit aligmentBaseline, InlineLayoutUnit contentLogicalLeftOffset, InlineLayoutUnit contentLogicalWidth);
- InlineLayoutUnit logicalLeft() const { return logicalRect().left(); };
- InlineLayoutUnit logicalRight() const { return logicalRect().right(); };
-
- InlineLayoutUnit logicalTop() const { return logicalRect().top(); };
- InlineLayoutUnit logicalBottom() const { return logicalRect().bottom(); };
-
- InlineLayoutUnit logicalWidth() const { return logicalRect().width(); };
- InlineLayoutUnit logicalHeight() const { return logicalRect().height(); };
-
const InlineRect& logicalRect() const { return m_logicalRect; }
const InlineLayoutSize& lineBoxLogicalSize() const { return m_lineBoxLogicalSize; }
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp (270143 => 270144)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp 2020-11-21 12:56:46 UTC (rev 270143)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp 2020-11-21 13:13:29 UTC (rev 270144)
@@ -186,8 +186,9 @@
lineLevelVisualAdjustmentsForRuns[lineIndex].needsIntegralPosition = lineNeedsLegacyIntegralVerticalPosition();
if (shouldCheckHorizontalOverflowForContentReplacement) {
auto& line = lines[lineIndex];
- auto overflowWidth = lineOverflowWidth(m_blockFlow, line.logicalWidth(), line.lineBoxLogicalSize().width());
- lineLevelVisualAdjustmentsForRuns[lineIndex].needsTrailingContentReplacement = overflowWidth > line.logicalWidth();
+ auto& lineLogicalRect = line.logicalRect();
+ auto overflowWidth = lineOverflowWidth(m_blockFlow, lineLogicalRect.width(), line.lineBoxLogicalSize().width());
+ lineLevelVisualAdjustmentsForRuns[lineIndex].needsTrailingContentReplacement = overflowWidth > lineLogicalRect.width();
}
}
return lineLevelVisualAdjustmentsForRuns;
@@ -212,13 +213,13 @@
auto createDisplayBoxRun = [&](auto& lineRun) {
auto& layoutBox = lineRun.layoutBox();
auto lineIndex = lineRun.lineIndex();
- auto& line = lines[lineIndex];
+ auto& lineLogicalRect = lines[lineIndex].logicalRect();
// Inline boxes are relative to the line box while final Runs need to be relative to the parent Box
// FIXME: Shouldn't we just leave them be relative to the line box?
auto runRect = FloatRect { lineRun.logicalRect() };
// Line runs are margin box based, let's convert them to border box.
auto& geometry = m_layoutState.geometryForBox(layoutBox);
- runRect.moveBy({ line.logicalLeft() + std::max(geometry.marginStart(), 0_lu), line.logicalTop() + geometry.marginBefore() });
+ runRect.moveBy({ lineLogicalRect.left() + std::max(geometry.marginStart(), 0_lu), lineLogicalRect.top() + geometry.marginBefore() });
runRect.setSize({ geometry.borderBoxWidth(), geometry.borderBoxHeight() });
if (lineLevelVisualAdjustmentsForRuns[lineIndex].needsIntegralPosition)
runRect.setY(roundToInt(runRect.y()));
@@ -231,11 +232,11 @@
RELEASE_ASSERT(startOffset < endOffset);
auto& layoutBox = lineRun.layoutBox();
auto lineIndex = lineRun.lineIndex();
- auto& line = lines[lineIndex];
+ auto& lineLogicalRect = lines[lineIndex].logicalRect();
auto runRect = FloatRect { lineRun.logicalRect() };
// Inline boxes are relative to the line box while final Runs need to be relative to the parent Box
// FIXME: Shouldn't we just leave them be relative to the line box?
- runRect.moveBy({ line.logicalLeft(), line.logicalTop() });
+ runRect.moveBy({ lineLogicalRect.left(), lineLogicalRect.top() });
if (lineLevelVisualAdjustmentsForRuns[lineIndex].needsIntegralPosition)
runRect.setY(roundToInt(runRect.y()));
@@ -252,14 +253,13 @@
return emptyString();
}
auto runLogicalRect = lineRun.logicalRect();
- auto lineLogicalRight = line.logicalRight();
auto ellipsisWidth = style.fontCascade().width(WebCore::TextRun { &horizontalEllipsis });
- if (runLogicalRect.right() + ellipsisWidth > lineLogicalRight) {
+ if (runLogicalRect.right() + ellipsisWidth > lineLogicalRect.right()) {
// The next run with ellipsis would surely overflow. So let's just add it to this run even if
// it makes the run wider than it originally was.
hasAdjustedTrailingLineList[lineIndex] = true;
float resultWidth = 0;
- auto maxWidth = line.logicalWidth() - runLogicalRect.left();
+ auto maxWidth = lineLogicalRect.width() - runLogicalRect.left();
return StringTruncator::rightTruncate(originalContent, maxWidth, style.fontCascade(), resultWidth, true);
}
}
@@ -307,9 +307,10 @@
size_t runIndex = 0;
for (size_t lineIndex = 0; lineIndex < lines.size(); ++lineIndex) {
auto& line = lines[lineIndex];
+ auto& lineLogicalRect = line.logicalRect();
auto lineBoxLogicalSize = line.lineBoxLogicalSize();
// FIXME: This is where the logical to physical translate should happen.
- auto scrollableOverflowRect = FloatRect { line.logicalLeft(), line.logicalTop(), lineOverflowWidth(m_blockFlow, line.logicalWidth(), lineBoxLogicalSize.width()), line.logicalHeight() };
+ auto scrollableOverflowRect = FloatRect { lineLogicalRect.left(), lineLogicalRect.top(), lineOverflowWidth(m_blockFlow, lineLogicalRect.width(), lineBoxLogicalSize.width()), lineLogicalRect.height() };
auto firstRunIndex = runIndex;
auto lineInkOverflowRect = scrollableOverflowRect;
@@ -316,7 +317,7 @@
while (runIndex < runs.size() && runs[runIndex].lineIndex() == lineIndex)
lineInkOverflowRect.unite(runs[runIndex++].inkOverflow());
auto runCount = runIndex - firstRunIndex;
- auto lineRect = FloatRect { line.logicalRect() };
+ auto lineRect = FloatRect { lineLogicalRect };
auto enclosingTopAndBottom = [&] {
// Let's (vertically)enclose all the inline level boxes.
// This mostly matches 'lineRect', unless line-height triggers line box overflow (not to be confused with ink or scroll overflow).
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (270143 => 270144)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2020-11-21 12:56:46 UTC (rev 270143)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2020-11-21 13:13:29 UTC (rev 270144)
@@ -394,7 +394,8 @@
};
addSpacing();
auto& line = lines[lineIndex];
- stream << "line at (" << line.logicalLeft() << "," << line.logicalTop() << ") size (" << line.logicalWidth() << "x" << line.logicalHeight() << ") baseline (" << line.baseline() << ")";
+ auto& lineLogicalRect = line.logicalRect();
+ stream << "line at (" << lineLogicalRect.left() << "," << lineLogicalRect.top() << ") size (" << lineLogicalRect.width() << "x" << lineLogicalRect.height() << ") baseline (" << line.baseline() << ")";
stream.nextLine();
addSpacing();