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

Changeset 286000 in webkit


Ignore:
Timestamp:
Nov 18, 2021, 6:43:13 AM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][IFC] Inline boxes with unbreakable decoration can produce a breaking position with no trailing run
https://bugs.webkit.org/show_bug.cgi?id=233302

Reviewed by Antti Koivisto.

Source/WebCore:

This is a rare case when the overflowing run is the first inline box start with unbreakable decoration while its content is breakable.
e.g.
<div style="width: 0xp"><span style="border: solid; word-break: break-word;">breakable</span></div>

While the overflowing run (inline box start) is unbreakable (border), we find the first breaking position right between
the <span> (inline box start) and its content (inline text item).
However we also don't want to separate the content from its parent inline box (i.e. should not be breaking between these 2 inline items)
so we start searching for a trailing run candidate by looking at the previous set of runs.
Now if this <span> is the first run in this set we won't find a trailing run and we should just return the breaking position with no trailing content.

Test: fast/inline/inline-box-with-unbreakable-decoration-and-word-break.html

  • layout/formattingContexts/inline/InlineContentBreaker.cpp:

(WebCore::Layout::InlineContentBreaker::tryBreakingNextOverflowingRuns const):

LayoutTests:

  • fast/inline/inline-box-with-unbreakable-decoration-and-word-break-expected.html: Added.
  • fast/inline/inline-box-with-unbreakable-decoration-and-word-break.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r285998 r286000  
     12021-11-18  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Inline boxes with unbreakable decoration can produce a breaking position with no trailing run
     4        https://bugs.webkit.org/show_bug.cgi?id=233302
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/inline/inline-box-with-unbreakable-decoration-and-word-break-expected.html: Added.
     9        * fast/inline/inline-box-with-unbreakable-decoration-and-word-break.html: Added.
     10
    1112021-11-18  Ziran Sun  <zsun@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r285999 r286000  
     12021-11-18  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC][IFC] Inline boxes with unbreakable decoration can produce a breaking position with no trailing run
     4        https://bugs.webkit.org/show_bug.cgi?id=233302
     5
     6        Reviewed by Antti Koivisto.
     7
     8        This is a rare case when the overflowing run is the first inline box start with unbreakable decoration while its content is breakable.
     9        e.g.
     10        <div style="width: 0xp"><span style="border: solid; word-break: break-word;">breakable</span></div>
     11
     12          While the overflowing run (inline box start) is unbreakable (border), we find the first breaking position right between
     13          the <span> (inline box start) and its content (inline text item).
     14          However we also don't want to separate the content from its parent inline box (i.e. should not be breaking between these 2 inline items)
     15          so we start searching for a trailing run candidate by looking at the previous set of runs.
     16          Now if this <span> is the first run in this set we won't find a trailing run and we should just return the breaking position with no trailing content.
     17
     18        Test: fast/inline/inline-box-with-unbreakable-decoration-and-word-break.html
     19
     20        * layout/formattingContexts/inline/InlineContentBreaker.cpp:
     21        (WebCore::Layout::InlineContentBreaker::tryBreakingNextOverflowingRuns const):
     22
    1232021-11-18  Alan Bujtas  <zalan@apple.com>
    224
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp

    r285956 r286000  
    578578                return OverflowingTextContent::BreakingPosition { index, OverflowingTextContent::BreakingPosition::TrailingContent { true, partialRun } };
    579579            }
    580             auto trailingRunIndex = *findTrailingRunIndex(runs, index);
    581             // At worst we are back to the overflowing run, like in the example above.
    582             ASSERT(trailingRunIndex >= overflowingRunIndex);
    583             return OverflowingTextContent::BreakingPosition { trailingRunIndex, OverflowingTextContent::BreakingPosition::TrailingContent { true } };
     580            if (auto trailingRunIndex = findTrailingRunIndex(runs, index)) {
     581                // At worst we are back to the overflowing run, like in the example above.
     582                ASSERT(*trailingRunIndex >= overflowingRunIndex);
     583                return OverflowingTextContent::BreakingPosition { *trailingRunIndex, OverflowingTextContent::BreakingPosition::TrailingContent { true } };
     584            }
     585            // This happens when the overflowing run is also the first run in this set, no trailing run.
     586            return OverflowingTextContent::BreakingPosition { overflowingRunIndex, { } };
    584587        }
    585588        nextContentWidth += run.logicalWidth;
Note: See TracChangeset for help on using the changeset viewer.