Changeset 248528 in webkit


Ignore:
Timestamp:
Aug 12, 2019 8:31:34 AM (5 years ago)
Author:
Antti Koivisto
Message:

Only construct ComplexLineLayout when needed
https://bugs.webkit.org/show_bug.cgi?id=200625

Reviewed by Zalan Bujtas.

  • rendering/ComplexLineLayout.cpp:

(WebCore::ComplexLineLayout::createInlineBoxForRenderer):
(WebCore::ComplexLineLayout::createLineBoxes):
(WebCore::ComplexLineLayout::constructLine):
(WebCore::ComplexLineLayout::updateLogicalWidthForAlignment):

Make static so this can be invoked without constructing complex line layout (from startAlignedOffsetForLine).

(WebCore::ComplexLineLayout::computeInlineDirectionPositionsForSegment):
(WebCore::ComplexLineLayout::deleteEllipsisLineBoxes):
(WebCore::ComplexLineLayout::checkLinesForTextOverflow):
(WebCore::ComplexLineLayout::startAlignedOffsetForLine): Deleted.

This is also used in block layout to set static positions of positioned objects.
Move to RenderBlockFlow where its only caller is.

  • rendering/ComplexLineLayout.h:
  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::RenderBlockFlow):
(WebCore::RenderBlockFlow::willBeDestroyed):
(WebCore::RenderBlockFlow::layoutInlineChildren):
(WebCore::RenderBlockFlow::updateStaticInlinePositionForChild):
(WebCore::RenderBlockFlow::startAlignedOffsetForLine):
(WebCore::RenderBlockFlow::deleteLines):
(WebCore::RenderBlockFlow::hitTestInlineChildren):
(WebCore::RenderBlockFlow::addOverflowFromInlineChildren):
(WebCore::RenderBlockFlow::paintInlineChildren):
(WebCore::RenderBlockFlow::hasLines const):
(WebCore::RenderBlockFlow::layoutSimpleLines):
(WebCore::RenderBlockFlow::deleteLineBoxesBeforeSimpleLineLayout):
(WebCore::RenderBlockFlow::ensureLineBoxes):

  • rendering/RenderBlockFlow.h:

(WebCore::RenderBlockFlow::firstRootBox const):
(WebCore::RenderBlockFlow::lastRootBox const):
(WebCore::RenderBlockFlow::complexLineLayout):
(WebCore::RenderBlockFlow::lineBoxes): Deleted.
(WebCore::RenderBlockFlow::lineBoxes const): Deleted.

  • rendering/RootInlineBox.cpp:

(WebCore::RootInlineBox::removeLineBoxFromRenderObject):
(WebCore::RootInlineBox::extractLineBoxFromRenderObject):
(WebCore::RootInlineBox::attachLineBoxToRenderObject):

  • rendering/SimpleLineLayoutFunctions.cpp:

