<!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>[281754] trunk/Source/WebCore</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/281754">281754</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2021-08-30 07:12:45 -0700 (Mon, 30 Aug 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[LFC][IFC] Introduce Line::Run::Text to hold text content related properties
https://bugs.webkit.org/show_bug.cgi?id=229658

Reviewed by Antti Koivisto.

Let's use a dedicated (and more compact) structure here instead of relying on a display type of structure.
This is in preparation for merging the display and the integration runs.

* layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::createRunsAndUpdateGeometryForLineContent):
* layout/formattingContexts/inline/InlineLine.cpp:
(WebCore::Layout::Line::applyRunExpansion):
(WebCore::Layout::Line::TrimmableTrailingContent::remove):
(WebCore::Layout::Line::Run::Run):
(WebCore::Layout::m_textContent):
(WebCore::Layout::Line::Run::expand):
(WebCore::Layout::Line::Run::removeTrailingWhitespace):
* layout/formattingContexts/inline/InlineLine.h:
(WebCore::Layout::Line::Run::textContent const):
(WebCore::Layout::Line::Run::setNeedsHyphen):
* layout/formattingContexts/inline/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::close):
* layout/formattingContexts/inline/InlineLineRun.h:
(WebCore::Layout::LineRun::Text::needsHyphen const):
(WebCore::Layout::LineRun::Text::Text):
(WebCore::Layout::LineRun::Text::setNeedsHyphen): Deleted.
(WebCore::Layout::LineRun::Text::expand): Deleted.
(WebCore::Layout::LineRun::Text::shrink): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineDisplayContentBuildercpp">trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp</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="#trunkSourceWebCorelayoutformattingContextsinlineInlineLineBuildercpp">trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineLineRunh">trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineRun.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (281753 => 281754)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-08-30 09:26:45 UTC (rev 281753)
+++ trunk/Source/WebCore/ChangeLog      2021-08-30 14:12:45 UTC (rev 281754)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2021-08-30  Alan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Introduce Line::Run::Text to hold text content related properties
+        https://bugs.webkit.org/show_bug.cgi?id=229658
+
+        Reviewed by Antti Koivisto.
+
+        Let's use a dedicated (and more compact) structure here instead of relying on a display type of structure.
+        This is in preparation for merging the display and the integration runs.
+
+        * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
+        (WebCore::Layout::InlineDisplayContentBuilder::createRunsAndUpdateGeometryForLineContent):
+        * layout/formattingContexts/inline/InlineLine.cpp:
+        (WebCore::Layout::Line::applyRunExpansion):
+        (WebCore::Layout::Line::TrimmableTrailingContent::remove):
+        (WebCore::Layout::Line::Run::Run):
+        (WebCore::Layout::m_textContent):
+        (WebCore::Layout::Line::Run::expand):
+        (WebCore::Layout::Line::Run::removeTrailingWhitespace):
+        * layout/formattingContexts/inline/InlineLine.h:
+        (WebCore::Layout::Line::Run::textContent const):
+        (WebCore::Layout::Line::Run::setNeedsHyphen):
+        * layout/formattingContexts/inline/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::close):
+        * layout/formattingContexts/inline/InlineLineRun.h:
+        (WebCore::Layout::LineRun::Text::needsHyphen const):
+        (WebCore::Layout::LineRun::Text::Text):
+        (WebCore::Layout::LineRun::Text::setNeedsHyphen): Deleted.
+        (WebCore::Layout::LineRun::Text::expand): Deleted.
+        (WebCore::Layout::LineRun::Text::shrink): Deleted.
+
</ins><span class="cx"> 2021-08-29  Alan Bujtas  <zalan@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [LFC][IFC] Move "line needs integral snapping" computing to IFC from the integration layer
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineDisplayContentBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (281753 => 281754)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp    2021-08-30 09:26:45 UTC (rev 281753)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp       2021-08-30 14:12:45 UTC (rev 281754)
</span><span class="lines">@@ -88,13 +88,18 @@
</span><span class="cx">                 }
</span><span class="cx">                 return inkOverflow;
</span><span class="cx">             };
</span><del>-            formattingState.addLineRun({ lineIndex, LineRun::Type::Text, layoutBox, textRunRect, inkOverflow(), lineRun.expansion(), lineRun.textContent() });
</del><ins>+            ASSERT(lineRun.textContent() && is<InlineTextBox>(layoutBox));
+            auto& textContent = lineRun.textContent();
+            formattingState.addLineRun({ lineIndex, LineRun::Type::Text, layoutBox, textRunRect, inkOverflow(), lineRun.expansion(), LineRun::Text { textContent->start, textContent->length, downcast<InlineTextBox>(layoutBox).content(), textContent->needsHyphen } });
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case InlineItem::Type::SoftLineBreak: {
</span><span class="cx">             auto softLineBreakRunRect = lineBox.logicalRectForTextRun(lineRun);
</span><span class="cx">             softLineBreakRunRect.moveBy(lineBoxLogicalTopLeft);
</span><del>-            formattingState.addLineRun({ lineIndex, LineRun::Type::SoftLineBreak, layoutBox, softLineBreakRunRect, softLineBreakRunRect, lineRun.expansion(), lineRun.textContent() });
</del><ins>+
+            ASSERT(lineRun.textContent() && is<InlineTextBox>(layoutBox));
+            auto& textContent = lineRun.textContent();
+            formattingState.addLineRun({ lineIndex, LineRun::Type::SoftLineBreak, layoutBox, softLineBreakRunRect, softLineBreakRunRect, lineRun.expansion(), LineRun::Text { textContent->start, textContent->length, downcast<InlineTextBox>(layoutBox).content(), textContent->needsHyphen } });
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         case InlineItem::Type::HardLineBreak: {
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineLinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp (281753 => 281754)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp     2021-08-30 09:26:45 UTC (rev 281753)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.cpp        2021-08-30 14:12:45 UTC (rev 281754)
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx">                 expansionBehavior = ForbidLeftExpansion | ForbidRightExpansion;
</span><span class="cx">             else {
</span><span class="cx">                 expansionBehavior = (runIsAfterExpansion ? ForbidLeftExpansion : AllowLeftExpansion) | AllowRightExpansion;
</span><del>-                std::tie(expansionOpportunitiesInRun, runIsAfterExpansion) = FontCascade::expansionOpportunityCount(StringView(run.textContent()->content()).substring(run.textContent()->start(), run.textContent()->length()), run.style().direction(), expansionBehavior);
</del><ins>+                std::tie(expansionOpportunitiesInRun, runIsAfterExpansion) = FontCascade::expansionOpportunityCount(StringView(downcast<InlineTextBox>(run.layoutBox()).content()).substring(run.textContent()->start, run.textContent()->length), run.style().direction(), expansionBehavior);
</ins><span class="cx">             }
</span><span class="cx">         } else if (run.isBox())
</span><span class="cx">             runIsAfterExpansion = false;
</span><span class="lines">@@ -428,7 +428,7 @@
</span><span class="cx">         ASSERT(run.isWordBreakOpportunity() || run.isInlineBoxStart() || run.isInlineBoxEnd() || run.isLineBreak());
</span><span class="cx">         run.moveHorizontally(-trimmableWidth);
</span><span class="cx">     }
</span><del>-    if (!trimmableRun.textContent()->length()) {
</del><ins>+    if (!trimmableRun.textContent()->length) {
</ins><span class="cx">         // This trimmable run is fully collapsed now (e.g. <div><img>    <span></span></div>).
</span><span class="cx">         // We don't need to keep it around anymore.
</span><span class="cx">         m_runs.remove(*m_firstTrimmableRunIndex);
</span><span class="lines">@@ -457,7 +457,7 @@
</span><span class="cx">     : m_type(softLineBreakItem.type())
</span><span class="cx">     , m_layoutBox(&softLineBreakItem.layoutBox())
</span><span class="cx">     , m_logicalLeft(logicalLeft)
</span><del>-    , m_textContent({ softLineBreakItem.position(), 1, softLineBreakItem.inlineTextBox().content() })
</del><ins>+    , m_textContent({ softLineBreakItem.position(), 1 })
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -468,7 +468,7 @@
</span><span class="cx">     , m_logicalWidth(logicalWidth)
</span><span class="cx">     , m_trailingWhitespaceType(trailingWhitespaceType(inlineTextItem))
</span><span class="cx">     , m_trailingWhitespaceWidth(m_trailingWhitespaceType != TrailingWhitespace::None ? logicalWidth : InlineLayoutUnit { })
</span><del>-    , m_textContent({ inlineTextItem.start(), m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length(), inlineTextItem.inlineTextBox().content() })
</del><ins>+    , m_textContent({ inlineTextItem.start(), m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length() })
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -483,11 +483,11 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_trailingWhitespaceType == TrailingWhitespace::None) {
</span><span class="cx">         m_trailingWhitespaceWidth = { };
</span><del>-        m_textContent->expand(inlineTextItem.length());
</del><ins>+        m_textContent->length += inlineTextItem.length();
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     m_trailingWhitespaceWidth += logicalWidth;
</span><del>-    m_textContent->expand(m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length());
</del><ins>+    m_textContent->length += m_trailingWhitespaceType == TrailingWhitespace::Collapsed ? 1 : inlineTextItem.length();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool Line::Run::hasTrailingLetterSpacing() const
</span><span class="lines">@@ -513,9 +513,9 @@
</span><span class="cx"> {
</span><span class="cx">     // According to https://www.w3.org/TR/css-text-3/#white-space-property matrix
</span><span class="cx">     // Trimmable whitespace is always collapsible so the length of the trailing trimmable whitespace is always 1 (or non-existent).
</span><del>-    ASSERT(m_textContent->length());
</del><ins>+    ASSERT(m_textContent->length);
</ins><span class="cx">     constexpr size_t trailingTrimmableContentLength = 1;
</span><del>-    m_textContent->shrink(trailingTrimmableContentLength);
</del><ins>+    m_textContent->length -= trailingTrimmableContentLength;
</ins><span class="cx">     visuallyCollapseTrailingWhitespace(m_trailingWhitespaceWidth);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineLineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h (281753 => 281754)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h       2021-08-30 09:26:45 UTC (rev 281753)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLine.h  2021-08-30 14:12:45 UTC (rev 281754)
</span><span class="lines">@@ -72,7 +72,12 @@
</span><span class="cx"> 
</span><span class="cx">         const Box& layoutBox() const { return *m_layoutBox; }
</span><span class="cx">         const RenderStyle& style() const { return m_layoutBox->style(); }
</span><del>-        const std::optional<LineRun::Text>& textContent() const { return m_textContent; }
</del><ins>+        struct Text {
+            size_t start { 0 };
+            size_t length { 0 };
+            bool needsHyphen { false };
+        };
+        const std::optional<Text>& textContent() const { return m_textContent; }
</ins><span class="cx"> 
</span><span class="cx">         InlineLayoutUnit logicalWidth() const { return m_logicalWidth; }
</span><span class="cx">         InlineLayoutUnit logicalLeft() const { return m_logicalLeft; }
</span><span class="lines">@@ -118,7 +123,7 @@
</span><span class="cx">         InlineLayoutUnit m_logicalWidth { 0 };
</span><span class="cx">         TrailingWhitespace m_trailingWhitespaceType { TrailingWhitespace::None };
</span><span class="cx">         InlineLayoutUnit m_trailingWhitespaceWidth { 0 };
</span><del>-        std::optional<LineRun::Text> m_textContent;
</del><ins>+        std::optional<Text> m_textContent;
</ins><span class="cx">         LineRun::Expansion m_expansion;
</span><span class="cx">     };
</span><span class="cx">     using RunList = Vector<Run, 10>;
</span><span class="lines">@@ -192,7 +197,7 @@
</span><span class="cx"> inline void Line::Run::setNeedsHyphen(InlineLayoutUnit hyphenLogicalWidth)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_textContent);
</span><del>-    m_textContent->setNeedsHyphen();
</del><ins>+    m_textContent->needsHyphen = true;
</ins><span class="cx">     m_logicalWidth += hyphenLogicalWidth;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineLineBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp (281753 => 281754)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp      2021-08-30 09:26:45 UTC (rev 281753)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBuilder.cpp 2021-08-30 14:12:45 UTC (rev 281754)
</span><span class="lines">@@ -375,7 +375,7 @@
</span><span class="cx">     auto lineEndsWithHyphen = false;
</span><span class="cx">     if (!m_line.runs().isEmpty()) {
</span><span class="cx">         auto& lastTextContent = m_line.runs().last().textContent();
</span><del>-        lineEndsWithHyphen = lastTextContent && lastTextContent->needsHyphen();
</del><ins>+        lineEndsWithHyphen = lastTextContent && lastTextContent->needsHyphen;
</ins><span class="cx">     }
</span><span class="cx">     m_successiveHyphenatedLineCount = lineEndsWithHyphen ? m_successiveHyphenatedLineCount + 1 : 0;
</span><span class="cx">     return lineRange;
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineLineRunh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineRun.h (281753 => 281754)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineRun.h    2021-08-30 09:26:45 UTC (rev 281753)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineRun.h       2021-08-30 14:12:45 UTC (rev 281754)
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx">     struct Text {
</span><span class="cx">         WTF_MAKE_STRUCT_FAST_ALLOCATED;
</span><span class="cx">     public:
</span><del>-        Text(size_t position, size_t length, const String&);
</del><ins>+        Text(size_t position, size_t length, const String&, bool needsHyphen = false);
</ins><span class="cx"> 
</span><span class="cx">         size_t start() const { return m_start; }
</span><span class="cx">         size_t end() const { return start() + length(); }
</span><span class="lines">@@ -47,11 +47,7 @@
</span><span class="cx">         String content() const { return m_contentString; }
</span><span class="cx"> 
</span><span class="cx">         bool needsHyphen() const { return m_needsHyphen; }
</span><del>-        void setNeedsHyphen() { m_needsHyphen = true; }
</del><span class="cx"> 
</span><del>-        void expand(size_t delta) { m_length += delta; }
-        void shrink(size_t delta) { m_length -= delta; }
-
</del><span class="cx">     private:
</span><span class="cx">         size_t m_start { 0 };
</span><span class="cx">         size_t m_length { 0 };
</span><span class="lines">@@ -137,9 +133,10 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline LineRun::Text::Text(size_t start, size_t length, const String& contentString)
</del><ins>+inline LineRun::Text::Text(size_t start, size_t length, const String& contentString, bool needsHyphen)
</ins><span class="cx">     : m_start(start)
</span><span class="cx">     , m_length(length)
</span><ins>+    , m_needsHyphen(needsHyphen)
</ins><span class="cx">     , m_contentString(contentString)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>