Changeset 252924 in webkit


Ignore:
Timestamp:
Nov 28, 2019 6:49:54 AM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Adjust the line's is-visually-empty status after trimming the trailing whitespace content
https://bugs.webkit.org/show_bug.cgi?id=204660
<rdar://problem/57513035>

Reviewed by Antti Koivisto.

We need to check if the line is still visually empty after trimming the trailing content.

  • layout/inlineformatting/InlineLineBox.h:

(WebCore::Layout::LineBox::setIsConsideredEmpty):

  • layout/inlineformatting/InlineLineBuilder.cpp:

(WebCore::Layout::LineBuilder::removeTrailingTrimmableContent):
(WebCore::Layout::LineBuilder::appendTextContent):

  • layout/inlineformatting/InlineLineBuilder.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r252923 r252924  
     12019-11-28  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Adjust the line's is-visually-empty status after trimming the trailing whitespace content
     4        https://bugs.webkit.org/show_bug.cgi?id=204660
     5        <rdar://problem/57513035>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        We need to check if the line is still visually empty after trimming the trailing content.
     10
     11        * layout/inlineformatting/InlineLineBox.h:
     12        (WebCore::Layout::LineBox::setIsConsideredEmpty):
     13        * layout/inlineformatting/InlineLineBuilder.cpp:
     14        (WebCore::Layout::LineBuilder::removeTrailingTrimmableContent):
     15        (WebCore::Layout::LineBuilder::appendTextContent):
     16        * layout/inlineformatting/InlineLineBuilder.h:
     17
    1182019-11-28  Zalan Bujtas  <zalan@apple.com>
    219
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h

    r252143 r252924  
    116116    // Note that it does not necessarily mean visually non-empty line. <span style="font-size: 0px">this is still considered non-empty</span>
    117117    bool isConsideredEmpty() const { return m_isConsideredEmpty; }
     118    void setIsConsideredEmpty() { m_isConsideredEmpty = true; }
    118119    void setIsConsideredNonEmpty() { m_isConsideredEmpty = false; }
    119120
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp

    r252923 r252924  
    235235    m_inlineItemRuns.clear();
    236236    m_trimmableContent.clear();
     237    m_lineIsVisuallyEmptyBeforeTrimmableContent = { };
    237238}
    238239
     
    436437    m_lineBox.shrinkHorizontally(m_trimmableContent.width());
    437438    m_trimmableContent.clear();
     439    // If we trimmed the first visible run on the line, we need to re-check the visibility status.
     440    ASSERT(m_lineIsVisuallyEmptyBeforeTrimmableContent.hasValue());
     441    if (*m_lineIsVisuallyEmptyBeforeTrimmableContent) {
     442        // Just because the line was visually empty before the trimmed content, it does not necessarily mean it is still visually empty.
     443        // <span>  </span><span style="padding-left: 10px"></span>  <- non-empty
     444        auto lineIsVisuallyEmpty = [&] {
     445            for (auto& run : m_inlineItemRuns) {
     446                if (isVisuallyNonEmpty(*run))
     447                    return false;
     448            }
     449            return true;
     450        };
     451        // We could only go from visually non empty -> to visually empty. Trimming runs should never make the line visible.
     452        if (lineIsVisuallyEmpty())
     453            m_lineBox.setIsConsideredEmpty();
     454        m_lineIsVisuallyEmptyBeforeTrimmableContent = { };
     455    }
    438456}
    439457
     
    541559    if (collapsedRun)
    542560        lineRun->setIsCollapsed();
    543     if (isTrimmable)
     561    if (isTrimmable) {
     562        // If we ever trim this content, we need to know if the line visibility state needs to be recomputed.
     563        if (m_trimmableContent.isEmpty())
     564            m_lineIsVisuallyEmptyBeforeTrimmableContent = isVisuallyEmpty();
    544565        m_trimmableContent.append(*lineRun);
     566    }
    545567
    546568    m_lineBox.expandHorizontally(lineRun->logicalRect().width());
  • trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h

    r252923 r252924  
    173173    bool m_hasIntrusiveFloat { false };
    174174    LineBox m_lineBox;
     175    Optional<bool> m_lineIsVisuallyEmptyBeforeTrimmableContent;
    175176};
    176177
Note: See TracChangeset for help on using the changeset viewer.