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

Changeset 272649 in webkit


Ignore:
Timestamp:
Feb 10, 2021, 6:59:20 AM (6 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Pass in sane content width values to InlineContentBreaker
​https://bugs.webkit.org/show_bug.cgi?id=221628
Source/WebCore:

rdar://problem/73874164

Reviewed by Antti Koivisto.

Insanely large zoom value could produce Nan letter-spacing values.
Let's tighten the inline content width values so that InlineContentBreaker can always expect valid InlineLayoutUnit values.

Test: fast/text/letter-spacing-produces-nan-width.html

  • layout/inlineformatting/InlineContentBreaker.cpp:

(WebCore::Layout::InlineContentBreaker::ContinuousContent::append):

  • layout/inlineformatting/text/TextUtil.cpp:

(WebCore::Layout::TextUtil::width):

LayoutTests:

Reviewed by Antti Koivisto.

  • fast/text/letter-spacing-produces-nan-width-expected.txt: Added.
  • fast/text/letter-spacing-produces-nan-width.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r272645 r272649  
     12021-02-10  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Pass in sane content width values to InlineContentBreaker
     4        https://bugs.webkit.org/show_bug.cgi?id=221628
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/text/letter-spacing-produces-nan-width-expected.txt: Added.
     9        * fast/text/letter-spacing-produces-nan-width.html: Added.
     10
    1112021-02-10  Kimmo Kinnunen  <kkinnunen@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r272648 r272649  
     12021-02-10  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Pass in sane content width values to InlineContentBreaker
     4        https://bugs.webkit.org/show_bug.cgi?id=221628
     5        rdar://problem/73874164
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Insanely large zoom value could produce Nan letter-spacing values.
     10        Let's tighten the inline content width values so that InlineContentBreaker can always expect valid InlineLayoutUnit values.
     11
     12        Test: fast/text/letter-spacing-produces-nan-width.html
     13
     14        * layout/inlineformatting/InlineContentBreaker.cpp:
     15        (WebCore::Layout::InlineContentBreaker::ContinuousContent::append):
     16        * layout/inlineformatting/text/TextUtil.cpp:
     17        (WebCore::Layout::TextUtil::width):
     18
    1192021-02-10  Zalan Bujtas  <zalan@apple.com>
    220
  • trunk/Source/WebCore/layout/inlineformatting/InlineContentBreaker.cpp

    r272412 r272649  
    489489{
    490490    m_runs.append({ inlineItem, logicalWidth });
    491     m_logicalWidth += logicalWidth;
     491    m_logicalWidth = clampTo<InlineLayoutUnit>(m_logicalWidth + logicalWidth);
    492492    if (!collapsibleWidth) {
    493493        m_collapsibleLogicalWidth = { };
  • trunk/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp

    r272578 r272649  
    4848    RELEASE_ASSERT(from >= inlineTextItem.start());
    4949    RELEASE_ASSERT(to <= inlineTextItem.end());
    50     if (inlineTextItem.isWhitespace() && !InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem))
    51         return inlineTextItem.style().fontCascade().spaceWidth();
     50    if (inlineTextItem.isWhitespace() && !InlineTextItem::shouldPreserveSpacesAndTabs(inlineTextItem)) {
     51        auto spaceWidth = inlineTextItem.style().fontCascade().spaceWidth();
     52        return std::isnan(spaceWidth) ? 0.0f : std::isinf(spaceWidth) ? maxInlineLayoutUnit() : spaceWidth;
     53    }
    5254    return TextUtil::width(inlineTextItem.inlineTextBox(), from, to, contentLogicalLeft);
    5355}
    … …  
    8082        width -= (font.spaceWidth() + font.wordSpacing());
    8183
    82     return width;
     84    return std::isnan(width) ? 0.0f : std::isinf(width) ? maxInlineLayoutUnit() : width;
    8385}
    8486
Note: See TracChangeset for help on using the changeset viewer.