<!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>[286541] 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/286541">286541</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2021-12-06 00:13:26 -0800 (Mon, 06 Dec 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[LFC][Integration] Use end bits in text box iterator
https://bugs.webkit.org/show_bug.cgi?id=233858

Reviewed by Alan Bujtas.

Make text box traversal work correctly in bidi context where encountering a different
layout box does not necessarily mean there are no further text boxes for the layout box.

* layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
(WebCore::Layout::InlineDisplayContentBuilder::computeIsFirstIsLastBoxForInlineContent):

Set the bits for all box types.

* layout/formattingContexts/inline/display/InlineDisplayBox.h:
(WebCore::InlineDisplay::Box::Box):
(WebCore::InlineDisplay::Box::isTextOrSoftLineBreak const):
(WebCore::InlineDisplay::Box::isFirstForLayoutBox const):
(WebCore::InlineDisplay::Box::isLastForLayoutBox const):
(WebCore::InlineDisplay::Box::setIsFirstForLayoutBox):
(WebCore::InlineDisplay::Box::setIsLastForLayoutBox):
(WebCore::InlineDisplay::Box::isFirstBox const): Deleted.
(WebCore::InlineDisplay::Box::isLastBox const): Deleted.
(WebCore::InlineDisplay::Box::setIsLastBox): Deleted.
(WebCore::InlineDisplay::Box::setIsFirstBox): Deleted.

Renamed for clarity and correctness.

* layout/integration/InlineIteratorBoxModernPath.h:
(WebCore::InlineIterator::BoxModernPath::isText const):
(WebCore::InlineIterator::BoxModernPath::traverseNextTextBox):

Use the isLastForLayoutBox bit to end the traversal.

(WebCore::InlineIterator::BoxModernPath::traverseNextInlineBox):
(WebCore::InlineIterator::BoxModernPath::traversePreviousInlineBox):
(WebCore::InlineIterator::BoxModernPath::traverseNextWithSameLayoutBox):
(WebCore::InlineIterator::BoxModernPath::traversePreviousWithSameLayoutBox):

Factor into helpers.

