Title: [267463] trunk/Source/WebCore
Revision
267463
Author
[email protected]
Date
2020-09-22 21:39:06 -0700 (Tue, 22 Sep 2020)

Log Message

[LFC][Integration] Basic pagination support
https://bugs.webkit.org/show_bug.cgi?id=215451
<rdar://problem/67482721>

Reviewed by Zalan Bujtas.

Port the Simple Line Layout pagination code to LFC integration layer.
Pagination is the last remaining use of SLL so this patch turns it into dead code.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* layout/displaytree/DisplayInlineContent.h:
(WebCore::Display::InlineContent::create):
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::canUseFor):

This now the same as SLL test, covering all cases.

(WebCore::LayoutIntegration::LineLayout::contentLogicalHeight const):
(WebCore::LayoutIntegration::LineLayout::adjustForPagination):
(WebCore::LayoutIntegration::LineLayout::ensureDisplayInlineContent):

This is fairly direct copy of the SLL code. It is not future proof or otherwise great but it serves the job for now.

* layout/integration/LayoutIntegrationLineLayout.h:
(WebCore::LayoutIntegration::LineLayout::isPaginated const):
* layout/integration/LayoutIntegrationPagination.cpp: Added.
(WebCore::LayoutIntegration::computeLineTopAndBottomWithOverflow):
(WebCore::LayoutIntegration::computeLineBreakIndex):
(WebCore::LayoutIntegration::computeOffsetAfterLineBreak):
(WebCore::LayoutIntegration::setPageBreakForLine):
(WebCore::LayoutIntegration::updateMinimumPageHeight):
(WebCore::LayoutIntegration::makeAdjustedContent):
(WebCore::LayoutIntegration::adjustLinePositionsForPagination):
* layout/integration/LayoutIntegrationPagination.h: Copied from Source/WebCore/layout/displaytree/DisplayInlineContent.h.
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutLFCLines):
(WebCore::RenderBlockFlow::ensureLineBoxes):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (267462 => 267463)


--- trunk/Source/WebCore/ChangeLog	2020-09-23 04:08:08 UTC (rev 267462)
+++ trunk/Source/WebCore/ChangeLog	2020-09-23 04:39:06 UTC (rev 267463)
@@ -1,3 +1,44 @@
+2020-09-22  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] Basic pagination support
+        https://bugs.webkit.org/show_bug.cgi?id=215451
+        <rdar://problem/67482721>
+
+        Reviewed by Zalan Bujtas.
+
+        Port the Simple Line Layout pagination code to LFC integration layer.
+        Pagination is the last remaining use of SLL so this patch turns it into dead code.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * layout/displaytree/DisplayInlineContent.h:
+        (WebCore::Display::InlineContent::create):
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::canUseFor):
+
+        This now the same as SLL test, covering all cases.
+
+        (WebCore::LayoutIntegration::LineLayout::contentLogicalHeight const):
+        (WebCore::LayoutIntegration::LineLayout::adjustForPagination):
+        (WebCore::LayoutIntegration::LineLayout::ensureDisplayInlineContent):
+
+        This is fairly direct copy of the SLL code. It is not future proof or otherwise great but it serves the job for now.
+
+        * layout/integration/LayoutIntegrationLineLayout.h:
+        (WebCore::LayoutIntegration::LineLayout::isPaginated const):
+        * layout/integration/LayoutIntegrationPagination.cpp: Added.
+        (WebCore::LayoutIntegration::computeLineTopAndBottomWithOverflow):
+        (WebCore::LayoutIntegration::computeLineBreakIndex):
+        (WebCore::LayoutIntegration::computeOffsetAfterLineBreak):
+        (WebCore::LayoutIntegration::setPageBreakForLine):
+        (WebCore::LayoutIntegration::updateMinimumPageHeight):
+        (WebCore::LayoutIntegration::makeAdjustedContent):
+        (WebCore::LayoutIntegration::adjustLinePositionsForPagination):
+        * layout/integration/LayoutIntegrationPagination.h: Copied from Source/WebCore/layout/displaytree/DisplayInlineContent.h.
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::layoutLFCLines):
+        (WebCore::RenderBlockFlow::ensureLineBoxes):
+
 2020-09-22  Zalan Bujtas  <[email protected]>
 
         [LFC][Integration] Move RuntimeEnabledFeatures::layoutFormattingContextIntegrationEnabled() check out from LineBuilder::constraintsForLine

Modified: trunk/Source/WebCore/Sources.txt (267462 => 267463)


