<!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>[246154] 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/246154">246154</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2019-06-06 07:50:54 -0700 (Thu, 06 Jun 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>[LFC][IFC] Layout and preferred width computation should both call placeInlineItems().
https://bugs.webkit.org/show_bug.cgi?id=198587
<rdar://problem/51460340>

Reviewed by Antti Koivisto.

This patch enables inline placement logic sharing between layout and preferred width computation.

* layout/inlineformatting/InlineFormattingContext.h:
* layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
(WebCore::Layout::InlineFormattingContext::LineLayout::LineInput::LineInput):
(WebCore::Layout::InlineFormattingContext::LineLayout::placeInlineItems const):
(WebCore::Layout::InlineFormattingContext::LineLayout::layout const):
(WebCore::Layout::InlineFormattingContext::LineLayout::computedIntrinsicWidth const):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorelayoutinlineformattingInlineFormattingContexth">trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h</a></li>
<li><a href="#trunkSourceWebCorelayoutinlineformattingInlineFormattingContextLineLayoutcpp">trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (246153 => 246154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-06-06 14:12:15 UTC (rev 246153)
+++ trunk/Source/WebCore/ChangeLog      2019-06-06 14:50:54 UTC (rev 246154)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2019-06-06  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Layout and preferred width computation should both call placeInlineItems().
+        https://bugs.webkit.org/show_bug.cgi?id=198587
+        <rdar://problem/51460340>
+
+        Reviewed by Antti Koivisto.
+
+        This patch enables inline placement logic sharing between layout and preferred width computation.
+
+        * layout/inlineformatting/InlineFormattingContext.h:
+        * layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
+        (WebCore::Layout::InlineFormattingContext::LineLayout::LineInput::LineInput):
+        (WebCore::Layout::InlineFormattingContext::LineLayout::placeInlineItems const):
+        (WebCore::Layout::InlineFormattingContext::LineLayout::layout const):
+        (WebCore::Layout::InlineFormattingContext::LineLayout::computedIntrinsicWidth const):
+
</ins><span class="cx"> 2019-06-05  Takashi Komori  <Takashi.Komori@sony.com>
</span><span class="cx"> 
</span><span class="cx">         [Curl] Report all request headers to web inspector.
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutinlineformattingInlineFormattingContexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (246153 => 246154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h   2019-06-06 14:12:15 UTC (rev 246153)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h      2019-06-06 14:50:54 UTC (rev 246154)
</span><span class="lines">@@ -66,7 +66,8 @@
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         struct LineInput {
</span><del>-            LineInput(LayoutPoint logicalTopLeft, LayoutUnit availableLogicalWidth, unsigned firstInlineItemIndex, const InlineItems&);
</del><ins>+            enum class SkipVerticalAligment { No, Yes };
+            LineInput(LayoutPoint logicalTopLeft, LayoutUnit availableLogicalWidth, SkipVerticalAligment, unsigned firstInlineItemIndex, const InlineItems&);
</ins><span class="cx">             struct HorizontalConstraint {
</span><span class="cx">                 HorizontalConstraint(LayoutPoint logicalTopLeft, LayoutUnit availableLogicalWidth);
</span><span class="cx"> 
</span><span class="lines">@@ -74,6 +75,8 @@
</span><span class="cx">                 LayoutUnit availableLogicalWidth;
</span><span class="cx">             };
</span><span class="cx">             HorizontalConstraint horizontalConstraint;
</span><ins>+            // FIXME Alternatively we could just have a second pass with vertical positioning (preferred width computation opts out) 
+            SkipVerticalAligment skipVerticalAligment;
</ins><span class="cx">             unsigned firstInlineItemIndex { 0 };
</span><span class="cx">             const InlineItems& inlineItems;
</span><span class="cx">         };
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutinlineformattingInlineFormattingContextLineLayoutcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp (246153 => 246154)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp       2019-06-06 14:12:15 UTC (rev 246153)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp  2019-06-06 14:50:54 UTC (rev 246154)
</span><span class="lines">@@ -78,8 +78,9 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-InlineFormattingContext::LineLayout::LineInput::LineInput(LayoutPoint logicalTopLeft, LayoutUnit availableLogicalWidth, unsigned firstInlineItemIndex, const InlineItems& inlineItems)
</del><ins>+InlineFormattingContext::LineLayout::LineInput::LineInput(LayoutPoint logicalTopLeft, LayoutUnit availableLogicalWidth, SkipVerticalAligment skipVerticalAligment, unsigned firstInlineItemIndex, const InlineItems& inlineItems)
</ins><span class="cx">     : horizontalConstraint(logicalTopLeft, availableLogicalWidth)
</span><ins>+    , skipVerticalAligment(skipVerticalAligment)
</ins><span class="cx">     , firstInlineItemIndex(firstInlineItemIndex)
</span><span class="cx">     , inlineItems(inlineItems)
</span><span class="cx"> {
</span><span class="lines">@@ -220,15 +221,17 @@
</span><span class="cx">             ++committedInlineItemCount;
</span><span class="cx">             continue;
</span><span class="cx">         }
</span><del>-        if (inlineItem->isHardLineBreak()) {
-            uncommittedContent.add(*inlineItem, { itemLogicalWidth, inlineItemHeight(layoutState(), *inlineItem) });
-            commitPendingContent();
-            return closeLine();
-        }
</del><span class="cx"> 
</span><del>-        uncommittedContent.add(*inlineItem, { itemLogicalWidth, inlineItemHeight(layoutState(), *inlineItem) });
</del><ins>+        Optional<LayoutUnit> itemLogicalHeight;
+        if (lineInput.skipVerticalAligment == LineInput::SkipVerticalAligment::No)
+            itemLogicalHeight = inlineItemHeight(layoutState(), *inlineItem);
+        uncommittedContent.add(*inlineItem, { itemLogicalWidth, itemLogicalHeight });
+
</ins><span class="cx">         if (breakingContext.isAtBreakingOpportunity)
</span><span class="cx">             commitPendingContent();
</span><ins>+
+        if (inlineItem->isHardLineBreak())
+            return closeLine();
</ins><span class="cx">     }
</span><span class="cx">     commitPendingContent();
</span><span class="cx">     return closeLine();
</span><span class="lines">@@ -275,7 +278,7 @@
</span><span class="cx">     auto& inlineItems = m_formattingState.inlineItems();
</span><span class="cx">     unsigned currentInlineItemIndex = 0;
</span><span class="cx">     while (currentInlineItemIndex < inlineItems.size()) {
</span><del>-        auto lineInput = LineInput { { lineLogicalLeft, lineLogicalTop }, widthConstraint, currentInlineItemIndex, inlineItems };
</del><ins>+        auto lineInput = LineInput { { lineLogicalLeft, lineLogicalTop }, widthConstraint, LineInput::SkipVerticalAligment::No, currentInlineItemIndex, inlineItems };
</ins><span class="cx">         applyFloatConstraint(lineInput.horizontalConstraint);
</span><span class="cx">         auto lineContent = placeInlineItems(lineInput);
</span><span class="cx">         createDisplayRuns(*lineContent.runs, lineContent.floats, widthConstraint);
</span><span class="lines">@@ -288,31 +291,18 @@
</span><span class="cx"> 
</span><span class="cx"> LayoutUnit InlineFormattingContext::LineLayout::computedIntrinsicWidth(LayoutUnit widthConstraint) const
</span><span class="cx"> {
</span><del>-    // FIXME: Consider running it through layout().
</del><span class="cx">     LayoutUnit maximumLineWidth;
</span><del>-    LayoutUnit lineLogicalRight;
-    LayoutUnit trimmableTrailingWidth;
-
-    LineBreaker lineBreaker;
-    auto& inlineContent = m_formattingState.inlineItems();
-    for (auto& inlineItem : inlineContent) {
-        auto logicalWidth = inlineItemWidth(layoutState(), *inlineItem, lineLogicalRight);
-        auto breakingContext = lineBreaker.breakingContext(*inlineItem, logicalWidth, { widthConstraint, lineLogicalRight, !lineLogicalRight });
-        if (breakingContext.breakingBehavior == LineBreaker::BreakingBehavior::Wrap) {
-            maximumLineWidth = std::max(maximumLineWidth, lineLogicalRight - trimmableTrailingWidth);
-            trimmableTrailingWidth = { };
-            lineLogicalRight = { };
-        }
-        if (TextUtil::isTrimmableContent(*inlineItem)) {
-            // Skip leading whitespace.
-            if (!lineLogicalRight)
-                continue;
-            trimmableTrailingWidth += logicalWidth;
-        } else
-            trimmableTrailingWidth = { };
-        lineLogicalRight += logicalWidth;
</del><ins>+    auto& inlineItems = m_formattingState.inlineItems();
+    unsigned currentInlineItemIndex = 0;
+    while (currentInlineItemIndex < inlineItems.size()) {
+        auto lineContent = placeInlineItems({ { }, widthConstraint, LineInput::SkipVerticalAligment::Yes, currentInlineItemIndex, inlineItems });
+        currentInlineItemIndex = *lineContent.lastInlineItemIndex + 1;
+        LayoutUnit floatsWidth;
+        for (auto& floatItem : lineContent.floats)
+            floatsWidth += layoutState().displayBoxForLayoutBox(floatItem->layoutBox()).marginBoxWidth();
+        maximumLineWidth = std::max(maximumLineWidth, floatsWidth + lineContent.runs->logicalWidth());
</ins><span class="cx">     }
</span><del>-    return std::max(maximumLineWidth, lineLogicalRight - trimmableTrailingWidth);
</del><ins>+    return maximumLineWidth;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InlineFormattingContext::LineLayout::createDisplayRuns(const Line::Content& lineContent, const Vector<WeakPtr<InlineItem>>& floats, LayoutUnit widthConstraint) const
</span></span></pre>
</div>
</div>

</body>
</html>