* layout/integration/InlineIteratorTextBox.h:</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="#trunkSourceWebCorelayoutformattingContextsinlinedisplayInlineDisplayBoxh">trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationInlineIteratorBoxModernPathh">trunk/Source/WebCore/layout/integration/InlineIteratorBoxModernPath.h</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationInlineIteratorTextBoxh">trunk/Source/WebCore/layout/integration/InlineIteratorTextBox.h</a></li>
<li><a href="#trunkSourceWebCorelayoutintegrationLayoutIntegrationPaginationcpp">trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (286540 => 286541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-12-06 08:13:05 UTC (rev 286540)
+++ trunk/Source/WebCore/ChangeLog      2021-12-06 08:13:26 UTC (rev 286541)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2021-12-06  Antti Koivisto  <antti@apple.com>
+
+        [LFC][Integration] Use end bits in text box iterator
+        https://bugs.webkit.org/show_bug.cgi?id=233858
+
+        Reviewed by Alan Bujtas.
+
+        Make text box traversal work correctly in bidi context where encountering a different
+        layout box does not necessarily mean there are no further text boxes for the layout box.
+
+        * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
+        (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
+        (WebCore::Layout::InlineDisplayContentBuilder::computeIsFirstIsLastBoxForInlineContent):
+
+        Set the bits for all box types.
+
+        * layout/formattingContexts/inline/display/InlineDisplayBox.h:
+        (WebCore::InlineDisplay::Box::Box):
+        (WebCore::InlineDisplay::Box::isTextOrSoftLineBreak const):
+        (WebCore::InlineDisplay::Box::isFirstForLayoutBox const):
+        (WebCore::InlineDisplay::Box::isLastForLayoutBox const):
+        (WebCore::InlineDisplay::Box::setIsFirstForLayoutBox):
+        (WebCore::InlineDisplay::Box::setIsLastForLayoutBox):
+        (WebCore::InlineDisplay::Box::isFirstBox const): Deleted.
+        (WebCore::InlineDisplay::Box::isLastBox const): Deleted.
+        (WebCore::InlineDisplay::Box::setIsLastBox): Deleted.
+        (WebCore::InlineDisplay::Box::setIsFirstBox): Deleted.
+
+        Renamed for clarity and correctness.
+
+        * layout/integration/InlineIteratorBoxModernPath.h:
+        (WebCore::InlineIterator::BoxModernPath::isText const):
+        (WebCore::InlineIterator::BoxModernPath::traverseNextTextBox):
+
+        Use the isLastForLayoutBox bit to end the traversal.
+
+        (WebCore::InlineIterator::BoxModernPath::traverseNextInlineBox):
+        (WebCore::InlineIterator::BoxModernPath::traversePreviousInlineBox):
+        (WebCore::InlineIterator::BoxModernPath::traverseNextWithSameLayoutBox):
+        (WebCore::InlineIterator::BoxModernPath::traversePreviousWithSameLayoutBox):
+
+        Factor into helpers.
+
+        * layout/integration/InlineIteratorTextBox.h:
+
</ins><span class="cx"> 2021-12-05  Said Abou-Hallawa  <said@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [GPU Process] Add the encoding/decoding for Filter and FilterEffect
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlineInlineDisplayContentBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (286540 => 286541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp    2021-12-06 08:13:05 UTC (rev 286540)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp       2021-12-06 08:13:26 UTC (rev 286541)
</span><span class="lines">@@ -478,7 +478,7 @@
</span><span class="cx">                             auto lastDisplayBoxForInlineBoxIndex = inlineBoxDisplayBoxMap.take(inlineBox);
</span><span class="cx">                             auto isFirstFragment = !lastDisplayBoxForInlineBoxIndex;
</span><span class="cx">                             if (!isFirstFragment)
</span><del>-                                boxes[lastDisplayBoxForInlineBoxIndex].setIsLastBox(false);
</del><ins>+                                boxes[lastDisplayBoxForInlineBoxIndex].setIsLastForLayoutBox(false);
</ins><span class="cx">                             inlineBoxDisplayBoxMap.set(inlineBox, index);
</span><span class="cx"> 
</span><span class="cx">                             auto& boxGeometry = formattingState().boxGeometry(*inlineBox);
</span><span class="lines">@@ -534,13 +534,13 @@
</span><span class="cx"> 
</span><span class="cx">                 auto& boxGeometry = formattingState().boxGeometry(inlineBoxDisplayBox.layoutBox());
</span><span class="cx">                 auto contentRight = displayBox.logicalRight();
</span><del>-                if (inlineBoxDisplayBox.isLastBox()) {
</del><ins>+                if (inlineBoxDisplayBox.isLastForLayoutBox()) {
</ins><span class="cx">                     accumulatedOffset += boxGeometry.borderAndPaddingEnd() + boxGeometry.marginEnd();
</span><span class="cx">                     inlineBoxDisplayBox.setLogicalRight(contentRight + boxGeometry.borderAndPaddingEnd());
</span><span class="cx">                 } else
</span><span class="cx">                     inlineBoxDisplayBox.setLogicalRight(contentRight);
</span><span class="cx">             }
</span><del>-            if (displayBox.isNonRootInlineBox() && displayBox.isFirstBox()) {
</del><ins>+            if (displayBox.isNonRootInlineBox() && displayBox.isFirstForLayoutBox()) {
</ins><span class="cx">                 auto& layoutBox = displayBox.layoutBox();
</span><span class="cx">                 auto& boxGeometry = formattingState().boxGeometry(layoutBox);
</span><span class="cx"> 
</span><span class="lines">@@ -556,7 +556,7 @@
</span><span class="cx">         ASSERT(!inlineBoxRangeList.isEmpty());
</span><span class="cx">         for (auto& inlineBoxRange : inlineBoxRangeList) {
</span><span class="cx">             auto& inlineBoxDisplayBox = boxes[inlineBoxRange.begin()];
</span><del>-            setInlineBoxGeometry(inlineBoxDisplayBox.layoutBox(), inlineBoxDisplayBox.logicalRect(), inlineBoxDisplayBox.isFirstBox());
</del><ins>+            setInlineBoxGeometry(inlineBoxDisplayBox.layoutBox(), inlineBoxDisplayBox.logicalRect(), inlineBoxDisplayBox.isFirstForLayoutBox());
</ins><span class="cx">         }
</span><span class="cx">     };
</span><span class="cx">     if (needsNonRootInlineBoxDisplayBox)
</span><span class="lines">@@ -653,20 +653,26 @@
</span><span class="cx"> 
</span><span class="cx"> void InlineDisplayContentBuilder::computeIsFirstIsLastBoxForInlineContent(DisplayBoxes& boxes)
</span><span class="cx"> {
</span><del>-    HashMap<const Box*, size_t> lastDisplayBoxForInlineTextBoxIndexes;
</del><ins>+    HashMap<const Box*, size_t> lastDisplayBoxForLayoutBoxIndexes;
+
</ins><span class="cx">     ASSERT(boxes[0].isRootInlineBox());
</span><ins>+    boxes[0].setIsFirstForLayoutBox(true);
+    size_t lastRootInlineBoxIndex = 0;
+
</ins><span class="cx">     for (size_t index = 1; index < boxes.size(); ++index) {
</span><span class="cx">         auto& displayBox = boxes[index];
</span><del>-        // FIXME: Transition the inline box isFirst/isLast computation here as well.
-        if (!displayBox.isText())
</del><ins>+        if (displayBox.isRootInlineBox()) {
+            lastRootInlineBoxIndex = index;
</ins><span class="cx">             continue;
</span><ins>+        }
</ins><span class="cx">         auto& layoutBox = displayBox.layoutBox();
</span><del>-        if (!lastDisplayBoxForInlineTextBoxIndexes.contains(&layoutBox))
-            displayBox.setIsFirstBox(true);
-        lastDisplayBoxForInlineTextBoxIndexes.set(&layoutBox, index);
</del><ins>+        if (lastDisplayBoxForLayoutBoxIndexes.set(&layoutBox, index).isNewEntry)
+            displayBox.setIsFirstForLayoutBox(true);
</ins><span class="cx">     }
</span><del>-    for (auto lastDisplayBoxForInlineTextBoxIndex : lastDisplayBoxForInlineTextBoxIndexes)
-        boxes[lastDisplayBoxForInlineTextBoxIndex.value].setIsLastBox(true);
</del><ins>+    for (auto index : lastDisplayBoxForLayoutBoxIndexes.values())
+        boxes[index].setIsLastForLayoutBox(true);
+
+    boxes[lastRootInlineBoxIndex].setIsLastForLayoutBox(true);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutformattingContextsinlinedisplayInlineDisplayBoxh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h (286540 => 286541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h 2021-12-06 08:13:05 UTC (rev 286540)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayBox.h    2021-12-06 08:13:26 UTC (rev 286541)
</span><span class="lines">@@ -74,11 +74,12 @@
</span><span class="cx">         First = 1 << 0,
</span><span class="cx">         Last  = 1 << 1
</span><span class="cx">     };
</span><del>-    Box(size_t lineIndex, Type, const Layout::Box&, UBiDiLevel, const Layout::InlineRect&, const Layout::InlineRect& inkOverflow, Expansion, std::optional<Text> = std::nullopt, bool hasContent = true, OptionSet<PositionWithinInlineLevelBox> = { PositionWithinInlineLevelBox::First, PositionWithinInlineLevelBox::Last });
</del><ins>+    Box(size_t lineIndex, Type, const Layout::Box&, UBiDiLevel, const Layout::InlineRect&, const Layout::InlineRect& inkOverflow, Expansion, std::optional<Text> = std::nullopt, bool hasContent = true, OptionSet<PositionWithinInlineLevelBox> = { });
</ins><span class="cx"> 
</span><span class="cx">     bool isText() const { return m_type == Type::Text; }
</span><span class="cx">     bool isEllipsis() const { return m_type == Type::Ellipsis; }
</span><span class="cx">     bool isSoftLineBreak() const { return m_type == Type::SoftLineBreak; }
</span><ins>+    bool isTextOrSoftLineBreak() const { return isText() || isSoftLineBreak(); }
</ins><span class="cx">     bool isLineBreakBox() const { return m_type == Type::LineBreakBox; }
</span><span class="cx">     bool isLineBreak() const { return isSoftLineBreak() || isLineBreakBox(); }
</span><span class="cx">     bool isAtomicInlineLevelBox() const { return m_type == Type::AtomicInlineLevelBox; }
</span><span class="lines">@@ -105,8 +106,16 @@
</span><span class="cx">     Layout::InlineLayoutUnit logicalWidth() const { return logicalRect().width(); }
</span><span class="cx">     Layout::InlineLayoutUnit logicalHeight() const { return logicalRect().height(); }
</span><span class="cx"> 
</span><del>-    void moveVertically(Layout::InlineLayoutUnit offset) { m_logicalRect.moveVertically(offset); }
-    void moveHorizontally(Layout::InlineLayoutUnit offset) { m_logicalRect.moveHorizontally(offset); }
</del><ins>+    void moveVertically(Layout::InlineLayoutUnit offset)
+    {
+        m_logicalRect.moveVertically(offset);
+        m_inkOverflow.moveVertically(offset);
+    }
+    void moveHorizontally(Layout::InlineLayoutUnit offset)
+    {
+        m_logicalRect.moveHorizontally(offset);
+        m_inkOverflow.moveHorizontally(offset);
+    }
</ins><span class="cx">     void adjustInkOverflow(const Layout::InlineRect& childBorderBox) { return m_inkOverflow.expandToContain(childBorderBox); }
</span><span class="cx">     void truncate(Layout::InlineLayoutUnit truncatedwidth = 0.f);
</span><span class="cx">     void setLogicalRight(Layout::InlineLayoutUnit right) { m_logicalRect.setRight(right); }
</span><span class="lines">@@ -126,11 +135,11 @@
</span><span class="cx">     size_t lineIndex() const { return m_lineIndex; }
</span><span class="cx">     // These functions tell you whether this display box is the first/last for the associated inline level box (Layout::Box) and not whether it's the first/last box on the line.
</span><span class="cx">     // (e.g. always true for atomic boxes, but inline boxes spanning over multiple lines can produce individual first/last boxes).
</span><del>-    bool isFirstBox() const { return m_isFirstWithinInlineLevelBox; }
-    bool isLastBox() const { return m_isLastWithinInlineLevelBox; }
</del><ins>+    bool isFirstForLayoutBox() const { return m_isFirstForLayoutBox; }
+    bool isLastForLayoutBox() const { return m_isLastForLayoutBox; }
</ins><span class="cx"> 
</span><del>-    void setIsLastBox(bool isLastBox) { m_isLastWithinInlineLevelBox = isLastBox; }
-    void setIsFirstBox(bool isFirstBox) { m_isFirstWithinInlineLevelBox = isFirstBox; }
</del><ins>+    void setIsFirstForLayoutBox(bool isFirstBox) { m_isFirstForLayoutBox = isFirstBox; }
+    void setIsLastForLayoutBox(bool isLastBox) { m_isLastForLayoutBox = isLastBox; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     const size_t m_lineIndex { 0 };
</span><span class="lines">@@ -140,8 +149,8 @@
</span><span class="cx">     Layout::InlineRect m_logicalRect;
</span><span class="cx">     Layout::InlineRect m_inkOverflow;
</span><span class="cx">     bool m_hasContent : 1;
</span><del>-    bool m_isFirstWithinInlineLevelBox : 1;
-    bool m_isLastWithinInlineLevelBox : 1;
</del><ins>+    bool m_isFirstForLayoutBox : 1;
+    bool m_isLastForLayoutBox : 1;
</ins><span class="cx">     Expansion m_expansion;
</span><span class="cx">     std::optional<Text> m_text;
</span><span class="cx"> };
</span><span class="lines">@@ -154,8 +163,8 @@
</span><span class="cx">     , m_logicalRect(logicalRect)
</span><span class="cx">     , m_inkOverflow(inkOverflow)
</span><span class="cx">     , m_hasContent(hasContent)
</span><del>-    , m_isFirstWithinInlineLevelBox(positionWithinInlineLevelBox.contains(PositionWithinInlineLevelBox::First))
-    , m_isLastWithinInlineLevelBox(positionWithinInlineLevelBox.contains(PositionWithinInlineLevelBox::Last))
</del><ins>+    , m_isFirstForLayoutBox(positionWithinInlineLevelBox.contains(PositionWithinInlineLevelBox::First))
+    , m_isLastForLayoutBox(positionWithinInlineLevelBox.contains(PositionWithinInlineLevelBox::Last))
</ins><span class="cx">     , m_expansion(expansion)
</span><span class="cx">     , m_text(text)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationInlineIteratorBoxModernPathh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/InlineIteratorBoxModernPath.h (286540 => 286541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/InlineIteratorBoxModernPath.h    2021-12-06 08:13:05 UTC (rev 286540)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorBoxModernPath.h       2021-12-06 08:13:26 UTC (rev 286541)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx">     {
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    bool isText() const { return !!box().text(); }
</del><ins>+    bool isText() const { return box().isTextOrSoftLineBreak(); }
</ins><span class="cx">     bool isInlineBox() const { return box().isInlineBox(); }
</span><span class="cx">     bool isRootInlineBox() const { return box().isRootInlineBox(); }
</span><span class="cx"> 
</span><span class="lines">@@ -106,16 +106,16 @@
</span><span class="cx">     void traverseNextTextBox()
</span><span class="cx">     {
</span><span class="cx">         ASSERT(!atEnd());
</span><del>-        ASSERT(box().text());
</del><ins>+        ASSERT(box().isTextOrSoftLineBreak());
</ins><span class="cx"> 
</span><del>-        auto& layoutBox = box().layoutBox();
</del><ins>+        if (box().isLastForLayoutBox()) {
+            setAtEnd();
+            return;
+        }
</ins><span class="cx"> 
</span><del>-        traverseNextLeaf();
</del><ins>+        traverseNextWithSameLayoutBox();
</ins><span class="cx"> 
</span><del>-        if (!atEnd() && &layoutBox != &box().layoutBox())
-            setAtEnd();
-
-        ASSERT(atEnd() || box().text());
</del><ins>+        ASSERT(box().isTextOrSoftLineBreak());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     void traverseNextOnLine()
</span><span class="lines">@@ -144,36 +144,32 @@
</span><span class="cx"> 
</span><span class="cx">     void traverseNextInlineBox()
</span><span class="cx">     {
</span><ins>+        ASSERT(!atEnd());
</ins><span class="cx">         ASSERT(box().isInlineBox());
</span><span class="cx"> 
</span><del>-        if (box().isLastBox()) {
</del><ins>+        if (box().isLastForLayoutBox()) {
</ins><span class="cx">             setAtEnd();
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        auto& layoutBox = box().layoutBox();
-        do {
-            traverseNextBox();
-        } while (!atEnd() && &box().layoutBox() != &layoutBox);
</del><ins>+        traverseNextWithSameLayoutBox();
</ins><span class="cx"> 
</span><del>-        ASSERT(atEnd() || box().isInlineBox());
</del><ins>+        ASSERT(box().isInlineBox());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     void traversePreviousInlineBox()
</span><span class="cx">     {
</span><ins>+        ASSERT(!atEnd());
</ins><span class="cx">         ASSERT(box().isInlineBox());
</span><span class="cx"> 
</span><del>-        if (box().isFirstBox()) {
</del><ins>+        if (box().isFirstForLayoutBox()) {
</ins><span class="cx">             setAtEnd();
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        auto& layoutBox = box().layoutBox();
-        do {
-            traversePreviousBox();
-        } while (!atEnd() && &box().layoutBox() != &layoutBox);
</del><ins>+        traversePreviousWithSameLayoutBox();
</ins><span class="cx"> 
</span><del>-        ASSERT(atEnd() || box().isInlineBox());
</del><ins>+        ASSERT(box().isInlineBox());
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     BoxModernPath firstLeafBoxForInlineBox() const
</span><span class="lines">@@ -249,6 +245,22 @@
</span><span class="cx">         } while (!atEnd() && box().isInlineBox());
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    void traverseNextWithSameLayoutBox()
+    {
+        auto& layoutBox = box().layoutBox();
+        do {
+            traverseNextBox();
+        } while (!atEnd() && &box().layoutBox() != &layoutBox);
+    }
+
+    void traversePreviousWithSameLayoutBox()
+    {
+        auto& layoutBox = box().layoutBox();
+        do {
+            traversePreviousBox();
+        } while (!atEnd() && &box().layoutBox() != &layoutBox);
+    }
+
</ins><span class="cx">     void setAtEnd() { m_boxIndex = boxes().size(); }
</span><span class="cx"> 
</span><span class="cx">     const LayoutIntegration::InlineContent::Boxes& boxes() const { return m_inlineContent->boxes; }
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationInlineIteratorTextBoxh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/InlineIteratorTextBox.h (286540 => 286541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/InlineIteratorTextBox.h  2021-12-06 08:13:05 UTC (rev 286540)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorTextBox.h     2021-12-06 08:13:26 UTC (rev 286541)
</span><span class="lines">@@ -59,8 +59,8 @@
</span><span class="cx">     // FIXME: Remove. For intermediate porting steps only.
</span><span class="cx">     const LegacyInlineTextBox* legacyInlineBox() const { return downcast<LegacyInlineTextBox>(Box::legacyInlineBox()); }
</span><span class="cx"> 
</span><ins>+    // This returns the next text box generated for the same RenderText/Layout::InlineTextBox.
</ins><span class="cx">     TextBoxIterator nextTextBox() const;
</span><del>-    TextBoxIterator previousTextBox() const;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class TextBoxIterator : public LeafBoxIterator {
</span><span class="lines">@@ -74,6 +74,7 @@
</span><span class="cx">     const TextBox& operator*() const { return get(); }
</span><span class="cx">     const TextBox* operator->() const { return &get(); }
</span><span class="cx"> 
</span><ins>+    // This traverses to the next text box generated for the same RenderText/Layout::InlineTextBox.
</ins><span class="cx">     TextBoxIterator& traverseNextTextBox();
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebCorelayoutintegrationLayoutIntegrationPaginationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp (286540 => 286541)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp  2021-12-06 08:13:05 UTC (rev 286540)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationPagination.cpp     2021-12-06 08:13:26 UTC (rev 286541)
</span><span class="lines">@@ -142,16 +142,9 @@
</span><span class="cx"> 
</span><span class="cx">     auto adjustedBox = [&](const InlineDisplay::Box& box, float offset)
</span><span class="cx">     {
</span><del>-        return InlineDisplay::Box {
-            box.lineIndex(),
-            box.type(),
-            box.layoutBox(),
-            box.bidiLevel(),
-            moveVertically(box.logicalRect(), offset),
-            moveVertically(box.inkOverflow(), offset),
-            box.expansion(),
-            box.text()
-        };
</del><ins>+        auto adjustedBox = box;
+        adjustedBox.moveVertically(offset);
+        return adjustedBox;
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx">     auto adjustedContent = InlineContent::create(inlineContent.lineLayout());
</span></span></pre>
</div>
</div>

</body>
</html>