(WebCore::SimpleLineLayout::generateLineBoxTree):

Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r248527 r248528  
     12019-08-12  Antti Koivisto  <antti@apple.com>
     2
     3        Only construct ComplexLineLayout when needed
     4        https://bugs.webkit.org/show_bug.cgi?id=200625
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        * rendering/ComplexLineLayout.cpp:
     9        (WebCore::ComplexLineLayout::createInlineBoxForRenderer):
     10        (WebCore::ComplexLineLayout::createLineBoxes):
     11        (WebCore::ComplexLineLayout::constructLine):
     12        (WebCore::ComplexLineLayout::updateLogicalWidthForAlignment):
     13
     14        Make static so this can be invoked without constructing complex line layout (from startAlignedOffsetForLine).
     15
     16        (WebCore::ComplexLineLayout::computeInlineDirectionPositionsForSegment):
     17        (WebCore::ComplexLineLayout::deleteEllipsisLineBoxes):
     18        (WebCore::ComplexLineLayout::checkLinesForTextOverflow):
     19        (WebCore::ComplexLineLayout::startAlignedOffsetForLine): Deleted.
     20
     21        This is also used in block layout to set static positions of positioned objects.
     22        Move to RenderBlockFlow where its only caller is.
     23
     24        * rendering/ComplexLineLayout.h:
     25        * rendering/RenderBlockFlow.cpp:
     26        (WebCore::RenderBlockFlow::RenderBlockFlow):
     27        (WebCore::RenderBlockFlow::willBeDestroyed):
     28        (WebCore::RenderBlockFlow::layoutInlineChildren):
     29        (WebCore::RenderBlockFlow::updateStaticInlinePositionForChild):
     30        (WebCore::RenderBlockFlow::startAlignedOffsetForLine):
     31        (WebCore::RenderBlockFlow::deleteLines):
     32        (WebCore::RenderBlockFlow::hitTestInlineChildren):
     33        (WebCore::RenderBlockFlow::addOverflowFromInlineChildren):
     34        (WebCore::RenderBlockFlow::paintInlineChildren):
     35        (WebCore::RenderBlockFlow::hasLines const):
     36        (WebCore::RenderBlockFlow::layoutSimpleLines):
     37        (WebCore::RenderBlockFlow::deleteLineBoxesBeforeSimpleLineLayout):
     38        (WebCore::RenderBlockFlow::ensureLineBoxes):
     39        * rendering/RenderBlockFlow.h:
     40        (WebCore::RenderBlockFlow::firstRootBox const):
     41        (WebCore::RenderBlockFlow::lastRootBox const):
     42        (WebCore::RenderBlockFlow::complexLineLayout):
     43        (WebCore::RenderBlockFlow::lineBoxes): Deleted.
     44        (WebCore::RenderBlockFlow::lineBoxes const): Deleted.
     45        * rendering/RootInlineBox.cpp:
     46        (WebCore::RootInlineBox::removeLineBoxFromRenderObject):
     47        (WebCore::RootInlineBox::extractLineBoxFromRenderObject):
     48        (WebCore::RootInlineBox::attachLineBoxToRenderObject):
     49        * rendering/SimpleLineLayoutFunctions.cpp:
     50        (WebCore::SimpleLineLayout::generateLineBoxTree):
     51
    1522019-08-12  Youenn Fablet  <youenn@apple.com>
    253
  • trunk/Source/WebCore/rendering/ComplexLineLayout.cpp

    r248517 r248528  
    153153}
    154154
    155 inline InlineBox* ComplexLineLayout::createInlineBoxForRenderer(RenderObject* renderer, bool isRootLineBox, bool isOnlyRun)
    156 {
    157     if (isRootLineBox)
    158         return downcast<RenderBlockFlow>(*renderer).complexLineLayout().createAndAppendRootInlineBox();
     155InlineBox* ComplexLineLayout::createInlineBoxForRenderer(RenderObject* renderer, bool isOnlyRun)
     156{
     157    if (renderer == &m_flow)
     158        return createAndAppendRootInlineBox();
    159159
    160160    if (is<RenderText>(*renderer))
     
    227227            // We need to make a new box for this render object. Once
    228228            // made, we need to place it at the end of the current line.
    229             InlineBox* newBox = createInlineBoxForRenderer(obj, obj == &m_flow);
     229            InlineBox* newBox = createInlineBoxForRenderer(obj);
    230230            parentBox = downcast<InlineFlowBox>(newBox);
    231231            parentBox->setIsFirstLine(lineInfo.isFirstLine());
     
    302302            continue;
    303303
    304         InlineBox* box = createInlineBoxForRenderer(&r->renderer(), false, isOnlyRun);
     304        InlineBox* box = createInlineBoxForRenderer(&r->renderer(), isOnlyRun);
    305305        r->setBox(box);
    306306
     
    632632}
    633633
    634 void ComplexLineLayout::updateLogicalWidthForAlignment(const TextAlignMode& textAlign, const RootInlineBox* rootInlineBox, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount)
     634void ComplexLineLayout::updateLogicalWidthForAlignment(RenderBlockFlow& flow, const TextAlignMode& textAlign, const RootInlineBox* rootInlineBox, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount)
    635635{
    636636    TextDirection direction;
    637     if (rootInlineBox && style().unicodeBidi() == Plaintext)
     637    if (rootInlineBox && flow.style().unicodeBidi() == Plaintext)
    638638        direction = rootInlineBox->direction();
    639639    else
    640         direction = style().direction();
     640        direction = flow.style().direction();
     641
     642    bool isLeftToRightDirection = flow.style().isLeftToRightDirection();
    641643
    642644    // Armed with the total width of the line (without justification),
     
    647649    case TextAlignMode::Left:
    648650    case TextAlignMode::WebKitLeft:
    649         updateLogicalWidthForLeftAlignedBlock(style().isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
     651        updateLogicalWidthForLeftAlignedBlock(isLeftToRightDirection, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
    650652        break;
    651653    case TextAlignMode::Right:
    652654    case TextAlignMode::WebKitRight:
    653         updateLogicalWidthForRightAlignedBlock(style().isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
     655        updateLogicalWidthForRightAlignedBlock(isLeftToRightDirection, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
    654656        break;
    655657    case TextAlignMode::Center:
    656658    case TextAlignMode::WebKitCenter:
    657         updateLogicalWidthForCenterAlignedBlock(style().isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
     659        updateLogicalWidthForCenterAlignedBlock(isLeftToRightDirection, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
    658660        break;
    659661    case TextAlignMode::Justify:
    660         m_flow.adjustInlineDirectionLineBounds(expansionOpportunityCount, logicalLeft, availableLogicalWidth);
     662        flow.adjustInlineDirectionLineBounds(expansionOpportunityCount, logicalLeft, availableLogicalWidth);
    661663        if (expansionOpportunityCount) {
    662664            if (trailingSpaceRun) {
     
    669671    case TextAlignMode::Start:
    670672        if (direction == TextDirection::LTR)
    671             updateLogicalWidthForLeftAlignedBlock(style().isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
     673            updateLogicalWidthForLeftAlignedBlock(isLeftToRightDirection, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
    672674        else
    673             updateLogicalWidthForRightAlignedBlock(style().isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
     675            updateLogicalWidthForRightAlignedBlock(isLeftToRightDirection, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
    674676        break;
    675677    case TextAlignMode::End:
    676678        if (direction == TextDirection::LTR)
    677             updateLogicalWidthForRightAlignedBlock(style().isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
     679            updateLogicalWidthForRightAlignedBlock(isLeftToRightDirection, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
    678680        else
    679             updateLogicalWidthForLeftAlignedBlock(style().isLeftToRightDirection(), trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
     681            updateLogicalWidthForLeftAlignedBlock(isLeftToRightDirection, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth);
    680682        break;
    681683    }
     
    960962        textAlign = TextAlignMode::Center;
    961963
    962     updateLogicalWidthForAlignment(textAlign, lineBox, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth, expansionOpportunityCount);
     964    updateLogicalWidthForAlignment(m_flow, textAlign, lineBox, trailingSpaceRun, logicalLeft, totalLogicalWidth, availableLogicalWidth, expansionOpportunityCount);
    963965
    964966    computeExpansionForJustifiedText(firstRun, trailingSpaceRun, expansionOpportunities, expansionOpportunityCount, totalLogicalWidth, availableLogicalWidth);
     
    21142116            float availableLogicalWidth = m_flow.logicalRightOffsetForLine(curr->lineTop(), DoNotIndentText) - logicalLeft;
    21152117            float totalLogicalWidth = curr->logicalWidth();
    2116             updateLogicalWidthForAlignment(textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
     2118            updateLogicalWidthForAlignment(m_flow, textAlign, curr, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
    21172119
    21182120            if (ltr)
     
    21592161                float logicalLeft = 0; // We are only interested in the delta from the base position.
    21602162                float truncatedWidth = m_flow.availableLogicalWidthForLine(curr->lineTop(), shouldIndentText);
    2161                 updateLogicalWidthForAlignment(textAlign, curr, nullptr, logicalLeft, totalLogicalWidth, truncatedWidth, 0);
     2163                updateLogicalWidthForAlignment(m_flow, textAlign, curr, nullptr, logicalLeft, totalLogicalWidth, truncatedWidth, 0);
    21622164                if (ltr)
    21632165                    curr->adjustLogicalPosition(logicalLeft, 0);
     
    22262228}
    22272229
    2228 LayoutUnit ComplexLineLayout::startAlignedOffsetForLine(LayoutUnit position, IndentTextOrNot shouldIndentText)
    2229 {
    2230     TextAlignMode textAlign = style().textAlign();
    2231     bool shouldApplyIndentText = false;
    2232     switch (textAlign) {
    2233     case TextAlignMode::Left:
    2234     case TextAlignMode::WebKitLeft:
    2235         shouldApplyIndentText = style().isLeftToRightDirection();
    2236         break;
    2237     case TextAlignMode::Right:
    2238     case TextAlignMode::WebKitRight:
    2239         shouldApplyIndentText = !style().isLeftToRightDirection();
    2240         break;
    2241     case TextAlignMode::Start:
    2242         shouldApplyIndentText = true;
    2243         break;
    2244     default:
    2245         shouldApplyIndentText = false;
    2246     }
    2247     // <rdar://problem/15427571>
    2248     // https://bugs.webkit.org/show_bug.cgi?id=124522
    2249     // This quirk is for legacy content that doesn't work properly with the center positioning scheme
    2250     // being honored (e.g., epubs).
    2251     if (shouldApplyIndentText || m_flow.settings().useLegacyTextAlignPositionedElementBehavior()) // FIXME: Handle TextAlignMode::End here
    2252         return m_flow.startOffsetForLine(position, shouldIndentText);
    2253 
    2254     // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here
    2255     float totalLogicalWidth = 0;
    2256     float logicalLeft = m_flow.logicalLeftOffsetForLine(m_flow.logicalHeight(), DoNotIndentText);
    2257     float availableLogicalWidth = m_flow.logicalRightOffsetForLine(m_flow.logicalHeight(), DoNotIndentText) - logicalLeft;
    2258 
    2259     // FIXME: Bug 129311: We need to pass a valid RootInlineBox here, considering the bidi level used to construct the line.
    2260     updateLogicalWidthForAlignment(textAlign, 0, 0, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
    2261 
    2262     if (!style().isLeftToRightDirection())
    2263         return LayoutUnit(m_flow.logicalWidth() - logicalLeft);
    2264     return LayoutUnit(logicalLeft);
    2265 }
    2266 
    22672230void ComplexLineLayout::updateFragmentForLine(RootInlineBox* lineBox) const
    22682231{
  • trunk/Source/WebCore/rendering/ComplexLineLayout.h

    r248517 r248528  
    6767    void layoutLineBoxes(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom);
    6868
    69     LayoutUnit startAlignedOffsetForLine(LayoutUnit position, IndentTextOrNot shouldIndentText);
    7069    RootInlineBox* constructLine(BidiRunList<BidiRun>&, const LineInfo&);
    7170    bool positionNewFloatOnLine(const FloatingObject& newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo&, LineWidth&);
     
    7372
    7473    static void appendRunsForObject(BidiRunList<BidiRun>*, int start, int end, RenderObject&, InlineBidiResolver&);
     74    static void updateLogicalWidthForAlignment(RenderBlockFlow&, const TextAlignMode&, const RootInlineBox*, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount);
    7575
    7676private:
    7777    std::unique_ptr<RootInlineBox> createRootInlineBox();
    7878    RootInlineBox* createAndAppendRootInlineBox();
    79     static InlineBox* createInlineBoxForRenderer(RenderObject*, bool isRootLineBox, bool isOnlyRun = false);
     79    InlineBox* createInlineBoxForRenderer(RenderObject*, bool isOnlyRun = false);
    8080    InlineFlowBox* createLineBoxes(RenderObject*, const LineInfo&, InlineBox*);
    8181    TextAlignMode textAlignmentForLine(bool endsWithSoftBreak) const;
     
    8383    void updateRubyForJustifiedText(RenderRubyRun&, BidiRun&, const Vector<unsigned, 16>& expansionOpportunities, unsigned& expansionOpportunityCount, float& totalLogicalWidth, float availableLogicalWidth, size_t&);
    8484    void computeExpansionForJustifiedText(BidiRun* firstRun, BidiRun* trailingSpaceRun, const Vector<unsigned, 16>& expansionOpportunities, unsigned expansionOpportunityCount, float totalLogicalWidth, float availableLogicalWidth);
    85     void updateLogicalWidthForAlignment(const TextAlignMode&, const RootInlineBox*, BidiRun* trailingSpaceRun, float& logicalLeft, float& totalLogicalWidth, float& availableLogicalWidth, int expansionOpportunityCount);
    8685    void computeInlineDirectionPositionsForLine(RootInlineBox*, const LineInfo&, BidiRun* firstRun, BidiRun* trailingSpaceRun, bool reachedEnd, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&, WordMeasurements&);
    8786    BidiRun* computeInlineDirectionPositionsForSegment(RootInlineBox*, const LineInfo&, TextAlignMode, float& logicalLeft, float& availableLogicalWidth, BidiRun* firstRun, BidiRun* trailingSpaceRun, GlyphOverflowAndFallbackFontsMap&, VerticalPositionCache&, WordMeasurements&);
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r248517 r248528  
    112112    , m_lineCountForTextAutosizing(NOT_SET)
    113113#endif
    114     , m_complexLineLayout(*this)
    115114{
    116115    setChildrenInline(true);
     
    123122    , m_lineCountForTextAutosizing(NOT_SET)
    124123#endif
    125     , m_complexLineLayout(*this)
    126124{
    127125    setChildrenInline(true);
     
    155153    }
    156154
    157     lineBoxes().deleteLineBoxes();
     155    if (m_complexLineLayout)
     156        m_complexLineLayout->lineBoxes().deleteLineBoxes();
    158157
    159158    blockWillBeDestroyed();
     
    678677
    679678    m_simpleLineLayout = nullptr;
    680     complexLineLayout().layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
     679
     680    if (!m_complexLineLayout)
     681        m_complexLineLayout = std::make_unique<ComplexLineLayout>(*this);
     682
     683    m_complexLineLayout->layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
    681684}
    682685
     
    900903{
    901904    if (child.style().isOriginalDisplayInlineType())
    902         setStaticInlinePositionForChild(child, logicalTop, complexLineLayout().startAlignedOffsetForLine(logicalTop, shouldIndentText));
     905        setStaticInlinePositionForChild(child, logicalTop, startAlignedOffsetForLine(logicalTop, shouldIndentText));
    903906    else
    904907        setStaticInlinePositionForChild(child, logicalTop, startOffsetForContent(logicalTop));
     
    912915    }
    913916    child.layer()->setStaticInlinePosition(inlinePosition);
     917}
     918
     919LayoutUnit RenderBlockFlow::startAlignedOffsetForLine(LayoutUnit position, IndentTextOrNot shouldIndentText)
     920{
     921    TextAlignMode textAlign = style().textAlign();
     922    bool shouldApplyIndentText = false;
     923    switch (textAlign) {
     924    case TextAlignMode::Left:
     925    case TextAlignMode::WebKitLeft:
     926        shouldApplyIndentText = style().isLeftToRightDirection();
     927        break;
     928    case TextAlignMode::Right:
     929    case TextAlignMode::WebKitRight:
     930        shouldApplyIndentText = !style().isLeftToRightDirection();
     931        break;
     932    case TextAlignMode::Start:
     933        shouldApplyIndentText = true;
     934        break;
     935    default:
     936        shouldApplyIndentText = false;
     937    }
     938    // <rdar://problem/15427571>
     939    // https://bugs.webkit.org/show_bug.cgi?id=124522
     940    // This quirk is for legacy content that doesn't work properly with the center positioning scheme
     941    // being honored (e.g., epubs).
     942    if (shouldApplyIndentText || settings().useLegacyTextAlignPositionedElementBehavior()) // FIXME: Handle TextAlignMode::End here
     943        return startOffsetForLine(position, shouldIndentText);
     944
     945    // updateLogicalWidthForAlignment() handles the direction of the block so no need to consider it here
     946    float totalLogicalWidth = 0;
     947    float logicalLeft = logicalLeftOffsetForLine(logicalHeight(), DoNotIndentText);
     948    float availableLogicalWidth = logicalRightOffsetForLine(logicalHeight(), DoNotIndentText) - logicalLeft;
     949
     950    ComplexLineLayout::updateLogicalWidthForAlignment(*this, textAlign, nullptr, nullptr, logicalLeft, totalLogicalWidth, availableLogicalWidth, 0);
     951
     952    if (!style().isLeftToRightDirection())
     953        return LayoutUnit(logicalWidth() - logicalLeft);
     954
     955    return LayoutUnit(logicalLeft);
    914956}
    915957
     
    20682110
    20692111    if (m_simpleLineLayout) {
    2070         ASSERT(!lineBoxes().firstLineBox());
     2112        ASSERT(!m_complexLineLayout);
    20712113        m_simpleLineLayout = nullptr;
    2072     } else
    2073         lineBoxes().deleteLineBoxTree();
     2114    } else if (m_complexLineLayout)
     2115        m_complexLineLayout->lineBoxes().deleteLineBoxTree();
    20742116
    20752117    RenderBlock::deleteLines();
     
    29082950        return SimpleLineLayout::hitTestFlow(*this, *simpleLineLayout, request, result, locationInContainer, accumulatedOffset, hitTestAction);
    29092951
    2910     return lineBoxes().hitTest(this, request, result, locationInContainer, accumulatedOffset, hitTestAction);
     2952    return m_complexLineLayout && m_complexLineLayout->lineBoxes().hitTest(this, request, result, locationInContainer, accumulatedOffset, hitTestAction);
    29112953}
    29122954
     
    29192961    }
    29202962
    2921     complexLineLayout().addOverflowFromInlineChildren();
     2963    m_complexLineLayout->addOverflowFromInlineChildren();
    29222964}
    29232965
     
    35013543        return;
    35023544    }
    3503     lineBoxes().paint(this, paintInfo, paintOffset);
     3545
     3546    if (m_complexLineLayout)
     3547        m_complexLineLayout->lineBoxes().paint(this, paintInfo, paintOffset);
    35043548}
    35053549
     
    35563600        return simpleLineLayout->lineCount();
    35573601
    3558     return lineBoxes().firstLineBox();
     3602    return m_complexLineLayout && m_complexLineLayout->lineBoxes().firstLineBox();
    35593603}
    35603604
     
    35963640    for (auto& renderer : childrenOfType<RenderObject>(*this))
    35973641        renderer.clearNeedsLayout();
    3598     ASSERT(!lineBoxes().firstLineBox());
     3642    ASSERT(!m_complexLineLayout);
    35993643    LayoutUnit lineLayoutHeight = SimpleLineLayout::computeFlowHeight(*this, *m_simpleLineLayout);
    36003644    LayoutUnit lineLayoutTop = borderAndPaddingBefore();
     
    36073651{
    36083652    ASSERT(lineLayoutPath() == SimpleLinesPath);
    3609     lineBoxes().deleteLineBoxes();
     3653
     3654    if (m_complexLineLayout)
     3655        m_complexLineLayout->lineBoxes().deleteLineBoxes();
     3656
    36103657    for (auto& renderer : childrenOfType<RenderObject>(*this)) {
    36113658        if (is<RenderText>(renderer))
     
    36163663            ASSERT_NOT_REACHED();
    36173664    }
     3665
     3666    m_complexLineLayout = nullptr;
    36183667}
    36193668
    36203669void RenderBlockFlow::ensureLineBoxes()
    36213670{
     3671    if (!childrenInline())
     3672        return;
     3673
    36223674    setLineLayoutPath(ForceLineBoxesPath);
     3675
    36233676    if (!m_simpleLineLayout)
    36243677        return;
     3678
     3679    ASSERT(!m_complexLineLayout);
     3680    m_complexLineLayout = std::make_unique<ComplexLineLayout>(*this);
    36253681
    36263682    if (SimpleLineLayout::canUseForLineBoxTree(*this, *m_simpleLineLayout)) {
     
    36423698    if (isPaginated) {
    36433699        PaginatedLayoutStateMaintainer state(*this);
    3644         complexLineLayout().layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
     3700        m_complexLineLayout->layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
    36453701        // This matches relayoutToAvoidWidows.
    36463702        if (shouldBreakAtLineToAvoidWidow())
    3647             complexLineLayout().layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
     3703            m_complexLineLayout->layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
    36483704        // FIXME: This is needed as long as simple and normal line layout produce different line breakings.
    36493705        repaint();
    36503706    } else
    3651         complexLineLayout().layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
     3707        m_complexLineLayout->layoutLineBoxes(relayoutChildren, repaintLogicalTop, repaintLogicalBottom);
    36523708
    36533709    updateLogicalHeight();
  • trunk/Source/WebCore/rendering/RenderBlockFlow.h

    r248517 r248528  
    7171    LayoutUnit collapsedMarginAfter() const final { return maxPositiveMarginAfter() - maxNegativeMarginAfter(); }
    7272
    73     void dirtyLinesFromChangedChild(RenderObject& child) final { lineBoxes().dirtyLinesFromChangedChild(*this, child); }
     73    void dirtyLinesFromChangedChild(RenderObject& child) final
     74    {
     75        if (m_complexLineLayout)
     76            m_complexLineLayout->lineBoxes().dirtyLinesFromChangedChild(*this, child);
     77    }
    7478
    7579    void paintColumnRules(PaintInfo&, const LayoutPoint&) override;
     
    232236    void updateStaticInlinePositionForChild(RenderBox& child, LayoutUnit logicalTop, IndentTextOrNot shouldIndentText);
    233237
     238    LayoutUnit startAlignedOffsetForLine(LayoutUnit position, IndentTextOrNot);
     239
    234240    LayoutUnit collapseMargins(RenderBox& child, MarginInfo&);
    235241    LayoutUnit collapseMarginsWithChildInfo(RenderBox* child, RenderObject* prevSibling, MarginInfo&);
     
    327333    LayoutPoint flipFloatForWritingModeForChild(const FloatingObject&, const LayoutPoint&) const;
    328334
    329     RenderLineBoxList& lineBoxes() { return m_complexLineLayout.lineBoxes(); }
    330     const RenderLineBoxList& lineBoxes() const { return m_complexLineLayout.lineBoxes(); }
    331 
    332     RootInlineBox* firstRootBox() const { return m_complexLineLayout.firstRootBox(); }
    333     RootInlineBox* lastRootBox() const { return m_complexLineLayout.lastRootBox(); }
     335    RootInlineBox* firstRootBox() const { return m_complexLineLayout ? m_complexLineLayout->firstRootBox() : nullptr; }
     336    RootInlineBox* lastRootBox() const { return m_complexLineLayout ? m_complexLineLayout->lastRootBox() : nullptr; }
    334337
    335338    bool hasLines() const;
     
    519522
    520523public:
    521     ComplexLineLayout& complexLineLayout() { return m_complexLineLayout; }
     524    ComplexLineLayout* complexLineLayout() { return m_complexLineLayout.get(); }
    522525
    523526    virtual Optional<TextAlignMode> overrideTextAlignmentForLine(bool /* endsWithSoftBreak */) const { return { }; }
     
    564567
    565568    // FIXME: Only one of these should be needed at any given time.
    566     ComplexLineLayout m_complexLineLayout;
     569    std::unique_ptr<ComplexLineLayout> m_complexLineLayout;
    567570    std::unique_ptr<SimpleLineLayout::Layout> m_simpleLineLayout;
    568571
  • trunk/Source/WebCore/rendering/RootInlineBox.cpp

    r246490 r248528  
    829829void RootInlineBox::removeLineBoxFromRenderObject()
    830830{
    831     blockFlow().lineBoxes().removeLineBox(this);
     831    blockFlow().complexLineLayout()->lineBoxes().removeLineBox(this);
    832832}
    833833
    834834void RootInlineBox::extractLineBoxFromRenderObject()
    835835{
    836     blockFlow().lineBoxes().extractLineBox(this);
     836    blockFlow().complexLineLayout()->lineBoxes().extractLineBox(this);
    837837}
    838838
    839839void RootInlineBox::attachLineBoxToRenderObject()
    840840{
    841     blockFlow().lineBoxes().attachLineBox(this);
     841    blockFlow().complexLineLayout()->lineBoxes().attachLineBox(this);
    842842}
    843843
  • trunk/Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp

    r248517 r248528  
    332332void generateLineBoxTree(RenderBlockFlow& flow, const Layout& layout)
    333333{
    334     ASSERT(!flow.lineBoxes().firstLineBox());
     334    ASSERT(!flow.complexLineLayout()->lineBoxes().firstLineBox());
    335335    if (!layout.runCount())
    336336        return;
     
    352352
    353353        LineInfo lineInfo;
    354         lineInfo.setFirstLine(!flow.lineBoxes().firstLineBox());
     354        lineInfo.setFirstLine(!flow.complexLineLayout()->lineBoxes().firstLineBox());
    355355        // FIXME: This is needed for flow boxes -but we don't have them yet.
    356356        // lineInfo.setLastLine(lastLine);
    357357        lineInfo.setEmpty(!bidiRuns.runCount());
    358358        bidiRuns.setLogicallyLastRun(bidiRuns.lastRun());
    359         auto* root = flow.complexLineLayout().constructLine(bidiRuns, lineInfo);
     359        auto* root = flow.complexLineLayout()->constructLine(bidiRuns, lineInfo);
    360360        bidiRuns.clear();
    361361        if (!root)
  • trunk/Source/WebCore/rendering/line/LineBreaker.cpp

    r248517 r248528  
    6767            }
    6868        } else if (object.isFloating())
    69             m_block.complexLineLayout().positionNewFloatOnLine(*m_block.insertFloatingObject(downcast<RenderBox>(object)), lastFloatFromPreviousLine, lineInfo, width);
     69            m_block.complexLineLayout()->positionNewFloatOnLine(*m_block.insertFloatingObject(downcast<RenderBox>(object)), lastFloatFromPreviousLine, lineInfo, width);
    7070        else if (object.style().hasTextCombine() && is<RenderCombineText>(object)) {
    7171            downcast<RenderCombineText>(object).combineTextIfNeeded();
  • trunk/Source/WebCore/rendering/line/LineBreaker.h

    r248517 r248528  
    6767    bool positionNewFloatOnLine(const FloatingObject& newFloat, FloatingObject* lastFloatFromPreviousLine, LineInfo& lineInfo, LineWidth& width)
    6868    {
    69         return m_block.complexLineLayout().positionNewFloatOnLine(newFloat, lastFloatFromPreviousLine, lineInfo, width);
     69        return m_block.complexLineLayout()->positionNewFloatOnLine(newFloat, lastFloatFromPreviousLine, lineInfo, width);
    7070    }
    7171
  • trunk/Source/WebCore/rendering/line/LineInlineHeaders.h

    r248517 r248528  
    131131        // position as though we were an inline. Set |staticInlinePosition| and |staticBlockPosition| on the relative positioned
    132132        // inline so that we can obtain the value later.
    133         downcast<RenderInline>(*containerBlock).layer()->setStaticInlinePosition(block.complexLineLayout().startAlignedOffsetForLine(blockHeight, DoNotIndentText));
     133        downcast<RenderInline>(*containerBlock).layer()->setStaticInlinePosition(block.startAlignedOffsetForLine(blockHeight, DoNotIndentText));
    134134        downcast<RenderInline>(*containerBlock).layer()->setStaticBlockPosition(blockHeight);
    135135    }
Note: See TracChangeset for help on using the changeset viewer.