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

Changeset 285826 in webkit


Ignore:
Timestamp:
Nov 15, 2021, 12:47:49 PM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Fix fast/text/letter-spacing-negative-opacity.html
https://bugs.webkit.org/show_bug.cgi?id=233132

Reviewed by Antti Koivisto.

Special case the negative letter spacing content when computing the content logical width.

  • layout/formattingContexts/inline/InlineLine.cpp:

(WebCore::Layout::Line::appendTextContent):

  1. Negative letter space value could produce negative content width
  2. Subsequent text content (e.g. "this text has whitepspace content") may go from positive to negative content width as parts of the content may produce positive width even with negative letter spacing.
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r285823 r285826  
     12021-11-15  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Fix fast/text/letter-spacing-negative-opacity.html
     4        https://bugs.webkit.org/show_bug.cgi?id=233132
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Special case the negative letter spacing content when computing the content logical width.
     9
     10        * layout/formattingContexts/inline/InlineLine.cpp:
     11        (WebCore::Layout::Line::appendTextContent):
     12        1. Negative letter space value could produce negative content width
     13        2. Subsequent text content (e.g. "this text has whitepspace content") may go from positive to negative content width as parts of the content may produce positive width even with negative letter spacing.
     14
    1152021-11-15  Chris Dumez  <cdumez@apple.com>
    216
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp

    r285160 r285826  
    343343        auto contentLogicalRight = runLogicalLeft + logicalWidth + m_clonedEndDecorationWidthForInlineBoxRuns;
    344344        m_contentLogicalWidth = std::max(oldContentLogicalWidth, contentLogicalRight);
     345    } else if (style.letterSpacing() >= 0) {
     346        m_runs.last().expand(inlineTextItem, logicalWidth);
     347        m_contentLogicalWidth += logicalWidth;
    345348    } else {
    346         m_runs.last().expand(inlineTextItem, logicalWidth);
    347         // Do not let negative letter spacing make the content shorter than it already is.
    348         m_contentLogicalWidth += std::max(0.0f, logicalWidth);
     349        auto& lastRun = m_runs.last();
     350        ASSERT(lastRun.isText());
     351        // Negative letter spacing should only shorten the content to the boundary of the previous run.
     352        // FIXME: We may need to traverse all the way to the previous non-text run (or even across inline boxes).
     353        auto lastRunLogicalWidth = lastRun.logicalWidth();
     354        auto contentWidthWithoutLastTextRun = m_contentLogicalWidth - std::max(0.f, lastRunLogicalWidth);
     355        lastRun.expand(inlineTextItem, logicalWidth);
     356        m_contentLogicalWidth = std::max(contentWidthWithoutLastTextRun, lastRunLogicalWidth + logicalWidth);
    349357    }
    350358
Note: See TracChangeset for help on using the changeset viewer.