⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 267463 in webkit


Ignore:
Timestamp:
Sep 22, 2020, 9:39:06 PM (6 years ago)
Author:
Antti Koivisto
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):

Location:
trunk/Source/WebCore
Files:
1 added
7 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r267461 r267463  
     12020-09-22  Antti Koivisto  <antti@apple.com>
     2
     3        [LFC][Integration] Basic pagination support
     4        https://bugs.webkit.org/show_bug.cgi?id=215451
     5        <rdar://problem/67482721>
     6
     7        Reviewed by Zalan Bujtas.
     8
     9        Port the Simple Line Layout pagination code to LFC integration layer.
     10        Pagination is the last remaining use of SLL so this patch turns it into dead code.
     11
     12        * Sources.txt:
     13        * WebCore.xcodeproj/project.pbxproj:
     14        * layout/displaytree/DisplayInlineContent.h:
     15        (WebCore::Display::InlineContent::create):
     16        * layout/integration/LayoutIntegrationLineLayout.cpp:
     17        (WebCore::LayoutIntegration::LineLayout::canUseFor):
     18
     19        This now the same as SLL test, covering all cases.
     20
     21        (WebCore::LayoutIntegration::LineLayout::contentLogicalHeight const):
     22        (WebCore::LayoutIntegration::LineLayout::adjustForPagination):
     23        (WebCore::LayoutIntegration::LineLayout::ensureDisplayInlineContent):
     24
     25        This is fairly direct copy of the SLL code. It is not future proof or otherwise great but it serves the job for now.
     26
     27        * layout/integration/LayoutIntegrationLineLayout.h:
     28        (WebCore::LayoutIntegration::LineLayout::isPaginated const):
     29        * layout/integration/LayoutIntegrationPagination.cpp: Added.
     30        (WebCore::LayoutIntegration::computeLineTopAndBottomWithOverflow):
     31        (WebCore::LayoutIntegration::computeLineBreakIndex):
     32        (WebCore::LayoutIntegration::computeOffsetAfterLineBreak):
     33        (WebCore::LayoutIntegration::setPageBreakForLine):
     34        (WebCore::LayoutIntegration::updateMinimumPageHeight):
     35        (WebCore::LayoutIntegration::makeAdjustedContent):
     36        (WebCore::LayoutIntegration::adjustLinePositionsForPagination):
     37        * layout/integration/LayoutIntegrationPagination.h: Copied from Source/WebCore/layout/displaytree/DisplayInlineContent.h.
     38        * rendering/RenderBlockFlow.cpp:
     39        (WebCore::RenderBlockFlow::layoutLFCLines):
     40        (WebCore::RenderBlockFlow::ensureLineBoxes):
     41
    1422020-09-22  Zalan Bujtas  <zalan@apple.com>
    243
  • trunk/Source/WebCore/Sources.txt

    r267449 r267463  
    14571457layout/integration/LayoutIntegrationBoxTree.cpp
    14581458layout/integration/LayoutIntegrationLineLayout.cpp
     1459layout/integration/LayoutIntegrationPagination.cpp
    14591460layout/invalidation/InvalidationContext.cpp
    14601461layout/invalidation/InvalidationState.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r267449 r267463  
    1583115831                E43105B716750F0C00DB2FB8 /* NodeTraversal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NodeTraversal.cpp; sourceTree = "<group>"; };
    1583215832                E43105BA16750F1600DB2FB8 /* NodeTraversal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeTraversal.h; sourceTree = "<group>"; };
     15833                E4312AB524B3265600678349 /* LayoutIntegrationPagination.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutIntegrationPagination.cpp; sourceTree = "<group>"; };
     15834                E4312AB724B3265600678349 /* LayoutIntegrationPagination.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayoutIntegrationPagination.h; sourceTree = "<group>"; };
    1583315835                E4343D212392778300EBBB66 /* LineLayoutTraversalSimplePath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineLayoutTraversalSimplePath.h; sourceTree = "<group>"; };
    1583415836                E4343D242392778F00EBBB66 /* LineLayoutTraversalComplexPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineLayoutTraversalComplexPath.h; sourceTree = "<group>"; };
     
    2844228444                        isa = PBXGroup;
    2844328445                        children = (
     28446                                E4312AB524B3265600678349 /* LayoutIntegrationPagination.cpp */,
     28447                                E4312AB724B3265600678349 /* LayoutIntegrationPagination.h */,
    2844428448                                E418025623D454B500FFB071 /* LayoutIntegrationBoxTree.cpp */,
    2844528449                                E418025323D4549A00FFB071 /* LayoutIntegrationBoxTree.h */,
  • trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.h

    r267325 r267463  
    3737
    3838struct InlineContent : public RefCounted<InlineContent> {
     39    static Ref<InlineContent> create() { return adoptRef(*new InlineContent); }
    3940    ~InlineContent();
    4041
     
    4849    WTF::IteratorRange<const Run*> runsForRect(const LayoutRect&) const;
    4950    void shrinkToFit();
     51
     52private:
     53    InlineContent() = default;
    5054};
    5155
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp

    r267325 r267463  
    3838#include "InvalidationState.h"
    3939#include "LayoutBoxGeometry.h"
     40#include "LayoutIntegrationPagination.h"
    4041#include "LayoutTreeBuilder.h"
    4142#include "PaintInfo.h"
     
    7576    });
    7677
    77     if (!passesSimpleLineLayoutTest)
    78         return false;
    79 
    80     if (flow.fragmentedFlowState() != RenderObject::NotInsideFragmentedFlow)
    81         return false;
    82 
    83     return true;
     78    return passesSimpleLineLayoutTest;
    8479}
    8580
     
    226221LayoutUnit LineLayout::contentLogicalHeight() const
    227222{
     223    if (m_paginatedHeight)
     224        return *m_paginatedHeight;
     225
    228226    auto& lines = m_inlineFormattingState.lines();
    229227    return LayoutUnit { lines.last().logicalBottom() - lines.first().logicalTop() };
     
    264262}
    265263
     264void LineLayout::adjustForPagination(RenderBlockFlow& flow)
     265{
     266    ASSERT(&flow == &m_flow);
     267    auto paginedInlineContent = adjustLinePositionsForPagination(*m_displayInlineContent, flow);
     268    if (paginedInlineContent.ptr() == m_displayInlineContent) {
     269        m_paginatedHeight = { };
     270        return;
     271    }
     272
     273    auto& lines = paginedInlineContent->lines;
     274    m_paginatedHeight = LayoutUnit { lines.last().rect().maxY() - lines.first().rect().y() };
     275
     276    m_displayInlineContent = WTFMove(paginedInlineContent);
     277}
     278
    266279void LineLayout::collectOverflow(RenderBlockFlow& flow)
    267280{
     
    278291{
    279292    if (!m_displayInlineContent)
    280         m_displayInlineContent = adoptRef(*new Display::InlineContent);
     293        m_displayInlineContent = Display::InlineContent::create();
    281294    return *m_displayInlineContent;
    282295}
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h

    r267325 r267463  
    6868    LayoutUnit lastLineBaseline() const;
    6969
     70    void adjustForPagination(RenderBlockFlow&);
    7071    void collectOverflow(RenderBlockFlow&);
    7172
    7273    const Display::InlineContent* displayInlineContent() const { return m_displayInlineContent.get(); }
     74    bool isPaginated() const { return !!m_paginatedHeight; }
    7375
    7476    void paint(PaintInfo&, const LayoutPoint& paintOffset);
     
    9698    Layout::InlineFormattingState& m_inlineFormattingState;
    9799    RefPtr<Display::InlineContent> m_displayInlineContent;
     100    Optional<LayoutUnit> m_paginatedHeight;
    98101};
    99102
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.h

    r267462 r267463  
    11/*
    2  * Copyright (C) 2019 Apple Inc. All rights reserved.
     2 * Copyright (C) 2020 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
    30 #include "DisplayLine.h"
    31 #include "DisplayRun.h"
    32 #include <wtf/IteratorRange.h>
    33 #include <wtf/Vector.h>
     30#include "DisplayInlineContent.h"
    3431
    3532namespace WebCore {
    36 namespace Display {
    3733
    38 struct InlineContent : public RefCounted<InlineContent> {
    39     ~InlineContent();
     34class RenderBlockFlow;
    4035
    41     using Runs = Vector<Run, 4>;
    42     using Lines = Vector<Line, 4>;
    43 
    44     Runs runs;
    45     Lines lines;
    46 
    47     const Line& lineForRun(const Run& run) const { return lines[run.lineIndex()]; }
    48     WTF::IteratorRange<const Run*> runsForRect(const LayoutRect&) const;
    49     void shrinkToFit();
    50 };
    51 
    52 inline void InlineContent::shrinkToFit()
    53 {
    54     runs.shrinkToFit();
    55     lines.shrinkToFit();
    56 }
     36namespace LayoutIntegration {
     37   
     38Ref<Display::InlineContent> adjustLinePositionsForPagination(Display::InlineContent&, RenderBlockFlow&);
    5739
    5840}
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r267363 r267463  
    37443744    layoutFormattingContextLineLayout.layout();
    37453745
     3746    if (view().frameView().layoutContext().layoutState()->isPaginated())
     3747        layoutFormattingContextLineLayout.adjustForPagination(*this);
     3748
    37463749    auto contentHeight = layoutFormattingContextLineLayout.contentLogicalHeight();
    37473750    auto contentBoxTop = borderAndPaddingBefore();
     
    37673770    auto simpleLineLayout = makeRefPtr(this->simpleLineLayout());
    37683771
     3772    bool needsToPaginateComplexLines = [&] {
     3773        if (simpleLineLayout && simpleLineLayout->isPaginated())
     3774            return true;
     3775#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
     3776        if (layoutFormattingContextLineLayout() && layoutFormattingContextLineLayout()->isPaginated())
     3777            return true;
     3778#endif
     3779        return false;
     3780    }();
     3781
    37693782    m_lineLayout = makeUnique<ComplexLineLayout>(*this);
    37703783
     
    37863799    LayoutUnit repaintLogicalTop;
    37873800    LayoutUnit repaintLogicalBottom;
    3788     if (simpleLineLayout && simpleLineLayout->isPaginated()) {
     3801    if (needsToPaginateComplexLines) {
    37893802        PaginatedLayoutStateMaintainer state(*this);
    37903803        complexLineLayout.layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
Note: See TracChangeset for help on using the changeset viewer.