Title: [267617] trunk
Revision
267617
Author
[email protected]
Date
2020-09-25 22:21:18 -0700 (Fri, 25 Sep 2020)

Log Message

[LFC][IFC] Incorrect breaking position when inline box content fits the line but the inline content itself does not.
https://bugs.webkit.org/show_bug.cgi?id=217007

Reviewed by Simon Fraser.

Source/WebCore:

When the inline box does not fit the line but its text content does, the last breaking opportunity (in case of arbitrary breaking position)
is not the end of the text.
e.g
<div style="width: 200px; word-break: break-word;"><span style="border-right: 100px;">text_content_fits</span></div>
in this case the border right overflows the containing block and should be wrapped to the next available vertical position.
However the last breaking opportunity is not between 's' and the </span> but between 't' and 's'.

Test: fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not.html

* layout/inlineformatting/InlineLineBreaker.cpp:
(WebCore::Layout::LineBreaker::tryBreakingTextRun const):
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineCandidate::InlineContent::appendInlineItem): [container start](<span>) and [container end](</span>) runs are not collapsible.

LayoutTests:

* fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not-expected.html: Added.
* fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (267616 => 267617)


--- trunk/LayoutTests/ChangeLog	2020-09-26 02:44:02 UTC (rev 267616)
+++ trunk/LayoutTests/ChangeLog	2020-09-26 05:21:18 UTC (rev 267617)
@@ -1,3 +1,13 @@
+2020-09-25  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Incorrect breaking position when inline box content fits the line but the inline content itself does not.
+        https://bugs.webkit.org/show_bug.cgi?id=217007
+
+        Reviewed by Simon Fraser.
+
+        * fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not-expected.html: Added.
+        * fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not.html: Added.
+
 2020-09-25  Wenson Hsieh  <[email protected]>
 
         [GPU Process] fast/canvas/canvas-composite-canvas.html and fast/canvas/canvas-composite-image.html fail

Added: trunk/LayoutTests/fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not-expected.html (0 => 267617)


--- trunk/LayoutTests/fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not-expected.html	2020-09-26 05:21:18 UTC (rev 267617)
@@ -0,0 +1,3 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<div style="width: 300px; height: 40px; background-color: green;"></div>
+<div style="width: 50px; height: 20px; background-color: red; position: relative; top: -20px; left: 90px"></div>

Added: trunk/LayoutTests/fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not.html (0 => 267617)


--- trunk/LayoutTests/fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not.html	2020-09-26 05:21:18 UTC (rev 267617)
@@ -0,0 +1,15 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+  background-color: green;
+  font-family: Ahem;
+  font-size: 20px;
+  word-wrap: break-word;
+  width: 300px;
+}
+
+span {
+  border-right: 50px solid red;
+}
+</style>
+<div><span>text_content_fits</span></div>

Modified: trunk/Source/WebCore/ChangeLog (267616 => 267617)


--- trunk/Source/WebCore/ChangeLog	2020-09-26 02:44:02 UTC (rev 267616)
+++ trunk/Source/WebCore/ChangeLog	2020-09-26 05:21:18 UTC (rev 267617)
@@ -1,3 +1,24 @@
+2020-09-25  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Incorrect breaking position when inline box content fits the line but the inline content itself does not.
+        https://bugs.webkit.org/show_bug.cgi?id=217007
+
+        Reviewed by Simon Fraser.
+
+        When the inline box does not fit the line but its text content does, the last breaking opportunity (in case of arbitrary breaking position)
+        is not the end of the text.
+        e.g
+        <div style="width: 200px; word-break: break-word;"><span style="border-right: 100px;">text_content_fits</span></div>
+        in this case the border right overflows the containing block and should be wrapped to the next available vertical position.
+        However the last breaking opportunity is not between 's' and the </span> but between 't' and 's'.
+
+        Test: fast/layoutformattingcontext/inlin-box-content-fits-but-the-box-does-not.html
+
+        * layout/inlineformatting/InlineLineBreaker.cpp:
+        (WebCore::Layout::LineBreaker::tryBreakingTextRun const):
+        * layout/inlineformatting/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineCandidate::InlineContent::appendInlineItem): [container start](<span>) and [container end](</span>) runs are not collapsible.
+
 2020-09-25  Wenson Hsieh  <[email protected]>
 
         [GPU Process] fast/canvas/canvas-composite-canvas.html and fast/canvas/canvas-composite-image.html fail

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp (267616 => 267617)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp	2020-09-26 02:44:02 UTC (rev 267616)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp	2020-09-26 05:21:18 UTC (rev 267617)
@@ -301,7 +301,9 @@
         if (findLastBreakablePosition) {
             // When the run can be split at arbitrary position,
             // let's just return the entire run when it is intended to fit on the line.
-            return PartialRun { inlineTextItem.length(), overflowRun.logicalWidth, false };
+            ASSERT(inlineTextItem.length());
+            auto trailingPartialRunWidth = TextUtil::width(inlineTextItem, inlineTextItem.start(), inlineTextItem.end() - 1, logicalLeft);
+            return PartialRun { inlineTextItem.length() - 1, trailingPartialRunWidth, false };
         }
         auto splitData = TextUtil::split(inlineTextItem.inlineTextBox(), inlineTextItem.start(), inlineTextItem.length(), overflowRun.logicalWidth, availableWidth, logicalLeft);
         return PartialRun { splitData.length, splitData.logicalWidth, false };

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp (267616 => 267617)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2020-09-26 02:44:02 UTC (rev 267616)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp	2020-09-26 05:21:18 UTC (rev 267617)
@@ -247,6 +247,9 @@
             auto& inlineTextItem = downcast<InlineTextItem>(inlineItem);
             return inlineTextItem.isWhitespace() && !TextUtil::shouldPreserveTrailingWhitespace(inlineTextItem.style());
         }
+        if (inlineItem.isContainerStart() || inlineItem.isContainerEnd())
+            return false;
+        ASSERT_NOT_REACHED();
         return true;
     };
     if (isFullyCollapsible()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to