Changeset 253001 in webkit


Ignore:
Timestamp:
Dec 2, 2019 11:52:10 AM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] TrimmableContent only needs to keep track of the first trimmable run index
https://bugs.webkit.org/show_bug.cgi?id=204747
<rdar://problem/57557732>

Reviewed by Antti Koivisto.

Every run after the first trimmable run should either also be trimmable (more whitespace) or skippable (</span>).

  • layout/inlineformatting/InlineLineBuilder.cpp:

(WebCore::Layout::LineBuilder::removeTrailingTrimmableContent):
(WebCore::Layout::LineBuilder::TrimmableContent::append):

  • layout/inlineformatting/InlineLineBuilder.h:

(WebCore::Layout::LineBuilder::TrimmableContent::firstRunIndex):
(WebCore::Layout::LineBuilder::TrimmableContent::isEmpty const):
(WebCore::Layout::LineBuilder::TrimmableContent::clear):
(WebCore::Layout::LineBuilder::TrimmableContent::runIndexes): Deleted.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r252998 r253001  
     12019-12-02  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] TrimmableContent only needs to keep track of the first trimmable run index
     4        https://bugs.webkit.org/show_bug.cgi?id=204747
     5        <rdar://problem/57557732>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Every run after the first trimmable run should either also be trimmable (more whitespace) or skippable (</span>).
     10
     11        * layout/inlineformatting/InlineLineBuilder.cpp:
     12        (WebCore::Layout::LineBuilder::removeTrailingTrimmableContent):
     13        (WebCore::Layout::LineBuilder::TrimmableContent::append):
     14        * layout/inlineformatting/InlineLineBuilder.h:
     15        (WebCore::Layout::LineBuilder::TrimmableContent::firstRunIndex):
     16        (WebCore::Layout::LineBuilder::TrimmableContent::isEmpty const):
     17        (WebCore::Layout::LineBuilder::TrimmableContent::clear):
     18        (WebCore::Layout::LineBuilder::TrimmableContent::runIndexes): Deleted.
     19
    1202019-12-02  Alex Christensen  <achristensen@webkit.org>
    221
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp

    r252982 r253001  
    377377        return;
    378378
    379     // Collapse trimmable trailing content
    380     for (auto trimmableRunIndex : m_trimmableContent.runIndexes()) {
    381         auto& trimmableRun = m_inlineItemRuns[trimmableRunIndex];
    382         ASSERT(trimmableRun.isText());
    383         if (trimmableRun.isWhitespace())
    384             trimmableRun.setCollapsesToZeroAdvanceWidth();
    385         else
    386             trimmableRun.removeTrailingLetterSpacing();
     379#ifndef NDEBUG
     380    auto hasSeenNonWhitespaceTextContent = false;
     381#endif
     382    // Collapse trimmable trailing content.
     383    for (auto index = *m_trimmableContent.firstRunIndex(); index < m_inlineItemRuns.size(); ++index) {
     384        auto& run = m_inlineItemRuns[index];
     385        if (!run.isText()) {
     386            ASSERT(run.isContainerStart() || run.isContainerEnd() || run.isForcedLineBreak());
     387            continue;
     388        }
     389        if (run.isWhitespace())
     390            run.setCollapsesToZeroAdvanceWidth();
     391        else {
     392            ASSERT(!hasSeenNonWhitespaceTextContent);
     393#ifndef NDEBUG
     394            hasSeenNonWhitespaceTextContent = true;
     395#endif
     396            // Must be a letter spacing trim.
     397            ASSERT(run.layoutBox().style().letterSpacing());
     398            run.removeTrailingLetterSpacing();
     399        }
    387400    }
    388401    m_lineBox.shrinkHorizontally(m_trimmableContent.width());
     
    715728    itemRunWidth = std::max(0_lu, itemRunWidth);
    716729    m_width += itemRunWidth;
     730    m_firstRunIndex = m_firstRunIndex.valueOr(runIndex);
    717731    m_lastRunIsFullyTrimmable = isFullyTrimmable == IsFullyTrimmable::Yes;
    718     m_runIndexes.append(runIndex);
    719732}
    720733
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h

    r252972 r253001  
    195195
    196196        LayoutUnit width() const { return m_width; }
    197         Vector<size_t, 5>& runIndexes() { return m_runIndexes; }
    198         bool isEmpty() const { return m_runIndexes.isEmpty(); }
     197        Optional<size_t> firstRunIndex() { return m_firstRunIndex; }
     198        bool isEmpty() const { return !m_firstRunIndex.hasValue(); }
    199199        bool isTrailingContentFullyTrimmable() const { return m_lastRunIsFullyTrimmable; }
    200200
    201201    private:
    202         Vector<size_t, 5> m_runIndexes;
     202        Optional<size_t> m_firstRunIndex;
    203203        LayoutUnit m_width;
    204204        bool m_lastRunIsFullyTrimmable { false };
     
    219219inline void LineBuilder::TrimmableContent::clear()
    220220{
    221     m_runIndexes.clear();
     221    m_firstRunIndex = { };
    222222    m_width = { };
    223223    m_lastRunIsFullyTrimmable = false;
Note: See TracChangeset for help on using the changeset viewer.