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

Changeset 283481 in webkit


Ignore:
Timestamp:
Oct 3, 2021, 2:57:12 PM (5 years ago)
Author:
Alan Bujtas
Message:

Incorrect preferred width computation when trimmable leading whitespace is present
https://bugs.webkit.org/show_bug.cgi?id=231139

Reviewed by Antti Koivisto.

Source/WebCore:

stripFrontSpaces should be reset to the default value whenever we are at the beginning of the line, while computing the preferred trimmed width.
This is already done for line break boxes (<br>) but not when the force line break comes from a text content with
preserved linebreak ("\n").

See WPT progressions.

  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths const):

  • rendering/RenderText.cpp:

(WebCore::RenderText::trimmedPreferredWidths):

  • rendering/RenderText.h:

LayoutTests:

  • TestExpectations: IFC already supports these cases. Preferred width computation produced an incorrect shrink-fit width.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r283465 r283481  
     12021-10-03  Alan Bujtas  <zalan@apple.com>
     2
     3        Incorrect preferred width computation when trimmable leading whitespace is present
     4        https://bugs.webkit.org/show_bug.cgi?id=231139
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * TestExpectations: IFC already supports these cases. Preferred width computation produced an incorrect shrink-fit width.
     9
    1102021-10-03  Simon Fraser  <simon.fraser@apple.com>
    211
  • trunk/LayoutTests/TestExpectations

    r283321 r283481  
    44434443webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/text-transform/text-transform-upperlower-016.html [ ImageOnlyFailure ]
    44444444webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/text-transform/text-transform-upperlower-044.html [ ImageOnlyFailure ]
    4445 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-051.html [ ImageOnlyFailure ]
    4446 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-052.html [ ImageOnlyFailure ]
    44474445webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/break-spaces-before-first-char-015.html [ ImageOnlyFailure ]
    44484446webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/eol-spaces-bidi-001.html [ ImageOnlyFailure ]
    4449 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/pre-wrap-051.html [ ImageOnlyFailure ]
    4450 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/pre-wrap-052.html [ ImageOnlyFailure ]
    44514447webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/seg-break-transformation-018.html [ ImageOnlyFailure ]
    44524448webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/seg-break-transformation-019.html [ ImageOnlyFailure ]
     
    44584454webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/trailing-other-space-separators-004.html [ ImageOnlyFailure ]
    44594455webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/trailing-space-align-start.tentative.html [ ImageOnlyFailure ]
    4460 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/white-space-pre-051.html [ ImageOnlyFailure ]
    4461 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/white-space-pre-052.html [ ImageOnlyFailure ]
    44624456webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/word-boundary/word-boundary-001.html [ ImageOnlyFailure ]
    44634457webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/word-boundary/word-boundary-002.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r283477 r283481  
     12021-10-03  Alan Bujtas  <zalan@apple.com>
     2
     3        Incorrect preferred width computation when trimmable leading whitespace is present
     4        https://bugs.webkit.org/show_bug.cgi?id=231139
     5
     6        Reviewed by Antti Koivisto.
     7
     8        stripFrontSpaces should be reset to the default value whenever we are at the beginning of the line, while computing the preferred trimmed width.
     9        This is already done for line break boxes (<br>) but not when the force line break comes from a text content with
     10        preserved linebreak ("\n").
     11
     12        See WPT progressions.
     13
     14        * rendering/RenderBlockFlow.cpp:
     15        (WebCore::RenderBlockFlow::computeInlinePreferredLogicalWidths const):
     16        * rendering/RenderText.cpp:
     17        (WebCore::RenderText::trimmedPreferredWidths):
     18        * rendering/RenderText.h:
     19
    1202021-10-03  Alan Bujtas  <zalan@apple.com>
    221
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r283443 r283481  
    45524552                    addedTextIndent = true;
    45534553                    addedStartPunctuationHang = true;
     4554                    if (widths.endsWithBreak)
     4555                        stripFrontSpaces = true;
     4556
    45544557                } else
    45554558                    inlineMax += std::max<float>(0, childMax);
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r283464 r283481  
    816816    widths.hasBreakableChar = m_hasBreakableChar;
    817817    widths.hasBreak = m_hasBreak;
     818    widths.endsWithBreak = m_hasBreak && text()[length - 1] == '\n';
    818819
    819820    if (text()[0] == ' ' || (text()[0] == '\n' && !style.preserveNewline()) || text()[0] == '\t') {
  • trunk/Source/WebCore/rendering/RenderText.h

    r282223 r283481  
    108108        bool hasBreakableChar { false };
    109109        bool hasBreak { false };
     110        bool endsWithBreak { false };
    110111    };
    111112    Widths trimmedPreferredWidths(float leadWidth, bool& stripFrontSpaces);
Note: See TracChangeset for help on using the changeset viewer.