Changeset 254630 in webkit


Ignore:
Timestamp:
Jan 15, 2020 1:17:50 PM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] LineLayoutContext::nextContentForLine should take LineCandidateContent&
https://bugs.webkit.org/show_bug.cgi?id=206300
<rdar://problem/58612197>

Reviewed by Antti Koivisto.

~5% progression on PerformanceTests/Layout/line-layout-simple.html.
LineLayoutContext::nextContentForLine is hot and LineCandidateContent has Vector members (too heavy).

  • layout/inlineformatting/LineLayoutContext.cpp:

(WebCore::Layout::LineCandidateContent::reset):
(WebCore::Layout::LineLayoutContext::layoutLine):
(WebCore::Layout::LineLayoutContext::nextContentForLine):

  • layout/inlineformatting/LineLayoutContext.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r254629 r254630  
     12020-01-15  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] LineLayoutContext::nextContentForLine should take LineCandidateContent&
     4        https://bugs.webkit.org/show_bug.cgi?id=206300
     5        <rdar://problem/58612197>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        ~5% progression on PerformanceTests/Layout/line-layout-simple.html.
     10        LineLayoutContext::nextContentForLine is hot and LineCandidateContent has Vector members (too heavy).
     11
     12        * layout/inlineformatting/LineLayoutContext.cpp:
     13        (WebCore::Layout::LineCandidateContent::reset):
     14        (WebCore::Layout::LineLayoutContext::layoutLine):
     15        (WebCore::Layout::LineLayoutContext::nextContentForLine):
     16        * layout/inlineformatting/LineLayoutContext.h:
     17
    1182020-01-15  Zalan Bujtas  <zalan@apple.com>
    219
  • trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp

    r253958 r254630  
    186186    const InlineItem* trailingLineBreak() const { return m_trailingLineBreak; }
    187187
     188    void reset();
     189
    188190private:
    189191    void setTrailingLineBreak(const InlineItem& lineBreakItem) { m_trailingLineBreak = &lineBreakItem; }
     
    202204        return m_floats.append(makeWeakPtr(inlineItem));
    203205    m_inlineRuns.append({ inlineItem, *logicalWidth });
     206}
     207
     208void LineCandidateContent::reset()
     209{
     210    m_inlineRuns.clear();
     211    m_floats.clear();
     212    m_trailingLineBreak = nullptr;
    204213}
    205214
     
    259268    auto currentItemIndex = leadingInlineItemIndex;
    260269    unsigned committedInlineItemCount = 0;
     270    auto candidateContent = LineCandidateContent { };
    261271    while (currentItemIndex < m_inlineItems.size()) {
    262272        // 1. Collect the set of runs that we can commit to the line as one entity e.g. <span>text_and_span_start_span_end</span>.
     
    264274        // 3. Check if the content fits the line and commit the content accordingly (full, partial or not commit at all).
    265275        // 4. Return if we are at the end of the line either by not being able to fit more content or because of an explicit line break.
    266         auto candidateContent = nextContentForLine(currentItemIndex, partialLeadingContentLength, line.lineBox().logicalWidth());
     276        nextContentForLine(candidateContent, currentItemIndex, partialLeadingContentLength, line.lineBox().logicalWidth());
    267277        if (candidateContent.hasIntrusiveFloats()) {
    268278            // Add floats first because they shrink the available horizontal space for the rest of the content.
     
    329339}
    330340
    331 LineCandidateContent LineLayoutContext::nextContentForLine(unsigned inlineItemIndex, Optional<unsigned> partialLeadingContentLength, InlineLayoutUnit currentLogicalRight)
     341void LineLayoutContext::nextContentForLine(LineCandidateContent& candidateContent, unsigned inlineItemIndex, Optional<unsigned> partialLeadingContentLength, InlineLayoutUnit currentLogicalRight)
    332342{
    333343    ASSERT(inlineItemIndex < m_inlineItems.size());
     344    candidateContent.reset();
    334345    // 1. Simply add any overflow content from the previous line to the candidate content. It's always a text content.
    335346    // 2. Find the next soft wrap position or explicit line break.
     
    339350    ASSERT(softWrapOpportunityIndex <= m_inlineItems.size());
    340351
    341     auto candidateContent = LineCandidateContent { };
    342352    if (partialLeadingContentLength) {
    343353        // Handle leading partial content first (split text from the previous line).
     
    362372        currentLogicalRight += inlineItenmWidth;
    363373    }
    364     return candidateContent;
    365374}
    366375
  • trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h

    r253958 r254630  
    5555
    5656private:
    57     LineCandidateContent nextContentForLine(unsigned inlineItemIndex, Optional<unsigned> overflowLength, InlineLayoutUnit currentLogicalRight);
     57    void nextContentForLine(LineCandidateContent&, unsigned inlineItemIndex, Optional<unsigned> overflowLength, InlineLayoutUnit currentLogicalRight);
    5858    struct Result {
    5959        LineBreaker::IsEndOfLine isEndOfLine { LineBreaker::IsEndOfLine::No };
Note: See TracChangeset for help on using the changeset viewer.