Title: [287478] trunk
Revision
287478
Author
[email protected]
Date
2021-12-29 08:33:42 -0800 (Wed, 29 Dec 2021)

Log Message

[LFC][IFC] Collapsed trailing whitespace may introduce stray inline box
https://bugs.webkit.org/show_bug.cgi?id=234735

Reviewed by Antti Koivisto.

Source/WebCore:

See the comment in LineBuilder::handleInlineContent.

Test: fast/inline/inline-box-with-collapsed-whitespace.html

* layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::handleInlineContent):

LayoutTests:

* fast/inline/inline-box-with-collapsed-whitespace-expected.html: Added.
* fast/inline/inline-box-with-collapsed-whitespace.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (287477 => 287478)


--- trunk/LayoutTests/ChangeLog	2021-12-29 01:16:06 UTC (rev 287477)
+++ trunk/LayoutTests/ChangeLog	2021-12-29 16:33:42 UTC (rev 287478)
@@ -1,3 +1,13 @@
+2021-12-29  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] Collapsed trailing whitespace may introduce stray inline box
+        https://bugs.webkit.org/show_bug.cgi?id=234735
+
+        Reviewed by Antti Koivisto.
+
+        * fast/inline/inline-box-with-collapsed-whitespace-expected.html: Added.
+        * fast/inline/inline-box-with-collapsed-whitespace.html: Added.
+
 2021-12-28  Diego Pino Garcia  <[email protected]>
 
         [GTK] fast/mediastream/media-element-current-time.html is failing since added in r256346

Added: trunk/LayoutTests/fast/inline/inline-box-with-collapsed-whitespace-expected.html (0 => 287478)


--- trunk/LayoutTests/fast/inline/inline-box-with-collapsed-whitespace-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/inline-box-with-collapsed-whitespace-expected.html	2021-12-29 16:33:42 UTC (rev 287478)
@@ -0,0 +1,15 @@
+<style>
+div {
+  font-family: Ahem;
+  font-size: 20px;
+  color: green;
+  width: 100px;
+}
+
+span {
+  border-left: 20px solid green;
+  border-right: 60px solid blue;
+}
+</style>
+<!-- The inline box should show up on the second line first. -->
+<div>X <span>X</span></div>

Added: trunk/LayoutTests/fast/inline/inline-box-with-collapsed-whitespace.html (0 => 287478)


--- trunk/LayoutTests/fast/inline/inline-box-with-collapsed-whitespace.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/inline-box-with-collapsed-whitespace.html	2021-12-29 16:33:42 UTC (rev 287478)
@@ -0,0 +1,15 @@
+<style>
+div {
+  font-family: Ahem;
+  font-size: 20px;
+  color: green;
+  width: 100px;
+}
+
+span {
+  border-left: 20px solid green;
+  border-right: 60px solid blue;
+}
+</style>
+<!-- The inline box should show up on the second line first. -->
+<div>X <span> X</span></div>

Modified: trunk/LayoutTests/platform/ios/fast/inline-block/003-expected.txt (287477 => 287478)


