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

Changeset 287819 in webkit


Ignore:
Timestamp:
Jan 9, 2022, 5:50:27 AM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Line::Run needs access to FontCascade
https://bugs.webkit.org/show_bug.cgi?id=235009

Reviewed by Antti Koivisto.

This is in preparation for computing trimmed trailing content width properly.

  • layout/formattingContexts/inline/InlineLine.cpp:

(WebCore::Layout::Line::append):
(WebCore::Layout::Line::appendLineBreak):
(WebCore::Layout::Line::appendWordBreakOpportunity):
(WebCore::Layout::Line::Run::Run):
(WebCore::Layout::m_textContent):
(WebCore::Layout::m_style): Deleted. - We learnt in the past that expanding structures like this (stack backed, large in number) could
lead to measurable perf regression.

  • layout/formattingContexts/inline/InlineLine.h:

(WebCore::Layout::Line::Run::shouldTrailingWhitespaceHang const):
(WebCore::Layout::Line::Run::inlineDirection const):
(WebCore::Layout::Line::Run::letterSpacing const):
(WebCore::Layout::Line::Run::hasTextCombine const):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r287818 r287819  
     12022-01-09  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Line::Run needs access to FontCascade
     4        https://bugs.webkit.org/show_bug.cgi?id=235009
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This is in preparation for computing trimmed trailing content width properly.
     9
     10        * layout/formattingContexts/inline/InlineLine.cpp:
     11        (WebCore::Layout::Line::append):
     12        (WebCore::Layout::Line::appendLineBreak):
     13        (WebCore::Layout::Line::appendWordBreakOpportunity):
     14        (WebCore::Layout::Line::Run::Run):
     15        (WebCore::Layout::m_textContent):
     16        (WebCore::Layout::m_style): Deleted. - We learnt in the past that expanding structures like this (stack backed, large in number) could
     17        lead to measurable perf regression.
     18        * layout/formattingContexts/inline/InlineLine.h:
     19        (WebCore::Layout::Line::Run::shouldTrailingWhitespaceHang const):
     20        (WebCore::Layout::Line::Run::inlineDirection const):
     21        (WebCore::Layout::Line::Run::letterSpacing const):
     22        (WebCore::Layout::Line::Run::hasTextCombine const):
     23
    1242022-01-09  Antti Koivisto  <antti@apple.com>
    225
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp

    r287558 r287819  
    206206        appendTextContent(downcast<InlineTextItem>(inlineItem), style, logicalWidth);
    207207    else if (inlineItem.isLineBreak())
    208         appendLineBreak(inlineItem);
     208        appendLineBreak(inlineItem, style);
    209209    else if (inlineItem.isWordBreakOpportunity())
    210         appendWordBreakOpportunity(inlineItem);
     210        appendWordBreakOpportunity(inlineItem, style);
    211211    else if (inlineItem.isInlineBoxStart())
    212212        appendInlineBoxStart(inlineItem, style, logicalWidth);
     
    373373}
    374374
    375 void Line::appendLineBreak(const InlineItem& inlineItem)
     375void Line::appendLineBreak(const InlineItem& inlineItem, const RenderStyle& style)
    376376{
    377377    m_trailingSoftHyphenWidth = { };
    378378    if (inlineItem.isHardLineBreak()) {
    379379        ++m_nonSpanningInlineLevelBoxCount;
    380         return m_runs.append({ inlineItem, lastRunLogicalRight() });
     380        return m_runs.append({ inlineItem, style, lastRunLogicalRight() });
    381381    }
    382382    // Soft line breaks (preserved new line characters) require inline text boxes for compatibility reasons.
    383383    ASSERT(inlineItem.isSoftLineBreak());
    384     m_runs.append({ downcast<InlineSoftLineBreakItem>(inlineItem), lastRunLogicalRight() });
    385 }
    386 
    387 void Line::appendWordBreakOpportunity(const InlineItem& inlineItem)
    388 {
    389     m_runs.append({ inlineItem, lastRunLogicalRight() });
     384    m_runs.append({ downcast<InlineSoftLineBreakItem>(inlineItem), inlineItem.style(), lastRunLogicalRight() });
     385}
     386
     387void Line::appendWordBreakOpportunity(const InlineItem& inlineItem, const RenderStyle& style)
     388{
     389    m_runs.append({ inlineItem, style, lastRunLogicalRight() });
    390390}
    391391
     
    539539    : m_type(toLineRunType(inlineItem.type()))
    540540    , m_layoutBox(&inlineItem.layoutBox())
     541    , m_style(style)
    541542    , m_logicalLeft(logicalLeft)
    542543    , m_logicalWidth(logicalWidth)
    543     , m_style({ { }, style.direction(), { }, { } })
    544544    , m_bidiLevel(inlineItem.bidiLevel())
    545545{
    546546}
    547547
    548 Line::Run::Run(const InlineItem& zeroWidhtInlineItem, InlineLayoutUnit logicalLeft)
     548Line::Run::Run(const InlineItem& zeroWidhtInlineItem, const RenderStyle& style, InlineLayoutUnit logicalLeft)
    549549    : m_type(toLineRunType(zeroWidhtInlineItem.type()))
    550550    , m_layoutBox(&zeroWidhtInlineItem.layoutBox())
     551    , m_style(style)
    551552    , m_logicalLeft(logicalLeft)
    552553    , m_bidiLevel(zeroWidhtInlineItem.bidiLevel())
     
    557558    : m_type(Type::LineSpanningInlineBoxStart)
    558559    , m_layoutBox(&lineSpanningInlineBoxItem.layoutBox())
     560    , m_style(lineSpanningInlineBoxItem.style())
    559561    , m_logicalLeft(logicalLeft)
    560562    , m_logicalWidth(logicalWidth)
     
    564566}
    565567
    566 Line::Run::Run(const InlineSoftLineBreakItem& softLineBreakItem, InlineLayoutUnit logicalLeft)
     568Line::Run::Run(const InlineSoftLineBreakItem& softLineBreakItem, const RenderStyle& style, InlineLayoutUnit logicalLeft)
    567569    : m_type(Type::SoftLineBreak)
    568570    , m_layoutBox(&softLineBreakItem.layoutBox())
     571    , m_style(style)
    569572    , m_logicalLeft(logicalLeft)
    570573    , m_textContent({ softLineBreakItem.position(), 1 })
     
    576579    : m_type(inlineTextItem.isWordSeparator() ? Type::WordSeparator : Type::Text)
    577580    , m_layoutBox(&inlineTextItem.layoutBox())
     581    , m_style(style)
    578582    , m_logicalLeft(logicalLeft)
    579583    , m_logicalWidth(logicalWidth)
     
    581585    , m_trailingWhitespaceWidth(m_trailingWhitespaceType != TrailingWhitespace::None ? logicalWidth : InlineLayoutUnit { })
    582586    , m_textContent({ inlineTextItem.start(), m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length() })
    583     , m_style({ style.whiteSpace() == WhiteSpace::PreWrap, style.direction(), style.letterSpacing(), style.hasTextCombine() })
    584587    , m_bidiLevel(inlineTextItem.bidiLevel())
    585588{
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h

    r287504 r287819  
    121121
    122122        Run(const InlineTextItem&, const RenderStyle&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
    123         Run(const InlineSoftLineBreakItem&, InlineLayoutUnit logicalLeft);
     123        Run(const InlineSoftLineBreakItem&, const RenderStyle&, InlineLayoutUnit logicalLeft);
    124124        Run(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
    125         Run(const InlineItem&, InlineLayoutUnit logicalLeft);
     125        Run(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalLeft);
    126126        Run(const InlineItem& lineSpanningInlineBoxItem, InlineLayoutUnit logicalLeft, InlineLayoutUnit logicalWidth);
    127127
     
    149149        Type m_type { Type::Text };
    150150        const Box* m_layoutBox { nullptr };
     151        const RenderStyle& m_style;
    151152        InlineLayoutUnit m_logicalLeft { 0 };
    152153        InlineLayoutUnit m_logicalWidth { 0 };
     
    155156        std::optional<Text> m_textContent;
    156157        InlineDisplay::Box::Expansion m_expansion;
    157         struct Style {
    158             bool shouldTrailingWhitespaceHang { false };
    159             TextDirection inlineDirection { TextDirection::RTL };
    160             InlineLayoutUnit letterSpacing { 0 };
    161             bool hasTextCombine { false };
    162         };
    163         Style m_style { };
    164158        UBiDiLevel m_bidiLevel { UBIDI_DEFAULT_LTR };
    165159    };
     
    177171    void appendInlineBoxStart(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalWidth);
    178172    void appendInlineBoxEnd(const InlineItem&, const RenderStyle&, InlineLayoutUnit logicalWidth);
    179     void appendLineBreak(const InlineItem&);
    180     void appendWordBreakOpportunity(const InlineItem&);
     173    void appendLineBreak(const InlineItem&, const RenderStyle&);
     174    void appendWordBreakOpportunity(const InlineItem&, const RenderStyle&);
    181175
    182176    InlineLayoutUnit addBorderAndPaddingEndForInlineBoxDecorationClone(const InlineItem& inlineBoxStartItem);
     
    278272inline bool Line::Run::shouldTrailingWhitespaceHang() const
    279273{
    280     return m_style.shouldTrailingWhitespaceHang;
     274    return m_style.whiteSpace() == WhiteSpace::PreWrap;
    281275}
    282276
    283277inline TextDirection Line::Run::inlineDirection() const
    284278{
    285     return m_style.inlineDirection;
     279    return m_style.direction();
    286280}
    287281
    288282inline InlineLayoutUnit Line::Run::letterSpacing() const
    289283{
    290     return m_style.letterSpacing;
     284    return m_style.letterSpacing();
    291285}
    292286
    293287inline bool Line::Run::hasTextCombine() const
    294288{
    295     return m_style.hasTextCombine;
     289    return m_style.hasTextCombine();
    296290}
    297291
Note: See TracChangeset for help on using the changeset viewer.