<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[287453] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/287453">287453</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2021-12-26 22:43:31 -0800 (Sun, 26 Dec 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[LFC][IFC] Do not trim the hanging trailing content
https://bugs.webkit.org/show_bug.cgi?id=234679

Reviewed by Antti Koivisto.

Source/WebCore:

This is the final step of making the hanging content handling inline with the spec.
(https://www.w3.org/TR/css-text-3/#hang)
Since we don't (fake)trim such content when closing the line, the content width matches
the actual content on the line which also helps when it is aligned to support RTL ordering.

* layout/formattingContexts/inline/InlineLine.cpp:
(WebCore::Layout::Line::Run::removeTrailingWhitespace):
(WebCore::Layout::Line::visuallyCollapseHangingOverflowingGlyphs): Deleted.
(WebCore::Layout::Line::Run::visuallyCollapseTrailingWhitespace): Deleted.
* layout/formattingContexts/inline/InlineLine.h:
* layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
(WebCore::Layout::horizontalAlignmentOffset):
* layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::close):

LayoutTests:

* platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt: Progression. Matches FF and Chrome selection behavior.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformiosfasttextwhitespaceprewrapoverflowselectionexpectedtxt">trunk/LayoutTests/platform/ios/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacfasttextwhitespaceprewrapoverflowselectionexpectedtxt">trunk/LayoutTests/platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmachttptestsmiscacid3expectedtxt">trunk/LayoutTests/platform/mac/http/tests/misc/acid3-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineLinecpp">trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineLineh">trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineLineBoxBuildercpp">trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineLineBoxBuilderh">trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineLineBuildercpp">trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlinedisplayInlineDisplayLineBuildercpp">trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (287452 => 287453)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-12-27 00:46:40 UTC (rev 287452)
+++ trunk/LayoutTests/ChangeLog 2021-12-27 06:43:31 UTC (rev 287453)
</span><span class="lines">@@ -1,3 +1,12 @@
</span><ins>+2021-12-26  Alan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Do not trim the hanging trailing content
+        https://bugs.webkit.org/show_bug.cgi?id=234679
+
+        Reviewed by Antti Koivisto.
+
+        * platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt: Progression. Matches FF and Chrome selection behavior.
+
</ins><span class="cx"> 2021-12-26  Tim Nguyen  <ntim@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Make -webkit-text-combine an inherited property
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiosfasttextwhitespaceprewrapoverflowselectionexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt (287452 => 287453)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt     2021-12-27 00:46:40 UTC (rev 287452)
+++ trunk/LayoutTests/platform/ios/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt        2021-12-27 06:43:31 UTC (rev 287453)
</span><span class="lines">@@ -21,8 +21,8 @@
</span><span class="cx">       RenderBlock {HR} at (0,92) size 784x2 [border: (1px inset #000000)]
</span><span class="cx">       RenderBlock {HR} at (0,198) size 784x2 [border: (1px inset #000000)]
</span><span class="cx">       RenderBlock {PRE} at (0,213) size 108x78 [border: (4px solid #0000FF)]
</span><del>-        RenderText {#text} at (4,4) size 100x70
-          text run at (4,4) width 100: "This   text     "
</del><ins>+        RenderText {#text} at (4,4) size 125x70
+          text run at (4,4) width 125: "This   text     "
</ins><span class="cx">           text run at (4,18) width 71: "will wrap"
</span><span class="cx">           text run at (74,18) width 1: " "
</span><span class="cx">           text run at (4,32) width 94: "and   fit   "
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacfasttextwhitespaceprewrapoverflowselectionexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt (287452 => 287453)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt     2021-12-27 00:46:40 UTC (rev 287452)
+++ trunk/LayoutTests/platform/mac/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt        2021-12-27 06:43:31 UTC (rev 287453)
</span><span class="lines">@@ -21,8 +21,8 @@
</span><span class="cx">       RenderBlock {HR} at (0,86) size 784x2 [border: (1px inset #000000)]
</span><span class="cx">       RenderBlock {HR} at (0,197) size 784x2 [border: (1px inset #000000)]
</span><span class="cx">       RenderBlock {PRE} at (0,212) size 108x83 [border: (4px solid #0000FF)]
</span><del>-        RenderText {#text} at (4,4) size 100x75
-          text run at (4,4) width 100: "This   text     "
</del><ins>+        RenderText {#text} at (4,4) size 125x75
+          text run at (4,4) width 125: "This   text     "
</ins><span class="cx">           text run at (4,19) width 71: "will wrap"
</span><span class="cx">           text run at (74,19) width 1: " "
</span><span class="cx">           text run at (4,34) width 94: "and   fit   "
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmachttptestsmiscacid3expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/http/tests/misc/acid3-expected.txt (287452 => 287453)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/http/tests/misc/acid3-expected.txt        2021-12-27 00:46:40 UTC (rev 287452)
+++ trunk/LayoutTests/platform/mac/http/tests/misc/acid3-expected.txt   2021-12-27 06:43:31 UTC (rev 287453)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx">                       text run at (0,90) width 8: "Y"
</span><span class="cx">                       text run at (0,105) width 8: "P"
</span><span class="cx">                       text run at (0,120) width 8: "E"
</span><del>-                      text run at (0,135) width 0: " "
</del><ins>+                      text run at (0,135) width 8: " "
</ins><span class="cx">                       text run at (0,150) width 8: "h"
</span><span class="cx">                       text run at (0,165) width 8: "t"
</span><span class="cx">                       text run at (0,180) width 8: "m"
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (287452 => 287453)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-12-27 00:46:40 UTC (rev 287452)
+++ trunk/Source/WebCore/ChangeLog      2021-12-27 06:43:31 UTC (rev 287453)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2021-12-26  Alan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Do not trim the hanging trailing content
+        https://bugs.webkit.org/show_bug.cgi?id=234679
+
+        Reviewed by Antti Koivisto.
+
+        This is the final step of making the hanging content handling inline with the spec.
+        (https://www.w3.org/TR/css-text-3/#hang)
+        Since we don't (fake)trim such content when closing the line, the content width matches
+        the actual content on the line which also helps when it is aligned to support RTL ordering.
+
+        * layout/formattingContexts/inline/InlineLine.cpp:
+        (WebCore::Layout::Line::Run::removeTrailingWhitespace):
+        (WebCore::Layout::Line::visuallyCollapseHangingOverflowingGlyphs): Deleted.
+        (WebCore::Layout::Line::Run::visuallyCollapseTrailingWhitespace): Deleted.
+        * layout/formattingContexts/inline/InlineLine.h:
+        * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
+        (WebCore::Layout::horizontalAlignmentOffset):
+        * layout/formattingContexts/inline/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::close):
+
</ins><span class="cx"> 2021-12-26  Tim Nguyen  <ntim@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Make -webkit-text-combine an inherited property
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineLinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp (287452 => 287453)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp     2021-12-27 00:46:40 UTC (rev 287452)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp        2021-12-27 06:43:31 UTC (rev 287453)
</span><span class="lines">@@ -200,44 +200,6 @@
</span><span class="cx">     m_hangingTrailingContent.reset();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Line::visuallyCollapseHangingOverflowingGlyphs(InlineLayoutUnit horizontalAvailableSpace)
-{
-    ASSERT(m_trimmableTrailingContent.isEmpty());
-    // If white-space is set to pre-wrap, the UA must
-    // ...
-    // It may also visually collapse the character advance widths of any that would otherwise overflow.
-    auto overflowWidth = contentLogicalWidth() - horizontalAvailableSpace;
-    if (overflowWidth <= 0)
-        return;
-    // Let's just find the trailing pre-wrap whitespace content for now (e.g check if there are multiple trailing runs with
-    // different set of white-space values and decide if the in-between pre-wrap content should be collapsed as well.)
-    auto trimmedContentWidth = InlineLayoutUnit { };
-    for (auto& run : makeReversedRange(m_runs)) {
-        if (!run.shouldTrailingWhitespaceHang())
-            break;
-        auto visuallyCollapsibleInlineItem = run.isLineSpanningInlineBoxStart() || run.isInlineBoxStart() || run.isInlineBoxEnd() || run.hasTrailingWhitespace();
-        if (!visuallyCollapsibleInlineItem)
-            break;
-        ASSERT(!run.hasCollapsibleTrailingWhitespace());
-        auto trimmableWidth = InlineLayoutUnit { };
-        if (run.isText()) {
-            // FIXME: We should always collapse the run at a glyph boundary as the spec indicates: "collapse the character advance widths of any that would otherwise overflow"
-            // and the trimmed width should be capped at std::min(run.trailingWhitespaceWidth(), overflowWidth) for text runs. Both FF and Chrome agree.
-            trimmableWidth = run.visuallyCollapseTrailingWhitespace(overflowWidth);
-        } else {
-            trimmableWidth = run.logicalWidth();
-            run.shrinkHorizontally(trimmableWidth);
-        }
-        trimmedContentWidth += trimmableWidth;
-        overflowWidth -= trimmableWidth;
-        if (overflowWidth <= 0)
-            break;
-    }
-    // FIXME: Add support for incremental reset, where the hanging whitespace partially overflows.
-    m_hangingTrailingContent.reset();
-    m_contentLogicalWidth -= trimmedContentWidth;
-}
-
</del><span class="cx"> void Line::append(const InlineItem& inlineItem, const RenderStyle& style, InlineLayoutUnit logicalWidth)
</span><span class="cx"> {
</span><span class="cx">     if (inlineItem.isText())
</span><span class="lines">@@ -667,24 +629,12 @@
</span><span class="cx">     ASSERT(m_textContent->length);
</span><span class="cx">     constexpr size_t trailingTrimmableContentLength = 1;
</span><span class="cx">     m_textContent->length -= trailingTrimmableContentLength;
</span><del>-    visuallyCollapseTrailingWhitespace(m_trailingWhitespaceWidth);
</del><ins>+    shrinkHorizontally(m_trailingWhitespaceWidth);
+    m_trailingWhitespaceWidth = { };
+    m_trailingWhitespaceType = TrailingWhitespace::None;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-InlineLayoutUnit Line::Run::visuallyCollapseTrailingWhitespace(InlineLayoutUnit tryCollapsingThisMuchSpace)
-{
-    ASSERT(hasTrailingWhitespace());
-    // This is just a visual adjustment, the text length should remain the same.
-    auto trimmedWidth = std::min(tryCollapsingThisMuchSpace, m_trailingWhitespaceWidth);
-    shrinkHorizontally(trimmedWidth);
-    m_trailingWhitespaceWidth -= trimmedWidth;
-    if (!m_trailingWhitespaceWidth) {
-        // We trimmed the trailing whitespace completely.
-        m_trailingWhitespaceType = TrailingWhitespace::None;
-    }
-    return trimmedWidth;
</del><span class="cx"> }
</span><del>-
</del><span class="cx"> }
</span><del>-}
</del><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineLineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h (287452 => 287453)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h       2021-12-27 00:46:40 UTC (rev 287452)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h  2021-12-27 06:43:31 UTC (rev 287453)
</span><span class="lines">@@ -66,7 +66,6 @@
</span><span class="cx">     enum class ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk { No, Yes };
</span><span class="cx">     void removeTrailingTrimmableContent(ShouldApplyTrailingWhiteSpaceFollowedByBRQuirk);
</span><span class="cx">     void removeHangingGlyphs();
</span><del>-    void visuallyCollapseHangingOverflowingGlyphs(InlineLayoutUnit horizontalAvailableSpace);
</del><span class="cx">     void applyRunExpansion(InlineLayoutUnit horizontalAvailableSpace);
</span><span class="cx"> 
</span><span class="cx">     struct Run {
</span><span class="lines">@@ -140,7 +139,6 @@
</span><span class="cx">         bool hasCollapsedTrailingWhitespace() const { return m_trailingWhitespaceType == TrailingWhitespace::Collapsed; }
</span><span class="cx">         TrailingWhitespace trailingWhitespaceType(const InlineTextItem&) const;
</span><span class="cx">         void removeTrailingWhitespace();
</span><del>-        InlineLayoutUnit visuallyCollapseTrailingWhitespace(InlineLayoutUnit tryCollapsingThisMuchSpace);
</del><span class="cx"> 
</span><span class="cx">         bool hasTrailingLetterSpacing() const;
</span><span class="cx">         InlineLayoutUnit trailingLetterSpacing() const;
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineLineBoxBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp (287452 => 287453)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp   2021-12-27 00:46:40 UTC (rev 287452)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp      2021-12-27 06:43:31 UTC (rev 287453)
</span><span class="lines">@@ -48,10 +48,10 @@
</span><span class="cx">         // Note that end of last line in a paragraph is considered a forced break.
</span><span class="cx">         auto isConditionalHanging = runs.last().isLineBreak() || lineContent.isLastLineWithInlineContent;
</span><span class="cx">         // In some cases, a glyph at the end of a line can conditionally hang: it hangs only if it does not otherwise fit in the line prior to justification.
</span><del>-        // FIXME: Only the overflowing glyphs should be considered for hanging.
-        if (isConditionalHanging)
</del><ins>+        if (isConditionalHanging) {
+            // FIXME: Conditional hanging needs partial overflow trimming at glyph boundary, one by one until they fit.
</ins><span class="cx">             contentLogicalWidth = std::min(contentLogicalWidth, lineContent.lineLogicalWidth);
</span><del>-        else
</del><ins>+        } else
</ins><span class="cx">             contentLogicalWidth -= lineContent.hangingWhitespaceWidth;
</span><span class="cx">     }
</span><span class="cx">     auto extraHorizontalSpace = lineContent.lineLogicalWidth - contentLogicalWidth;
</span><span class="lines">@@ -107,8 +107,9 @@
</span><span class="cx"> {
</span><span class="cx">     auto& rootStyle = lineIndex ? rootBox().firstLineStyle() : rootBox().style();
</span><span class="cx">     auto rootInlineBoxAlignmentOffset = Layout::horizontalAlignmentOffset(rootStyle.textAlign(), lineContent, rootStyle.isLeftToRightDirection()).value_or(InlineLayoutUnit { });
</span><del>-    auto lineBox = LineBox { rootBox(), rootInlineBoxAlignmentOffset, lineContent.contentLogicalWidth, lineIndex, lineContent.nonSpanningInlineLevelBoxCount };
-    auto lineBoxLogicalHeight = constructAndAlignInlineLevelBoxes(lineBox, lineContent.runs, lineIndex);
</del><ins>+    // FIXME: The overflowing hanging content should be part of the ink overflow.  
+    auto lineBox = LineBox { rootBox(), rootInlineBoxAlignmentOffset, lineContent.contentLogicalWidth - lineContent.hangingWhitespaceWidth, lineIndex, lineContent.nonSpanningInlineLevelBoxCount };
+    auto lineBoxLogicalHeight = constructAndAlignInlineLevelBoxes(lineBox, lineContent, lineIndex);
</ins><span class="cx">     return { lineBox, lineBoxLogicalHeight };
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -203,7 +204,7 @@
</span><span class="cx">     inlineBox.setLayoutBounds({ floorf(heightAndLayoutBounds.layoutBounds.ascent), ceilf(heightAndLayoutBounds.layoutBounds.descent) });
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-InlineLayoutUnit LineBoxBuilder::constructAndAlignInlineLevelBoxes(LineBox& lineBox, const Line::RunList& runs, size_t lineIndex)
</del><ins>+InlineLayoutUnit LineBoxBuilder::constructAndAlignInlineLevelBoxes(LineBox& lineBox, const LineBuilder::LineContent& lineContent, size_t lineIndex)
</ins><span class="cx"> {
</span><span class="cx">     auto& rootInlineBox = lineBox.rootInlineBox();
</span><span class="cx">     setInitialVerticalGeometryForInlineBox(rootInlineBox);
</span><span class="lines">@@ -222,7 +223,7 @@
</span><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     auto lineHasContent = false;
</span><del>-    for (auto& run : runs) {
</del><ins>+    for (auto& run : lineContent.runs) {
</ins><span class="cx">         auto& layoutBox = run.layoutBox();
</span><span class="cx">         auto& style = styleToUse(layoutBox);
</span><span class="cx">         auto runHasContent = [&] () -> bool {
</span><span class="lines">@@ -296,7 +297,8 @@
</span><span class="cx">             // Inline box run is based on margin box. Let's convert it to border box.
</span><span class="cx">             auto marginStart = formattingContext().geometryForBox(layoutBox).marginStart();
</span><span class="cx">             auto initialLogicalWidth = rootInlineBox.logicalWidth() - (run.logicalLeft() + marginStart);
</span><del>-            ASSERT(initialLogicalWidth >= 0);
</del><ins>+            ASSERT(initialLogicalWidth >= 0 || lineContent.hangingWhitespaceWidth);
+            initialLogicalWidth = std::max(initialLogicalWidth, 0.f);
</ins><span class="cx">             auto inlineBox = InlineLevelBox::createInlineBox(layoutBox, style, logicalLeft + marginStart, initialLogicalWidth);
</span><span class="cx">             inlineBox.setIsFirstBox();
</span><span class="cx">             setInitialVerticalGeometryForInlineBox(inlineBox);
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineLineBoxBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h (287452 => 287453)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h     2021-12-27 00:46:40 UTC (rev 287452)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.h        2021-12-27 06:43:31 UTC (rev 287453)
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx">     void setInitialVerticalGeometryForInlineBox(InlineLevelBox&) const;
</span><span class="cx">     void setVerticalGeometryForLineBreakBox(InlineLevelBox& lineBreakBox, const InlineLevelBox& parentInlineBox) const;
</span><span class="cx">     void adjustVerticalGeometryForInlineBoxWithFallbackFonts(InlineLevelBox&, const TextUtil::FallbackFontList&) const;
</span><del>-    InlineLayoutUnit constructAndAlignInlineLevelBoxes(LineBox&, const Line::RunList&, size_t lineIndex);
</del><ins>+    InlineLayoutUnit constructAndAlignInlineLevelBoxes(LineBox&, const LineBuilder::LineContent&, size_t lineIndex);
</ins><span class="cx"> 
</span><span class="cx">     const InlineFormattingContext& formattingContext() const { return m_inlineFormattingContext; }
</span><span class="cx">     const Box& rootBox() const { return formattingContext().root(); }
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineLineBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (287452 => 287453)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp      2021-12-27 00:46:40 UTC (rev 287452)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp 2021-12-27 06:43:31 UTC (rev 287453)
</span><span class="lines">@@ -520,9 +520,7 @@
</span><span class="cx">             if (!isConditionalHanging)
</span><span class="cx">                 m_line.removeHangingGlyphs();
</span><span class="cx">         }
</span><del>-    } else
-        m_line.visuallyCollapseHangingOverflowingGlyphs(horizontalAvailableSpace);
-
</del><ins>+    }
</ins><span class="cx">     auto horizontalAlignment = root().style().textAlign();
</span><span class="cx">     auto runsExpandHorizontally = horizontalAlignment == TextAlignMode::Justify && !isLastLine;
</span><span class="cx">     if (runsExpandHorizontally)
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlinedisplayInlineDisplayLineBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp (287452 => 287453)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp       2021-12-27 00:46:40 UTC (rev 287452)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLineBuilder.cpp  2021-12-27 06:43:31 UTC (rev 287453)
</span><span class="lines">@@ -86,7 +86,7 @@
</span><span class="cx">         : InlineLayoutUnit { rootGeometry.borderEnd() } + rootGeometry.paddingEnd().value_or(0_lu);
</span><span class="cx">     auto contentVisualLeft = isLeftToRightDirection
</span><span class="cx">         ? lineBox.rootInlineBoxAlignmentOffset()
</span><del>-        : rootGeometry.contentBoxWidth() - lineOffsetFromContentBox -  lineBox.rootInlineBoxAlignmentOffset() - rootInlineBox.logicalWidth();
</del><ins>+        : rootGeometry.contentBoxWidth() - lineOffsetFromContentBox -  lineBox.rootInlineBoxAlignmentOffset() - rootInlineBox.logicalWidth() - lineContent.hangingWhitespaceWidth;
</ins><span class="cx"> 
</span><span class="cx">     auto lineBoxRect = InlineRect { lineContent.lineLogicalTopLeft.y(), lineBoxVisualLeft, lineContent.lineLogicalWidth, lineBoxLogicalHeight };
</span><span class="cx">     auto enclosingLineGeometry = collectEnclosingLineGeometry(lineBox, lineBoxRect);
</span></span></pre>
</div>
</div>

</body>
</html>