Diff
Modified: trunk/Source/WebCore/ChangeLog (269988 => 269989)
--- trunk/Source/WebCore/ChangeLog 2020-11-18 22:41:41 UTC (rev 269988)
+++ trunk/Source/WebCore/ChangeLog 2020-11-18 22:42:20 UTC (rev 269989)
@@ -1,3 +1,37 @@
+2020-11-18 Zalan Bujtas <[email protected]>
+
+ [LFC][Integration] Line::enclosingRect should only include the border box (exclude vertical margins)
+ https://bugs.webkit.org/show_bug.cgi?id=219106
+
+ Reviewed by Antti Koivisto.
+
+ LineIteratorPath::top/bottom expects border box enclosing values (and not margin box values).
+ (and while we are here, let's just compute the vertical enclosing values and ignore the horizontal aspect of it as the line box always
+ encloses all the inline level boxes on the line anyway)
+
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent):
+ * layout/inlineformatting/InlineLineBox.cpp:
+ (WebCore::Layout::LineBox::logicalMarginRectForInlineLevelBox const):
+ (WebCore::Layout::LineBox::logicalRectForInlineLevelBox const): Deleted.
+ * layout/inlineformatting/InlineLineBox.h:
+ * layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
+ (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const):
+ * layout/integration/LayoutIntegrationLine.h:
+ (WebCore::LayoutIntegration::Line::Line):
+ (WebCore::LayoutIntegration::Line::enclosingContentTop const):
+ (WebCore::LayoutIntegration::Line::enclosingContentBottom const):
+ (WebCore::LayoutIntegration::Line::enclosingContentRect const): Deleted.
+ * layout/integration/LayoutIntegrationLineIteratorModernPath.h:
+ (WebCore::LayoutIntegration::LineIteratorModernPath::top const):
+ (WebCore::LayoutIntegration::LineIteratorModernPath::bottom const):
+ * layout/integration/LayoutIntegrationPagination.cpp:
+ (WebCore::LayoutIntegration::makeAdjustedContent):
+ * layout/integration/LayoutIntegrationRunIteratorModernPath.h:
+ (WebCore::LayoutIntegration::RunIteratorModernPath::selectionRect const):
+ * layout/layouttree/LayoutTreeBuilder.cpp:
+ (WebCore::Layout::showInlineTreeAndRuns):
+
2020-11-18 Antoine Quint <[email protected]>
Move <model> code under Modules/model-element
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (269988 => 269989)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-11-18 22:41:41 UTC (rev 269988)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-11-18 22:42:20 UTC (rev 269989)
@@ -438,7 +438,7 @@
if (lineRun.isText() || lineRun.isLineBreak())
formattingState.addLineRun({ lineIndex, lineRun.layoutBox(), lineBox.logicalRectForTextRun(lineRun), lineRun.expansion(), lineRun.textContent() });
else if (lineRun.isBox())
- formattingState.addLineRun({ lineIndex, lineRun.layoutBox(), lineBox.logicalRectForInlineLevelBox(lineRun.layoutBox()), lineRun.expansion(), { } });
+ formattingState.addLineRun({ lineIndex, lineRun.layoutBox(), lineBox.logicalMarginRectForInlineLevelBox(lineRun.layoutBox()), lineRun.expansion(), { } });
}
};
constructLineRuns();
@@ -455,7 +455,7 @@
auto& boxGeometry = formattingState.boxGeometry(layoutBox);
// Inline box coordinates are relative to the line box.
// Let's convert top/left relative to the formatting context root.
- auto logicalRect = lineBox.logicalRectForInlineLevelBox(layoutBox);
+ auto logicalRect = lineBox.logicalMarginRectForInlineLevelBox(layoutBox);
// Inline box height includes the margin box. Let's account for that.
auto borderBoxLogicalTopLeft = lineLogicalRect.topLeft();
borderBoxLogicalTopLeft.move(logicalRect.left(), logicalRect.top() + boxGeometry.marginBefore());
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp (269988 => 269989)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp 2020-11-18 22:41:41 UTC (rev 269988)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.cpp 2020-11-18 22:42:20 UTC (rev 269989)
@@ -110,7 +110,7 @@
return { runlogicalTop, m_horizontalAlignmentOffset.valueOr(InlineLayoutUnit { }) + run.logicalLeft(), run.logicalWidth(), logicalHeight };
}
-InlineRect LineBox::logicalRectForInlineLevelBox(const Box& layoutBox) const
+InlineRect LineBox::logicalMarginRectForInlineLevelBox(const Box& layoutBox) const
{
auto* inlineBox = &inlineLevelBoxForLayoutBox(layoutBox);
if (inlineBox->hasLineBoxRelativeAlignment())
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h (269988 => 269989)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h 2020-11-18 22:41:41 UTC (rev 269988)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h 2020-11-18 22:42:20 UTC (rev 269989)
@@ -141,7 +141,7 @@
const InlineLevelBox& inlineLevelBoxForLayoutBox(const Box& layoutBox) const { return *m_inlineLevelBoxRectMap.get(&layoutBox); }
InlineRect logicalRectForTextRun(const Line::Run&) const;
- InlineRect logicalRectForInlineLevelBox(const Box&) const;
+ InlineRect logicalMarginRectForInlineLevelBox(const Box&) const;
auto inlineLevelBoxList() const { return m_inlineLevelBoxRectMap.values(); }
bool containsInlineLevelBox(const Box& layoutBox) const { return m_inlineLevelBoxRectMap.contains(&layoutBox); }
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp (269988 => 269989)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp 2020-11-18 22:41:41 UTC (rev 269988)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp 2020-11-18 22:42:20 UTC (rev 269989)
@@ -317,25 +317,34 @@
lineInkOverflowRect.unite(runs[runIndex++].inkOverflow());
auto runCount = runIndex - firstRunIndex;
auto lineRect = FloatRect { line.logicalRect() };
- auto enclosingContentRect = [&] {
+ 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).
- auto enclosingRect = FloatRect { lineRect.location(), lineBoxLogicalSize };
+ auto enclosingTop = Optional<float> { };
+ auto enclosingBottom = Optional<float> { };
auto& lineBox = lineBoxes[lineIndex];
for (auto& inlineLevelBox : lineBox.inlineLevelBoxList()) {
- auto inlineLevelBoxLogicalRect = lineBox.logicalRectForInlineLevelBox(inlineLevelBox->layoutBox());
- // inlineLevelBoxLogicalRect is relative to the line.
- inlineLevelBoxLogicalRect.moveBy(lineRect.location());
- enclosingRect.setY(std::min(enclosingRect.y(), inlineLevelBoxLogicalRect.top()));
- enclosingRect.shiftMaxYEdgeTo(std::max(enclosingRect.maxY(), inlineLevelBoxLogicalRect.bottom()));
+ auto& layoutBox = inlineLevelBox->layoutBox();
+ auto inlineLevelBoxLogicalRect = lineBox.logicalMarginRectForInlineLevelBox(layoutBox);
+ // inlineLevelBoxLogicalRect encloses the margin box, but we need border box for the display line.
+ auto& geometry = m_layoutState.geometryForBox(layoutBox);
+ inlineLevelBoxLogicalRect.expandVertically(-std::max(0_lu, geometry.marginBefore() + geometry.marginAfter()));
+ inlineLevelBoxLogicalRect.moveVertically(std::max(0_lu, geometry.marginBefore()));
+
+ enclosingTop = std::min(enclosingTop.valueOr(inlineLevelBoxLogicalRect.top()), inlineLevelBoxLogicalRect.top());
+ enclosingBottom = std::max(enclosingBottom.valueOr(inlineLevelBoxLogicalRect.bottom()), inlineLevelBoxLogicalRect.bottom());
}
- return enclosingRect;
+ // There's always at least one inline level box, the root inline box.
+ ASSERT(enclosingBottom && enclosingTop);
+ // inline boxes are relative to the line, let's make them relative to the root's content box.
+ return Line::EnclosingTopAndBottom { lineRect.y() + *enclosingTop, lineRect.y() + *enclosingBottom };
}();
if (lineLevelVisualAdjustmentsForRuns[lineIndex].needsIntegralPosition) {
lineRect.setY(roundToInt(lineRect.y()));
- enclosingContentRect.setY(roundToInt(enclosingContentRect.y()));
+ enclosingTopAndBottom.top = roundToInt(enclosingTopAndBottom.top);
+ enclosingTopAndBottom.bottom = roundToInt(enclosingTopAndBottom.bottom);
}
- inlineContent.lines.append({ firstRunIndex, runCount, lineRect, lineBoxLogicalSize.width(), enclosingContentRect, scrollableOverflowRect, lineInkOverflowRect, line.baseline(), line.horizontalAlignmentOffset() });
+ inlineContent.lines.append({ firstRunIndex, runCount, lineRect, lineBoxLogicalSize.width(), enclosingTopAndBottom, scrollableOverflowRect, lineInkOverflowRect, line.baseline(), line.horizontalAlignmentOffset() });
}
}
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLine.h (269988 => 269989)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLine.h 2020-11-18 22:41:41 UTC (rev 269988)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLine.h 2020-11-18 22:42:20 UTC (rev 269989)
@@ -35,12 +35,17 @@
class Line {
WTF_MAKE_FAST_ALLOCATED;
public:
- Line(size_t firstRunIndex, size_t runCount, const FloatRect& lineRect, float lineBoxWidth, const FloatRect& enclosingContentRect, const FloatRect& scrollableOverflow, const FloatRect& inkOverflow, float baseline, float horizontalAlignmentOffset)
+ struct EnclosingTopAndBottom {
+ // This values encloses the root inline box and any other inline level box's border box.
+ float top { 0 };
+ float bottom { 0 };
+ };
+ Line(size_t firstRunIndex, size_t runCount, const FloatRect& lineRect, float lineBoxWidth, EnclosingTopAndBottom enclosingTopAndBottom, const FloatRect& scrollableOverflow, const FloatRect& inkOverflow, float baseline, float horizontalAlignmentOffset)
: m_firstRunIndex(firstRunIndex)
, m_runCount(runCount)
, m_lineRect(lineRect)
, m_lineBoxWidth(lineBoxWidth)
- , m_enclosingContentRect(enclosingContentRect)
+ , m_enclosingTopAndBottom(enclosingTopAndBottom)
, m_scrollableOverflow(scrollableOverflow)
, m_inkOverflow(inkOverflow)
, m_baseline(baseline)
@@ -52,7 +57,8 @@
size_t runCount() const { return m_runCount; }
const FloatRect& rect() const { return m_lineRect; }
float lineBoxWidth() const { return m_lineBoxWidth; }
- const FloatRect& enclosingContentRect() const { return m_enclosingContentRect; }
+ float enclosingContentTop() const { return m_enclosingTopAndBottom.top; }
+ float enclosingContentBottom() const { return m_enclosingTopAndBottom.bottom; }
const FloatRect& scrollableOverflow() const { return m_scrollableOverflow; }
const FloatRect& inkOverflow() const { return m_inkOverflow; }
float baseline() const { return m_baseline; }
@@ -63,11 +69,11 @@
size_t m_runCount { 0 };
// Line is always as tall as the line box is. However they may differ in width.
// While line box encloses all the inline level boxes on the line horizontally, the line itself may be shorter (and trigger horizontal overflow).
- // Enclosing content rect includes all inline level boxes both vertically and horizontally. In certain cases (see line-height property)
+ // Enclosing top and bottom includes all inline level boxes (border box) vertically. In certain cases (see line-height property)
// the line (and the line box) is not as tall as the inline level boxes on the line.
FloatRect m_lineRect;
float m_lineBoxWidth { 0 };
- FloatRect m_enclosingContentRect;
+ EnclosingTopAndBottom m_enclosingTopAndBottom;
FloatRect m_scrollableOverflow;
FloatRect m_inkOverflow;
float m_baseline { 0 };
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h (269988 => 269989)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h 2020-11-18 22:41:41 UTC (rev 269988)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h 2020-11-18 22:42:20 UTC (rev 269989)
@@ -49,8 +49,8 @@
LineIteratorModernPath& operator=(const LineIteratorModernPath&) = default;
LineIteratorModernPath& operator=(LineIteratorModernPath&&) = default;
- LayoutUnit top() const { return LayoutUnit::fromFloatRound(line().enclosingContentRect().y()); }
- LayoutUnit bottom() const { return LayoutUnit::fromFloatRound(line().enclosingContentRect().maxY()); }
+ LayoutUnit top() const { return LayoutUnit::fromFloatRound(line().enclosingContentTop()); }
+ LayoutUnit bottom() const { return LayoutUnit::fromFloatRound(line().enclosingContentBottom()); }
LayoutUnit lineBoxTop() const { return LayoutUnit::fromFloatRound(line().rect().y()); }
LayoutUnit lineBoxBottom() const { return LayoutUnit::fromFloatRound(line().rect().maxY()); }
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp (269988 => 269989)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp 2020-11-18 22:41:41 UTC (rev 269988)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp 2020-11-18 22:42:20 UTC (rev 269989)
@@ -131,7 +131,7 @@
line.runCount(),
moveVertically(line.rect(), offset),
line.rect().width(),
- moveVertically(line.enclosingContentRect(), offset),
+ { line.enclosingContentTop() + offset, line.enclosingContentBottom() + offset },
moveVertically(line.scrollableOverflow(), offset),
moveVertically(line.inkOverflow(), offset),
line.baseline(),
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h (269988 => 269989)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h 2020-11-18 22:41:41 UTC (rev 269988)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h 2020-11-18 22:42:20 UTC (rev 269989)
@@ -117,8 +117,8 @@
auto logicalWidth = logicalRight - logicalLeft;
// FIXME: These should share implementation with the line iterator.
- auto selectionTop = LayoutUnit::fromFloatRound(line().enclosingContentRect().y());
- auto selectionHeight = LayoutUnit::fromFloatRound(line().enclosingContentRect().height());
+ auto selectionTop = LayoutUnit::fromFloatRound(line().enclosingContentTop());
+ auto selectionHeight = LayoutUnit::fromFloatRound(line().enclosingContentBottom() - line().enclosingContentTop());
LayoutRect selectionRect { logicalLeft, selectionTop, logicalWidth, selectionHeight };
Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (269988 => 269989)
--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2020-11-18 22:41:41 UTC (rev 269988)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2020-11-18 22:42:20 UTC (rev 269989)
@@ -415,7 +415,7 @@
stream << "Generic inline box";
else
stream << "Generic inline level box";
- auto logicalRect = lineBox.logicalRectForInlineLevelBox(inlineLevelBox.layoutBox());
+ auto logicalRect = lineBox.logicalMarginRectForInlineLevelBox(inlineLevelBox.layoutBox());
stream
<< " at (" << logicalRect.left() << "," << logicalRect.top() << ")"
<< " size (" << logicalRect.width() << "x" << logicalRect.height() << ")"