<!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>[269402] 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/269402">269402</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2020-11-04 16:11:51 -0800 (Wed, 04 Nov 2020)</dd>
</dl>

<h3>Log Message</h3>
<pre>[LFC][Integration] Introduce LayoutIntegration::Run::renderedContent
https://bugs.webkit.org/show_bug.cgi?id=218550

Reviewed by Antti Koivisto.

This is in preparation for supporting "text-overflow: ellipsis" where the rendered content could
be very different from the original content (e.g. runs after the truncation go completely blank)

* layout/integration/LayoutIntegrationLine.h:
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::constructContent):
(WebCore::LayoutIntegration::LineLayout::paint):
* layout/integration/LayoutIntegrationRun.h:
(WebCore::LayoutIntegration::Run::TextContent::originalContent const):
(WebCore::LayoutIntegration::Run::TextContent::renderedContent const):
(WebCore::LayoutIntegration::Run::isLineBreak const):
(WebCore::LayoutIntegration::Run::TextContent::TextContent):
(WebCore::LayoutIntegration::Run::TextContent::content const): Deleted.
* layout/integration/LayoutIntegrationRunIteratorModernPath.h:
(WebCore::LayoutIntegration::RunIteratorModernPath::text const):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationLineh">trunk/Source/WebCore/layout/integration/LayoutIntegrationLine.h</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationLineLayoutcpp">trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationRunh">trunk/Source/WebCore/layout/integration/LayoutIntegrationRun.h</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationRunIteratorModernPathh">trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (269401 => 269402)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2020-11-05 00:05:49 UTC (rev 269401)
+++ trunk/Source/WebCore/ChangeLog      2020-11-05 00:11:51 UTC (rev 269402)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2020-11-04  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][Integration] Introduce LayoutIntegration::Run::renderedContent
+        https://bugs.webkit.org/show_bug.cgi?id=218550
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for supporting "text-overflow: ellipsis" where the rendered content could
+        be very different from the original content (e.g. runs after the truncation go completely blank)
+
+        * layout/integration/LayoutIntegrationLine.h:
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::constructContent):
+        (WebCore::LayoutIntegration::LineLayout::paint):
+        * layout/integration/LayoutIntegrationRun.h:
+        (WebCore::LayoutIntegration::Run::TextContent::originalContent const):
+        (WebCore::LayoutIntegration::Run::TextContent::renderedContent const):
+        (WebCore::LayoutIntegration::Run::isLineBreak const):
+        (WebCore::LayoutIntegration::Run::TextContent::TextContent):
+        (WebCore::LayoutIntegration::Run::TextContent::content const): Deleted.
+        * layout/integration/LayoutIntegrationRunIteratorModernPath.h:
+        (WebCore::LayoutIntegration::RunIteratorModernPath::text const):
+
</ins><span class="cx"> 2020-11-04  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r257839): Miscomputed style due to computed 'rem' value in matched declaration cache
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationLineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLine.h (269401 => 269402)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLine.h  2020-11-05 00:05:49 UTC (rev 269401)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLine.h     2020-11-05 00:11:51 UTC (rev 269402)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">     FloatRect m_scrollableOverflow;
</span><span class="cx">     FloatRect m_inkOverflow;
</span><span class="cx">     float m_baseline { 0 };
</span><del>-    float m_horizontalAlignmentOffset;
</del><ins>+    float m_horizontalAlignmentOffset { 0 };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (269401 => 269402)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp  2020-11-05 00:05:49 UTC (rev 269401)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp     2020-11-05 00:11:51 UTC (rev 269402)
</span><span class="lines">@@ -198,8 +198,13 @@
</span><span class="cx">                 runRect.setY(roundToInt(runRect.y()));
</span><span class="cx"> 
</span><span class="cx">             WTF::Optional<Run::TextContent> textContent;
</span><del>-            if (auto text = lineRun.text())
-                textContent = Run::TextContent { text->start(), text->length(), text->content(), text->needsHyphen() };
</del><ins>+            if (auto text = lineRun.text()) {
+                auto adjustedContentToRenderer = [&] {
+                    // FIXME: This is where we create strings with trailing hyphens and truncate/replace content with ellipsis.
+                    return String();
+                };
+                textContent = Run::TextContent { text->start(), text->length(), text->content(), adjustedContentToRenderer(), text->needsHyphen() };
+            }
</ins><span class="cx">             auto expansion = Run::Expansion { lineRun.expansion().behavior, lineRun.expansion().horizontalExpansion };
</span><span class="cx">             auto displayRun = Run { lineIndex, layoutBox, runRect, computedInkOverflow(runRect), expansion, textContent };
</span><span class="cx">             displayInlineContent.runs.append(displayRun);
</span><span class="lines">@@ -214,7 +219,7 @@
</span><span class="cx">     };
</span><span class="cx">     constructDisplayLineRuns();
</span><span class="cx"> 
</span><del>-    auto constructDisplayLine = [&] {
</del><ins>+    auto constructDisplayLines = [&] {
</ins><span class="cx">         auto& lines = m_inlineFormattingState.lines();
</span><span class="cx">         auto& lineBoxes = m_inlineFormattingState.lineBoxes();
</span><span class="cx">         auto& runs = displayInlineContent.runs;
</span><span class="lines">@@ -266,7 +271,8 @@
</span><span class="cx">             displayInlineContent.lines.append({ firstRunIndex, runCount, lineRect, enclosingLineRect, scrollableOverflowRect, lineInkOverflowRect, line.baseline(), line.horizontalAlignmentOffset() });
</span><span class="cx">         }
</span><span class="cx">     };
</span><del>-    constructDisplayLine();
</del><ins>+    constructDisplayLines();
+
</ins><span class="cx">     displayInlineContent.clearGapAfterLastLine = m_inlineFormattingState.clearGapAfterLastLine();
</span><span class="cx">     displayInlineContent.shrinkToFit();
</span><span class="cx">     m_inlineFormattingState.shrinkToFit();
</span><span class="lines">@@ -505,11 +511,11 @@
</span><span class="cx"> 
</span><span class="cx">         String textWithHyphen;
</span><span class="cx">         if (textContent.hasHyphen())
</span><del>-            textWithHyphen = makeString(textContent.content(), style.hyphenString());
</del><ins>+            textWithHyphen = makeString(textContent.renderedContent(), style.hyphenString());
</ins><span class="cx">         // TextRun expects the xPos to be adjusted with the aligment offset (e.g. when the line is center aligned
</span><span class="cx">         // and the run starts at 100px, due to the horizontal aligment, the xpos is supposed to be at 0px).
</span><span class="cx">         auto xPos = rect.x() - (line.rect().x() + line.horizontalAlignmentOffset());
</span><del>-        WebCore::TextRun textRun { !textWithHyphen.isEmpty() ? textWithHyphen : textContent.content(), xPos, expansion.horizontalExpansion, expansion.behavior };
</del><ins>+        WebCore::TextRun textRun { !textWithHyphen.isEmpty() ? textWithHyphen : textContent.renderedContent(), xPos, expansion.horizontalExpansion, expansion.behavior };
</ins><span class="cx">         textRun.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
</span><span class="cx">         FloatPoint textOrigin { rect.x() + paintOffset.x(), roundToDevicePixel(baseline, deviceScaleFactor) };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationRunh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRun.h (269401 => 269402)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRun.h   2020-11-05 00:05:49 UTC (rev 269401)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRun.h      2020-11-05 00:11:51 UTC (rev 269402)
</span><span class="lines">@@ -43,12 +43,13 @@
</span><span class="cx">     struct TextContent {
</span><span class="cx">         WTF_MAKE_STRUCT_FAST_ALLOCATED;
</span><span class="cx">     public:
</span><del>-        TextContent(size_t position, size_t length, const String&, bool hasHyphen);
</del><ins>+        TextContent(size_t position, size_t length, const String&, String adjustedContentToRender, bool hasHyphen);
</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="cx">         size_t length() const { return m_length; }
</span><del>-        StringView content() const { return StringView(m_contentString).substring(m_start, m_length); }
</del><ins>+        StringView originalContent() const { return StringView(m_originalContent).substring(m_start, m_length); }
+        StringView renderedContent() const { return m_adjustedContentToRender.isNull() ? originalContent() : m_adjustedContentToRender; }
</ins><span class="cx">         bool hasHyphen() const { return m_hasHyphen; }
</span><span class="cx"> 
</span><span class="cx">     private:
</span><span class="lines">@@ -55,7 +56,8 @@
</span><span class="cx">         size_t m_start { 0 };
</span><span class="cx">         size_t m_length { 0 };
</span><span class="cx">         bool m_hasHyphen { false };
</span><del>-        String m_contentString;
</del><ins>+        String m_originalContent;
+        String m_adjustedContentToRender;
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     struct Expansion;
</span><span class="lines">@@ -67,7 +69,7 @@
</span><span class="cx">     Optional<TextContent>& textContent() { return m_textContent; }
</span><span class="cx">     const Optional<TextContent>& textContent() const { return m_textContent; }
</span><span class="cx">     // FIXME: This information should be preserved at Run construction time.
</span><del>-    bool isLineBreak() const { return layoutBox().isLineBreakBox() || (textContent() && textContent()->content() == "\n" && style().preserveNewline()); }
</del><ins>+    bool isLineBreak() const { return layoutBox().isLineBreakBox() || (textContent() && textContent()->originalContent() == "\n" && style().preserveNewline()); }
</ins><span class="cx"> 
</span><span class="cx">     struct Expansion {
</span><span class="cx">         ExpansionBehavior behavior { DefaultExpansion };
</span><span class="lines">@@ -105,11 +107,12 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline Run::TextContent::TextContent(size_t start, size_t length, const String& contentString, bool hasHyphen)
</del><ins>+inline Run::TextContent::TextContent(size_t start, size_t length, const String& originalContent, String adjustedContentToRender, bool hasHyphen)
</ins><span class="cx">     : m_start(start)
</span><span class="cx">     , m_length(length)
</span><span class="cx">     , m_hasHyphen(hasHyphen)
</span><del>-    , m_contentString(contentString)
</del><ins>+    , m_originalContent(originalContent)
+    , m_adjustedContentToRender(adjustedContentToRender)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationRunIteratorModernPathh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h (269401 => 269402)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h 2020-11-05 00:05:49 UTC (rev 269401)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h    2020-11-05 00:11:51 UTC (rev 269402)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx">     unsigned char bidiLevel() const { return 0; }
</span><span class="cx"> 
</span><span class="cx">     bool hasHyphen() const { return run().textContent()->hasHyphen(); }
</span><del>-    StringView text() const { return run().textContent()->content(); }
</del><ins>+    StringView text() const { return run().textContent()->originalContent(); }
</ins><span class="cx">     unsigned start() const { return run().textContent()->start(); }
</span><span class="cx">     unsigned end() const { return run().textContent()->end(); }
</span><span class="cx">     unsigned length() const { return run().textContent()->length(); }
</span></span></pre>
</div>
</div>

</body>
</html>