Title: [287470] trunk
Revision
287470
Author
[email protected]
Date
2021-12-28 08:40:24 -0800 (Tue, 28 Dec 2021)

Log Message

REGRESSION(r287440) Do not wrap the content for a collapsed whitespace
https://bugs.webkit.org/show_bug.cgi?id=234710

Reviewed by Antti Koivisto.

Source/WebCore:

While r287440 was correct, shouldKeepEndOfLineWhitespace had an unintentional side-effect of
keeping collapsed whitespace content on the line even when it is followed by an inline box end
with margin/padding/border that would otherwise overflow the line.

e.g <div style="width: 0px"><span style="border-right: 100px;">X </span></div>
^^ the overflowing inline box end should not be wrapped over to the next line.

Test: fast/inline/trailing-whitespace-content-with-overflowing-inline-box.html

* layout/formattingContexts/inline/InlineContentBreaker.cpp:
(WebCore::Layout::isWhitespaceOnlyContent):
(WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
(WebCore::Layout::isVisuallyEmptyWhitespaceContent): Deleted.

LayoutTests:

* fast/inline/trailing-whitespace-content-with-overflowing-inline-box-expected.html: Added.
* fast/inline/trailing-whitespace-content-with-overflowing-inline-box.html: Added.
* platform/ios/fast/borders/rtl-border-01-expected.txt: Redo rebaselining. While the content visually looks
odd (overflowing inline box), it is the expected behavior.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (287469 => 287470)


--- trunk/LayoutTests/ChangeLog	2021-12-28 12:28:33 UTC (rev 287469)
+++ trunk/LayoutTests/ChangeLog	2021-12-28 16:40:24 UTC (rev 287470)
@@ -1,3 +1,15 @@
+2021-12-28  Alan Bujtas  <[email protected]>
+
+        REGRESSION(r287440) Do not wrap the content for a collapsed whitespace
+        https://bugs.webkit.org/show_bug.cgi?id=234710
+
+        Reviewed by Antti Koivisto.
+
+        * fast/inline/trailing-whitespace-content-with-overflowing-inline-box-expected.html: Added.
+        * fast/inline/trailing-whitespace-content-with-overflowing-inline-box.html: Added.
+        * platform/ios/fast/borders/rtl-border-01-expected.txt: Redo rebaselining. While the content visually looks
+        odd (overflowing inline box), it is the expected behavior.
+
 2021-12-28  Manuel Rego Casasnovas  <[email protected]>
 
         [selectors] Import two :focus-visible tests from WPT

Added: trunk/LayoutTests/fast/inline/trailing-whitespace-content-with-overflowing-inline-box-expected.html (0 => 287470)


--- trunk/LayoutTests/fast/inline/trailing-whitespace-content-with-overflowing-inline-box-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/trailing-whitespace-content-with-overflowing-inline-box-expected.html	2021-12-28 16:40:24 UTC (rev 287470)
@@ -0,0 +1,13 @@
+<style>
+div {
+  font-family: Ahem;
+  font-size: 15px;
+  width: 40px;
+  color: green;
+}
+span {
+  padding-left: 25px;
+  border-right: 15px solid green;
+}
+</style>
+<div><span>X</span> X</p>

Added: trunk/LayoutTests/fast/inline/trailing-whitespace-content-with-overflowing-inline-box.html (0 => 287470)


--- trunk/LayoutTests/fast/inline/trailing-whitespace-content-with-overflowing-inline-box.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/trailing-whitespace-content-with-overflowing-inline-box.html	2021-12-28 16:40:24 UTC (rev 287470)
@@ -0,0 +1,14 @@
+<style>
+div {
+  font-family: Ahem;
+  font-size: 15px;
+  width: 40px;
+  color: green;
+}
+span {
+  padding-left: 25px;
+  border-right: 15px solid green;
+}
+</style>
+<!-- While the border-right makes the content overflow the line, it should stick with the X (and the collapsed whitespace) -->
+<div><span>X </span>X</p>

Modified: trunk/LayoutTests/platform/ios/fast/borders/rtl-border-01-expected.txt (287469 => 287470)


--- trunk/LayoutTests/platform/ios/fast/borders/rtl-border-01-expected.txt	2021-12-28 12:28:33 UTC (rev 287469)
+++ trunk/LayoutTests/platform/ios/fast/borders/rtl-border-01-expected.txt	2021-12-28 16:40:24 UTC (rev 287470)
@@ -1,4 +1,4 @@
-layer at (0,0) size 800x688
+layer at (0,0) size 812x688
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x688
   RenderBlock {HTML} at (0,0) size 800x689
@@ -24,7 +24,7 @@
             text run at (0,6) width 604: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut "
             text run at (603,6) width 148: "labore et dolore magna"
             text run at (0,38) width 441: "aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco "
-          RenderInline {SPAN} at (0,0) size 766x117 [border: (1px solid #0000FF) (10px solid #FFA500) (1px solid #0000FF) (10px solid #008000)]
+          RenderInline {SPAN} at (0,0) size 789x85 [border: (1px solid #0000FF) (10px solid #FFA500) (1px solid #0000FF) (10px solid #008000)]
             RenderText {#text} at (485,38) size 766x83
               text run at (485,38) width 242: "laboris nisi ut aliquip ex ea commodo"
               text run at (0,70) width 331: "consequat. Duis aute irure dolor in reprehenderit in "
@@ -31,8 +31,8 @@
               text run at (331,70) width 435: "voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur"
               text run at (0,102) width 149: "sint occaecat cupidatat "
               text run at (148,102) width 606: "non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor"
-          RenderText {#text} at (45,134) size 577x19
-            text run at (45,134) width 577: "sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore"
+          RenderText {#text} at (0,134) size 577x19
+            text run at (0,134) width 577: "sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore"
       RenderBlock {H1} at (0,349) size 784x21
         RenderText {#text} at (0,0) size 91x19
           text run at (0,0) width 91: "Right-to-Left"

Modified: trunk/Source/WebCore/ChangeLog (287469 => 287470)


--- trunk/Source/WebCore/ChangeLog	2021-12-28 12:28:33 UTC (rev 287469)
+++ trunk/Source/WebCore/ChangeLog	2021-12-28 16:40:24 UTC (rev 287470)
@@ -1,3 +1,24 @@
+2021-12-28  Alan Bujtas  <[email protected]>
+
+        REGRESSION(r287440) Do not wrap the content for a collapsed whitespace
+        https://bugs.webkit.org/show_bug.cgi?id=234710
+
+        Reviewed by Antti Koivisto.
+
+        While r287440 was correct, shouldKeepEndOfLineWhitespace had an unintentional side-effect of
+        keeping collapsed whitespace content on the line even when it is followed by an inline box end
+        with margin/padding/border that would otherwise overflow the line.
+
+        e.g <div style="width: 0px"><span style="border-right: 100px;">X </span></div>
+        ^^ the overflowing inline box end should not be wrapped over to the next line.
+
+        Test: fast/inline/trailing-whitespace-content-with-overflowing-inline-box.html
+
+        * layout/formattingContexts/inline/InlineContentBreaker.cpp:
+        (WebCore::Layout::isWhitespaceOnlyContent):
+        (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
+        (WebCore::Layout::isVisuallyEmptyWhitespaceContent): Deleted.
+
 2021-12-27  Wenson Hsieh  <[email protected]>
 
         Element::boundingAbsoluteRectWithoutLayout() should be marked `const`

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp (287469 => 287470)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp	2021-12-28 12:28:33 UTC (rev 287469)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp	2021-12-28 16:40:24 UTC (rev 287470)
@@ -84,7 +84,7 @@
     return { };
 }
 
-static inline bool isVisuallyEmptyWhitespaceContent(const InlineContentBreaker::ContinuousContent& continuousContent)
+static inline bool isWhitespaceOnlyContent(const InlineContentBreaker::ContinuousContent& continuousContent)
 {
     // [<span></span> ] [<span> </span>] [ <span style="padding: 0px;"></span>] are all considered visually empty whitespace content.
     // [<span style="border: 1px solid red"></span> ] while this is whitespace content only, it is not considered visually empty.
@@ -92,7 +92,6 @@
     auto hasWhitespace = false;
     for (auto& run : continuousContent.runs()) {
         auto& inlineItem = run.inlineItem;
-        // FIXME: check if visual decoration makes a difference here e.g. padding border.
         if (inlineItem.isInlineBoxStart() || inlineItem.isInlineBoxEnd())
             continue;
         auto isWhitespace = inlineItem.isText() && downcast<InlineTextItem>(inlineItem).isWhitespace();
@@ -159,16 +158,16 @@
     auto checkForTrailingContentFit = [&]() -> std::optional<InlineContentBreaker::Result> {
         if (continuousContent.hasCollapsibleContent()) {
             // Check if the content fits if we collapsed it.
-            if (continuousContent.isFullyCollapsible()) {
-                // If this new content is fully collapsible, it should surely fit.
+            if (continuousContent.isFullyCollapsible() || isWhitespaceOnlyContent(continuousContent)) {
+                // If this new content is fully collapsible (including when it is enclosed by an inline box with overflowing decoration)
+                // it should not be wrapped to the next line (as it either fits/or gets fully collapsed).
                 return InlineContentBreaker::Result { Result::Action::Keep };
-            } else {
-                auto spaceRequired = continuousContent.logicalWidth() - continuousContent.trailingCollapsibleWidth().value_or(0.f);
-                if (lineStatus.hasFullyCollapsibleTrailingContent || isVisuallyEmptyWhitespaceContent(continuousContent))
-                    spaceRequired -= continuousContent.leadingCollapsibleWidth().value_or(0.f);
-                if (spaceRequired <= lineStatus.availableWidth)
-                    return InlineContentBreaker::Result { Result::Action::Keep };
             }
+            auto spaceRequired = continuousContent.logicalWidth() - continuousContent.trailingCollapsibleWidth().value_or(0.f);
+            if (lineStatus.hasFullyCollapsibleTrailingContent)
+                spaceRequired -= continuousContent.leadingCollapsibleWidth().value_or(0.f);
+            if (spaceRequired <= lineStatus.availableWidth)
+                return InlineContentBreaker::Result { Result::Action::Keep };
         }
 
         if (continuousContent.isHangingContent())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to