Title: [253289] trunk/Source/WebCore
Revision
253289
Author
[email protected]
Date
2019-12-09 08:41:49 -0800 (Mon, 09 Dec 2019)

Log Message

[LFC][IFC] Do not create PartialContent for a single character run when it does not fit.
https://bugs.webkit.org/show_bug.cgi?id=205010
<rdar://problem/57752705>

Reviewed by Antti Koivisto.

Use ContentWrappingRule::Keep instead of ContentWrappingRule::Split when dealing with single character overflown runs on empty lines.
<div style="width: 0px; word-break: break-all">text</div> <- produces single character runs.

* layout/inlineformatting/InlineLineBreaker.cpp:
(WebCore::Layout::LineBreaker::breakingContextForInlineContent):
* layout/inlineformatting/InlineTextItem.cpp:
(WebCore::Layout::InlineTextItem::left const):
(WebCore::Layout::InlineTextItem::right const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (253288 => 253289)


--- trunk/Source/WebCore/ChangeLog	2019-12-09 15:36:42 UTC (rev 253288)
+++ trunk/Source/WebCore/ChangeLog	2019-12-09 16:41:49 UTC (rev 253289)
@@ -1,3 +1,20 @@
+2019-12-09  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Do not create PartialContent for a single character run when it does not fit.
+        https://bugs.webkit.org/show_bug.cgi?id=205010
+        <rdar://problem/57752705>
+
+        Reviewed by Antti Koivisto.
+
+        Use ContentWrappingRule::Keep instead of ContentWrappingRule::Split when dealing with single character overflown runs on empty lines.
+        <div style="width: 0px; word-break: break-all">text</div> <- produces single character runs.
+
+        * layout/inlineformatting/InlineLineBreaker.cpp:
+        (WebCore::Layout::LineBreaker::breakingContextForInlineContent):
+        * layout/inlineformatting/InlineTextItem.cpp:
+        (WebCore::Layout::InlineTextItem::left const):
+        (WebCore::Layout::InlineTextItem::right const):
+
 2019-12-09  youenn fablet  <[email protected]>
 
         Add an option to capture audio in GPU process

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp (253288 => 253289)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp	2019-12-09 15:36:42 UTC (rev 253288)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp	2019-12-09 16:41:49 UTC (rev 253289)
@@ -80,17 +80,23 @@
     if (candidateRuns.hasTextContentOnly()) {
         auto& runs = candidateRuns.runs();
         if (auto partialTrailingContent = wordBreakingBehavior(runs, lineStatus.availableWidth)) {
-            // We tried to split the content but the available space can't even accommodate the first character (but we need something on the line).
-            if (lineStatus.lineIsEmpty && !partialTrailingContent->length) {
+            // We tried to split the content but the available space can't even accommodate the first character.
+            if (!partialTrailingContent->length) {
+                // 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).
+                if (!lineStatus.lineIsEmpty)
+                    return { BreakingContext::ContentWrappingRule::Push, { } };
                 auto firstTextRunIndex = *candidateRuns.firstTextRunIndex();
                 auto& inlineTextItem = downcast<InlineTextItem>(runs[firstTextRunIndex].inlineItem);
                 ASSERT(inlineTextItem.length());
+                if (inlineTextItem.length() == 1)
+                    return { BreakingContext::ContentWrappingRule::Keep, { } };
                 auto firstCharacterWidth = TextUtil::width(inlineTextItem.layoutBox(), inlineTextItem.start(), inlineTextItem.start() + 1);
-                partialTrailingContent = BreakingContext::PartialTrailingContent { firstTextRunIndex, 1, firstCharacterWidth, false };
+                return { BreakingContext::ContentWrappingRule::Split, BreakingContext::PartialTrailingContent { firstTextRunIndex, 1, firstCharacterWidth, false } };
             }
             return { BreakingContext::ContentWrappingRule::Split, partialTrailingContent };
         }
-        // If we did not manage to break this content, we still need to decide whether keep it or push it to the next line.
+        // If we are not allowed to break this content, we still need to decide whether keep it or push it to the next line.
         auto contentShouldOverflow = lineStatus.lineIsEmpty || !isContentWrappingAllowed(runs[0]);
         // FIXME: white-space: pre-wrap needs clarification. According to CSS Text Module Level 3, content wrapping is as 'normal' but apparently
         // we need to keep the overlapping whitespace on the line (and hang it I'd assume).

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp (253288 => 253289)


--- trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp	2019-12-09 15:36:42 UTC (rev 253288)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineTextItem.cpp	2019-12-09 16:41:49 UTC (rev 253289)
@@ -161,6 +161,7 @@
 {
     RELEASE_ASSERT(length <= this->length());
     ASSERT(m_textItemType != TextItemType::Undefined);
+    ASSERT(length);
     return makeUnique<InlineTextItem>(layoutBox(), start(), length, WTF::nullopt, m_textItemType);
 }
 
@@ -168,6 +169,7 @@
 {
     RELEASE_ASSERT(length <= this->length());
     ASSERT(m_textItemType != TextItemType::Undefined);
+    ASSERT(length);
     return makeUnique<InlineTextItem>(layoutBox(), end() - length, length, WTF::nullopt, m_textItemType);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to