Diff
Modified: trunk/Source/WebCore/ChangeLog (282318 => 282319)
--- trunk/Source/WebCore/ChangeLog 2021-09-12 20:52:53 UTC (rev 282318)
+++ trunk/Source/WebCore/ChangeLog 2021-09-13 02:14:13 UTC (rev 282319)
@@ -1,3 +1,26 @@
+2021-09-12 Alan Bujtas <[email protected]>
+
+ [LFC][IFC] Add scrollable overflow to LineGeometry
+ https://bugs.webkit.org/show_bug.cgi?id=230200
+
+ Reviewed by Antti Koivisto.
+
+ This is in preparation for making the integration line structure redundant.
+ (LineGeometry should be able to contain all the geometry information required for layout/paint/hittest).
+
+ * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
+ (WebCore::Layout::LineBoxBuilder::build):
+ * layout/formattingContexts/inline/InlineLineGeometry.h:
+ (WebCore::Layout::LineGeometry::scrollableOverflow const):
+ (WebCore::Layout::LineGeometry::LineGeometry):
+ * layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
+ (WebCore::LayoutIntegration::lineOverflowWidth):
+ (WebCore::LayoutIntegration::InlineContentBuilder::InlineContentBuilder):
+ (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLines const):
+ * layout/integration/LayoutIntegrationInlineContentBuilder.h:
+ * layout/integration/LayoutIntegrationLineLayout.cpp:
+ (WebCore::LayoutIntegration::LineLayout::constructContent):
+
2021-09-12 Simon Fraser <[email protected]>
Implement getClientRects() for SVG elements
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp (282318 => 282319)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp 2021-09-12 20:52:53 UTC (rev 282318)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp 2021-09-13 02:14:13 UTC (rev 282319)
@@ -120,28 +120,40 @@
auto lineGeometry = [&] {
auto lineBoxLogicalRect = InlineRect { lineContent.logicalTopLeft, lineContent.lineLogicalWidth, lineBoxLogicalHeight };
+ auto scrollableOverflowRect = lineBoxLogicalRect;
auto& rootInlineBox = lineBox.rootInlineBox();
- auto enclosingTopAndBottom = LineGeometry::EnclosingTopAndBottom { rootInlineBox.logicalTop(), rootInlineBox.logicalBottom() };
+ auto enclosingTopAndBottom = LineGeometry::EnclosingTopAndBottom { lineBoxLogicalRect.top() + rootInlineBox.logicalTop(), lineBoxLogicalRect.top() + rootInlineBox.logicalBottom() };
for (auto& inlineLevelBox : lineBox.nonRootInlineLevelBoxes()) {
- if (!inlineLevelBox.isAtomicInlineLevelBox() || !inlineLevelBox.isInlineBox())
+ if (!inlineLevelBox.isAtomicInlineLevelBox() && !inlineLevelBox.isInlineBox())
continue;
auto& layoutBox = inlineLevelBox.layoutBox();
auto borderBox = InlineRect { };
- if (inlineLevelBox.isAtomicInlineLevelBox())
+ if (inlineLevelBox.isAtomicInlineLevelBox()) {
borderBox = lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, formattingContext().geometryForBox(layoutBox));
- else if (inlineLevelBox.isInlineBox())
- borderBox = lineBox.logicalBorderBoxForInlineBox(layoutBox, formattingContext().geometryForBox(layoutBox));
- else
+ borderBox.moveBy(lineBoxLogicalRect.topLeft());
+ } else if (inlineLevelBox.isInlineBox()) {
+ auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
+ borderBox = lineBox.logicalBorderBoxForInlineBox(layoutBox, boxGeometry);
+ borderBox.moveBy(lineBoxLogicalRect.topLeft());
+ // Collect scrollable overflow from inline boxes. All other inline level boxes (e.g atomic inline level boxes) stretch the line.
+ auto hasScrollableContent = [&] {
+ // In standards mode, inline boxes always start with an imaginary strut.
+ return layoutState().inStandardsMode() || inlineLevelBox.hasContent() || boxGeometry.horizontalBorder() || (boxGeometry.horizontalPadding() && boxGeometry.horizontalPadding().value());
+ };
+ if (lineBox.hasContent() && hasScrollableContent()) {
+ // Empty lines (e.g. continuation pre/post blocks) don't expect scrollbar overflow.
+ scrollableOverflowRect.expandToContain(borderBox);
+ }
+ } else
ASSERT_NOT_REACHED();
- borderBox.moveBy(lineBoxLogicalRect.topLeft());
enclosingTopAndBottom.top = std::min(enclosingTopAndBottom.top, borderBox.top());
enclosingTopAndBottom.bottom = std::max(enclosingTopAndBottom.bottom, borderBox.bottom());
}
- return LineGeometry { lineBoxLogicalRect, enclosingTopAndBottom, rootInlineBox.logicalTop() + rootInlineBox.baseline(), rootInlineBox.logicalLeft(), rootInlineBox.logicalWidth() };
+ return LineGeometry { lineBoxLogicalRect, scrollableOverflowRect, enclosingTopAndBottom, rootInlineBox.logicalTop() + rootInlineBox.baseline(), rootInlineBox.logicalLeft(), rootInlineBox.logicalWidth() };
};
return { lineBox, lineGeometry() };
}
Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineGeometry.h (282318 => 282319)
--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineGeometry.h 2021-09-12 20:52:53 UTC (rev 282318)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineGeometry.h 2021-09-13 02:14:13 UTC (rev 282319)
@@ -40,9 +40,10 @@
InlineLayoutUnit top { 0 };
InlineLayoutUnit bottom { 0 };
};
- LineGeometry(const InlineRect& lineBoxLogicalRect, EnclosingTopAndBottom, InlineLayoutUnit aligmentBaseline, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth);
+ LineGeometry(const InlineRect& lineBoxLogicalRect, const InlineRect& scrollableOverflow, EnclosingTopAndBottom, InlineLayoutUnit aligmentBaseline, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth);
const InlineRect& lineBoxLogicalRect() const { return m_lineBoxLogicalRect; }
+ const InlineRect& scrollableOverflow() const { return m_scrollableOverflow; }
EnclosingTopAndBottom enclosingTopAndBottom() const { return m_enclosingTopAndBottom; }
@@ -56,6 +57,7 @@
private:
// This is line box geometry (see https://www.w3.org/TR/css-inline-3/#line-box).
InlineRect m_lineBoxLogicalRect;
+ InlineRect m_scrollableOverflow;
// Enclosing top and bottom includes all inline level boxes (border box) vertically.
// While the line box usually enclose them as well, its vertical geometry is based on
// the layout bounds of the inline level boxes which may be different when line-height is present.
@@ -65,8 +67,9 @@
InlineLayoutUnit m_contentLogicalWidth { 0 };
};
-inline LineGeometry::LineGeometry(const InlineRect& lineBoxLogicalRect, EnclosingTopAndBottom enclosingTopAndBottom, InlineLayoutUnit aligmentBaseline, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth)
+inline LineGeometry::LineGeometry(const InlineRect& lineBoxLogicalRect, const InlineRect& scrollableOverflow, EnclosingTopAndBottom enclosingTopAndBottom, InlineLayoutUnit aligmentBaseline, InlineLayoutUnit contentLogicalLeft, InlineLayoutUnit contentLogicalWidth)
: m_lineBoxLogicalRect(lineBoxLogicalRect)
+ , m_scrollableOverflow(scrollableOverflow)
, m_enclosingTopAndBottom(enclosingTopAndBottom)
, m_aligmentBaseline(aligmentBaseline)
, m_contentLogicalLeft(contentLogicalLeft)
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp (282318 => 282319)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp 2021-09-12 20:52:53 UTC (rev 282318)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp 2021-09-13 02:14:13 UTC (rev 282319)
@@ -46,7 +46,7 @@
return { enclosingTopAndBottom.top + offset, enclosingTopAndBottom.bottom + offset };
}
-inline static float lineOverflowWidth(const RenderBlockFlow& flow, Layout::InlineLayoutUnit lineBoxLogicalWidth, Layout::InlineLayoutUnit lineContentLogicalWidth)
+inline static float lineOverflowWidth(const RenderBlockFlow& flow, Layout::InlineLayoutUnit lineContentLogicalWidth)
{
// FIXME: It's the copy of the lets-adjust-overflow-for-the-caret behavior from LegacyLineLayout::addOverflowFromInlineChildren.
auto endPadding = flow.hasNonVisibleOverflow() ? flow.paddingEnd() : 0_lu;
@@ -54,13 +54,11 @@
endPadding = flow.endPaddingWidthForCaret();
if (flow.hasNonVisibleOverflow() && !endPadding && flow.element() && flow.element()->isRootEditableElement())
endPadding = 1;
- lineContentLogicalWidth += endPadding;
- return std::max(lineBoxLogicalWidth, lineContentLogicalWidth);
+ return lineContentLogicalWidth + endPadding;
}
-InlineContentBuilder::InlineContentBuilder(const Layout::LayoutState& layoutState, const RenderBlockFlow& blockFlow, const BoxTree& boxTree)
- : m_layoutState(layoutState)
- , m_blockFlow(blockFlow)
+InlineContentBuilder::InlineContentBuilder(const RenderBlockFlow& blockFlow, const BoxTree& boxTree)
+ : m_blockFlow(blockFlow)
, m_boxTree(boxTree)
{
}
@@ -80,9 +78,9 @@
inlineContent.lines.reserveInitialCapacity(lines.size());
for (size_t lineIndex = 0; lineIndex < lines.size(); ++lineIndex) {
auto& line = lines[lineIndex];
- auto& lineBoxLogicalRect = line.lineBoxLogicalRect();
- // FIXME: This is where the logical to physical translate should happen.
- auto scrollableOverflowRect = FloatRect { lineBoxLogicalRect.left(), lineBoxLogicalRect.top(), lineOverflowWidth(m_blockFlow, lineBoxLogicalRect.width(), line.contentLogicalWidth()), lineBoxLogicalRect.height() };
+ auto scrollableOverflowRect = FloatRect { line.scrollableOverflow() };
+ if (auto overflowWidth = lineOverflowWidth(m_blockFlow, line.contentLogicalWidth()); overflowWidth > scrollableOverflowRect.width())
+ scrollableOverflowRect.setWidth(overflowWidth);
auto firstRunIndex = runIndex;
auto lineInkOverflowRect = scrollableOverflowRect;
@@ -93,17 +91,6 @@
lineInkOverflowRect.unite(run.inkOverflow());
auto& layoutBox = run.layoutBox();
- if (run.isNonRootInlineBox()) {
- // Collect scrollable overflow from inline boxes. All other inline level boxes (e.g atomic inline level boxes) stretch the line.
- auto hasScrollableContent = [&] {
- // In standards mode, inline boxes always start with an imaginary strut.
- auto& boxGeometry = inlineFormattingState.boxGeometry(layoutBox);
- return m_layoutState.inStandardsMode() || run.hasContent() || boxGeometry.horizontalBorder() || (boxGeometry.horizontalPadding() && boxGeometry.horizontalPadding().value());
- };
- if (hasScrollableContent())
- scrollableOverflowRect.unite(run.logicalRect());
- continue;
- }
if (layoutBox.isReplacedBox()) {
// Similar to LegacyInlineFlowBox::addReplacedChildOverflow.
auto& box = downcast<RenderBox>(m_boxTree.rendererForLayoutBox(layoutBox));
@@ -116,15 +103,11 @@
auto childScrollableOverflow = box.logicalLayoutOverflowRectForPropagation(&box.parent()->style());
childScrollableOverflow.move(runLogicalRect.left(), runLogicalRect.top());
scrollableOverflowRect.unite(childScrollableOverflow);
- continue;
}
}
-
- auto adjustedLineBoxRect = FloatRect { lineBoxLogicalRect };
- // Final enclosing top and bottom values are in the same coordinate space as the line itself.
- auto enclosingTopAndBottom = line.enclosingTopAndBottom() + lineBoxLogicalRect.top();
+ auto lineBoxLogicalRect = FloatRect { line.lineBoxLogicalRect() };
auto runCount = runIndex - firstRunIndex;
- inlineContent.lines.append({ firstRunIndex, runCount, adjustedLineBoxRect, enclosingTopAndBottom.top, enclosingTopAndBottom.bottom, scrollableOverflowRect, lineInkOverflowRect, line.baseline(), line.contentLogicalLeft(), line.contentLogicalWidth() });
+ inlineContent.lines.append({ firstRunIndex, runCount, lineBoxLogicalRect, line.enclosingTopAndBottom().top, line.enclosingTopAndBottom().bottom, scrollableOverflowRect, lineInkOverflowRect, line.baseline(), line.contentLogicalLeft(), line.contentLogicalWidth() });
}
}
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.h (282318 => 282319)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.h 2021-09-12 20:52:53 UTC (rev 282318)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.h 2021-09-13 02:14:13 UTC (rev 282319)
@@ -41,7 +41,7 @@
class InlineContentBuilder {
public:
- InlineContentBuilder(const Layout::LayoutState&, const RenderBlockFlow&, const BoxTree&);
+ InlineContentBuilder(const RenderBlockFlow&, const BoxTree&);
void build(Layout::InlineFormattingState&, InlineContent&) const;
@@ -48,7 +48,6 @@
private:
void createDisplayLines(Layout::InlineFormattingState&, InlineContent&) const;
- const Layout::LayoutState& m_layoutState;
const RenderBlockFlow& m_blockFlow;
const BoxTree& m_boxTree;
};
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (282318 => 282319)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2021-09-12 20:52:53 UTC (rev 282318)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2021-09-13 02:14:13 UTC (rev 282319)
@@ -226,7 +226,7 @@
void LineLayout::constructContent()
{
- auto inlineContentBuilder = InlineContentBuilder { m_layoutState, flow(), m_boxTree };
+ auto inlineContentBuilder = InlineContentBuilder { flow(), m_boxTree };
inlineContentBuilder.build(m_inlineFormattingState, ensureInlineContent());
ASSERT(m_inlineContent);