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

Changeset 251642 in webkit


Ignore:
Timestamp:
Oct 27, 2019, 10:18:58 AM (7 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Do not expand runs with collapsed trailing whitespace
https://bugs.webkit.org/show_bug.cgi?id=203468
<rdar://problem/56653689>

Reviewed by Antti Koivisto.

Runs are supposed to be a continuous chunk of content. Runs with trailing
collapsed whitespace can't accommodate additional trailing content.

  • layout/inlineformatting/InlineLine.cpp:

(WebCore::Layout::Line::close):
(WebCore::Layout::Line::Run::isWhitespace const): Deleted.
(WebCore::Layout::Line::Run::canBeExtended const): Deleted.

  • layout/inlineformatting/InlineLine.h:

(WebCore::Layout::Line::Run::expand):
(WebCore::Layout::Line::Run::isWhitespace const):
(WebCore::Layout::Line::Run::setIsCollapsed):
(WebCore::Layout::Line::Run::canBeExtended const):
(WebCore::Layout::Line::Run::setCollapsesToZeroAdvanceWidth):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r251640 r251642  
     12019-10-27  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Do not expand runs with collapsed trailing whitespace
     4        https://bugs.webkit.org/show_bug.cgi?id=203468
     5        <rdar://problem/56653689>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Runs are supposed to be a continuous chunk of content. Runs with trailing
     10        collapsed whitespace can't accommodate additional trailing content.
     11
     12        * layout/inlineformatting/InlineLine.cpp:
     13        (WebCore::Layout::Line::close):
     14        (WebCore::Layout::Line::Run::isWhitespace const): Deleted.
     15        (WebCore::Layout::Line::Run::canBeExtended const): Deleted.
     16        * layout/inlineformatting/InlineLine.h:
     17        (WebCore::Layout::Line::Run::expand):
     18        (WebCore::Layout::Line::Run::isWhitespace const):
     19        (WebCore::Layout::Line::Run::setIsCollapsed):
     20        (WebCore::Layout::Line::Run::canBeExtended const):
     21        (WebCore::Layout::Line::Run::setCollapsesToZeroAdvanceWidth):
     22
    1232019-10-27  Zalan Bujtas  <zalan@apple.com>
    224
  • trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp

    r251633 r251642  
    4444}
    4545
    46 bool Line::Run::isWhitespace() const
    47 {
    48     if (!isText())
    49         return false;
    50     return downcast<InlineTextItem>(m_inlineItem).isWhitespace();
    51 }
    52 
    53 bool Line::Run::canBeExtended() const
    54 {
    55     if (!isText())
    56         return false;
    57     // Non-collapsed text runs can be merged into one continuous run.
    58     if (isCollapsedToZeroAdvanceWidth())
    59         return false;
    60     return !isCollapsed();
    61 }
    62 
    6346Line::Line(const InlineFormattingContext& inlineFormattingContext, const InitialConstraints& initialConstraints, Optional<TextAlignMode> horizontalAlignment, SkipAlignment skipAlignment)
    6447    : m_inlineFormattingContext(inlineFormattingContext)
     
    139122        }
    140123        auto& currentRun = m_runList[index];
    141         if (!currentRun->isText() || &currentRun->layoutBox() != &previousRun->layoutBox()) {
    142             // Do not merge runs from different boxes (<span>foo</span><span>bar</span>)
    143             // or within the same layout box but with preserved \n
    144             // (<span>text\n<span <- both the "text" and "\" belong to the same layout box)
     124        // Do not merge runs from different boxes (<span>foo</span><span>bar</span>)
     125        // or within the same layout box but with preserved \n
     126        // (<span>text\n<span <- both the "text" and "\" belong to the same layout box)
     127        auto canAppendToPreviousRun = currentRun->isText() && &currentRun->layoutBox() ==  &previousRun->layoutBox();
     128        if (!canAppendToPreviousRun) {
    145129            ++index;
    146130            continue;
  • trunk/Source/WebCore/layout/inlineformatting/InlineLine.h

    r251633 r251642  
    9191        void expand(const Run&);
    9292
    93         void setIsCollapsed() { m_isCollapsed = true; }
     93        void setIsCollapsed();
    9494        void setCollapsesToZeroAdvanceWidth();
    9595
     
    101101        bool m_isCollapsed { false };
    102102        bool m_collapsedToZeroAdvanceWidth { false };
     103        bool m_hasTrailingCollapsedContent { false };
    103104    };
    104105    using RunList = Vector<std::unique_ptr<Run>>;
     
    156157    ASSERT(other.isText());
    157158    ASSERT(!isCollapsedToZeroAdvanceWidth());
     159    ASSERT(!m_hasTrailingCollapsedContent);
    158160
    159161    auto& otherDisplayRun = other.displayRun();
    160162    m_displayRun.expandHorizontally(otherDisplayRun.logicalWidth());
    161163    m_displayRun.textContext()->expand(*otherDisplayRun.textContext());
     164    m_hasTrailingCollapsedContent = other.isCollapsed();
     165}
     166
     167inline bool Line::Run::isWhitespace() const
     168{
     169    return isText() && downcast<InlineTextItem>(m_inlineItem).isWhitespace();
     170}
     171
     172inline void Line::Run::setIsCollapsed()
     173{
     174    ASSERT(isWhitespace());
     175    m_isCollapsed = true;
     176    m_hasTrailingCollapsedContent = true;
     177}
     178
     179inline bool Line::Run::canBeExtended() const
     180{
     181    return isText() && !m_hasTrailingCollapsedContent;
    162182}
    163183
     
    170190inline void Line::Run::setCollapsesToZeroAdvanceWidth()
    171191{
     192    setIsCollapsed();
    172193    m_collapsedToZeroAdvanceWidth = true;
    173     m_isCollapsed = true;
    174194    m_displayRun.setLogicalWidth({ });
    175195}
Note: See TracChangeset for help on using the changeset viewer.