--- trunk/Source/WebCore/Sources.txt	2020-09-23 04:08:08 UTC (rev 267462)
+++ trunk/Source/WebCore/Sources.txt	2020-09-23 04:39:06 UTC (rev 267463)
@@ -1456,6 +1456,7 @@
 layout/inlineformatting/text/TextUtil.cpp
 layout/integration/LayoutIntegrationBoxTree.cpp
 layout/integration/LayoutIntegrationLineLayout.cpp
+layout/integration/LayoutIntegrationPagination.cpp
 layout/invalidation/InvalidationContext.cpp
 layout/invalidation/InvalidationState.cpp
 layout/layouttree/LayoutBox.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (267462 => 267463)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-09-23 04:08:08 UTC (rev 267462)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-09-23 04:39:06 UTC (rev 267463)
@@ -15830,6 +15830,8 @@
 		E42E76DB1C7AF77600E3614D /* StyleUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleUpdate.h; sourceTree = "<group>"; };
 		E43105B716750F0C00DB2FB8 /* NodeTraversal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NodeTraversal.cpp; sourceTree = "<group>"; };
 		E43105BA16750F1600DB2FB8 /* NodeTraversal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeTraversal.h; sourceTree = "<group>"; };
+		E4312AB524B3265600678349 /* LayoutIntegrationPagination.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutIntegrationPagination.cpp; sourceTree = "<group>"; };
+		E4312AB724B3265600678349 /* LayoutIntegrationPagination.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutIntegrationPagination.h; sourceTree = "<group>"; };
 		E4343D212392778300EBBB66 /* LineLayoutTraversalSimplePath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineLayoutTraversalSimplePath.h; sourceTree = "<group>"; };
 		E4343D242392778F00EBBB66 /* LineLayoutTraversalComplexPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineLayoutTraversalComplexPath.h; sourceTree = "<group>"; };
 		E43A023A17EB370A004CDD25 /* RenderElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderElement.h; sourceTree = "<group>"; };
@@ -28441,6 +28443,8 @@
 		E4FB4B1E2395356F003C336A /* integration */ = {
 			isa = PBXGroup;
 			children = (
+				E4312AB524B3265600678349 /* LayoutIntegrationPagination.cpp */,
+				E4312AB724B3265600678349 /* LayoutIntegrationPagination.h */,
 				E418025623D454B500FFB071 /* LayoutIntegrationBoxTree.cpp */,
 				E418025323D4549A00FFB071 /* LayoutIntegrationBoxTree.h */,
 				E4ABABDE2360893D00FA4345 /* LayoutIntegrationLineLayout.cpp */,

Modified: trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.h (267462 => 267463)


--- trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.h	2020-09-23 04:08:08 UTC (rev 267462)
+++ trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.h	2020-09-23 04:39:06 UTC (rev 267463)
@@ -36,6 +36,7 @@
 namespace Display {
 
 struct InlineContent : public RefCounted<InlineContent> {
+    static Ref<InlineContent> create() { return adoptRef(*new InlineContent); }
     ~InlineContent();
 
     using Runs = Vector<Run, 4>;
@@ -47,6 +48,9 @@
     const Line& lineForRun(const Run& run) const { return lines[run.lineIndex()]; }
     WTF::IteratorRange<const Run*> runsForRect(const LayoutRect&) const;
     void shrinkToFit();
+
+private:
+    InlineContent() = default;
 };
 
 inline void InlineContent::shrinkToFit()

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (267462 => 267463)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-09-23 04:08:08 UTC (rev 267462)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-09-23 04:39:06 UTC (rev 267463)
@@ -37,6 +37,7 @@
 #include "InlineFormattingState.h"
 #include "InvalidationState.h"
 #include "LayoutBoxGeometry.h"
+#include "LayoutIntegrationPagination.h"
 #include "LayoutTreeBuilder.h"
 #include "PaintInfo.h"
 #include "RenderBlockFlow.h"
@@ -74,13 +75,7 @@
         return SimpleLineLayout::canUseFor(flow);
     });
 
-    if (!passesSimpleLineLayoutTest)
-        return false;
-
-    if (flow.fragmentedFlowState() != RenderObject::NotInsideFragmentedFlow)
-        return false;
-
-    return true;
+    return passesSimpleLineLayoutTest;
 }
 
 bool LineLayout::canUseForAfterStyleChange(const RenderBlockFlow& flow, StyleDifference diff)
