<!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>[247257] 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/247257">247257</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2019-07-09 08:29:31 -0700 (Tue, 09 Jul 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>[LFC][IFC] Remove InlineItem references from inline runs.
https://bugs.webkit.org/show_bug.cgi?id=199608
<rdar://problem/52812775>

Reviewed by Antti Koivisto.

Constructing the inline runs is where we stop using InlineItems in the process of processing the inline content.
InlineItems are redundant in the context of Display::Runs.
It also enables us to create temporary InlineItems to process split content.

* layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
(WebCore::Layout::InlineFormattingContext::LineLayout::createDisplayRuns const):
* layout/inlineformatting/InlineFormattingContextQuirks.cpp:
(WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing):
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::Content::Run::Run):
(WebCore::Layout::Line::isVisuallyEmpty const):
(WebCore::Layout::Line::close):
(WebCore::Layout::Line::removeTrailingTrimmableContent):
(WebCore::Layout::Line::trailingTrimmableWidth const):
(WebCore::Layout::Line::appendNonBreakableSpace):
(WebCore::Layout::Line::appendTextContent):
(WebCore::Layout::Line::appendNonReplacedInlineBox):
(WebCore::Layout::Line::appendHardLineBreak):
* layout/inlineformatting/InlineLine.h:
(WebCore::Layout::Line::Content::Run::layoutBox const):
(WebCore::Layout::Line::Content::Run::logicalRect const):
(WebCore::Layout::Line::Content::Run::textContext const):
(WebCore::Layout::Line::Content::Run::type const):
(WebCore::Layout::Line::Content::Run::isText const):
(WebCore::Layout::Line::Content::Run::isBox const):
(WebCore::Layout::Line::Content::Run::isLineBreak const):
(WebCore::Layout::Line::Content::Run::isContainerStart const):
(WebCore::Layout::Line::Content::Run::isContainerEnd const):
(WebCore::Layout::Line::Content::Run::adjustLogicalTop):
(WebCore::Layout::Line::Content::Run::moveVertically):
(WebCore::Layout::Line::Content::Run::moveHorizontally):
(WebCore::Layout::Line::Content::Run::setTextIsCollapsed):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorelayoutinlineformattingInlineFormattingContextLineLayoutcpp">trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutinlineformattingInlineFormattingContextQuirkscpp">trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutinlineformattingInlineLinecpp">trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutinlineformattingInlineLineh">trunk/Source/WebCore/layout/inlineformatting/InlineLine.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (247256 => 247257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-07-09 15:21:11 UTC (rev 247256)
+++ trunk/Source/WebCore/ChangeLog      2019-07-09 15:29:31 UTC (rev 247257)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2019-07-09  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Remove InlineItem references from inline runs.
+        https://bugs.webkit.org/show_bug.cgi?id=199608
+        <rdar://problem/52812775>
+
+        Reviewed by Antti Koivisto.
+
+        Constructing the inline runs is where we stop using InlineItems in the process of processing the inline content.
+        InlineItems are redundant in the context of Display::Runs.
+        It also enables us to create temporary InlineItems to process split content.  
+
+        * layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
+        (WebCore::Layout::InlineFormattingContext::LineLayout::createDisplayRuns const):
+        * layout/inlineformatting/InlineFormattingContextQuirks.cpp:
+        (WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing):
+        * layout/inlineformatting/InlineLine.cpp:
+        (WebCore::Layout::Line::Content::Run::Run):
+        (WebCore::Layout::Line::isVisuallyEmpty const):
+        (WebCore::Layout::Line::close):
+        (WebCore::Layout::Line::removeTrailingTrimmableContent):
+        (WebCore::Layout::Line::trailingTrimmableWidth const):
+        (WebCore::Layout::Line::appendNonBreakableSpace):
+        (WebCore::Layout::Line::appendTextContent):
+        (WebCore::Layout::Line::appendNonReplacedInlineBox):
+        (WebCore::Layout::Line::appendHardLineBreak):
+        * layout/inlineformatting/InlineLine.h:
+        (WebCore::Layout::Line::Content::Run::layoutBox const):
+        (WebCore::Layout::Line::Content::Run::logicalRect const):
+        (WebCore::Layout::Line::Content::Run::textContext const):
+        (WebCore::Layout::Line::Content::Run::type const):
+        (WebCore::Layout::Line::Content::Run::isText const):
+        (WebCore::Layout::Line::Content::Run::isBox const):
+        (WebCore::Layout::Line::Content::Run::isLineBreak const):
+        (WebCore::Layout::Line::Content::Run::isContainerStart const):
+        (WebCore::Layout::Line::Content::Run::isContainerEnd const):
+        (WebCore::Layout::Line::Content::Run::adjustLogicalTop):
+        (WebCore::Layout::Line::Content::Run::moveVertically):
+        (WebCore::Layout::Line::Content::Run::moveHorizontally):
+        (WebCore::Layout::Line::Content::Run::setTextIsCollapsed):
+
</ins><span class="cx"> 2019-07-09  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r244906): Crash in WebCore::positionOffsetValue
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutinlineformattingInlineFormattingContextLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp (247256 => 247257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp       2019-07-09 15:21:11 UTC (rev 247256)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp  2019-07-09 15:29:31 UTC (rev 247257)
</span><span class="lines">@@ -317,13 +317,11 @@
</span><span class="cx">     auto& lineRuns = lineContent.runs();
</span><span class="cx">     for (unsigned index = 0; index < lineRuns.size(); ++index) {
</span><span class="cx">         auto& lineRun = lineRuns.at(index);
</span><del>-
-        auto& inlineItem = lineRun->inlineItem;
-        auto& logicalRect = lineRun->logicalRect;
-        auto& layoutBox = inlineItem.layoutBox();
</del><ins>+        auto& logicalRect = lineRun->logicalRect();
+        auto& layoutBox = lineRun->layoutBox();
</ins><span class="cx">         auto& displayBox = layoutState().displayBoxForLayoutBox(layoutBox);
</span><span class="cx"> 
</span><del>-        if (inlineItem.isHardLineBreak()) {
</del><ins>+        if (lineRun->isLineBreak()) {
</ins><span class="cx">             displayBox.setTopLeft(logicalRect.topLeft());
</span><span class="cx">             displayBox.setContentBoxWidth(logicalRect.width());
</span><span class="cx">             displayBox.setContentBoxHeight(logicalRect.height());
</span><span class="lines">@@ -332,7 +330,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Inline level box (replaced or inline-block)
</span><del>-        if (inlineItem.isBox()) {
</del><ins>+        if (lineRun->isBox()) {
</ins><span class="cx">             auto topLeft = logicalRect.topLeft();
</span><span class="cx">             if (layoutBox.isInFlowPositioned())
</span><span class="cx">                 topLeft += Geometry::inFlowPositionedPositionOffset(layoutState(), layoutBox);
</span><span class="lines">@@ -343,7 +341,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Inline level container start (<span>)
</span><del>-        if (inlineItem.isContainerStart()) {
</del><ins>+        if (lineRun->isContainerStart()) {
</ins><span class="cx">             displayBox.setTopLeft(logicalRect.topLeft());
</span><span class="cx">             lineBoxRect.expandHorizontally(logicalRect.width());
</span><span class="cx">             continue;
</span><span class="lines">@@ -350,7 +348,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Inline level container end (</span>)
</span><del>-        if (inlineItem.isContainerEnd()) {
</del><ins>+        if (lineRun->isContainerEnd()) {
</ins><span class="cx">             if (layoutBox.isInFlowPositioned()) {
</span><span class="cx">                 auto inflowOffset = Geometry::inFlowPositionedPositionOffset(layoutState(), layoutBox);
</span><span class="cx">                 displayBox.moveHorizontally(inflowOffset.width());
</span><span class="lines">@@ -366,28 +364,29 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Text content. Try to join multiple text runs when possible.
</span><del>-        ASSERT(lineRun->textContext);        
</del><ins>+        ASSERT(lineRun->isText());
+        auto textContext = lineRun->textContext();   
</ins><span class="cx">         const Line::Content::Run* previousLineRun = !index ? nullptr : lineRuns[index - 1].get();
</span><del>-        if (!lineRun->isCollapsed) {
-            auto previousRunCanBeExtended = previousLineRun ? previousLineRun->canBeExtended : false;
-            auto requiresNewRun = !index || !previousRunCanBeExtended || &layoutBox != &previousLineRun->inlineItem.layoutBox();
</del><ins>+        if (!textContext->isCollapsed) {
+            auto previousRunCanBeExtended = previousLineRun && previousLineRun->textContext() ? previousLineRun->textContext()->canBeExtended : false;
+            auto requiresNewRun = !index || !previousRunCanBeExtended || &layoutBox != &previousLineRun->layoutBox();
</ins><span class="cx">             if (requiresNewRun)
</span><del>-                m_formattingState.addInlineRun(std::make_unique<Display::Run>(logicalRect, Display::Run::TextContext { lineRun->textContext->start, lineRun->textContext->length }));
</del><ins>+                m_formattingState.addInlineRun(std::make_unique<Display::Run>(logicalRect, Display::Run::TextContext { textContext->start, textContext->length }));
</ins><span class="cx">             else {
</span><span class="cx">                 auto& lastDisplayRun = m_formattingState.inlineRuns().last();
</span><span class="cx">                 lastDisplayRun->expandHorizontally(logicalRect.width());
</span><del>-                lastDisplayRun->textContext()->expand(lineRun->textContext->length);
</del><ins>+                lastDisplayRun->textContext()->expand(textContext->length);
</ins><span class="cx">             }
</span><span class="cx">             lineBoxRect.expandHorizontally(logicalRect.width());
</span><span class="cx">         }
</span><span class="cx">         // FIXME take content breaking into account when part of the layout box is on the previous line.
</span><del>-        auto firstInlineRunForLayoutBox = !previousLineRun || &previousLineRun->inlineItem.layoutBox() != &layoutBox;
</del><ins>+        auto firstInlineRunForLayoutBox = !previousLineRun || &previousLineRun->layoutBox() != &layoutBox;
</ins><span class="cx">         if (firstInlineRunForLayoutBox) {
</span><span class="cx">             // Setup display box for the associated layout box.
</span><span class="cx">             displayBox.setTopLeft(logicalRect.topLeft());
</span><del>-            displayBox.setContentBoxWidth(lineRun->isCollapsed ? LayoutUnit() : logicalRect.width());
</del><ins>+            displayBox.setContentBoxWidth(textContext->isCollapsed ? LayoutUnit() : logicalRect.width());
</ins><span class="cx">             displayBox.setContentBoxHeight(logicalRect.height());
</span><del>-        } else if (!lineRun->isCollapsed) {
</del><ins>+        } else if (!textContext->isCollapsed) {
</ins><span class="cx">             // FIXME fix it for multirun/multiline.
</span><span class="cx">             displayBox.setContentBoxWidth(displayBox.contentBoxWidth() + logicalRect.width());
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutinlineformattingInlineFormattingContextQuirkscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp (247256 => 247257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp   2019-07-09 15:21:11 UTC (rev 247256)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp      2019-07-09 15:29:31 UTC (rev 247257)
</span><span class="lines">@@ -44,19 +44,19 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     for (auto& run : lineContent.runs()) {
</span><del>-        auto& inlineItem = run->inlineItem;
-        if (inlineItem.style().verticalAlign() != VerticalAlign::Baseline)
</del><ins>+        auto& layoutBox = run->layoutBox();
+        if (layoutBox.style().verticalAlign() != VerticalAlign::Baseline)
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        switch (inlineItem.type()) {
</del><ins>+        switch (run->type()) {
</ins><span class="cx">         case InlineItem::Type::Text:
</span><del>-            if (!run->isCollapsed)
</del><ins>+            if (!run->textContext() || !run->textContext()->isCollapsed)
</ins><span class="cx">                 return false;
</span><span class="cx">             break;
</span><span class="cx">         case InlineItem::Type::HardLineBreak:
</span><span class="cx">             return false;
</span><span class="cx">         case InlineItem::Type::ContainerStart: {
</span><del>-            auto& displayBox = layoutState.displayBoxForLayoutBox(inlineItem.layoutBox());
</del><ins>+            auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
</ins><span class="cx">             if (displayBox.horizontalBorder() || (displayBox.horizontalPadding() && displayBox.horizontalPadding().value()))
</span><span class="cx">                 return false;
</span><span class="cx">             break;
</span><span class="lines">@@ -64,7 +64,6 @@
</span><span class="cx">         case InlineItem::Type::ContainerEnd:
</span><span class="cx">             break;
</span><span class="cx">         case InlineItem::Type::Box: {
</span><del>-            auto& layoutBox = inlineItem.layoutBox();
</del><span class="cx">             if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) {
</span><span class="cx">                 auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(layoutBox));
</span><span class="cx">                 ASSERT(!formattingState.lineBoxes().isEmpty());
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutinlineformattingInlineLinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (247256 => 247257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp      2019-07-09 15:21:11 UTC (rev 247256)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-07-09 15:29:31 UTC (rev 247257)
</span><span class="lines">@@ -35,15 +35,21 @@
</span><span class="cx"> 
</span><span class="cx"> WTF_MAKE_ISO_ALLOCATED_IMPL(Line);
</span><span class="cx"> 
</span><del>-Line::Content::Run::Run(const InlineItem& inlineItem, const Display::Rect& logicalRect, TextContext textContext, bool isCollapsed, bool canBeExtended)
-    : inlineItem(inlineItem)
-    , logicalRect(logicalRect)
-    , textContext(textContext)
-    , isCollapsed(isCollapsed)
-    , canBeExtended(canBeExtended)
</del><ins>+Line::Content::Run::Run(const InlineItem& inlineItem, const Display::Rect& logicalRect)
+    : m_layoutBox(inlineItem.layoutBox())
+    , m_type(inlineItem.type())
+    , m_logicalRect(logicalRect)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Line::Content::Run::Run(const InlineItem& inlineItem, const TextContext& textContext, const Display::Rect& logicalRect)
+    : m_layoutBox(inlineItem.layoutBox())
+    , m_type(inlineItem.type())
+    , m_logicalRect(logicalRect)
+    , m_textContext(textContext)
+{
+}
+
</ins><span class="cx"> Line::Line(const LayoutState& layoutState, const InitialConstraints& initialConstraints, SkipVerticalAligment skipVerticalAligment)
</span><span class="cx">     : m_layoutState(layoutState)
</span><span class="cx">     , m_content(std::make_unique<Line::Content>())
</span><span class="lines">@@ -68,16 +74,16 @@
</span><span class="cx">     // FIXME: This should be cached instead -as the inline items are being added.
</span><span class="cx">     // Return true for empty inline containers like <span></span>.
</span><span class="cx">     for (auto& run : m_content->runs()) {
</span><del>-        if (run->inlineItem.isContainerStart()) {
-            if (!isInlineContainerConsideredEmpty(m_layoutState, run->inlineItem.layoutBox()))
</del><ins>+        if (run->isContainerStart()) {
+            if (!isInlineContainerConsideredEmpty(m_layoutState, run->layoutBox()))
</ins><span class="cx">                 return false;
</span><span class="cx">             continue;
</span><span class="cx">         }
</span><del>-        if (run->inlineItem.isContainerEnd())
</del><ins>+        if (run->isContainerEnd())
</ins><span class="cx">             continue;
</span><del>-        if (run->inlineItem.layoutBox().establishesFormattingContext()) {
-            ASSERT(run->inlineItem.layoutBox().isInlineBlockBox());
-            auto& displayBox = m_layoutState.displayBoxForLayoutBox(run->inlineItem.layoutBox());
</del><ins>+        if (run->layoutBox().establishesFormattingContext()) {
+            ASSERT(run->layoutBox().isInlineBlockBox());
+            auto& displayBox = m_layoutState.displayBoxForLayoutBox(run->layoutBox());
</ins><span class="cx">             if (!displayBox.width())
</span><span class="cx">                 continue;
</span><span class="cx">             if (m_skipVerticalAligment || displayBox.height())
</span><span class="lines">@@ -84,7 +90,7 @@
</span><span class="cx">                 return false;
</span><span class="cx">             continue;
</span><span class="cx">         }
</span><del>-        if (!run->isCollapsed)
</del><ins>+        if (!run->textContext() || !run->textContext()->isCollapsed)
</ins><span class="cx">             return false;
</span><span class="cx">     }
</span><span class="cx">     return true;
</span><span class="lines">@@ -108,16 +114,15 @@
</span><span class="cx"> 
</span><span class="cx">         for (auto& run : m_content->runs()) {
</span><span class="cx">             LayoutUnit logicalTop;
</span><del>-            auto& inlineItem = run->inlineItem;
-            auto& layoutBox = inlineItem.layoutBox();
-            auto verticalAlign = inlineItem.style().verticalAlign();
-            auto ascent = inlineItem.style().fontMetrics().ascent();
</del><ins>+            auto& layoutBox = run->layoutBox();
+            auto verticalAlign = layoutBox.style().verticalAlign();
+            auto ascent = layoutBox.style().fontMetrics().ascent();
</ins><span class="cx"> 
</span><span class="cx">             switch (verticalAlign) {
</span><span class="cx">             case VerticalAlign::Baseline:
</span><del>-                if (inlineItem.isLineBreak() || inlineItem.isText())
</del><ins>+                if (run->isLineBreak() || run->isText())
</ins><span class="cx">                     logicalTop = baselineOffset() - ascent;
</span><del>-                else if (inlineItem.isContainerStart()) {
</del><ins>+                else if (run->isContainerStart()) {
</ins><span class="cx">                     auto& displayBox = m_layoutState.displayBoxForLayoutBox(layoutBox);
</span><span class="cx">                     logicalTop = baselineOffset() - ascent - displayBox.borderTop() - displayBox.paddingTop().valueOr(0);
</span><span class="cx">                 } else if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) {
</span><span class="lines">@@ -127,22 +132,22 @@
</span><span class="cx">                     auto inlineBlockBaseline = formattingState.lineBoxes().last().baseline();
</span><span class="cx">                     logicalTop = baselineOffset() - inlineBlockBaseline.ascent;
</span><span class="cx">                 } else
</span><del>-                    logicalTop = baselineOffset() - run->logicalRect.height();
</del><ins>+                    logicalTop = baselineOffset() - run->logicalRect().height();
</ins><span class="cx">                 break;
</span><span class="cx">             case VerticalAlign::Top:
</span><span class="cx">                 logicalTop = { };
</span><span class="cx">                 break;
</span><span class="cx">             case VerticalAlign::Bottom:
</span><del>-                logicalTop = logicalBottom() - run->logicalRect.height();
</del><ins>+                logicalTop = logicalBottom() - run->logicalRect().height();
</ins><span class="cx">                 break;
</span><span class="cx">             default:
</span><span class="cx">                 ASSERT_NOT_IMPLEMENTED_YET();
</span><span class="cx">                 break;
</span><span class="cx">             }
</span><del>-            run->logicalRect.setTop(logicalTop);
</del><ins>+            run->adjustLogicalTop(logicalTop);
</ins><span class="cx">             // Convert runs from relative to the line top/left to the formatting root's border box top/left.
</span><del>-            run->logicalRect.moveVertically(this->logicalTop());
-            run->logicalRect.moveHorizontally(this->logicalLeft());
</del><ins>+            run->moveVertically(this->logicalTop());
+            run->moveHorizontally(this->logicalLeft());
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     m_content->setLogicalRect({ logicalTop(), logicalLeft(), contentLogicalWidth(), logicalHeight() });
</span><span class="lines">@@ -156,8 +161,9 @@
</span><span class="cx">     // Collapse trimmable trailing content
</span><span class="cx">     LayoutUnit trimmableWidth;
</span><span class="cx">     for (auto* trimmableRun : m_trimmableContent) {
</span><del>-        trimmableRun->isCollapsed = true;
-        trimmableWidth += trimmableRun->logicalRect.width();
</del><ins>+        ASSERT(trimmableRun->isText());
+        trimmableRun->setTextIsCollapsed();
+        trimmableWidth += trimmableRun->logicalRect().width();
</ins><span class="cx">     }
</span><span class="cx">     m_contentLogicalWidth -= trimmableWidth;
</span><span class="cx"> }
</span><span class="lines">@@ -182,8 +188,8 @@
</span><span class="cx"> {
</span><span class="cx">     LayoutUnit trimmableWidth;
</span><span class="cx">     for (auto* trimmableRun : m_trimmableContent) {
</span><del>-        ASSERT(!trimmableRun->isCollapsed);
-        trimmableWidth += trimmableRun->logicalRect.width();
</del><ins>+        ASSERT(!trimmableRun->textContext()->isCollapsed);
+        trimmableWidth += trimmableRun->logicalRect().width();
</ins><span class="cx">     }
</span><span class="cx">     return trimmableWidth;
</span><span class="cx"> }
</span><span class="lines">@@ -205,7 +211,7 @@
</span><span class="cx"> 
</span><span class="cx"> void Line::appendNonBreakableSpace(const InlineItem& inlineItem, const Display::Rect& logicalRect)
</span><span class="cx"> {
</span><del>-    m_content->runs().append(std::make_unique<Content::Run>(inlineItem, logicalRect, Content::Run::TextContext { }, false, false));
</del><ins>+    m_content->runs().append(std::make_unique<Content::Run>(inlineItem, logicalRect));
</ins><span class="cx">     m_contentLogicalWidth += logicalRect.width();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -250,12 +256,12 @@
</span><span class="cx">             return true;
</span><span class="cx">         // Check if the last item is trimmable as well.
</span><span class="cx">         for (int index = runs.size() - 1; index >= 0; --index) {
</span><del>-            auto& inlineItem = runs[index]->inlineItem;
-            if (inlineItem.isBox())
</del><ins>+            auto& run = runs[index];
+            if (run->isBox())
</ins><span class="cx">                 return false;
</span><del>-            if (inlineItem.isText())
-                return TextUtil::isTrimmableContent(inlineItem);
-            ASSERT(inlineItem.isContainerStart() || inlineItem.isContainerEnd());
</del><ins>+            if (run->isText())
+                return run->textContext()->isWhitespace && run->layoutBox().style().collapseWhiteSpace();
+            ASSERT(run->isContainerStart() || run->isContainerEnd());
</ins><span class="cx">         }
</span><span class="cx">         return true;
</span><span class="cx">     };
</span><span class="lines">@@ -273,8 +279,8 @@
</span><span class="cx">         adjustBaselineAndLineHeight(inlineItem, runHeight);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    auto textContext = Content::Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length() };
-    auto lineItem = std::make_unique<Content::Run>(inlineItem, logicalRect, textContext, isCompletelyCollapsed, canBeExtended);
</del><ins>+    auto textContext = Content::Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length(), isCompletelyCollapsed, canBeExtended, inlineItem.isWhitespace() };
+    auto lineItem = std::make_unique<Content::Run>(inlineItem, textContext, logicalRect);
</ins><span class="cx">     if (isTrimmable && !isCompletelyCollapsed)
</span><span class="cx">         m_trimmableContent.add(lineItem.get());
</span><span class="cx"> 
</span><span class="lines">@@ -295,7 +301,7 @@
</span><span class="cx">         logicalRect.setHeight(inlineItemContentHeight(inlineItem));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_content->runs().append(std::make_unique<Content::Run>(inlineItem, logicalRect, Content::Run::TextContext { }, false, false));
</del><ins>+    m_content->runs().append(std::make_unique<Content::Run>(inlineItem, logicalRect));
</ins><span class="cx">     m_contentLogicalWidth += (logicalWidth + horizontalMargin.start + horizontalMargin.end);
</span><span class="cx">     m_trimmableContent.clear();
</span><span class="cx"> }
</span><span class="lines">@@ -315,7 +321,7 @@
</span><span class="cx">         adjustBaselineAndLineHeight(inlineItem, { });
</span><span class="cx">         logicalRect.setHeight(logicalHeight());
</span><span class="cx">     }
</span><del>-    m_content->runs().append(std::make_unique<Content::Run>(inlineItem, logicalRect, Content::Run::TextContext { }, false, false));
</del><ins>+    m_content->runs().append(std::make_unique<Content::Run>(inlineItem, logicalRect));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem, LayoutUnit runHeight)
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutinlineformattingInlineLineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (247256 => 247257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h        2019-07-09 15:21:11 UTC (rev 247256)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h   2019-07-09 15:29:31 UTC (rev 247257)
</span><span class="lines">@@ -57,15 +57,35 @@
</span><span class="cx">             struct TextContext {
</span><span class="cx">                 unsigned start { 0 };
</span><span class="cx">                 unsigned length { 0 };
</span><ins>+                bool isCollapsed { false };
+                bool isWhitespace { false };
+                bool canBeExtended { false };
</ins><span class="cx">             };
</span><del>-            Run(const InlineItem&, const Display::Rect&, TextContext, bool isCollapsed, bool canBeExtended);
</del><ins>+            Run(const InlineItem&, const Display::Rect&);
+            Run(const InlineItem&, const TextContext&, const Display::Rect&);
</ins><span class="cx"> 
</span><del>-            const InlineItem& inlineItem;
-            Display::Rect logicalRect;
-            LayoutUnit baseline;
-            Optional<TextContext> textContext;
-            bool isCollapsed { false };
-            bool canBeExtended { false };
</del><ins>+            const Box& layoutBox() const { return m_layoutBox; }
+            const Display::Rect& logicalRect() const { return m_logicalRect; }
+            const Optional<TextContext> textContext() const { return m_textContext; }
+            InlineItem::Type type() const { return m_type; }
+
+            bool isText() const { return m_type == InlineItem::Type::Text; }
+            bool isBox() const { return m_type == InlineItem::Type::Box; }
+            bool isLineBreak() const { return m_type == InlineItem::Type::HardLineBreak; }
+            bool isContainerStart() const { return m_type == InlineItem::Type::ContainerStart; }
+            bool isContainerEnd() const { return m_type == InlineItem::Type::ContainerEnd; }
+
+        private:
+            friend class Line;
+            void adjustLogicalTop(LayoutUnit logicalTop) { m_logicalRect.setTop(logicalTop); }
+            void moveVertically(LayoutUnit offset) { m_logicalRect.moveVertically(offset); }
+            void moveHorizontally(LayoutUnit offset) { m_logicalRect.moveHorizontally(offset); }
+            void setTextIsCollapsed() { m_textContext->isCollapsed = true; }
+
+            const Box& m_layoutBox;
+            const InlineItem::Type m_type;
+            Display::Rect m_logicalRect;
+            Optional<TextContext> m_textContext;
</ins><span class="cx">         };
</span><span class="cx">         using Runs = Vector<std::unique_ptr<Run>>;
</span><span class="cx">         const Runs& runs() const { return m_runs; }
</span></span></pre>
</div>
</div>

</body>
</html>