Changeset 253004 in webkit


Ignore:
Timestamp:
Dec 2, 2019 12:16:07 PM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Adjust trailing runs horizontally while trimming content
https://bugs.webkit.org/show_bug.cgi?id=204749
<rdar://problem/57559163>

Reviewed by Antti Koivisto.

When trailing content is getting trimmed, we also need to adjust subsequent trailing runs e.g. <span> </span> <- the [container end]'s run should be adjusted.

  • layout/inlineformatting/InlineLineBuilder.cpp:

(WebCore::Layout::LineBuilder::removeTrailingTrimmableContent):
(WebCore::Layout::LineBuilder::appendTextContent): there's nothing to trim when the spacing is zero or negative.

  • layout/inlineformatting/InlineLineBuilder.h:

(WebCore::Layout::LineBuilder::InlineItemRun::moveHorizontally):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r253003 r253004  
     12019-12-02  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Adjust trailing runs horizontally while trimming content
     4        https://bugs.webkit.org/show_bug.cgi?id=204749
     5        <rdar://problem/57559163>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        When trailing content is getting trimmed, we also need to adjust subsequent trailing runs e.g. <span>   </span> <- the [container end]'s run should be adjusted.
     10
     11        * layout/inlineformatting/InlineLineBuilder.cpp:
     12        (WebCore::Layout::LineBuilder::removeTrailingTrimmableContent):
     13        (WebCore::Layout::LineBuilder::appendTextContent): there's nothing to trim when the spacing is zero or negative.
     14        * layout/inlineformatting/InlineLineBuilder.h:
     15        (WebCore::Layout::LineBuilder::InlineItemRun::moveHorizontally):
     16
    1172019-12-02  Zalan Bujtas  <zalan@apple.com>
    218
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp

    r253003 r253004  
    377377    auto hasSeenNonWhitespaceTextContent = false;
    378378#endif
    379     // Collapse trimmable trailing content.
     379    // Collapse trimmable trailing content and move all the other trailing runs.
     380    // <span> </span><span></span> ->
     381    // [whitespace][container end][container start][container end]
     382    // Trim the whitespace run and move the trailing inline container runs to the left.
     383    LayoutUnit accumulatedTrimmedWidth;
    380384    for (auto index = *m_trimmableContent.firstRunIndex(); index < m_inlineItemRuns.size(); ++index) {
    381385        auto& run = m_inlineItemRuns[index];
     386        run.moveHorizontally(-accumulatedTrimmedWidth);
    382387        if (!run.isText()) {
    383388            ASSERT(run.isContainerStart() || run.isContainerEnd() || run.isForcedLineBreak());
    384389            continue;
    385390        }
    386         if (run.isWhitespace())
     391        if (run.isWhitespace()) {
     392            accumulatedTrimmedWidth += run.logicalWidth();
    387393            run.setCollapsesToZeroAdvanceWidth();
    388         else {
     394        } else {
    389395            ASSERT(!hasSeenNonWhitespaceTextContent);
    390396#ifndef NDEBUG
     
    392398#endif
    393399            // Must be a letter spacing trim.
    394             ASSERT(run.layoutBox().style().letterSpacing());
     400            ASSERT(run.layoutBox().style().letterSpacing() > 0);
     401            accumulatedTrimmedWidth += run.layoutBox().style().letterSpacing();
    395402            run.removeTrailingLetterSpacing();
    396403        }
    397404    }
     405    ASSERT(accumulatedTrimmedWidth == m_trimmableContent.width());
    398406    m_lineBox.shrinkHorizontally(m_trimmableContent.width());
    399407    m_trimmableContent.clear();
     
    518526    // Trailing whitespace content is fully trimmable so as the trailing letter space.
    519527    auto isFullyTrimmable = !shouldPreserveTrailingContent(inlineItem);
    520     auto isPartiallyTrimmable = !inlineItem.isWhitespace() && inlineItem.style().letterSpacing();
     528    auto isPartiallyTrimmable = !inlineItem.isWhitespace() && inlineItem.style().letterSpacing() > 0;
    521529    auto isTrimmable = isFullyTrimmable || isPartiallyTrimmable;
    522530    // Reset the trimmable content if needed.
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h

    r253003 r253004  
    173173        bool isCollapsed() const { return m_isCollapsed; }
    174174
     175        void moveHorizontally(LayoutUnit offset) { m_logicalWidth += offset; }
     176
    175177        void removeTrailingLetterSpacing();
    176178        void setCollapsesToZeroAdvanceWidth();
Note: See TracChangeset for help on using the changeset viewer.