@@ -225,6 +220,9 @@
 
 LayoutUnit LineLayout::contentLogicalHeight() const
 {
+    if (m_paginatedHeight)
+        return *m_paginatedHeight;
+
     auto& lines = m_inlineFormattingState.lines();
     return LayoutUnit { lines.last().logicalBottom() - lines.first().logicalTop() };
 }
@@ -263,6 +261,21 @@
     return Layout::toLayoutUnit(lastLine.logicalTop() + lastLine.baseline());
 }
 
+void LineLayout::adjustForPagination(RenderBlockFlow& flow)
+{
+    ASSERT(&flow == &m_flow);
+    auto paginedInlineContent = adjustLinePositionsForPagination(*m_displayInlineContent, flow);
+    if (paginedInlineContent.ptr() == m_displayInlineContent) {
+        m_paginatedHeight = { };
+        return;
+    }
+
+    auto& lines = paginedInlineContent->lines;
+    m_paginatedHeight = LayoutUnit { lines.last().rect().maxY() - lines.first().rect().y() };
+
+    m_displayInlineContent = WTFMove(paginedInlineContent);
+}
+
 void LineLayout::collectOverflow(RenderBlockFlow& flow)
 {
     ASSERT(&flow == &m_flow);
@@ -277,7 +290,7 @@
 Display::InlineContent& LineLayout::ensureDisplayInlineContent()
 {
     if (!m_displayInlineContent)
-        m_displayInlineContent = adoptRef(*new Display::InlineContent);
+        m_displayInlineContent = Display::InlineContent::create();
     return *m_displayInlineContent;
 }
 

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (267462 => 267463)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2020-09-23 04:08:08 UTC (rev 267462)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2020-09-23 04:39:06 UTC (rev 267463)
@@ -67,9 +67,11 @@
     LayoutUnit firstLineBaseline() const;
     LayoutUnit lastLineBaseline() const;
 
+    void adjustForPagination(RenderBlockFlow&);
     void collectOverflow(RenderBlockFlow&);
 
     const Display::InlineContent* displayInlineContent() const { return m_displayInlineContent.get(); }
+    bool isPaginated() const { return !!m_paginatedHeight; }
 
     void paint(PaintInfo&, const LayoutPoint& paintOffset);
     bool hitTest(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint& accumulatedOffset, HitTestAction);
@@ -95,6 +97,7 @@
     Layout::LayoutState m_layoutState;
     Layout::InlineFormattingState& m_inlineFormattingState;
     RefPtr<Display::InlineContent> m_displayInlineContent;
+    Optional<LayoutUnit> m_paginatedHeight;
 };
 
 }

