Title: [270813] branches/safari-610-branch/Source/WebCore
Revision
270813
Author
[email protected]
Date
2020-12-14 17:27:49 -0800 (Mon, 14 Dec 2020)

Log Message

Cherry-pick r269535. rdar://problem/72298703

    Empty text runs can't be split any further.
    https://bugs.webkit.org/show_bug.cgi?id=218506

    Reviewed by David Kilzer and Ryosuke Niwa.

    This patch ensures that when we can't fit an empty text run on the line (available space is negative) we don't
    try to split it even when the style says so.

    * layout/inlineformatting/InlineContentBreaker.cpp:
    (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
    (WebCore::Layout::InlineContentBreaker::tryBreakingTextRun const):
    * layout/inlineformatting/text/TextUtil.cpp:
    (WebCore::Layout::TextUtil::fixedPitchWidth):
    (WebCore::Layout::TextUtil::split):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269535 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-610-branch/Source/WebCore/ChangeLog (270812 => 270813)


--- branches/safari-610-branch/Source/WebCore/ChangeLog	2020-12-15 01:16:43 UTC (rev 270812)
+++ branches/safari-610-branch/Source/WebCore/ChangeLog	2020-12-15 01:27:49 UTC (rev 270813)
@@ -1,3 +1,41 @@
+2020-12-14  Alan Coon  <[email protected]>
+
+        Cherry-pick r269535. rdar://problem/72298703
+
+    Empty text runs can't be split any further.
+    https://bugs.webkit.org/show_bug.cgi?id=218506
+    
+    Reviewed by David Kilzer and Ryosuke Niwa.
+    
+    This patch ensures that when we can't fit an empty text run on the line (available space is negative) we don't
+    try to split it even when the style says so.
+    
+    * layout/inlineformatting/InlineContentBreaker.cpp:
+    (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
+    (WebCore::Layout::InlineContentBreaker::tryBreakingTextRun const):
+    * layout/inlineformatting/text/TextUtil.cpp:
+    (WebCore::Layout::TextUtil::fixedPitchWidth):
+    (WebCore::Layout::TextUtil::split):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269535 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-11-06  Zalan Bujtas  <[email protected]>
+
+            Empty text runs can't be split any further.
+            https://bugs.webkit.org/show_bug.cgi?id=218506
+
+            Reviewed by David Kilzer and Ryosuke Niwa.
+
+            This patch ensures that when we can't fit an empty text run on the line (available space is negative) we don't
+            try to split it even when the style says so.
+
+            * layout/inlineformatting/InlineContentBreaker.cpp:
+            (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
+            (WebCore::Layout::InlineContentBreaker::tryBreakingTextRun const):
+            * layout/inlineformatting/text/TextUtil.cpp:
+            (WebCore::Layout::TextUtil::fixedPitchWidth):
+            (WebCore::Layout::TextUtil::split):
+
 2020-12-01  Alan Coon  <[email protected]>
 
         Cherry-pick r269190. rdar://problem/71381759

Modified: branches/safari-610-branch/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp (270812 => 270813)


--- branches/safari-610-branch/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp	2020-12-15 01:16:43 UTC (rev 270812)
+++ branches/safari-610-branch/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp	2020-12-15 01:27:49 UTC (rev 270813)
@@ -184,13 +184,12 @@
             if (!wrappedTextContent->trailingRunIndex && wrappedTextContent->contentOverflows) {
                 // We tried to split the content but the available space can't even accommodate the first character.
                 // 1. Push the content over to the next line when we've got content on the line already.
-                // 2. Keep the first character on the empty line (or keep the whole run if it has only one character).
+                // 2. Keep the first character on the empty line (or keep the whole run if it has only one character/completely empty).
                 if (!lineStatus.lineIsEmpty)
                     return { Result::Action::Push, IsEndOfLine::Yes, { } };
                 auto firstTextRunIndex = *candidateContent.firstTextRunIndex();
                 auto& inlineTextItem = downcast<InlineTextItem>(runs[firstTextRunIndex].inlineItem);
-                ASSERT(inlineTextItem.length());
-                if (inlineTextItem.length() == 1)
+                if (inlineTextItem.length() <= 1)
                     return Result { Result::Action::Keep, IsEndOfLine::Yes };
                 auto firstCharacterWidth = TextUtil::width(inlineTextItem, inlineTextItem.start(), inlineTextItem.start() + 1);
                 auto firstCharacterRun = PartialRun { 1, firstCharacterWidth, false };
@@ -304,6 +303,10 @@
 
     auto breakRule = wordBreakBehavior(style);
     if (breakRule == WordBreakRule::AtArbitraryPosition) {
+        if (!inlineTextItem.length()) {
+            // Empty text runs may be breakable based on style, but in practice we can't really split them any further.
+            return PartialRun { };
+        }
         if (findLastBreakablePosition) {
             // When the run can be split at arbitrary position,
             // let's just return the entire run when it is intended to fit on the line.

Modified: branches/safari-610-branch/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp (270812 => 270813)


--- branches/safari-610-branch/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp	2020-12-15 01:16:43 UTC (rev 270812)
+++ branches/safari-610-branch/Source/WebCore/layout/inlineformatting/text/TextUtil.cpp	2020-12-15 01:27:49 UTC (rev 270813)
@@ -83,6 +83,7 @@
 
 InlineLayoutUnit TextUtil::fixedPitchWidth(const StringView& text, const RenderStyle& style, unsigned from, unsigned to, InlineLayoutUnit contentLogicalLeft)
 {
+    RELEASE_ASSERT(to <= text.length());
     auto& font = style.fontCascade();
     auto monospaceCharacterWidth = font.spaceWidth();
     float width = 0;
@@ -96,12 +97,12 @@
         if (i > from && (character == ' ' || character == '\t' || character == '\n'))
             width += font.wordSpacing();
     }
-
     return std::max<InlineLayoutUnit>(0, InlineLayoutUnit(width));
 }
 
 TextUtil::SplitData TextUtil::split(const InlineTextBox& inlineTextBox, unsigned startPosition, unsigned length, InlineLayoutUnit textWidth, InlineLayoutUnit availableWidth, InlineLayoutUnit contentLogicalLeft)
 {
+    ASSERT(length);
     ASSERT(availableWidth >= 0);
     auto left = startPosition;
     // Pathological case of (extremely)long string and narrow lines.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to