Changeset 293644 in webkit


Ignore:
Timestamp:
Apr 30, 2022 6:01:57 AM (2 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Do not wrap </span> to the next line when it is preceded by overflowing text
https://bugs.webkit.org/show_bug.cgi?id=239879
<rdar://problem/92497176>

Reviewed by Antti Koivisto.

Source/WebCore:

This patch makes sure that inline content run(s) ("X") followed by inline box end run(s) (</span></span>)
don't get separated when they overflow the line (e.g. width: 0px).

Test: fast/inline/overflowing-content-inside-inline-box.html

  • layout/formattingContexts/inline/InlineContentBreaker.cpp:

(WebCore::Layout::InlineContentBreaker::processOverflowingContent const):

LayoutTests:

  • fast/inline/overflowing-content-inside-inline-box-expected.html: Added.
  • fast/inline/overflowing-content-inside-inline-box.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r293640 r293644  
     12022-04-30  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Do not wrap </span> to the next line when it is preceded by overflowing text
     4        https://bugs.webkit.org/show_bug.cgi?id=239879
     5        <rdar://problem/92497176>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        * fast/inline/overflowing-content-inside-inline-box-expected.html: Added.
     10        * fast/inline/overflowing-content-inside-inline-box.html: Added.
     11
    1122022-04-27  Jean-Yves Avenard  <jya@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r293642 r293644  
     12022-04-30  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Do not wrap </span> to the next line when it is preceded by overflowing text
     4        https://bugs.webkit.org/show_bug.cgi?id=239879
     5        <rdar://problem/92497176>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        This patch makes sure that inline content run(s) ("X") followed by inline box end run(s) (</span></span>)
     10        don't get separated when they overflow the line (e.g. width: 0px).
     11
     12        Test: fast/inline/overflowing-content-inside-inline-box.html
     13
     14        * layout/formattingContexts/inline/InlineContentBreaker.cpp:
     15        (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
     16
    1172022-04-29  Rob Buis  <rbuis@igalia.com>
    218
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp

    r291134 r293644  
    202202                // We tried to break the content but the available space can't even accommodate the first glyph.
    203203                // 1. Wrap the content over to the next line when we've got content on the line already.
    204                 // 2. Keep the first glyph on the empty line (or keep the whole run if it has only one glyph/completely empty).
     204                // 2. Keep the first glyph on the empty line (or keep the whole run if it has only one glyph/completely empty)
     205                // including closing inline boxes e.g. <span><span>X</span></span> where "X" is the overflowing glyph).
    205206                if (lineStatus.hasContent)
    206207                    return Result { Result::Action::Wrap, IsEndOfLine::Yes };
     
    213214
    214215                if (inlineTextItem.length() <= firstCharacterLength) {
    215                     if (continuousContent.runs().size() == 1)
    216                         return Result { Result::Action::Keep, IsEndOfLine::Yes };
    217                     return Result { Result::Action::Break, IsEndOfLine::Yes, Result::PartialTrailingContent { leadingTextRunIndex, { } } };
     216                    auto trailingRunIndex = [&]() -> std::optional<size_t> {
     217                        // Keep the overflowing text content and the closing inline box runs together.
     218                        // e.g. X</span><span>Y</span> where "X" overflows, the trailing run index is 1.
     219                        auto& runs = continuousContent.runs();
     220                        if (leadingTextRunIndex == runs.size() - 1)
     221                            return { };
     222                        if (!runs[leadingTextRunIndex + 1].inlineItem.isInlineBoxEnd())
     223                            return leadingTextRunIndex;
     224                        for (auto runIndex = leadingTextRunIndex + 1; runIndex < runs.size(); ++runIndex) {
     225                            if (!runs[runIndex].inlineItem.isInlineBoxEnd())
     226                                return runIndex - 1;
     227                        }
     228                        return { };
     229                    };
     230                    if (auto runToBreakAfter = trailingRunIndex())
     231                        return Result { Result::Action::Break, IsEndOfLine::Yes, Result::PartialTrailingContent { *runToBreakAfter, { } } };
     232                    return Result { Result::Action::Keep, IsEndOfLine::Yes };
    218233                }
    219234
Note: See TracChangeset for help on using the changeset viewer.