Added: trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp (0 => 267463)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp	                        (rev 0)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp	2020-09-23 04:39:06 UTC (rev 267463)
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LayoutIntegrationPagination.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "FontCascade.h"
+#include "RenderBlockFlow.h"
+#include "SimpleLineLayout.h"
+#include "SimpleLineLayoutFunctions.h"
+
+namespace WebCore {
+namespace LayoutIntegration {
+
+struct Strut {
+    unsigned lineBreak;
+    float offset;
+};
+
+struct PaginatedLine {
+    LayoutUnit top;
+    LayoutUnit height;
+};
+using PaginatedLines = Vector<PaginatedLine, 20>;
+
+static PaginatedLine computeLineTopAndBottomWithOverflow(const RenderBlockFlow&, Display::InlineContent::Lines& lines, unsigned lineIndex, Vector<Strut>& struts)
+{
+    LayoutUnit offset = 0;
+    for (auto& strut : struts) {
+        if (strut.lineBreak > lineIndex)
+            break;
+        offset += strut.offset;
+    }
+    auto overflowRect = LayoutRect(lines[lineIndex].inkOverflow());
+    return { overflowRect.y() + offset, overflowRect.height() };
+}
+
+static unsigned computeLineBreakIndex(unsigned breakCandidate, unsigned lineCount, int orphansNeeded, int widowsNeeded,
+    const Vector<Strut>& struts)
+{
+    // First line does not fit the current page.
+    if (!breakCandidate)
+        return breakCandidate;
+    
+    int widowsOnTheNextPage = lineCount - breakCandidate;
+    if (widowsNeeded <= widowsOnTheNextPage)
+        return breakCandidate;
+    // Only break after the first line with widows.
+    auto lineBreak = std::max<int>(lineCount - widowsNeeded, 1);
+    if (orphansNeeded > lineBreak)
+        return breakCandidate;
+    // Break on current page only.
+    if (struts.isEmpty())
+        return lineBreak;
+    ASSERT(struts.last().lineBreak + 1 < lineCount);
+    return std::max<unsigned>(struts.last().lineBreak + 1, lineBreak);
+}
+
+static LayoutUnit computeOffsetAfterLineBreak(LayoutUnit lineBreakPosition, bool isFirstLine, bool atTheTopOfColumnOrPage, const RenderBlockFlow& flow)
+{
+    // No offset for top of the page lines unless widows pushed the line break.
+    LayoutUnit offset = isFirstLine ? flow.borderAndPaddingBefore() : 0_lu;
+    if (atTheTopOfColumnOrPage)
+        return offset;
+    return offset + flow.pageRemainingLogicalHeightForOffset(lineBreakPosition, RenderBlockFlow::ExcludePageBoundary);
+}
+
+static void setPageBreakForLine(unsigned lineBreakIndex, PaginatedLines& lines, RenderBlockFlow& flow, Vector<Strut>& struts,
+    bool atTheTopOfColumnOrPage, bool lineDoesNotFit)
+{
+    auto line = lines.at(lineBreakIndex);
+    auto remainingLogicalHeight = flow.pageRemainingLogicalHeightForOffset(line.top, RenderBlockFlow::ExcludePageBoundary);
+    auto& style = flow.style();
+    auto firstLineDoesNotFit = !lineBreakIndex && line.height < flow.pageLogicalHeightForOffset(line.top);
+    auto moveOrphanToNextColumn = lineDoesNotFit && !style.hasAutoOrphans() && style.orphans() > (short)lineBreakIndex;
+    if (firstLineDoesNotFit || moveOrphanToNextColumn) {
+        auto firstLine = lines.first();
+        auto firstLineUpperOverhang = std::max(LayoutUnit(-firstLine.top), 0_lu);
+        flow.setPaginationStrut(line.top + remainingLogicalHeight + firstLineUpperOverhang);
+        return;
+    }
+    if (atTheTopOfColumnOrPage)
+        flow.setPageBreak(line.top, line.height);
+    else
+        flow.setPageBreak(line.top, line.height - remainingLogicalHeight);
+    struts.append({ lineBreakIndex, computeOffsetAfterLineBreak(lines[lineBreakIndex].top, !lineBreakIndex, atTheTopOfColumnOrPage, flow) });
+}
+
+static void updateMinimumPageHeight(RenderBlockFlow& flow, const Display::InlineContent& inlineContent, unsigned lineCount)
+{
+    auto& style = flow.style();
+    auto widows = style.hasAutoWidows() ? 1 : std::max<int>(style.widows(), 1);
+    auto orphans = style.hasAutoOrphans() ? 1 : std::max<int>(style.orphans(), 1);
+    auto minimumLineCount = std::min<unsigned>(std::max(widows, orphans), lineCount);
+    flow.updateMinimumPageHeight(0, LayoutUnit(inlineContent.lines[minimumLineCount - 1].rect().maxY()));
+}
+
+static Ref<Display::InlineContent> makeAdjustedContent(const Display::InlineContent& inlineContent, Vector<float> adjustments)
+{
+    auto moveVertically = [](FloatRect rect, float offset) {
+        rect.move(FloatSize(0, offset));
+        return rect;
+    };
+
+    auto adjustedLine = [&](const Display::Line& line, float offset)
+    {
+        return Display::Line {
+            moveVertically(line.rect(), offset),
+            moveVertically(line.scrollableOverflow(), offset),
+            moveVertically(line.inkOverflow(), offset),
+            line.baseline(),
+            line.horizontalAlignmentOffset()
+        };
+    };
+
+    auto adjustedRun = [&](const Display::Run& run, float offset)
+    {
+        return Display::Run {
+            run.lineIndex(),
+            run.layoutBox(),
+            moveVertically(run.rect(), offset),
+            moveVertically(run.inkOverflow(), offset),
+            run.expansion(),
+            run.textContent()
+        };
+    };
+
+    auto adjustedContent = Display::InlineContent::create();
+
+    for (size_t lineIndex = 0; lineIndex < inlineContent.lines.size(); ++lineIndex)
+        adjustedContent->lines.append(adjustedLine(inlineContent.lines[lineIndex], adjustments[lineIndex]));
+
+    for (auto& run : inlineContent.runs)
+        adjustedContent->runs.append(adjustedRun(run, adjustments[run.lineIndex()]));
+
+    return adjustedContent;
+}
+
+Ref<Display::InlineContent> adjustLinePositionsForPagination(Display::InlineContent& inlineContent, RenderBlockFlow& flow)
+{
+    Vector<Strut> struts;
+    auto lineCount = inlineContent.lines.size();
+    updateMinimumPageHeight(flow, inlineContent, lineCount);
+    // First pass with no pagination offset?
+    if (!flow.pageLogicalHeightForOffset(0))
+        return inlineContent;
+
+    auto widows = flow.style().hasAutoWidows() ? 1 : std::max<int>(flow.style().widows(), 1);
+    auto orphans = flow.style().hasAutoOrphans() ? 1 : std::max<int>(flow.style().orphans(), 1);
+    PaginatedLines lines;
+    for (unsigned lineIndex = 0; lineIndex < lineCount; ++lineIndex) {
+        auto line = computeLineTopAndBottomWithOverflow(flow, inlineContent.lines, lineIndex, struts);
+        lines.append(line);
+        auto remainingHeight = flow.pageRemainingLogicalHeightForOffset(line.top, RenderBlockFlow::ExcludePageBoundary);
+        auto atTheTopOfColumnOrPage = flow.pageLogicalHeightForOffset(line.top) == remainingHeight;
+        auto lineDoesNotFit = line.height > remainingHeight;
+        if (lineDoesNotFit || (atTheTopOfColumnOrPage && lineIndex)) {
+            auto lineBreakIndex = computeLineBreakIndex(lineIndex, lineCount, orphans, widows, struts);
+            // Are we still at the top of the column/page?
+            atTheTopOfColumnOrPage = atTheTopOfColumnOrPage ? lineIndex == lineBreakIndex : false;
+            setPageBreakForLine(lineBreakIndex, lines, flow, struts, atTheTopOfColumnOrPage, lineDoesNotFit);
+            // Recompute line positions that we already visited but widow break pushed them to a new page.
+            for (auto i = lineBreakIndex; i < lines.size(); ++i)
+                lines.at(i) = computeLineTopAndBottomWithOverflow(flow, inlineContent.lines, i, struts);
+        }
+    }
+
+    if (struts.isEmpty())
+        return inlineContent;
+
+    auto adjustments = Vector<float>(lineCount, 0);
+    for (auto& strut : struts) {
+        for (auto lineIndex = strut.lineBreak; lineIndex < lineCount; ++lineIndex)
+            adjustments[lineIndex] += strut.offset;
+    }
+
+    return makeAdjustedContent(inlineContent, adjustments);
+}
+
+}
+}
+
+#endif

