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

Changeset 283486 in webkit


Ignore:
Timestamp:
Oct 3, 2021, 9:34:43 PM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Do not take hanging whitespace sequence into account while finding expansion opportunities
https://bugs.webkit.org/show_bug.cgi?id=231132

Reviewed by Antti Koivisto.

Source/WebCore:

Ignore hanging whitespace for expansion opportunities.
This patch fixes imported/w3c/web-platform-tests/css/css-text/white-space/textarea-pre-wrap-014.html

  • layout/formattingContexts/inline/InlineLine.cpp:

(WebCore::Layout::Line::applyRunExpansion):

LayoutTests:

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r283481 r283486  
     12021-10-03  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Do not take hanging whitespace sequence into account while finding expansion opportunities
     4        https://bugs.webkit.org/show_bug.cgi?id=231132
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * TestExpectations:
     9
    1102021-10-03  Alan Bujtas  <zalan@apple.com>
    211
  • trunk/LayoutTests/TestExpectations

    r283481 r283486  
    44484448webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/seg-break-transformation-019.html [ ImageOnlyFailure ]
    44494449webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/textarea-pre-wrap-012.html [ ImageOnlyFailure ]
    4450 webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/textarea-pre-wrap-014.html [ ImageOnlyFailure ]
    44514450webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/trailing-other-space-separators-001.html [ ImageOnlyFailure ]
    44524451webkit.org/b/214290 imported/w3c/web-platform-tests/css/css-text/white-space/trailing-other-space-separators-002.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r283485 r283486  
    112021-10-03  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Do not take hanging whitespace sequence into account while finding expansion opportunities
     4        https://bugs.webkit.org/show_bug.cgi?id=231132
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Ignore hanging whitespace for expansion opportunities.
     9        This patch fixes imported/w3c/web-platform-tests/css/css-text/white-space/textarea-pre-wrap-014.html
     10
     11        * layout/formattingContexts/inline/InlineLine.cpp:
     12        (WebCore::Layout::Line::applyRunExpansion):
     13
     142021-10-03  Zalan Bujtas  <zalan@apple.com>
    215
    316        [LFC][IFC] HangingTrailingContent should cache width/length
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp

    r283485 r283486  
    8080    if (m_runs.isEmpty() || m_runs.last().isLineBreak())
    8181        return;
    82     // Anything to distribute?
    83     auto spaceToDistribute = horizontalAvailableSpace - contentLogicalWidth();
     82    // A hanging glyph is still enclosed inside its parent inline box and still participates in text justification:
     83    // its character advance is just not measured when determining how much content fits on the line, how much the line’s contents
     84    // need to be expanded or compressed for justification, or how to position the content within the line box for text alignment.
     85    auto spaceToDistribute = horizontalAvailableSpace - contentLogicalWidth() + m_hangingTrailingContent.width();
    8486    if (spaceToDistribute <= 0)
    8587        return;
    86 
    8788    // Collect and distribute the expansion opportunities.
    8889    size_t lineExpansionOpportunities = 0;
     
    9394    // Line start behaves as if we had an expansion here (i.e. fist runs should not start with allowing left expansion).
    9495    auto runIsAfterExpansion = true;
     96    auto hangingTrailingContentLength = m_hangingTrailingContent.length();
    9597    for (size_t runIndex = 0; runIndex < m_runs.size(); ++runIndex) {
    9698        auto& run = m_runs[runIndex];
     
    98100        size_t expansionOpportunitiesInRun = 0;
    99101
    100         if (run.isText() && !TextUtil::shouldPreserveSpacesAndTabs(run.layoutBox())) {
     102        // FIXME: Check why we don't apply expansion when whitespace is preserved.
     103        if (run.isText() && (!TextUtil::shouldPreserveSpacesAndTabs(run.layoutBox()) || hangingTrailingContentLength)) {
    101104            if (run.hasTextCombine())
    102105                expansionBehavior = ForbidLeftExpansion | ForbidRightExpansion;
    103106            else {
    104107                expansionBehavior = (runIsAfterExpansion ? ForbidLeftExpansion : AllowLeftExpansion) | AllowRightExpansion;
    105                 std::tie(expansionOpportunitiesInRun, runIsAfterExpansion) = FontCascade::expansionOpportunityCount(StringView(downcast<InlineTextBox>(run.layoutBox()).content()).substring(run.textContent()->start, run.textContent()->length), run.inlineDirection(), expansionBehavior);
     108                auto& textContent = *run.textContent();
     109                // Trailing hanging whitespace sequence is ignored when computing the expansion opportunities.
     110                auto hangingTrailingContentInCurrentRun = std::min(textContent.length, hangingTrailingContentLength);
     111                auto length = textContent.length - hangingTrailingContentInCurrentRun;
     112                hangingTrailingContentLength -= hangingTrailingContentInCurrentRun;
     113                std::tie(expansionOpportunitiesInRun, runIsAfterExpansion) = FontCascade::expansionOpportunityCount(StringView(downcast<InlineTextBox>(run.layoutBox()).content()).substring(textContent.start, length), run.inlineDirection(), expansionBehavior);
    106114            }
    107115        } else if (run.isBox())
Note: See TracChangeset for help on using the changeset viewer.