Title: [272012] trunk/Source/WebCore
Revision
272012
Author
za...@apple.com
Date
2021-01-28 06:01:26 -0800 (Thu, 28 Jan 2021)

Log Message

[LFC][IFC] Incorrect soft opportunity position when the inline box starts with an atomic inline box
https://bugs.webkit.org/show_bug.cgi?id=221076

Reviewed by Antti Koivisto.

This patch fixes the following case:
  "text_content<span><img></span>"
On trunk we find the soft wrap opportunity after the <span> which could result the following, incorrect line setup
line #1: text_content<span>
line #2  <img></span>
This makes the inline box (<span>) taller than it is supposed to be as it shows up on both the first and the second line.

* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::nextWrapOpportunity const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (272011 => 272012)


--- trunk/Source/WebCore/ChangeLog	2021-01-28 12:48:07 UTC (rev 272011)
+++ trunk/Source/WebCore/ChangeLog	2021-01-28 14:01:26 UTC (rev 272012)
@@ -1,3 +1,20 @@
+2021-01-28  Zalan Bujtas  <za...@apple.com>
+
+        [LFC][IFC] Incorrect soft opportunity position when the inline box starts with an atomic inline box
+        https://bugs.webkit.org/show_bug.cgi?id=221076
+
+        Reviewed by Antti Koivisto.
+
+        This patch fixes the following case:
+          "text_content<span><img></span>"
+        On trunk we find the soft wrap opportunity after the <span> which could result the following, incorrect line setup
+        line #1: text_content<span>
+        line #2  <img></span>
+        This makes the inline box (<span>) taller than it is supposed to be as it shows up on both the first and the second line. 
+
+        * layout/inlineformatting/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::nextWrapOpportunity const):
+
 2021-01-28  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [SOUP] Stop using SoupRequest API in preparation for libsoup3

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (272011 => 272012)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2021-01-28 12:48:07 UTC (rev 272011)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2021-01-28 14:01:26 UTC (rev 272012)
@@ -520,7 +520,7 @@
             return ++index;
         }
         if (inlineItem.isInlineBoxStart() || inlineItem.isInlineBoxEnd()) {
-            // There's no wrapping opportunity between <span>text, <span></span> or </span>text. 
+            // Need to see what comes next to decide.
             continue;
         }
         ASSERT(inlineItem.isText() || inlineItem.isBox() || inlineItem.isFloat());
@@ -528,11 +528,14 @@
             previousInlineItemIndex = index;
             continue;
         }
+        // At this point previous and current items are not necessarily adjacent items e.g "previous<span>current</span>"
         auto& previousItem = m_inlineItems[*previousInlineItemIndex];
         auto& currentItem = m_inlineItems[index];
         if (isAtSoftWrapOpportunity(m_inlineFormattingContext, previousItem, currentItem)) {
-            if (!previousItem.isText() || !currentItem.isText())
+            if (*previousInlineItemIndex + 1 == index && (!previousItem.isText() || !currentItem.isText())) {
+                // We only know the exact soft wrap opportunity index when the previous and current items are next to each other.
                 return index;
+            }
             // There's a soft wrap opportunity between 'previousInlineItemIndex' and 'index'.
             // Now forward-find from the start position to see where we can actually wrap.
             // [ex-][ample] vs. [ex-][container start][container end][ample]
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to