<!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>[284090] 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/284090">284090</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2021-10-13 06:24:16 -0700 (Wed, 13 Oct 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[LFC][IFC] Do not break at the inline box boundary when wrapping is not allowed
https://bugs.webkit.org/show_bug.cgi?id=231581

Reviewed by Antti Koivisto.

Source/WebCore:

This patch ensures that we don't consider whitespace characters as soft wrap opportunities when wrapping is not allowed.

Test: fast/inline/no-soft-wrap-opportunity-at-inline-box.html

* layout/formattingContexts/inline/InlineContentBreaker.cpp:
(WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
(WebCore::Layout::isWrappableRun):
(WebCore::Layout::InlineContentBreaker::isWrappingAllowed): Deleted.
* layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::isAtSoftWrapOpportunity):
(WebCore::Layout::LineBuilder::handleInlineContent):
* layout/formattingContexts/inline/text/TextUtil.cpp:
(WebCore::Layout::TextUtil::isWrappingAllowed):
* layout/formattingContexts/inline/text/TextUtil.h:

LayoutTests:

* fast/inline/no-soft-wrap-opportunity-at-inline-box-expected.html: Added.
* fast/inline/no-soft-wrap-opportunity-at-inline-box.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineContentBreakercpp">trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineLineBuildercpp">trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlinetextTextUtilcpp">trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlinetextTextUtilh">trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastinlinenosoftwrapopportunityatinlineboxexpectedhtml">trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastinlinenosoftwrapopportunityatinlineboxhtml">trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (284089 => 284090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/LayoutTests/ChangeLog 2021-10-13 13:24:16 UTC (rev 284090)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2021-10-13  Alan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Do not break at the inline box boundary when wrapping is not allowed
+        https://bugs.webkit.org/show_bug.cgi?id=231581
+
+        Reviewed by Antti Koivisto.
+
+        * fast/inline/no-soft-wrap-opportunity-at-inline-box-expected.html: Added.
+        * fast/inline/no-soft-wrap-opportunity-at-inline-box.html: Added.
+
</ins><span class="cx"> 2021-10-13  Alicia Boya GarcĂ­a  <aboya@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, reverting r283609
</span></span></pre></div>
<a id="trunkLayoutTestsfastinlinenosoftwrapopportunityatinlineboxexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box-expected.html (0 => 284090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box-expected.html                               (rev 0)
+++ trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box-expected.html  2021-10-13 13:24:16 UTC (rev 284090)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+<div>should not wrap</div>
+<div>should not wrap</div>
+<div>should not wrap</div>
+<div>should not wrap</div>
+<div>should not wrap</div>
+<div>should not wrap</div>
</ins></span></pre></div>
<a id="trunkLayoutTestsfastinlinenosoftwrapopportunityatinlineboxhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box.html (0 => 284090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box.html                                (rev 0)
+++ trunk/LayoutTests/fast/inline/no-soft-wrap-opportunity-at-inline-box.html   2021-10-13 13:24:16 UTC (rev 284090)
</span><span class="lines">@@ -0,0 +1,12 @@
</span><ins>+<style>
+div {
+  width: 0px;
+}
+</style>
+<!-- While the whitespace character normally indicates soft wrap opportunities, pre/nowrap white-space property values disable them -->
+<div><span style="white-space: pre">should not </span>wrap</div>
+<div><span style="white-space: nowrap">should not </span>wrap</div>
+<div><span style="white-space: pre">should not </span><span style="white-space: normal">wrap</span></div>
+<div><span style="white-space: nowrap">should not </span><span style="white-space: normal">wrap</span></div>
+<div>should<span style="white-space: pre"> not </span>wrap</div>
+<div>should<span style="white-space: nowrap"> not </span>wrap</div>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (284089 => 284090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/Source/WebCore/ChangeLog      2021-10-13 13:24:16 UTC (rev 284090)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2021-10-13  Alan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Do not break at the inline box boundary when wrapping is not allowed
+        https://bugs.webkit.org/show_bug.cgi?id=231581
+
+        Reviewed by Antti Koivisto.
+
+        This patch ensures that we don't consider whitespace characters as soft wrap opportunities when wrapping is not allowed.
+
+        Test: fast/inline/no-soft-wrap-opportunity-at-inline-box.html
+
+        * layout/formattingContexts/inline/InlineContentBreaker.cpp:
+        (WebCore::Layout::InlineContentBreaker::processOverflowingContent const):
+        (WebCore::Layout::isWrappableRun):
+        (WebCore::Layout::InlineContentBreaker::isWrappingAllowed): Deleted.
+        * layout/formattingContexts/inline/InlineLineBuilder.cpp:
+        (WebCore::Layout::isAtSoftWrapOpportunity):
+        (WebCore::Layout::LineBuilder::handleInlineContent):
+        * layout/formattingContexts/inline/text/TextUtil.cpp:
+        (WebCore::Layout::TextUtil::isWrappingAllowed):
+        * layout/formattingContexts/inline/text/TextUtil.h:
+
</ins><span class="cx"> 2021-10-13  Philippe Normand  <pnormand@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, THUNDER build fix
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineContentBreakercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp (284089 => 284090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp   2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp      2021-10-13 13:24:16 UTC (rev 284090)
</span><span class="lines">@@ -130,12 +130,6 @@
</span><span class="cx">     return { };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool InlineContentBreaker::isWrappingAllowed(const ContinuousContent::Run& run)
-{
-    // Do not try to wrap overflown 'pre' and 'no-wrap' content to next line.
-    return run.style.whiteSpace() != WhiteSpace::Pre && run.style.whiteSpace() != WhiteSpace::NoWrap;
-}
-
</del><span class="cx"> bool InlineContentBreaker::shouldKeepEndOfLineWhitespace(const ContinuousContent& continuousContent) const
</span><span class="cx"> {
</span><span class="cx">     // Grab the style and check for white-space property to decide whether we should let this whitespace content overflow the current line.
</span><span class="lines">@@ -269,7 +263,7 @@
</span><span class="cx">         // Parent style drives the wrapping behavior here.
</span><span class="cx">         // e.g. <div style="white-space: nowrap">some text<div style="display: inline-block; white-space: pre-wrap"></div></div>.
</span><span class="cx">         // While the inline-block has pre-wrap which allows wrapping, the content lives in a nowrap context.
</span><del>-        return isWrappingAllowed(continuousContent.runs()[overflowingRunIndex]);
</del><ins>+        return TextUtil::isWrappingAllowed(continuousContent.runs()[overflowingRunIndex].style);
</ins><span class="cx">     };
</span><span class="cx">     if (shouldWrapUnbreakableContentToNextLine())
</span><span class="cx">         return { Result::Action::Wrap, IsEndOfLine::Yes };
</span><span class="lines">@@ -300,7 +294,7 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx">     // Check if this text run needs to stay on the current line.
</span><del>-    return InlineContentBreaker::isWrappingAllowed(run);
</del><ins>+    return TextUtil::isWrappingAllowed(run.style);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> std::optional<InlineContentBreaker::OverflowingTextContent::BreakingPosition> InlineContentBreaker::tryBreakingOverflowingRun(const LineStatus& lineStatus, const ContinuousContent::RunList& runs, size_t overflowingRunIndex, InlineLayoutUnit nonOverflowingContentWidth) const
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineLineBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (284089 => 284090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp      2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp 2021-10-13 13:24:16 UTC (rev 284090)
</span><span class="lines">@@ -77,6 +77,7 @@
</span><span class="cx"> 
</span><span class="cx"> static inline bool isAtSoftWrapOpportunity(const InlineFormattingContext& inlineFormattingContext, const InlineItem& current, const InlineItem& next)
</span><span class="cx"> {
</span><ins>+    // FIXME: Transition no-wrapping logic from InlineContentBreaker to here where we compute the soft wrap opportunity indexes.
</ins><span class="cx">     // "is at" simple means that there's a soft wrap opportunity right after the [current].
</span><span class="cx">     // [text][ ][text][inline box start]... (<div>text content<span>..</div>)
</span><span class="cx">     // soft wrap indexes: 0 and 1 definitely, 2 depends on the content after the [inline box start].
</span><span class="lines">@@ -93,12 +94,12 @@
</span><span class="cx">         auto& nextInlineTextItem = downcast<InlineTextItem>(next);
</span><span class="cx">         if (currentInlineTextItem.isWhitespace()) {
</span><span class="cx">             // [ ][text] : after [whitespace] position is a soft wrap opportunity.
</span><del>-            return true;
</del><ins>+            return TextUtil::isWrappingAllowed(currentInlineTextItem.style());
</ins><span class="cx">         }
</span><span class="cx">         if (nextInlineTextItem.isWhitespace()) {
</span><span class="cx">             // [text][ ] (<span>text</span> )
</span><span class="cx">             // white-space: break-spaces: line breaking opportunity exists after every preserved white space character, but not before.
</span><del>-            return nextInlineTextItem.style().whiteSpace() != WhiteSpace::BreakSpaces;
</del><ins>+            return TextUtil::isWrappingAllowed(nextInlineTextItem.style()) && nextInlineTextItem.style().whiteSpace() != WhiteSpace::BreakSpaces;
</ins><span class="cx">         }
</span><span class="cx">         if (current.style().lineBreak() == LineBreak::Anywhere || next.style().lineBreak() == LineBreak::Anywhere) {
</span><span class="cx">             // There is a soft wrap opportunity around every typographic character unit, including around any punctuation character
</span><span class="lines">@@ -711,7 +712,7 @@
</span><span class="cx">             auto& trailingRun = candidateRuns.last();
</span><span class="cx">             // FIXME: There must be a way to decide if the trailing run actually ended up on the line.
</span><span class="cx">             // Let's just deal with collapsed leading whitespace for now.
</span><del>-            if (!m_line.runs().isEmpty() && InlineContentBreaker::isWrappingAllowed(trailingRun))
</del><ins>+            if (!m_line.runs().isEmpty() && TextUtil::isWrappingAllowed(trailingRun.style))
</ins><span class="cx">                 m_wrapOpportunityList.append(&trailingRun.inlineItem);
</span><span class="cx">         }
</span><span class="cx">         return { result.isEndOfLine, { candidateRuns.size(), false } };
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlinetextTextUtilcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp (284089 => 284090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp  2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp     2021-10-13 13:24:16 UTC (rev 284090)
</span><span class="lines">@@ -222,6 +222,12 @@
</span><span class="cx">     return whitespace == WhiteSpace::Pre || whitespace == WhiteSpace::PreWrap || whitespace == WhiteSpace::BreakSpaces || whitespace == WhiteSpace::PreLine; 
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool TextUtil::isWrappingAllowed(const RenderStyle& style)
+{
+    // Do not try to wrap overflown 'pre' and 'no-wrap' content to next line.
+    return style.whiteSpace() != WhiteSpace::Pre && style.whiteSpace() != WhiteSpace::NoWrap;
+}
+
</ins><span class="cx"> LineBreakIteratorMode TextUtil::lineBreakIteratorMode(LineBreak lineBreak)
</span><span class="cx"> {
</span><span class="cx">     switch (lineBreak) {
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlinetextTextUtilh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.h (284089 => 284090)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.h    2021-10-13 11:21:47 UTC (rev 284089)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.h       2021-10-13 13:24:16 UTC (rev 284090)
</span><span class="lines">@@ -64,6 +64,7 @@
</span><span class="cx">     static bool shouldPreserveSpacesAndTabs(const Box&);
</span><span class="cx">     static bool shouldPreserveNewline(const Box&);
</span><span class="cx">     static bool canUseSimplifiedTextMeasuringForFirstLine(const RenderStyle&, const RenderStyle& firstLineStyle);
</span><ins>+    static bool isWrappingAllowed(const RenderStyle&);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>