<!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>[285050] 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/285050">285050</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2021-10-29 14:09:10 -0700 (Fri, 29 Oct 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[LFC][IFC] Introduce InlineItemsBuilder
https://bugs.webkit.org/show_bug.cgi?id=232487

Reviewed by Antti Koivisto.

This builder is going to be used for constructing bidi compatible inline items.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* layout/formattingContexts/inline/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::collectContentIfNeeded):
* layout/formattingContexts/inline/InlineItemsBuilder.cpp: Added.
(WebCore::Layout::InlineItemsBuilder::InlineItemsBuilder):
(WebCore::Layout::InlineItemsBuilder::build):
* layout/formattingContexts/inline/InlineItemsBuilder.h: Added.
(WebCore::Layout::InlineItemsBuilder::root const):
(WebCore::Layout::InlineItemsBuilder::formattingState const):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreSourcestxt">trunk/Source/WebCore/Sources.txt</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineFormattingContextcpp">trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineItemsBuildercpp">trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorelayoutformattingContextsinlineInlineItemsBuilderh">trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (285049 => 285050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-10-29 21:08:22 UTC (rev 285049)
+++ trunk/Source/WebCore/ChangeLog      2021-10-29 21:09:10 UTC (rev 285050)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2021-10-29  Alan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Introduce InlineItemsBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=232487
+
+        Reviewed by Antti Koivisto.
+
+        This builder is going to be used for constructing bidi compatible inline items.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * layout/formattingContexts/inline/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::collectContentIfNeeded):
+        * layout/formattingContexts/inline/InlineItemsBuilder.cpp: Added.
+        (WebCore::Layout::InlineItemsBuilder::InlineItemsBuilder):
+        (WebCore::Layout::InlineItemsBuilder::build):
+        * layout/formattingContexts/inline/InlineItemsBuilder.h: Added.
+        (WebCore::Layout::InlineItemsBuilder::root const):
+        (WebCore::Layout::InlineItemsBuilder::formattingState const):
+
</ins><span class="cx"> 2021-10-29  Darin Adler  <darin@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Create constants for all special frame names used in anchor target attribute values and elsewhere
</span></span></pre></div>
<a id="trunkSourceWebCoreSourcestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Sources.txt (285049 => 285050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Sources.txt 2021-10-29 21:08:22 UTC (rev 285049)
+++ trunk/Source/WebCore/Sources.txt    2021-10-29 21:09:10 UTC (rev 285050)
</span><span class="lines">@@ -1511,6 +1511,7 @@
</span><span class="cx"> layout/formattingContexts/inline/InlineFormattingQuirks.cpp
</span><span class="cx"> layout/formattingContexts/inline/InlineFormattingState.cpp
</span><span class="cx"> layout/formattingContexts/inline/InlineItem.cpp
</span><ins>+layout/formattingContexts/inline/InlineItemsBuilder.cpp
</ins><span class="cx"> layout/formattingContexts/inline/InlineLine.cpp
</span><span class="cx"> layout/formattingContexts/inline/InlineLineBox.cpp
</span><span class="cx"> layout/formattingContexts/inline/InlineLineBoxBuilder.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (285049 => 285050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2021-10-29 21:08:22 UTC (rev 285049)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2021-10-29 21:09:10 UTC (rev 285050)
</span><span class="lines">@@ -425,6 +425,7 @@
</span><span class="cx">          1199FA46208E35A3002358CC /* LayoutContainerBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 1199FA44208E35A3002358CC /* LayoutContainerBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          11C3227D26D958CE00328F4D /* InlineLineBoxBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 11C3227C26D958CE00328F4D /* InlineLineBoxBuilder.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          11CB2789203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h in Headers */ = {isa = PBXBuildFile; fileRef = 11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */; };
</span><ins>+               11D0363C272C4CFD009ED70D /* InlineItemsBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 11D0363B272C4CFD009ED70D /* InlineItemsBuilder.h */; };
</ins><span class="cx">           11E51638261E1A0600E69F25 /* WebXRInputSpace.h in Headers */ = {isa = PBXBuildFile; fileRef = 11E51635261E1A0500E69F25 /* WebXRInputSpace.h */; };
</span><span class="cx">          11E5163C261E1A1500E69F25 /* WebXRGamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 11E5163A261E1A1400E69F25 /* WebXRGamepad.h */; };
</span><span class="cx">          1400D7A817136EA70077CE05 /* ScriptWrappableInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = 1400D7A717136EA70077CE05 /* ScriptWrappableInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -6573,6 +6574,8 @@
</span><span class="cx">          11C5F134200527F90001AE60 /* RenderTreeBuilderMathML.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderMathML.h; sourceTree = "<group>"; };
</span><span class="cx">          11CB2786203BA570004A1DC9 /* RenderTreeBuilderFullScreen.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTreeBuilderFullScreen.cpp; sourceTree = "<group>"; };
</span><span class="cx">          11CB2787203BA570004A1DC9 /* RenderTreeBuilderFullScreen.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RenderTreeBuilderFullScreen.h; sourceTree = "<group>"; };
</span><ins>+               11D03639272C4CE7009ED70D /* InlineItemsBuilder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineItemsBuilder.cpp; sourceTree = "<group>"; };
+               11D0363B272C4CFD009ED70D /* InlineItemsBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineItemsBuilder.h; sourceTree = "<group>"; };
</ins><span class="cx">           11D19C2E23159BAE008F24D3 /* TableFormattingGeometry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TableFormattingGeometry.cpp; sourceTree = "<group>"; };
</span><span class="cx">          11E51635261E1A0500E69F25 /* WebXRInputSpace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebXRInputSpace.h; sourceTree = "<group>"; };
</span><span class="cx">          11E51637261E1A0500E69F25 /* WebXRInputSpace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebXRInputSpace.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -18465,6 +18468,8 @@
</span><span class="cx">                          115CFA7C208B8E10001E6991 /* InlineFormattingState.h */,
</span><span class="cx">                          6F7B8CEC23626E6600C9FF15 /* InlineItem.cpp */,
</span><span class="cx">                          6FE7CFA02177EEF1005B1573 /* InlineItem.h */,
</span><ins>+                               11D03639272C4CE7009ED70D /* InlineItemsBuilder.cpp */,
+                               11D0363B272C4CFD009ED70D /* InlineItemsBuilder.h */,
</ins><span class="cx">                           6FAAE71126A2814A00E07502 /* InlineLevelBox.h */,
</span><span class="cx">                          6F0CD692229ED31900C5994E /* InlineLine.cpp */,
</span><span class="cx">                          6F0CD694229ED32700C5994E /* InlineLine.h */,
</span><span class="lines">@@ -33242,6 +33247,7 @@
</span><span class="cx">                          115CFA7E208B8E10001E6991 /* InlineFormattingState.h in Headers */,
</span><span class="cx">                          111FA1C726F0F30F003B8F16 /* InlineInvalidation.h in Headers */,
</span><span class="cx">                          6FE7CFA22177EEF2005B1573 /* InlineItem.h in Headers */,
</span><ins>+                               11D0363C272C4CFD009ED70D /* InlineItemsBuilder.h in Headers */,
</ins><span class="cx">                           E4A664CC2521D4AF007081DC /* InlineIteratorBox.h in Headers */,
</span><span class="cx">                          E4A664CF2521D4E2007081DC /* InlineIteratorBoxLegacyPath.h in Headers */,
</span><span class="cx">                          E4A664CE2521D4C9007081DC /* InlineIteratorBoxModernPath.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineFormattingContextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp (285049 => 285050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp        2021-10-29 21:08:22 UTC (rev 285049)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp   2021-10-29 21:09:10 UTC (rev 285050)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include "InlineDisplayBox.h"
</span><span class="cx"> #include "InlineDisplayContentBuilder.h"
</span><span class="cx"> #include "InlineFormattingState.h"
</span><ins>+#include "InlineItemsBuilder.h"
</ins><span class="cx"> #include "InlineLineBox.h"
</span><span class="cx"> #include "InlineLineBoxBuilder.h"
</span><span class="cx"> #include "InlineTextItem.h"
</span><span class="lines">@@ -522,51 +523,8 @@
</span><span class="cx">     auto& formattingState = this->formattingState();
</span><span class="cx">     if (!formattingState.inlineItems().isEmpty())
</span><span class="cx">         return;
</span><del>-    // Traverse the tree and create inline items out of inline boxes and leaf nodes. This essentially turns the tree inline structure into a flat one.
-    // <span>text<span></span><img></span> -> [InlineBoxStart][InlineLevelBox][InlineBoxStart][InlineBoxEnd][InlineLevelBox][InlineBoxEnd]
-    ASSERT(root().hasInFlowOrFloatingChild());
-    LayoutQueue layoutQueue;
-    layoutQueue.append(root().firstChild());
-    while (!layoutQueue.isEmpty()) {
-        while (true) {
-            auto& layoutBox = *layoutQueue.last();
-            auto isInlineBoxWithInlineContent = layoutBox.isInlineBox() && !layoutBox.isInlineTextBox() && !layoutBox.isLineBreakBox() && !layoutBox.isOutOfFlowPositioned();
-            if (!isInlineBoxWithInlineContent)
-                break;
-            // This is the start of an inline box (e.g. <span>).
-            formattingState.addInlineItem({ layoutBox, InlineItem::Type::InlineBoxStart });
-            auto& inlineBoxWithInlineContent = downcast<ContainerBox>(layoutBox);
-            if (!inlineBoxWithInlineContent.hasChild())
-                break;
-            layoutQueue.append(inlineBoxWithInlineContent.firstChild());
-        }
-
-        while (!layoutQueue.isEmpty()) {
-            auto& layoutBox = *layoutQueue.takeLast();
-            if (layoutBox.isOutOfFlowPositioned()) {
-                // Let's not construct InlineItems for out-of-flow content as they don't participate in the inline layout.
-                // However to be able to static positioning them, we need to compute their approximate positions.
-                formattingState.addOutOfFlowBox(layoutBox);
-            } else if (is<LineBreakBox>(layoutBox)) {
-                auto& lineBreakBox = downcast<LineBreakBox>(layoutBox);
-                formattingState.addInlineItem({ layoutBox, lineBreakBox.isOptional() ? InlineItem::Type::WordBreakOpportunity : InlineItem::Type::HardLineBreak });
-            } else if (layoutBox.isFloatingPositioned())
-                formattingState.addInlineItem({ layoutBox, InlineItem::Type::Float });
-            else if (layoutBox.isAtomicInlineLevelBox())
-                formattingState.addInlineItem({ layoutBox, InlineItem::Type::Box });
-            else if (layoutBox.isInlineTextBox()) {
-                InlineTextItem::createAndAppendTextItems(formattingState.inlineItems(), downcast<InlineTextBox>(layoutBox));
-            } else if (layoutBox.isInlineBox())
-                formattingState.addInlineItem({ layoutBox, InlineItem::Type::InlineBoxEnd });
-            else
-                ASSERT_NOT_REACHED();
-
-            if (auto* nextSibling = layoutBox.nextSibling()) {
-                layoutQueue.append(nextSibling);
-                break;
-            }
-        }
-    }
</del><ins>+    auto inlineItemsBuilder = InlineItemsBuilder { root(), formattingState };
+    inlineItemsBuilder.build();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> InlineRect InlineFormattingContext::computeGeometryForLineContent(const LineBuilder::LineContent& lineContent)
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineItemsBuildercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp (0 => 285050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp                             (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp        2021-10-29 21:09:10 UTC (rev 285050)
</span><span class="lines">@@ -0,0 +1,94 @@
</span><ins>+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InlineItemsBuilder.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+namespace WebCore {
+namespace Layout {
+
+InlineItemsBuilder::InlineItemsBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState& formattingState)
+    : m_root(formattingContextRoot)
+    , m_formattingState(formattingState)
+{
+}
+
+void InlineItemsBuilder::build()
+{
+    // Traverse the tree and create inline items out of inline boxes and leaf nodes. This essentially turns the tree inline structure into a flat one.
+    // <span>text<span></span><img></span> -> [InlineBoxStart][InlineLevelBox][InlineBoxStart][InlineBoxEnd][InlineLevelBox][InlineBoxEnd]
+    ASSERT(root().hasInFlowOrFloatingChild());
+    auto& formattingState = this->formattingState();
+
+    Vector<const Box*> layoutQueue;
+    layoutQueue.append(root().firstChild());
+    while (!layoutQueue.isEmpty()) {
+        while (true) {
+            auto& layoutBox = *layoutQueue.last();
+            auto isInlineBoxWithInlineContent = layoutBox.isInlineBox() && !layoutBox.isInlineTextBox() && !layoutBox.isLineBreakBox() && !layoutBox.isOutOfFlowPositioned();
+            if (!isInlineBoxWithInlineContent)
+                break;
+            // This is the start of an inline box (e.g. <span>).
+            formattingState.addInlineItem({ layoutBox, InlineItem::Type::InlineBoxStart });
+            auto& inlineBoxWithInlineContent = downcast<ContainerBox>(layoutBox);
+            if (!inlineBoxWithInlineContent.hasChild())
+                break;
+            layoutQueue.append(inlineBoxWithInlineContent.firstChild());
+        }
+
+        while (!layoutQueue.isEmpty()) {
+            auto& layoutBox = *layoutQueue.takeLast();
+            if (layoutBox.isOutOfFlowPositioned()) {
+                // Let's not construct InlineItems for out-of-flow content as they don't participate in the inline layout.
+                // However to be able to static positioning them, we need to compute their approximate positions.
+                formattingState.addOutOfFlowBox(layoutBox);
+            } else if (is<LineBreakBox>(layoutBox)) {
+                auto& lineBreakBox = downcast<LineBreakBox>(layoutBox);
+                formattingState.addInlineItem({ layoutBox, lineBreakBox.isOptional() ? InlineItem::Type::WordBreakOpportunity : InlineItem::Type::HardLineBreak });
+            } else if (layoutBox.isFloatingPositioned())
+                formattingState.addInlineItem({ layoutBox, InlineItem::Type::Float });
+            else if (layoutBox.isAtomicInlineLevelBox())
+                formattingState.addInlineItem({ layoutBox, InlineItem::Type::Box });
+            else if (layoutBox.isInlineTextBox()) {
+                InlineTextItem::createAndAppendTextItems(formattingState.inlineItems(), downcast<InlineTextBox>(layoutBox));
+            } else if (layoutBox.isInlineBox())
+                formattingState.addInlineItem({ layoutBox, InlineItem::Type::InlineBoxEnd });
+            else
+                ASSERT_NOT_REACHED();
+
+            if (auto* nextSibling = layoutBox.nextSibling()) {
+                layoutQueue.append(nextSibling);
+                break;
+            }
+        }
+    }
+}
+
+}
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineItemsBuilderh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h (0 => 285050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h                               (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.h  2021-10-29 21:09:10 UTC (rev 285050)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "InlineFormattingState.h"
+#include "LayoutContainerBox.h"
+
+namespace WebCore {
+namespace Layout {
+
+class InlineItemsBuilder {
+public:
+    InlineItemsBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState&);
+    void build();
+
+private:
+    const ContainerBox& root() const { return m_root; }
+    InlineFormattingState& formattingState() const { return m_formattingState; }
+
+    const ContainerBox& m_root;
+    InlineFormattingState& m_formattingState;
+};
+
+}
+}
+
+#endif
</ins></span></pre>
</div>
</div>

</body>
</html>