--- trunk/LayoutTests/platform/ios/fast/inline-block/003-expected.txt	2021-12-29 01:16:06 UTC (rev 287477)
+++ trunk/LayoutTests/platform/ios/fast/inline-block/003-expected.txt	2021-12-29 16:33:42 UTC (rev 287478)
@@ -17,7 +17,7 @@
       RenderBlock (anonymous) at (0,44) size 784x68
         RenderText {#text} at (0,0) size 743x19
           text run at (0,0) width 743: "The two marquees below should be on separate lines, since marquees fill the width of a containing block by default."
-        RenderInline {SPAN} at (0,0) size 784x72
+        RenderInline {SPAN} at (0,0) size 784x43
           RenderText {#text} at (0,0) size 0x0
           RenderText {#text} at (0,0) size 0x0
           RenderText {#text} at (0,0) size 0x0

Modified: trunk/LayoutTests/platform/ios/tables/mozilla/core/bloomberg-expected.txt (287477 => 287478)


--- trunk/LayoutTests/platform/ios/tables/mozilla/core/bloomberg-expected.txt	2021-12-29 01:16:06 UTC (rev 287477)
+++ trunk/LayoutTests/platform/ios/tables/mozilla/core/bloomberg-expected.txt	2021-12-29 16:33:42 UTC (rev 287478)
@@ -245,7 +245,7 @@
                   RenderImage {IMG} at (0,0) size 175x270
                 RenderText {#text} at (0,0) size 0x0
                 RenderText {#text} at (0,0) size 0x0
-                RenderInline {A} at (0,0) size 168x49
+                RenderInline {A} at (0,0) size 161x19
                   RenderText {#text} at (0,0) size 0x0
                   RenderImage {IMG} at (7,270) size 161x30
                 RenderText {#text} at (0,0) size 0x0

Modified: trunk/LayoutTests/platform/mac/fast/inline-block/003-expected.txt (287477 => 287478)


--- trunk/LayoutTests/platform/mac/fast/inline-block/003-expected.txt	2021-12-29 01:16:06 UTC (rev 287477)
+++ trunk/LayoutTests/platform/mac/fast/inline-block/003-expected.txt	2021-12-29 16:33:42 UTC (rev 287478)
@@ -17,7 +17,7 @@
       RenderBlock (anonymous) at (0,40) size 784x62
         RenderText {#text} at (0,0) size 742x18
           text run at (0,0) width 742: "The two marquees below should be on separate lines, since marquees fill the width of a containing block by default."
-        RenderInline {SPAN} at (0,0) size 784x66
+        RenderInline {SPAN} at (0,0) size 784x40
           RenderText {#text} at (0,0) size 0x0
           RenderText {#text} at (0,0) size 0x0
           RenderText {#text} at (0,0) size 0x0

Modified: trunk/LayoutTests/platform/mac/tables/mozilla/core/bloomberg-expected.txt (287477 => 287478)


--- trunk/LayoutTests/platform/mac/tables/mozilla/core/bloomberg-expected.txt	2021-12-29 01:16:06 UTC (rev 287477)
+++ trunk/LayoutTests/platform/mac/tables/mozilla/core/bloomberg-expected.txt	2021-12-29 16:33:42 UTC (rev 287478)
@@ -245,7 +245,7 @@
                   RenderImage {IMG} at (0,0) size 175x270
                 RenderText {#text} at (0,0) size 0x0
                 RenderText {#text} at (0,0) size 0x0
-                RenderInline {A} at (0,0) size 168x48
+                RenderInline {A} at (0,0) size 161x18
                   RenderText {#text} at (0,0) size 0x0
                   RenderImage {IMG} at (7,270) size 161x30
                 RenderText {#text} at (0,0) size 0x0

Modified: trunk/LayoutTests/platform/mac-wk1/fast/inline-block/003-expected.txt (287477 => 287478)


--- trunk/LayoutTests/platform/mac-wk1/fast/inline-block/003-expected.txt	2021-12-29 01:16:06 UTC (rev 287477)
+++ trunk/LayoutTests/platform/mac-wk1/fast/inline-block/003-expected.txt	2021-12-29 16:33:42 UTC (rev 287478)
@@ -17,7 +17,7 @@
       RenderBlock (anonymous) at (0,40) size 784x62
         RenderText {#text} at (0,0) size 742x18
           text run at (0,0) width 742: "The two marquees below should be on separate lines, since marquees fill the width of a containing block by default."
-        RenderInline {SPAN} at (0,0) size 784x66
+        RenderInline {SPAN} at (0,0) size 784x40
           RenderText {#text} at (0,0) size 0x0
           RenderText {#text} at (0,0) size 0x0
           RenderText {#text} at (0,0) size 0x0

Modified: trunk/Source/WebCore/ChangeLog (287477 => 287478)


--- trunk/Source/WebCore/ChangeLog	2021-12-29 01:16:06 UTC (rev 287477)
+++ trunk/Source/WebCore/ChangeLog	2021-12-29 16:33:42 UTC (rev 287478)
@@ -1,3 +1,17 @@
+2021-12-29  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] Collapsed trailing whitespace may introduce stray inline box
+        https://bugs.webkit.org/show_bug.cgi?id=234735
+
+        Reviewed by Antti Koivisto.
+
+        See the comment in LineBuilder::handleInlineContent.
+
+        Test: fast/inline/inline-box-with-collapsed-whitespace.html
+
+        * layout/formattingContexts/inline/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::handleInlineContent):
+
 2021-12-28  Alan Bujtas  <[email protected]>
 
         [LFC][IFC] Do not let Layout geometry types leak into InlineDisplay::Line

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (287477 => 287478)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2021-12-29 01:16:06 UTC (rev 287477)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp	2021-12-29 16:33:42 UTC (rev 287478)
@@ -938,6 +938,18 @@
     if (result.action == InlineContentBreaker::Result::Action::Wrap) {
         ASSERT(result.isEndOfLine == InlineContentBreaker::IsEndOfLine::Yes);
         // This continuous content can't be placed on the current line. Nothing to commit at this time.
+        // However there are cases when, due to whitespace collapsing, this overflowing content should not be separated from
+        // the content on the line.
+        // <div>X <span> X</span></div>
+        // If the second 'X' overflows the line, the trailing whitespace gets trimmed which introduces a stray inline box
+        // on the first line ('X <span>' and 'X</span>' first and second line respectively).
+        // In such cases we need to revert the content on the line to a previous wrapping opportunity to keep such content together.
+        ASSERT(!m_line.runs().isEmpty());
+        auto needsRevert = m_line.trimmableTrailingWidth() && m_line.runs().last().isInlineBoxStart();
+        if (needsRevert && m_wrapOpportunityList.size() > 1) {
+            m_wrapOpportunityList.removeLast();
+            return { InlineContentBreaker::IsEndOfLine::Yes, { rebuildLine(layoutRange, *m_wrapOpportunityList.last()), true } };
+        }
         return { InlineContentBreaker::IsEndOfLine::Yes, { }, { }, eligibleOverflowWidthAsLeading() };
     }
     if (result.action == InlineContentBreaker::Result::Action::WrapWithHyphen) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to