Changeset 252932 in webkit


Ignore:
Timestamp:
Nov 28, 2019 12:06:49 PM (4 years ago)
Author:
Antti Koivisto
Message:

[LFC][IFC] Remove m_inlineRunToLineMap
https://bugs.webkit.org/show_bug.cgi?id=204688

Reviewed by Zalan Bujtas.

Add line index to Display::Run and use it to locate the line it is on.

This is 4-5% progression in PerformanceTests/Layout/line-layout-simple.html

  • layout/displaytree/DisplayRun.h:

(WebCore::Display::Run::lineIndex const):
(WebCore::Display::Run::Run):

  • layout/inlineformatting/InlineFormattingContext.cpp:

(WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):

  • layout/inlineformatting/InlineFormattingState.h:

(WebCore::Layout::InlineFormattingState::lineBoxForRun const):
(WebCore::Layout::InlineFormattingState::addInlineRun):
(WebCore::Layout::InlineFormattingState::resetInlineRuns):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r252928 r252932  
     12019-11-28  Antti Koivisto  <antti@apple.com>
     2
     3        [LFC][IFC] Remove m_inlineRunToLineMap
     4        https://bugs.webkit.org/show_bug.cgi?id=204688
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Add line index to Display::Run and use it to locate the line it is on.
     9
     10        This is 4-5% progression in PerformanceTests/Layout/line-layout-simple.html
     11
     12        * layout/displaytree/DisplayRun.h:
     13        (WebCore::Display::Run::lineIndex const):
     14        (WebCore::Display::Run::Run):
     15        * layout/inlineformatting/InlineFormattingContext.cpp:
     16        (WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):
     17        * layout/inlineformatting/InlineFormattingState.h:
     18        (WebCore::Layout::InlineFormattingState::lineBoxForRun const):
     19        (WebCore::Layout::InlineFormattingState::addInlineRun):
     20        (WebCore::Layout::InlineFormattingState::resetInlineRuns):
     21
    1222019-11-28  Antti Koivisto  <antti@apple.com>
    223
  • trunk/Source/WebCore/layout/displaytree/DisplayRun.h

    r252905 r252932  
    6868    };
    6969
    70     Run(const RenderStyle&, const Rect& logicalRect, Optional<TextContext> = WTF::nullopt);
     70    Run(size_t lineIndex, const RenderStyle&, const Rect& logicalRect, Optional<TextContext> = WTF::nullopt);
     71
     72    size_t lineIndex() const { return m_lineIndex; }
    7173
    7274    const Rect& logicalRect() const { return m_logicalRect; }
     
    100102private:
    101103    // FIXME: Find out the Display::Run <-> paint style setup.
     104    const size_t m_lineIndex;
    102105    const RenderStyle& m_style;
    103106    CachedImage* m_cachedImage { nullptr };
     
    106109};
    107110
    108 inline Run::Run(const RenderStyle& style, const Rect& logicalRect, Optional<TextContext> textContext)
    109     : m_style(style)
     111inline Run::Run(size_t lineIndex, const RenderStyle& style, const Rect& logicalRect, Optional<TextContext> textContext)
     112    : m_lineIndex(lineIndex)
     113    , m_style(style)
    110114    , m_logicalRect(logicalRect)
    111115    , m_textContext(textContext)
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp

    r252865 r252932  
    427427    }
    428428
     429    auto lineIndex = formattingState.lineBoxes().size();
    429430    formattingState.addLineBox(lineContent.lineBox);
    430     auto& currentLine = *formattingState.lineBoxes().last();
     431
    431432    // Compute box final geometry.
    432433    auto& lineRuns = lineContent.runList;
     
    441442        auto initiatesInlineRun = !lineRun.isContainerStart() && !lineRun.isContainerEnd() && !lineRun.isCollapsedToVisuallyEmpty();
    442443        if (initiatesInlineRun)
    443             formattingState.addInlineRun(makeUnique<Display::Run>(lineRun.layoutBox().style(), lineRun.logicalRect(), lineRun.textContext()), currentLine);
     444            formattingState.addInlineRun(makeUnique<Display::Run>(lineIndex, lineRun.layoutBox().style(), lineRun.logicalRect(), lineRun.textContext()));
    444445
    445446        if (lineRun.isForcedLineBreak()) {
  • trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h

    r252638 r252932  
    5555    const InlineRuns& inlineRuns() const { return m_inlineRuns; }
    5656    InlineRuns& inlineRuns() { return m_inlineRuns; }
    57     void addInlineRun(std::unique_ptr<Display::Run>&&, const LineBox&);
     57    void addInlineRun(std::unique_ptr<Display::Run>&&);
    5858    void resetInlineRuns();
    5959
     
    6262    void addLineBox(const LineBox& lineBox) { m_lineBoxes.append(makeUnique<LineBox>(lineBox)); }
    6363
    64     const LineBox& lineBoxForRun(const Display::Run& inlineRun) const { return *m_inlineRunToLineMap.get(&inlineRun); }
     64    const LineBox& lineBoxForRun(const Display::Run& inlineRun) const { return *m_lineBoxes[inlineRun.lineIndex()]; }
    6565
    6666private:
     
    6868    InlineRuns m_inlineRuns;
    6969    LineBoxes m_lineBoxes;
    70     // This is temporary until after we figure out the display run/line relationships.
    71     HashMap<const Display::Run*, const LineBox*> m_inlineRunToLineMap;
    7270};
    7371
    74 inline void InlineFormattingState::addInlineRun(std::unique_ptr<Display::Run>&& displayRun, const LineBox& line)
     72inline void InlineFormattingState::addInlineRun(std::unique_ptr<Display::Run>&& displayRun)
    7573{
    76     m_inlineRunToLineMap.set(displayRun.get(), &line);
    7774    m_inlineRuns.append(WTFMove(displayRun));
    7875}
     
    8380    // Resetting the runs means no more line boxes either.
    8481    m_lineBoxes.clear();
    85     m_inlineRunToLineMap.clear();
    8682
    8783}
Note: See TracChangeset for help on using the changeset viewer.