[LFC][Integration] Collect overflow from lines
https://bugs.webkit.org/show_bug.cgi?id=204994
Reviewed by Zalan Bujtas.
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::logicalRect const):
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::computeVisualOverflow):
(WebCore::LayoutIntegration::LineLayout::collectOverflow):
* layout/integration/LayoutIntegrationLineLayout.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::addOverflowFromInlineChildren):
Connect to LFC layout.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@253270 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 7246b26..2138262 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2019-12-08 Antti Koivisto <antti@apple.com>
+
+ [LFC][Integration] Collect overflow from lines
+ https://bugs.webkit.org/show_bug.cgi?id=204994
+
+ Reviewed by Zalan Bujtas.
+
+ * layout/displaytree/DisplayLineBox.h:
+ (WebCore::Display::LineBox::logicalRect const):
+ * layout/integration/LayoutIntegrationLineLayout.cpp:
+ (WebCore::LayoutIntegration::computeVisualOverflow):
+ (WebCore::LayoutIntegration::LineLayout::collectOverflow):
+ * layout/integration/LayoutIntegrationLineLayout.h:
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::addOverflowFromInlineChildren):
+
+ Connect to LFC layout.
+
2019-12-08 Zalan Bujtas <zalan@apple.com>
[LFC][IFC] Switch over to float based types in inline layout
diff --git a/Source/WebCore/layout/displaytree/DisplayLineBox.h b/Source/WebCore/layout/displaytree/DisplayLineBox.h
index 44cf8c9..f5c862b 100644
--- a/Source/WebCore/layout/displaytree/DisplayLineBox.h
+++ b/Source/WebCore/layout/displaytree/DisplayLineBox.h
@@ -60,7 +60,9 @@
LineBox(const InlineRect&, const Baseline&, InlineLayoutUnit baselineOffset);
LineBox() = default;
-
+
+ const InlineRect& logicalRect() const { return m_rect; }
+
InlineLayoutPoint logicalTopLeft() const { return m_rect.topLeft(); }
InlineLayoutUnit logicalLeft() const { return m_rect.left(); }
diff --git a/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp b/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp
index 0428ac18..a3571ed 100644
--- a/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp
+++ b/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp
@@ -132,6 +132,36 @@
return Layout::toLayoutUnit(lastLineBox.logicalTop() + lastLineBox.baselineOffset());
}
+// FIXME: LFC should handle overflow computations.
+static LayoutRect computeVisualOverflow(const RenderStyle& style, const LayoutRect& boxRect, IntSize& viewportSize)
+{
+ auto overflowRect = boxRect;
+ auto strokeOverflow = std::ceil(style.computedStrokeWidth(viewportSize));
+ overflowRect.inflate(strokeOverflow);
+
+ auto letterSpacing = style.fontCascade().letterSpacing();
+ if (letterSpacing >= 0)
+ return overflowRect;
+ // Last letter's negative spacing shrinks layout rect. Push it to visual overflow.
+ overflowRect.expand(-letterSpacing, 0);
+ return overflowRect;
+}
+
+void LineLayout::collectOverflow(RenderBlockFlow& flow)
+{
+ ASSERT(&flow == &m_flow);
+ ASSERT(!flow.hasOverflowClip());
+
+ auto viewportSize = m_flow.frame().view()->size();
+
+ for (auto& lineBox : displayInlineContent()->lineBoxes) {
+ auto lineRect = Layout::toLayoutRect(lineBox.logicalRect());
+ auto visualOverflowRect = computeVisualOverflow(flow.style(), lineRect, viewportSize);
+ flow.addLayoutOverflow(lineRect);
+ flow.addVisualOverflow(visualOverflowRect);
+ }
+}
+
const Display::InlineContent* LineLayout::displayInlineContent() const
{
return downcast<Layout::InlineFormattingState>(m_layoutState->establishedFormattingState(rootLayoutBox())).displayInlineContent();
@@ -184,20 +214,6 @@
return m_treeContent->rootLayoutBox();
}
-static LayoutRect computeOverflow(const RenderStyle& style, const LayoutRect& boxRect, IntSize& viewportSize)
-{
- auto overflowRect = boxRect;
- auto strokeOverflow = std::ceil(style.computedStrokeWidth(viewportSize));
- overflowRect.inflate(strokeOverflow);
-
- auto letterSpacing = style.fontCascade().letterSpacing();
- if (letterSpacing >= 0)
- return overflowRect;
- // Last letter's negative spacing shrinks layout rect. Push it to visual overflow.
- overflowRect.expand(-letterSpacing, 0);
- return overflowRect;
-}
-
void LineLayout::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (!displayInlineContent())
@@ -227,7 +243,7 @@
return;
auto rect = Layout::toLayoutRect(run.logicalRect());
- auto visualOverflowRect = computeOverflow(style, rect, viewportSize);
+ auto visualOverflowRect = computeVisualOverflow(style, rect, viewportSize);
if (paintRect.y() > visualOverflowRect.maxY() || paintRect.maxY() < visualOverflowRect.y())
continue;
diff --git a/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h b/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h
index b5db173..c4906df 100644
--- a/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h
+++ b/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h
@@ -60,9 +60,12 @@
LayoutUnit contentLogicalHeight() const { return m_contentLogicalHeight; }
size_t lineCount() const;
+
LayoutUnit firstLineBaseline() const;
LayoutUnit lastLineBaseline() const;
+ void collectOverflow(RenderBlockFlow&);
+
const Display::InlineContent* displayInlineContent() const;
void paint(PaintInfo&, const LayoutPoint& paintOffset);
diff --git a/Source/WebCore/rendering/RenderBlockFlow.cpp b/Source/WebCore/rendering/RenderBlockFlow.cpp
index f215509..6bad91c 100644
--- a/Source/WebCore/rendering/RenderBlockFlow.cpp
+++ b/Source/WebCore/rendering/RenderBlockFlow.cpp
@@ -2969,6 +2969,13 @@
return;
}
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+ if (layoutFormattingContextLineLayout()) {
+ layoutFormattingContextLineLayout()->collectOverflow(*this);
+ return;
+ }
+#endif
+
if (complexLineLayout())
complexLineLayout()->addOverflowFromInlineChildren();
}