[LFC][IFC] Empty text node should generate empty InlineTextItem
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jul 2019 14:02:22 +0000 (14:02 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Jul 2019 14:02:22 +0000 (14:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199495
<rdar://problem/52643225>

Reviewed by Antti Koivisto.

Empty text nodes generate empty RenderText renderers but they don't generate inline boxes.
This patch aligns LFC with the current rendering code.

* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::appendTextContent):
* layout/inlineformatting/InlineTextItem.cpp:
(WebCore::Layout::InlineTextItem::createAndAppendTextItems):

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

Source/WebCore/ChangeLog
Source/WebCore/layout/inlineformatting/InlineLine.cpp
Source/WebCore/layout/inlineformatting/InlineTextItem.cpp

index 63c46a8..7c02e64 100644 (file)
@@ -1,3 +1,19 @@
+2019-07-05  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Empty text node should generate empty InlineTextItem
+        https://bugs.webkit.org/show_bug.cgi?id=199495
+        <rdar://problem/52643225>
+
+        Reviewed by Antti Koivisto.
+
+        Empty text nodes generate empty RenderText renderers but they don't generate inline boxes.
+        This patch aligns LFC with the current rendering code.
+
+        * layout/inlineformatting/InlineLine.cpp:
+        (WebCore::Layout::Line::appendTextContent):
+        * layout/inlineformatting/InlineTextItem.cpp:
+        (WebCore::Layout::InlineTextItem::createAndAppendTextItems):
+
 2019-07-05  Adrian Perez de Castro  <aperez@igalia.com>
 
         [ATK] Do not use C linkage for functions using C++ features
index 87ca421..58170cc 100644 (file)
@@ -236,6 +236,11 @@ void Line::appendTextContent(const InlineTextItem& inlineItem, LayoutUnit logica
         m_trimmableContent.clear();
 
     auto shouldCollapseCompletely = [&] {
+        // Empty run.
+        if (!inlineItem.length()) {
+            ASSERT(!logicalWidth);
+            return true;
+        }
         if (!isTrimmable)
             return false;
         // Leading whitespace.
index 6e2a8fa..f9eef47 100644 (file)
@@ -88,12 +88,14 @@ static unsigned moveToNextBreakablePosition(unsigned startPosition, LazyLineBrea
 
 void InlineTextItem::createAndAppendTextItems(InlineItems& inlineContent, const InlineBox& inlineBox)
 {
+    auto text = inlineBox.textContent();
+    if (!text.length())
+        return inlineContent.append(std::make_unique<InlineTextItem>(inlineBox, 0, 0, false, false));
+
     auto& style = inlineBox.style();
     auto preserveNewline = style.preserveNewline();
     auto collapseWhiteSpace = style.collapseWhiteSpace();
-    auto text = inlineBox.textContent();
     LazyLineBreakIterator lineBreakIterator(text);
-
     unsigned currentPosition = 0;
     while (currentPosition < text.length()) {
         // Soft linebreak?