Changeset 279698 in webkit


Ignore:
Timestamp:
Jul 7, 2021, 6:35:44 PM (4 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Add support for partially trimmed trailing whitespace
https://bugs.webkit.org/show_bug.cgi?id=227688

Reviewed by Antti Koivisto.

Source/WebCore:

This patch fixes the case when as a result of the partially trimmed overflow content,
we don't need to conditionally hang the trailing end anymore.

https://drafts.csswg.org/css-text-3/#valdef-white-space-pre
"If white-space is set to pre-wrap, the UA must (unconditionally)
...
It may also visually collapse the character advance widths of any that would otherwise overflow."

  • layout/formattingContexts/inline/InlineLine.cpp:

(WebCore::Layout::Line::visuallyCollapsePreWrapOverflowContent):
(WebCore::Layout::Line::Run::removeTrailingWhitespace):
(WebCore::Layout::Line::Run::visuallyCollapseTrailingWhitespace):

  • layout/formattingContexts/inline/InlineLine.h:

LayoutTests:

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r279688 r279698  
     12021-07-07  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Add support for partially trimmed trailing whitespace
     4        https://bugs.webkit.org/show_bug.cgi?id=227688
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * TestExpectations: Progressions.
     9
    1102021-07-07  Chris Dumez  <cdumez@apple.com>
    211
  • trunk/LayoutTests/TestExpectations

    r279657 r279698  
    26452645webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/line-edge-white-space-collapse-001.html [ ImageOnlyFailure ]
    26462646webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/trailing-ideographic-space-003.html [ ImageOnlyFailure ]
    2647 webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-002.html [ ImageOnlyFailure ]
    26482647webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/pre-wrap-014.html [ ImageOnlyFailure ]
    26492648webkit.org/b/195275 imported/w3c/web-platform-tests/css/css-text/white-space/text-space-trim-trim-inner-001.xht [ ImageOnlyFailure ]
     
    43854384webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/white-space-pre-051.html [ ImageOnlyFailure ]
    43864385webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/white-space-pre-052.html [ ImageOnlyFailure ]
    4387 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/white-space-pre-wrap-trailing-spaces-001.html [ ImageOnlyFailure ]
    43884386webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/word-boundary/word-boundary-001.html [ ImageOnlyFailure ]
    43894387webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/word-boundary/word-boundary-002.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/platform/ios/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt

    r270150 r279698  
    2222      RenderBlock {HR} at (0,198) size 784x2 [border: (1px inset #000000)]
    2323      RenderBlock {PRE} at (0,213) size 108x78 [border: (4px solid #0000FF)]
    24         RenderText {#text} at (4,4) size 94x70
    25           text run at (4,4) width 86: "This   text     "
     24        RenderText {#text} at (4,4) size 100x70
     25          text run at (4,4) width 100: "This   text     "
    2626          text run at (4,18) width 71: "will wrap"
    2727          text run at (74,18) width 1: " "
  • trunk/Source/WebCore/ChangeLog

    r279688 r279698  
     12021-07-07  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Add support for partially trimmed trailing whitespace
     4        https://bugs.webkit.org/show_bug.cgi?id=227688
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This patch fixes the case when as a result of the partially trimmed overflow content,
     9        we don't need to conditionally hang the trailing end anymore.
     10
     11        https://drafts.csswg.org/css-text-3/#valdef-white-space-pre
     12        "If white-space is set to pre-wrap, the UA must (unconditionally)
     13        ...
     14        It may also visually collapse the character advance widths of any that would otherwise overflow."
     15
     16        * layout/formattingContexts/inline/InlineLine.cpp:
     17        (WebCore::Layout::Line::visuallyCollapsePreWrapOverflowContent):
     18        (WebCore::Layout::Line::Run::removeTrailingWhitespace):
     19        (WebCore::Layout::Line::Run::visuallyCollapseTrailingWhitespace):
     20        * layout/formattingContexts/inline/InlineLine.h:
     21
    1222021-07-07  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp

    r278185 r279698  
    145145    // Let's just find the trailing pre-wrap whitespace content for now (e.g check if there are multiple trailing runs with
    146146    // different set of white-space values and decide if the in-between pre-wrap content should be collapsed as well.)
    147     InlineLayoutUnit trimmedContentWidth = 0;
     147    auto trimmedContentWidth = InlineLayoutUnit { };
    148148    for (auto& run : WTF::makeReversedRange(m_runs)) {
    149149        if (run.style().whiteSpace() != WhiteSpace::PreWrap) {
     
    151151            break;
    152152        }
    153         auto preWrapVisuallyCollapsibleInlineItem = run.isInlineBoxStart() || run.isInlineBoxEnd() || run.hasTrailingWhitespace();
    154         if (!preWrapVisuallyCollapsibleInlineItem)
     153        auto visuallyCollapsibleInlineItem = run.isInlineBoxStart() || run.isInlineBoxEnd() || run.hasTrailingWhitespace();
     154        if (!visuallyCollapsibleInlineItem)
    155155            break;
    156156        ASSERT(!run.hasCollapsibleTrailingWhitespace());
    157         InlineLayoutUnit trimmableWidth = { };
     157        auto trimmableWidth = InlineLayoutUnit { };
    158158        if (run.isText()) {
    159159            // FIXME: We should always collapse the run at a glyph boundary as the spec indicates: "collapse the character advance widths of any that would otherwise overflow"
    160160            // and the trimmed width should be capped at std::min(run.trailingWhitespaceWidth(), overflowWidth) for text runs. Both FF and Chrome agree.
    161             trimmableWidth = run.trailingWhitespaceWidth();
    162             run.visuallyCollapseTrailingWhitespace();
     161            trimmableWidth = run.visuallyCollapseTrailingWhitespace(overflowWidth);
    163162        } else {
    164163            trimmableWidth = run.logicalWidth();
     
    498497    constexpr size_t trailingTrimmableContentLength = 1;
    499498    m_textContent->shrink(trailingTrimmableContentLength);
    500     visuallyCollapseTrailingWhitespace();
    501 }
    502 
    503 void Line::Run::visuallyCollapseTrailingWhitespace()
    504 {
     499    visuallyCollapseTrailingWhitespace(m_trailingWhitespaceWidth);
     500}
     501
     502InlineLayoutUnit Line::Run::visuallyCollapseTrailingWhitespace(InlineLayoutUnit tryCollapsingThisMuchSpace)
     503{
     504    ASSERT(hasTrailingWhitespace());
    505505    // This is just a visual adjustment, the text length should remain the same.
    506     shrinkHorizontally(m_trailingWhitespaceWidth);
    507     m_trailingWhitespaceWidth = { };
    508     m_trailingWhitespaceType = TrailingWhitespace::None;
    509 
    510     if (m_whitespaceIsExpansionOpportunity) {
    511         ASSERT(m_expansionOpportunityCount);
    512         m_expansionOpportunityCount--;
    513     }
    514     setExpansionBehavior(AllowLeftExpansion | AllowRightExpansion);
     506    auto trimmedWidth = std::min(tryCollapsingThisMuchSpace, m_trailingWhitespaceWidth);
     507    shrinkHorizontally(trimmedWidth);
     508    m_trailingWhitespaceWidth -= trimmedWidth;
     509    if (!m_trailingWhitespaceWidth) {
     510        // We trimmed the trailing whitespace completely.
     511        m_trailingWhitespaceType = TrailingWhitespace::None;
     512
     513        if (m_whitespaceIsExpansionOpportunity) {
     514            ASSERT(m_expansionOpportunityCount);
     515            m_expansionOpportunityCount--;
     516        }
     517        setExpansionBehavior(AllowLeftExpansion | AllowRightExpansion);
     518    }
     519    return trimmedWidth;
    515520}
    516521
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h

    r278244 r279698  
    110110        TrailingWhitespace trailingWhitespaceType(const InlineTextItem&) const;
    111111        void removeTrailingWhitespace();
    112         void visuallyCollapseTrailingWhitespace();
     112        InlineLayoutUnit visuallyCollapseTrailingWhitespace(InlineLayoutUnit tryCollapsingThisMuchSpace);
    113113
    114114        bool hasTrailingLetterSpacing() const;
Note: See TracChangeset for help on using the changeset viewer.