Title: [253270] trunk/Source/WebCore
Revision
253270
Author
[email protected]
Date
2019-12-08 07:30:50 -0800 (Sun, 08 Dec 2019)

Log Message

[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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (253269 => 253270)


--- trunk/Source/WebCore/ChangeLog	2019-12-08 15:10:06 UTC (rev 253269)
+++ trunk/Source/WebCore/ChangeLog	2019-12-08 15:30:50 UTC (rev 253270)
@@ -1,3 +1,21 @@
+2019-12-08  Antti Koivisto  <[email protected]>
+
+        [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  <[email protected]>
 
         [LFC][IFC] Switch over to float based types in inline layout

Modified: trunk/Source/WebCore/layout/displaytree/DisplayLineBox.h (253269 => 253270)


--- trunk/Source/WebCore/layout/displaytree/DisplayLineBox.h	2019-12-08 15:10:06 UTC (rev 253269)
+++ trunk/Source/WebCore/layout/displaytree/DisplayLineBox.h	2019-12-08 15:30:50 UTC (rev 253270)
@@ -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(); }

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (253269 => 253270)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2019-12-08 15:10:06 UTC (rev 253269)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2019-12-08 15:30:50 UTC (rev 253270)
@@ -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;
 

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (253269 => 253270)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2019-12-08 15:10:06 UTC (rev 253269)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2019-12-08 15:30:50 UTC (rev 253270)
@@ -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);

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (253269 => 253270)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2019-12-08 15:10:06 UTC (rev 253269)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2019-12-08 15:30:50 UTC (rev 253270)
@@ -2969,6 +2969,13 @@
         return;
     }
 
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+    if (layoutFormattingContextLineLayout()) {
+        layoutFormattingContextLineLayout()->collectOverflow(*this);
+        return;
+    }
+#endif
+    
     if (complexLineLayout())
         complexLineLayout()->addOverflowFromInlineChildren();
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to