Copied: trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.h (from rev 267462, trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.h) (0 => 267463)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.h	2020-09-23 04:39:06 UTC (rev 267463)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "DisplayInlineContent.h"
+
+namespace WebCore {
+
+class RenderBlockFlow;
+
+namespace LayoutIntegration {
+    
+Ref<Display::InlineContent> adjustLinePositionsForPagination(Display::InlineContent&, RenderBlockFlow&);
+
+}
+}
+
+#endif

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (267462 => 267463)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2020-09-23 04:08:08 UTC (rev 267462)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2020-09-23 04:39:06 UTC (rev 267463)
@@ -3743,6 +3743,9 @@
 
     layoutFormattingContextLineLayout.layout();
 
+    if (view().frameView().layoutContext().layoutState()->isPaginated())
+        layoutFormattingContextLineLayout.adjustForPagination(*this);
+
     auto contentHeight = layoutFormattingContextLineLayout.contentLogicalHeight();
     auto contentBoxTop = borderAndPaddingBefore();
     auto contentBoxBottom = contentBoxTop + contentHeight;
@@ -3766,6 +3769,16 @@
 
     auto simpleLineLayout = makeRefPtr(this->simpleLineLayout());
 
+    bool needsToPaginateComplexLines = [&] {
+        if (simpleLineLayout && simpleLineLayout->isPaginated())
+            return true;
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+        if (layoutFormattingContextLineLayout() && layoutFormattingContextLineLayout()->isPaginated())
+            return true;
+#endif
+        return false;
+    }();
+
     m_lineLayout = makeUnique<ComplexLineLayout>(*this);
 
     if (simpleLineLayout) {
@@ -3785,7 +3798,7 @@
     bool relayoutChildren = false;
     LayoutUnit repaintLogicalTop;
     LayoutUnit repaintLogicalBottom;
-    if (simpleLineLayout && simpleLineLayout->isPaginated()) {
+    if (needsToPaginateComplexLines) {
         PaginatedLayoutStateMaintainer state(*this);
         complexLineLayout.layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
         // This matches relayoutToAvoidWidows.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to