Title: [287271] trunk/Source/WebCore
Revision
287271
Author
[email protected]
Date
2021-12-20 12:17:09 -0800 (Mon, 20 Dec 2021)

Log Message

[LFC][IFC] Move display builder files under /display directory
https://bugs.webkit.org/show_bug.cgi?id=234517

Reviewed by Antti Koivisto.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp: Renamed from Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp.
* layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h: Renamed from Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.h.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287270 => 287271)


--- trunk/Source/WebCore/ChangeLog	2021-12-20 20:12:52 UTC (rev 287270)
+++ trunk/Source/WebCore/ChangeLog	2021-12-20 20:17:09 UTC (rev 287271)
@@ -1,3 +1,15 @@
+2021-12-20  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] Move display builder files under /display directory
+        https://bugs.webkit.org/show_bug.cgi?id=234517
+
+        Reviewed by Antti Koivisto.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp: Renamed from Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp.
+        * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h: Renamed from Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.h.
+
 2021-12-20  Patrick Griffis  <[email protected]>
 
         CSP: Always use UTF-8 encoded content when checking hashes

Modified: trunk/Source/WebCore/Sources.txt (287270 => 287271)


--- trunk/Source/WebCore/Sources.txt	2021-12-20 20:12:52 UTC (rev 287270)
+++ trunk/Source/WebCore/Sources.txt	2021-12-20 20:17:09 UTC (rev 287271)
@@ -1555,7 +1555,6 @@
 layout/floats/FloatingContext.cpp
 layout/floats/FloatingState.cpp
 layout/formattingContexts/inline/InlineContentBreaker.cpp
-layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp
 layout/formattingContexts/inline/InlineFormattingContext.cpp
 layout/formattingContexts/inline/InlineFormattingGeometry.cpp
 layout/formattingContexts/inline/InlineFormattingQuirks.cpp
@@ -1568,6 +1567,7 @@
 layout/formattingContexts/inline/InlineLineBuilder.cpp
 layout/formattingContexts/inline/InlineLineBoxVerticalAligner.cpp
 layout/formattingContexts/inline/InlineTextItem.cpp
+layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp
 layout/formattingContexts/inline/invalidation/InlineInvalidation.cpp
 layout/formattingContexts/inline/text/TextUtil.cpp
 layout/integration/InlineIteratorBox.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (287270 => 287271)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-12-20 20:12:52 UTC (rev 287270)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-12-20 20:17:09 UTC (rev 287271)
@@ -19220,8 +19220,6 @@
 				6FE7DDDD20EC6E8B008B5B4E /* text */,
 				6FE198132178397B00446F08 /* InlineContentBreaker.cpp */,
 				6FE198152178397C00446F08 /* InlineContentBreaker.h */,
-				11513D0026D981DD004D3FAA /* InlineDisplayContentBuilder.cpp */,
-				11513D0226D981E7004D3FAA /* InlineDisplayContentBuilder.h */,
 				6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */,
 				6F7CA3C8208C2B2E002F29AB /* InlineFormattingContext.h */,
 				6F35EFAF2187CBD50044E0F4 /* InlineFormattingGeometry.cpp */,
@@ -19257,6 +19255,8 @@
 			isa = PBXGroup;
 			children = (
 				6FC3F9452516756600A49BEA /* InlineDisplayBox.h */,
+				11513D0026D981DD004D3FAA /* InlineDisplayContentBuilder.cpp */,
+				11513D0226D981E7004D3FAA /* InlineDisplayContentBuilder.h */,
 				6F91420F25152137004E4FEA /* InlineDisplayLine.h */,
 			);
 			path = display;

Deleted: trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (287270 => 287271)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-12-20 20:12:52 UTC (rev 287270)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-12-20 20:17:09 UTC (rev 287271)
@@ -1,767 +0,0 @@
-/*
- * 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 "InlineDisplayContentBuilder.h"
-
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-
-#include "FontCascade.h"
-#include "LayoutBoxGeometry.h"
-#include "LayoutInitialContainingBlock.h"
-#include "RuntimeEnabledFeatures.h"
-#include "TextUtil.h"
-#include <wtf/ListHashSet.h>
-#include <wtf/Range.h>
-
-using WTF::Range;
-
-namespace WebCore {
-namespace Layout {
-
-static inline LayoutUnit marginLeft(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
-{
-    return isLeftToRightDirection ? boxGeometry.marginStart() : boxGeometry.marginEnd();
-}
-
-static inline LayoutUnit marginRight(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
-{
-    return isLeftToRightDirection ? boxGeometry.marginEnd() : boxGeometry.marginStart();
-}
-
-static inline LayoutUnit borderLeft(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
-{
-    return isLeftToRightDirection ? boxGeometry.borderStart() : boxGeometry.borderEnd();
-}
-
-static inline LayoutUnit borderRight(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
-{
-    return isLeftToRightDirection ? boxGeometry.borderEnd() : boxGeometry.borderStart();
-}
-
-static inline LayoutUnit paddingLeft(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
-{
-    return isLeftToRightDirection ? boxGeometry.paddingStart().value_or(0_lu) : boxGeometry.paddingEnd().value_or(0_lu);
-}
-
-static inline LayoutUnit paddingRight(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
-{
-    return isLeftToRightDirection ? boxGeometry.paddingEnd().value_or(0_lu) : boxGeometry.paddingStart().value_or(0_lu);
-}
-
-static inline OptionSet<InlineDisplay::Box::PositionWithinInlineLevelBox> isFirstLastBox(const InlineLevelBox& inlineBox)
-{
-    auto positionWithinInlineLevelBox = OptionSet<InlineDisplay::Box::PositionWithinInlineLevelBox> { };
-    if (inlineBox.isFirstBox())
-        positionWithinInlineLevelBox.add(InlineDisplay::Box::PositionWithinInlineLevelBox::First);
-    if (inlineBox.isLastBox())
-        positionWithinInlineLevelBox.add(InlineDisplay::Box::PositionWithinInlineLevelBox::Last);
-    return positionWithinInlineLevelBox;
-}
-
-InlineDisplayContentBuilder::InlineDisplayContentBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState& formattingState)
-    : m_formattingContextRoot(formattingContextRoot)
-    , m_formattingState(formattingState)
-{
-}
-
-DisplayBoxes InlineDisplayContentBuilder::build(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineRect& lineBoxLogicalRect, const size_t lineIndex)
-{
-    DisplayBoxes boxes;
-    boxes.reserveInitialCapacity(lineContent.runs.size() + lineBox.nonRootInlineLevelBoxes().size() + 1);
-
-    m_lineIndex = lineIndex;
-    // Every line starts with a root box, even the empty ones.
-    auto rootInlineBoxRect = lineBox.logicalRectForRootInlineBox();
-    rootInlineBoxRect.moveBy(lineBoxLogicalRect.topLeft());
-    boxes.append({ m_lineIndex, InlineDisplay::Box::Type::RootInlineBox, root(), UBIDI_DEFAULT_LTR, rootInlineBoxRect, rootInlineBoxRect, { }, { }, lineBox.rootInlineBox().hasContent() });
-
-    auto contentNeedsBidiReordering = !lineContent.visualOrderList.isEmpty();
-    if (contentNeedsBidiReordering)
-        processBidiContent(lineContent, lineBox, lineBoxLogicalRect.topLeft(), boxes);
-    else
-        processNonBidiContent(lineContent, lineBox, lineBoxLogicalRect.topLeft(), boxes);
-    processOverflownRunsForEllipsis(boxes, lineBoxLogicalRect.right());
-    collectInkOverflowForInlineBoxes(boxes);
-    return boxes;
-}
-
-static inline bool computeBoxShadowInkOverflow(const RenderStyle& style, InlineRect& inkOverflow)
-{
-    auto topBoxShadow = LayoutUnit { };
-    auto bottomBoxShadow = LayoutUnit { };
-    style.getBoxShadowBlockDirectionExtent(topBoxShadow, bottomBoxShadow);
-
-    auto leftBoxShadow = LayoutUnit { };
-    auto rightBoxShadow = LayoutUnit { };
-    style.getBoxShadowInlineDirectionExtent(leftBoxShadow, rightBoxShadow);
-    if (!topBoxShadow && !bottomBoxShadow && !leftBoxShadow && !rightBoxShadow)
-        return false;
-    inkOverflow.inflate(InlineLayoutUnit { topBoxShadow }, InlineLayoutUnit { rightBoxShadow }, InlineLayoutUnit { bottomBoxShadow }, InlineLayoutUnit { leftBoxShadow });
-    return true;
-}
-
-void InlineDisplayContentBuilder::appendTextDisplayBox(const Line::Run& lineRun, const InlineRect& textRunRect, DisplayBoxes& boxes)
-{
-    ASSERT(lineRun.textContent() && is<InlineTextBox>(lineRun.layoutBox()));
-
-    auto& layoutBox = lineRun.layoutBox();
-    auto& style = !m_lineIndex ? layoutBox.firstLineStyle() : layoutBox.style();
-
-    auto inkOverflow = [&] {
-        auto initialContaingBlockSize = RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()
-            ? formattingState().layoutState().viewportSize()
-            : formattingState().layoutState().geometryForBox(layoutBox.initialContainingBlock()).contentBox().size();
-        auto strokeOverflow = ceilf(style.computedStrokeWidth(ceiledIntSize(initialContaingBlockSize)));
-        auto inkOverflow = textRunRect;
-        inkOverflow.inflate(strokeOverflow);
-        auto letterSpacing = style.fontCascade().letterSpacing();
-        if (letterSpacing < 0) {
-            // Last letter's negative spacing shrinks logical rect. Push it to ink overflow.
-            inkOverflow.expand(-letterSpacing, { });
-        }
-        return inkOverflow;
-    };
-    auto content = downcast<InlineTextBox>(layoutBox).content();
-    auto text = lineRun.textContent();
-    auto adjustedContentToRender = [&] {
-        return text->needsHyphen ? makeString(content.substring(text->start, text->length), style.hyphenString()) : String();
-    };
-    boxes.append({ m_lineIndex
-        , InlineDisplay::Box::Type::Text
-        , layoutBox
-        , lineRun.bidiLevel()
-        , textRunRect
-        , inkOverflow()
-        , lineRun.expansion()
-        , InlineDisplay::Box::Text { text->start, text->length, content, adjustedContentToRender(), text->needsHyphen }
-        , true
-        , { }
-    });
-}
-
-void InlineDisplayContentBuilder::appendSoftLineBreakDisplayBox(const Line::Run& lineRun, const InlineRect& softLineBreakRunRect, DisplayBoxes& boxes)
-{
-    ASSERT(lineRun.textContent() && is<InlineTextBox>(lineRun.layoutBox()));
-
-    auto& layoutBox = lineRun.layoutBox();
-    auto& text = lineRun.textContent();
-
-    boxes.append({ m_lineIndex
-        , InlineDisplay::Box::Type::SoftLineBreak
-        , layoutBox
-        , lineRun.bidiLevel()
-        , softLineBreakRunRect
-        , softLineBreakRunRect
-        , lineRun.expansion()
-        , InlineDisplay::Box::Text { text->start, text->length, downcast<InlineTextBox>(layoutBox).content() }
-    });
-}
-
-void InlineDisplayContentBuilder::appendHardLineBreakDisplayBox(const Line::Run& lineRun, const InlineRect& lineBreakBoxRect, DisplayBoxes& boxes)
-{
-    auto& layoutBox = lineRun.layoutBox();
-
-    boxes.append({ m_lineIndex
-        , InlineDisplay::Box::Type::LineBreakBox
-        , layoutBox
-        , lineRun.bidiLevel()
-        , lineBreakBoxRect
-        , lineBreakBoxRect
-        , lineRun.expansion()
-        , { }
-    });
-
-    auto& boxGeometry = formattingState().boxGeometry(layoutBox);
-    boxGeometry.setLogicalTopLeft(toLayoutPoint(lineBreakBoxRect.topLeft()));
-    boxGeometry.setContentBoxHeight(toLayoutUnit(lineBreakBoxRect.height()));
-}
-
-void InlineDisplayContentBuilder::appendAtomicInlineLevelDisplayBox(const Line::Run& lineRun, const InlineRect& borderBoxRect, DisplayBoxes& boxes)
-{
-    ASSERT(lineRun.layoutBox().isAtomicInlineLevelBox());
-
-    auto& layoutBox = lineRun.layoutBox();
-    auto inkOverflow = [&] {
-        auto inkOverflow = borderBoxRect;
-        computeBoxShadowInkOverflow(!m_lineIndex ? layoutBox.firstLineStyle() : layoutBox.style(), inkOverflow);
-        // Atomic inline box contribute to their inline box parents ink overflow at all times (e.g. <span><img></span>).
-        m_contentHasInkOverflow = m_contentHasInkOverflow || &layoutBox.parent() != &root();
-        return inkOverflow;
-    };
-    boxes.append({ m_lineIndex
-        , InlineDisplay::Box::Type::AtomicInlineLevelBox
-        , layoutBox
-        , lineRun.bidiLevel()
-        , borderBoxRect
-        , inkOverflow()
-        , lineRun.expansion()
-        , { }
-    });
-    // Note that inline boxes are relative to the line and their top position can be negative.
-    // Atomic inline boxes are all set. Their margin/border/content box geometries are already computed. We just have to position them here.
-    formattingState().boxGeometry(layoutBox).setLogicalTopLeft(toLayoutPoint(borderBoxRect.topLeft()));
-}
-
-void InlineDisplayContentBuilder::setInlineBoxGeometry(const Box& layoutBox, const InlineRect& rect, bool isFirstInlineBoxFragment)
-{
-    auto adjustedSize = LayoutSize { LayoutUnit::fromFloatCeil(rect.width()), LayoutUnit::fromFloatCeil(rect.height()) };
-    auto adjustedRect = Rect { LayoutPoint { rect.topLeft() }, adjustedSize };
-    auto& boxGeometry = formattingState().boxGeometry(layoutBox);
-    if (!isFirstInlineBoxFragment) {
-        auto enclosingBorderBoxRect = BoxGeometry::borderBoxRect(boxGeometry);
-        enclosingBorderBoxRect.expandToContain(adjustedRect);
-        adjustedRect = enclosingBorderBoxRect;
-    }
-    boxGeometry.setLogicalTopLeft(adjustedRect.topLeft());
-    auto contentBoxHeight = adjustedRect.height() - (boxGeometry.verticalBorder() + boxGeometry.verticalPadding().value_or(0_lu));
-    auto contentBoxWidth = adjustedRect.width() - (boxGeometry.horizontalBorder() + boxGeometry.horizontalPadding().value_or(0_lu));
-    boxGeometry.setContentBoxHeight(contentBoxHeight);
-    boxGeometry.setContentBoxWidth(contentBoxWidth);
-}
-
-void InlineDisplayContentBuilder::appendInlineBoxDisplayBox(const Line::Run& lineRun, const InlineLevelBox& inlineBox, const InlineRect& inlineBoxBorderBox, bool linehasContent, DisplayBoxes& boxes)
-{
-    ASSERT(lineRun.layoutBox().isInlineBox());
-
-    auto& layoutBox = lineRun.layoutBox();
-
-    if (!linehasContent) {
-        // FIXME: It's expected to not have any boxes on empty lines. We should reconsider this.
-        setInlineBoxGeometry(layoutBox, inlineBoxBorderBox, true);
-        return;
-    }
-
-    auto inkOverflow = [&] {
-        auto inkOverflow = inlineBoxBorderBox;
-        m_contentHasInkOverflow = computeBoxShadowInkOverflow(!m_lineIndex ? layoutBox.firstLineStyle() : layoutBox.style(), inkOverflow) || m_contentHasInkOverflow;
-        return inkOverflow;
-    };
-    ASSERT(inlineBox.isInlineBox());
-    ASSERT(inlineBox.isFirstBox());
-    boxes.append({ m_lineIndex
-        , InlineDisplay::Box::Type::NonRootInlineBox
-        , layoutBox
-        , lineRun.bidiLevel()
-        , inlineBoxBorderBox
-        , inkOverflow()
-        , { }
-        , { }
-        , inlineBox.hasContent()
-        , isFirstLastBox(inlineBox)
-    });
-    // This inline box showed up first on this line.
-    setInlineBoxGeometry(layoutBox, inlineBoxBorderBox, true);
-}
-
-void InlineDisplayContentBuilder::appendSpanningInlineBoxDisplayBox(const Line::Run& lineRun, const InlineLevelBox& inlineBox, const InlineRect& inlineBoxBorderBox, DisplayBoxes& boxes)
-{
-    ASSERT(lineRun.layoutBox().isInlineBox());
-
-    auto& layoutBox = lineRun.layoutBox();
-    auto inkOverflow = [&] {
-        auto inkOverflow = inlineBoxBorderBox;
-        m_contentHasInkOverflow = computeBoxShadowInkOverflow(!m_lineIndex ? layoutBox.firstLineStyle() : layoutBox.style(), inkOverflow) || m_contentHasInkOverflow;
-        return inkOverflow;
-    };
-    ASSERT(!inlineBox.isFirstBox());
-    boxes.append({ m_lineIndex
-        , InlineDisplay::Box::Type::NonRootInlineBox
-        , layoutBox
-        , lineRun.bidiLevel()
-        , inlineBoxBorderBox
-        , inkOverflow()
-        , { }
-        , { }
-        , inlineBox.hasContent()
-        , isFirstLastBox(inlineBox)
-    });
-    // Middle or end of the inline box. Let's stretch the box as needed.
-    setInlineBoxGeometry(layoutBox, inlineBoxBorderBox, false);
-}
-
-void InlineDisplayContentBuilder::appendInlineDisplayBoxAtBidiBoundary(const Box& layoutBox, DisplayBoxes& boxes)
-{
-    // Geometries for inline boxes at bidi boundaries are computed at a post-process step.
-    boxes.append({ m_lineIndex
-        , InlineDisplay::Box::Type::NonRootInlineBox
-        , layoutBox
-        , UBIDI_DEFAULT_LTR
-        , { }
-        , { }
-        , { }
-        , { }
-    });
-}
-
-void InlineDisplayContentBuilder::processNonBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxLogicalTopLeft, DisplayBoxes& boxes)
-{
-    auto rootInlineBoxWidth = lineBox.logicalRectForRootInlineBox().width();
-    auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();
-    auto needsDirectionAdjustment = !root().style().isLeftToRightDirection();
-
-    for (auto& lineRun : lineContent.runs) {
-        auto& layoutBox = lineRun.layoutBox();
-
-        auto visualRectRelativeToRoot = [&](auto logicalRect) {
-            // When the logical order == visual order, RTL inline direction is just an offset.
-            auto horizontalOffset = needsDirectionAdjustment ? lineContent.lineLogicalWidth - rootInlineBoxWidth - rootInlineBoxAlignmentOffset : rootInlineBoxAlignmentOffset;
-            logicalRect.moveBy({ lineBoxLogicalTopLeft.x() + horizontalOffset, lineBoxLogicalTopLeft.y() });
-            return logicalRect;
-        };
-
-        if (lineRun.isText()) {
-            appendTextDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)), boxes);
-            continue;
-        }
-        if (lineRun.isSoftLineBreak()) {
-            appendSoftLineBreakDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)), boxes);
-            continue;
-        }
-        if (lineRun.isHardLineBreak()) {
-            appendHardLineBreakDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForLineBreakBox(layoutBox)), boxes);
-            continue;
-        }
-        if (lineRun.isBox()) {
-            appendAtomicInlineLevelDisplayBox(lineRun
-                , visualRectRelativeToRoot(lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, formattingState().boxGeometry(layoutBox)))
-                , boxes);
-            continue;
-        }
-        if (lineRun.isInlineBoxStart()) {
-            appendInlineBoxDisplayBox(lineRun
-                , lineBox.inlineLevelBoxForLayoutBox(lineRun.layoutBox())
-                , visualRectRelativeToRoot(lineBox.logicalBorderBoxForInlineBox(layoutBox, formattingState().boxGeometry(layoutBox)))
-                , lineBox.hasContent()
-                , boxes);
-            continue;
-        }
-        if (lineRun.isLineSpanningInlineBoxStart()) {
-            if (!lineBox.hasContent()) {
-                // When a spanning inline box (e.g. <div>text<span><br></span></div>) lands on an empty line
-                // (empty here means no content at all including line breaks, not just visually empty) then we
-                // don't extend the spanning line box over to this line -also there is no next line in cases like this.
-                continue;
-            }
-            appendSpanningInlineBoxDisplayBox(lineRun
-                , lineBox.inlineLevelBoxForLayoutBox(lineRun.layoutBox())
-                , visualRectRelativeToRoot(lineBox.logicalBorderBoxForInlineBox(layoutBox, formattingState().boxGeometry(layoutBox)))
-                , boxes);
-            continue;
-        }
-        ASSERT(lineRun.isInlineBoxEnd() || lineRun.isWordBreakOpportunity());
-    }
-}
-
-struct DisplayBoxTree {
-public:
-    struct Node {
-        // Node's parent index in m_displayBoxNodes.
-        std::optional<size_t> parentIndex;
-        // Associated display box index in DisplayBoxes.
-        size_t displayBoxIndex { 0 };
-        // Child indexes in m_displayBoxNodes.
-        Vector<size_t> children { };
-    };
-
-    DisplayBoxTree()
-    {
-        m_displayBoxNodes.append({ });
-    }
-
-    bool hasInlineBox() const { return m_displayBoxNodes.size() > 1; }
-    const Node& root() const { return m_displayBoxNodes.first(); }
-    Node& at(size_t index) { return m_displayBoxNodes[index]; }
-    const Node& at(size_t index) const { return m_displayBoxNodes[index]; }
-
-    size_t append(size_t parentNodeIndex, size_t childDisplayBoxIndex)
-    {
-        auto childDisplayBoxNodeIndex = m_displayBoxNodes.size();
-        m_displayBoxNodes.append({ parentNodeIndex, childDisplayBoxIndex });
-        at(parentNodeIndex).children.append(childDisplayBoxNodeIndex);
-        return childDisplayBoxNodeIndex;
-    }
-
-private:
-    Vector<Node, 10> m_displayBoxNodes;
-};
-
-struct AncestorStack {
-    std::optional<size_t> unwind(const ContainerBox& containerBox)
-    {
-        // Unwind the stack all the way to container box.
-        if (!m_set.contains(&containerBox))
-            return { };
-        while (m_set.last() != &containerBox) {
-            m_stack.removeLast();
-            m_set.removeLast();
-        }
-        // Root is always a common ancestor.
-        ASSERT(!m_stack.isEmpty());
-        return m_stack.last();
-    }
-
-    void push(size_t displayBoxNodeIndexForContainerBox, const ContainerBox& containerBox)
-    {
-        m_stack.append(displayBoxNodeIndexForContainerBox);
-        ASSERT(!m_set.contains(&containerBox));
-        m_set.add(&containerBox);
-    }
-
-private:
-    Vector<size_t> m_stack;
-    ListHashSet<const ContainerBox*> m_set;
-};
-
-static inline size_t createdDisplayBoxNodeForContainerBoxAndPushToAncestorStack(const ContainerBox& containerBox, size_t displayBoxIndex, size_t parentDisplayBoxNodeIndex, DisplayBoxTree& displayBoxTree, AncestorStack& ancestorStack)
-{
-    auto displayBoxNodeIndex = displayBoxTree.append(parentDisplayBoxNodeIndex, displayBoxIndex);
-    ancestorStack.push(displayBoxNodeIndex, containerBox);
-    return displayBoxNodeIndex;
-}
-
-size_t InlineDisplayContentBuilder::ensureDisplayBoxForContainer(const ContainerBox& containerBox, DisplayBoxTree& displayBoxTree, AncestorStack& ancestorStack, DisplayBoxes& boxes)
-{
-    ASSERT(containerBox.isInlineBox() || &containerBox == &root());
-    if (auto lowestCommonAncestorIndex = ancestorStack.unwind(containerBox))
-        return *lowestCommonAncestorIndex;
-    auto enclosingDisplayBoxNodeIndexForContainer = ensureDisplayBoxForContainer(containerBox.parent(), displayBoxTree, ancestorStack, boxes);
-    appendInlineDisplayBoxAtBidiBoundary(containerBox, boxes);
-    return createdDisplayBoxNodeForContainerBoxAndPushToAncestorStack(containerBox, boxes.size() - 1, enclosingDisplayBoxNodeIndexForContainer, displayBoxTree, ancestorStack);
-}
-
-struct IsFirstLastIndex {
-    std::optional<size_t> first;
-    std::optional<size_t> last;
-};
-using IsFirstLastIndexesMap = HashMap<const Box*, IsFirstLastIndex>;
-void InlineDisplayContentBuilder::adjustVisualGeometryForDisplayBox(size_t displayBoxNodeIndex, InlineLayoutUnit& contentRightInVisualOrder, InlineLayoutUnit lineBoxLogicalTop, const DisplayBoxTree& displayBoxTree, DisplayBoxes& boxes, const LineBox& lineBox, const IsFirstLastIndexesMap& isFirstLastIndexesMap)
-{
-    // Non-inline box display boxes just need a horizontal adjustment while
-    // inline box type of display boxes need
-    // 1. horizontal adjustment and margin/border/padding start offsetting on the first box
-    // 2. right edge computation including descendant content width and margin/border/padding end offsetting on the last box
-    auto& displayBox = boxes[displayBoxTree.at(displayBoxNodeIndex).displayBoxIndex];
-    auto& layoutBox = displayBox.layoutBox();
-
-    if (!displayBox.isNonRootInlineBox()) {
-        if (displayBox.isAtomicInlineLevelBox() || displayBox.isGenericInlineLevelBox()) {
-            auto isLeftToRightDirection = layoutBox.parent().style().isLeftToRightDirection();
-            auto& boxGeometry = formattingState().boxGeometry(layoutBox);
-            auto boxMarginLeft = marginLeft(boxGeometry, isLeftToRightDirection);
-            auto boxMarginRight = marginRight(boxGeometry, isLeftToRightDirection);
-
-            auto borderBoxLeft = LayoutUnit { contentRightInVisualOrder + boxMarginLeft };
-            boxGeometry.setLogicalLeft(borderBoxLeft);
-            displayBox.setLeft(borderBoxLeft);
-
-            contentRightInVisualOrder += boxMarginLeft + displayBox.width() + boxMarginRight;
-        } else {
-            displayBox.setLeft(contentRightInVisualOrder);
-            contentRightInVisualOrder += displayBox.width();
-        }
-        return;
-    }
-
-    auto& boxGeometry = formattingState().boxGeometry(layoutBox);
-    auto isLeftToRightDirection = layoutBox.style().isLeftToRightDirection();
-    auto isFirstLastIndexes = isFirstLastIndexesMap.get(&layoutBox);
-    auto isFirstBox = isFirstLastIndexes.first && *isFirstLastIndexes.first == displayBoxNodeIndex;
-    auto isLastBox = isFirstLastIndexes.last && *isFirstLastIndexes.last == displayBoxNodeIndex;
-    auto beforeInlineBoxContent = [&] {
-        auto logicalRect = lineBox.logicalBorderBoxForInlineBox(layoutBox, boxGeometry);
-        auto visualRect = InlineRect { lineBoxLogicalTop + logicalRect.top(), contentRightInVisualOrder, { }, logicalRect.height() };
-        auto shouldApplyLeftSide = (isLeftToRightDirection && isFirstBox) || (!isLeftToRightDirection && isLastBox);
-        if (!shouldApplyLeftSide)
-            return displayBox.setRect(visualRect, visualRect);
-
-        contentRightInVisualOrder += marginLeft(boxGeometry, isLeftToRightDirection);
-        auto visualRectWithMarginLeft = InlineRect { visualRect.top(), contentRightInVisualOrder, visualRect.width(), visualRect.height() };
-        displayBox.setRect(visualRectWithMarginLeft, visualRectWithMarginLeft);
-        contentRightInVisualOrder += borderLeft(boxGeometry, isLeftToRightDirection) + paddingLeft(boxGeometry, isLeftToRightDirection);
-    };
-    beforeInlineBoxContent();
-
-    for (auto childDisplayBoxNodeIndex : displayBoxTree.at(displayBoxNodeIndex).children)
-        adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBoxLogicalTop, displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
-
-    auto afterInlineBoxContent = [&] {
-        auto shouldApplyRightSide = (isLeftToRightDirection && isLastBox) || (!isLeftToRightDirection && isFirstBox);
-        if (!shouldApplyRightSide)
-            return displayBox.setRight(contentRightInVisualOrder);
-
-        contentRightInVisualOrder += borderRight(boxGeometry, isLeftToRightDirection) + paddingRight(boxGeometry, isLeftToRightDirection);
-        displayBox.setRight(contentRightInVisualOrder);
-        contentRightInVisualOrder += marginRight(boxGeometry, isLeftToRightDirection);
-    };
-    afterInlineBoxContent();
-
-    auto computeInkOverflow = [&] {
-        auto inkOverflow = displayBox.rect();
-        m_contentHasInkOverflow = computeBoxShadowInkOverflow(!m_lineIndex ? layoutBox.firstLineStyle() : layoutBox.style(), inkOverflow) || m_contentHasInkOverflow;
-        displayBox.adjustInkOverflow(inkOverflow);
-    };
-    computeInkOverflow();
-
-    setInlineBoxGeometry(layoutBox, displayBox.rect(), isFirstBox);
-    if (lineBox.inlineLevelBoxForLayoutBox(layoutBox).hasContent())
-        displayBox.setHasContent();
-}
-
-void InlineDisplayContentBuilder::processBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxLogicalTopLeft, DisplayBoxes& boxes)
-{
-    ASSERT(lineContent.visualOrderList.size() <= lineContent.runs.size());
-
-    AncestorStack ancestorStack;
-    auto displayBoxTree = DisplayBoxTree { };
-    ancestorStack.push({ }, root());
-
-    auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();
-    auto contentStartInVisualOrder = rootInlineBoxAlignmentOffset;
-    auto createDisplayBoxesInVisualOrder = [&] {
-        // First visual run's initial content position depends on the block's inline direction.
-        if (!root().style().isLeftToRightDirection())
-            contentStartInVisualOrder = lineContent.lineLogicalWidth - lineBox.logicalRectForRootInlineBox().width() - rootInlineBoxAlignmentOffset;
-
-        auto contentRightInVisualOrder = contentStartInVisualOrder;
-        auto& runs = lineContent.runs;
-        for (auto visualOrder : lineContent.visualOrderList) {
-            ASSERT(runs[visualOrder].bidiLevel() != InlineItem::opaqueBidiLevel);
-
-            auto& lineRun = runs[visualOrder];
-            auto& layoutBox = lineRun.layoutBox();
-
-            auto needsDisplayBox = !lineRun.isWordBreakOpportunity() && !lineRun.isInlineBoxEnd();
-            if (!needsDisplayBox)
-                continue;
-
-            auto visualRectRelativeToRoot = [&](auto logicalRect) {
-                logicalRect.setLeft(contentRightInVisualOrder);
-                logicalRect.moveBy(lineBoxLogicalTopLeft);
-                return logicalRect;
-            };
-
-            auto parentDisplayBoxNodeIndex = ensureDisplayBoxForContainer(layoutBox.parent(), displayBoxTree, ancestorStack, boxes);
-            if (lineRun.isText()) {
-                auto visualRect = visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun));
-                appendTextDisplayBox(lineRun, visualRect, boxes);
-                contentRightInVisualOrder += visualRect.width();
-                displayBoxTree.append(parentDisplayBoxNodeIndex, boxes.size() - 1);
-                continue;
-            }
-            if (lineRun.isSoftLineBreak()) {
-                ASSERT(!visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)).width());
-                appendSoftLineBreakDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)), boxes);
-                displayBoxTree.append(parentDisplayBoxNodeIndex, boxes.size() - 1);
-                continue;
-            }
-            if (lineRun.isHardLineBreak()) {
-                ASSERT(!visualRectRelativeToRoot(lineBox.logicalRectForLineBreakBox(layoutBox)).width());
-                appendHardLineBreakDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForLineBreakBox(layoutBox)), boxes);
-                displayBoxTree.append(parentDisplayBoxNodeIndex, boxes.size() - 1);
-                continue;
-            }
-            if (lineRun.isBox()) {
-                auto& boxGeometry = formattingState().boxGeometry(layoutBox);
-                auto visualRect = visualRectRelativeToRoot(lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, boxGeometry));
-
-                auto isLeftToRightDirection = layoutBox.parent().style().isLeftToRightDirection();
-                auto boxMarginLeft = marginLeft(boxGeometry, isLeftToRightDirection);
-                visualRect.moveHorizontally(boxMarginLeft);
-                appendAtomicInlineLevelDisplayBox(lineRun, visualRect, boxes);
-                contentRightInVisualOrder += boxMarginLeft + visualRect.width() + marginRight(boxGeometry, isLeftToRightDirection);
-                displayBoxTree.append(parentDisplayBoxNodeIndex, boxes.size() - 1);
-                continue;
-            }
-            if (lineRun.isInlineBoxStart() || lineRun.isLineSpanningInlineBoxStart()) {
-                // FIXME: While we should only get here with empty inline boxes, there are
-                // some cases where the inline box has some content on the paragraph level (at bidi split) but line breaking renders it empty
-                // or their content is completely collapsed.
-                // Such inline boxes should also be handled here.
-                appendInlineDisplayBoxAtBidiBoundary(layoutBox, boxes);
-                createdDisplayBoxNodeForContainerBoxAndPushToAncestorStack(downcast<ContainerBox>(layoutBox), boxes.size() - 1, parentDisplayBoxNodeIndex, displayBoxTree, ancestorStack);
-                continue;
-            }
-            ASSERT_NOT_REACHED();
-        }
-    };
-    createDisplayBoxesInVisualOrder();
-
-    if (displayBoxTree.hasInlineBox()) {
-        IsFirstLastIndexesMap isFirstLastIndexesMap;
-        auto computeIsFirstIsLastBox = [&] {
-            ASSERT(boxes[0].isRootInlineBox());
-            for (size_t index = 1; index < boxes.size(); ++index) {
-                if (!boxes[index].isNonRootInlineBox())
-                    continue;
-                auto& layoutBox = boxes[index].layoutBox();
-                auto isFirstBox = lineBox.inlineLevelBoxForLayoutBox(layoutBox).isFirstBox();
-                auto isLastBox = lineBox.inlineLevelBoxForLayoutBox(layoutBox).isLastBox();
-                if (!isFirstBox && !isLastBox)
-                    continue;
-                if (isFirstBox) {
-                    auto isFirstLastIndexes = isFirstLastIndexesMap.get(&layoutBox);
-                    if (!isFirstLastIndexes.first || isLastBox)
-                        isFirstLastIndexesMap.set(&layoutBox, IsFirstLastIndex { isFirstLastIndexes.first.value_or(index), isLastBox ? index : isFirstLastIndexes.last });
-                    continue;
-                }
-                if (isLastBox) {
-                    ASSERT(!isFirstBox);
-                    isFirstLastIndexesMap.set(&layoutBox, IsFirstLastIndex { { }, index });
-                    continue;
-                }
-            }
-        };
-        computeIsFirstIsLastBox();
-
-        auto adjustVisualGeometryWithInlineBoxes = [&] {
-            auto contentRightInVisualOrder = lineBoxLogicalTopLeft.x() + contentStartInVisualOrder;
-
-            for (auto childDisplayBoxNodeIndex : displayBoxTree.root().children)
-                adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBoxLogicalTopLeft.y(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
-        };
-        adjustVisualGeometryWithInlineBoxes();
-    }
-}
-
-void InlineDisplayContentBuilder::processOverflownRunsForEllipsis(DisplayBoxes& boxes, InlineLayoutUnit lineBoxLogicalRight)
-{
-    if (root().style().textOverflow() != TextOverflow::Ellipsis)
-        return;
-    auto& rootInlineBox = boxes[0];
-    ASSERT(rootInlineBox.isRootInlineBox());
-
-    auto rootInlineBoxRect = rootInlineBox.rect();
-    if (rootInlineBoxRect.right() <= lineBoxLogicalRight) {
-        ASSERT(boxes.last().right() <= lineBoxLogicalRight);
-        return;
-    }
-
-    static MainThreadNeverDestroyed<const AtomString> ellipsisStr(&horizontalEllipsis, 1);
-    auto ellipsisRun = WebCore::TextRun { ellipsisStr->string() };
-    auto ellipsisWidth = !m_lineIndex ? root().firstLineStyle().fontCascade().width(ellipsisRun) : root().style().fontCascade().width(ellipsisRun);
-    auto firstTruncatedBoxIndex = boxes.size();
-
-    for (auto index = boxes.size(); index--;) {
-        auto& displayBox = boxes[index];
-
-        if (displayBox.left() >= lineBoxLogicalRight) {
-            // Fully overflown boxes are collapsed.
-            displayBox.truncate();
-            continue;
-        }
-
-        // We keep truncating content until after we can accommodate the ellipsis content
-        // 1. fully truncate in case of inline level boxes (ie non-text content) or if ellipsis content is wider than the overflowing one.
-        // 2. partially truncated to make room for the ellipsis box.
-        auto availableRoomForEllipsis = lineBoxLogicalRight - displayBox.left();
-        if (availableRoomForEllipsis <= ellipsisWidth) {
-            // Can't accommodate the ellipsis content here. We need to truncate non-overflowing boxes too.
-            displayBox.truncate();
-            continue;
-        }
-
-        auto truncatedWidth = InlineLayoutUnit { };
-        if (displayBox.isText()) {
-            auto text = *displayBox.text();
-            // FIXME: Check if it needs adjustment for RTL direction.
-            truncatedWidth = TextUtil::breakWord(downcast<InlineTextBox>(displayBox.layoutBox()), text.start(), text.length(), displayBox.width(), availableRoomForEllipsis - ellipsisWidth, { }, displayBox.style().fontCascade()).logicalWidth;
-        }
-        displayBox.truncate(truncatedWidth);
-        firstTruncatedBoxIndex = index;
-        break;
-    }
-    ASSERT(firstTruncatedBoxIndex < boxes.size());
-    // Collapse truncated runs.
-    auto contentRight = boxes[firstTruncatedBoxIndex].right();
-    for (auto index = firstTruncatedBoxIndex + 1; index < boxes.size(); ++index)
-        boxes[index].moveHorizontally(contentRight - boxes[index].left());
-    // And append the ellipsis box as the trailing item.
-    auto ellispisBoxRect = InlineRect { rootInlineBoxRect.top(), contentRight, ellipsisWidth, rootInlineBoxRect.height() };
-    boxes.append({ m_lineIndex
-        , InlineDisplay::Box::Type::Ellipsis
-        , root()
-        , UBIDI_DEFAULT_LTR
-        , ellispisBoxRect
-        , ellispisBoxRect
-        , { }
-        , InlineDisplay::Box::Text { 0, 1, ellipsisStr->string() } });
-}
-
-void InlineDisplayContentBuilder::collectInkOverflowForInlineBoxes(DisplayBoxes& boxes)
-{
-    if (!m_contentHasInkOverflow)
-        return;
-    // Visit the inline boxes and propagate ink overflow to their parents -except to the root inline box.
-    // (e.g. <span style="font-size: 10px;">Small font size<span style="font-size: 300px;">Larger font size. This overflows the top most span.</span></span>).
-    auto accumulatedInkOverflowRect = InlineRect { { }, { } };
-    for (size_t index = boxes.size(); index--;) {
-        auto& displayBox = boxes[index];
-
-        auto mayHaveInkOverflow = displayBox.isAtomicInlineLevelBox() || displayBox.isGenericInlineLevelBox() || displayBox.isNonRootInlineBox();
-        if (!mayHaveInkOverflow)
-            continue;
-        if (displayBox.isNonRootInlineBox() && !accumulatedInkOverflowRect.isEmpty())
-            displayBox.adjustInkOverflow(accumulatedInkOverflowRect);
-
-        // We stop collecting ink overflow for at root inline box (i.e. don't inflate the root inline box with the inline content here).
-        auto parentBoxIsRoot = &displayBox.layoutBox().parent() == &root();
-        if (parentBoxIsRoot)
-            accumulatedInkOverflowRect = InlineRect { { }, { } };
-        else if (accumulatedInkOverflowRect.isEmpty())
-            accumulatedInkOverflowRect = displayBox.inkOverflow();
-        else
-            accumulatedInkOverflowRect.expandToContain(displayBox.inkOverflow());
-    }
-}
-
-void InlineDisplayContentBuilder::computeIsFirstIsLastBoxForInlineContent(DisplayBoxes& boxes)
-{
-    HashMap<const Box*, size_t> lastDisplayBoxForLayoutBoxIndexes;
-
-    ASSERT(boxes[0].isRootInlineBox());
-    boxes[0].setIsFirstForLayoutBox(true);
-    size_t lastRootInlineBoxIndex = 0;
-
-    for (size_t index = 1; index < boxes.size(); ++index) {
-        auto& displayBox = boxes[index];
-        if (displayBox.isRootInlineBox()) {
-            lastRootInlineBoxIndex = index;
-            continue;
-        }
-        auto& layoutBox = displayBox.layoutBox();
-        if (lastDisplayBoxForLayoutBoxIndexes.set(&layoutBox, index).isNewEntry)
-            displayBox.setIsFirstForLayoutBox(true);
-    }
-    for (auto index : lastDisplayBoxForLayoutBoxIndexes.values())
-        boxes[index].setIsLastForLayoutBox(true);
-
-    boxes[lastRootInlineBoxIndex].setIsLastForLayoutBox(true);
-}
-
-}
-}
-
-#endif

Deleted: trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.h (287270 => 287271)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.h	2021-12-20 20:12:52 UTC (rev 287270)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.h	2021-12-20 20:17:09 UTC (rev 287271)
@@ -1,81 +0,0 @@
-/*
- * 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 "InlineLineBuilder.h"
-#include "LayoutUnits.h"
-
-namespace WebCore {
-namespace Layout {
-
-struct AncestorStack;
-class ContainerBox;
-struct DisplayBoxTree;
-struct IsFirstLastIndex;
-class InlineFormattingState;
-class LineBox;
-
-class InlineDisplayContentBuilder {
-public:
-    InlineDisplayContentBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState&);
-
-    DisplayBoxes build(const LineBuilder::LineContent&, const LineBox&, const InlineRect& lineBoxLogicalRect, const size_t lineIndex);
-
-    static void computeIsFirstIsLastBoxForInlineContent(DisplayBoxes&);
-
-private:
-    void processNonBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineLayoutPoint& lineBoxLogicalTopLeft, DisplayBoxes&);
-    void processBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineLayoutPoint& lineBoxLogicalTopLeft, DisplayBoxes&);
-    void processOverflownRunsForEllipsis(DisplayBoxes&, InlineLayoutUnit lineBoxLogicalRight);
-    void collectInkOverflowForInlineBoxes(DisplayBoxes&);
-
-    void appendTextDisplayBox(const Line::Run&, const InlineRect&, DisplayBoxes&);
-    void appendSoftLineBreakDisplayBox(const Line::Run&, const InlineRect&, DisplayBoxes&);
-    void appendHardLineBreakDisplayBox(const Line::Run&, const InlineRect&, DisplayBoxes&);
-    void appendAtomicInlineLevelDisplayBox(const Line::Run&, const InlineRect& , DisplayBoxes&);
-    void appendInlineBoxDisplayBox(const Line::Run&, const InlineLevelBox&, const InlineRect&, bool linehasContent, DisplayBoxes&);
-    void appendSpanningInlineBoxDisplayBox(const Line::Run&, const InlineLevelBox&, const InlineRect&, DisplayBoxes&);
-    void appendInlineDisplayBoxAtBidiBoundary(const Box&, DisplayBoxes&);
-
-    void setInlineBoxGeometry(const Box&, const InlineRect&, bool isFirstInlineBoxFragment);
-    void adjustVisualGeometryForDisplayBox(size_t displayBoxNodeIndex, InlineLayoutUnit& accumulatedOffset, InlineLayoutUnit lineBoxLogicalTop, const DisplayBoxTree&, DisplayBoxes&, const LineBox&, const HashMap<const Box*, IsFirstLastIndex>&);
-    size_t ensureDisplayBoxForContainer(const ContainerBox&, DisplayBoxTree&, AncestorStack&, DisplayBoxes&);
-
-    const ContainerBox& root() const { return m_formattingContextRoot; }
-    InlineFormattingState& formattingState() const { return m_formattingState; } 
-
-    const ContainerBox& m_formattingContextRoot;
-    InlineFormattingState& m_formattingState;
-    size_t m_lineIndex { 0 };
-    bool m_contentHasInkOverflow { false };
-};
-
-}
-}
-
-#endif

Copied: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp (from rev 287270, trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp) (0 => 287271)


--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	                        (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	2021-12-20 20:17:09 UTC (rev 287271)
@@ -0,0 +1,767 @@
+/*
+ * 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 "InlineDisplayContentBuilder.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "FontCascade.h"
+#include "LayoutBoxGeometry.h"
+#include "LayoutInitialContainingBlock.h"
+#include "RuntimeEnabledFeatures.h"
+#include "TextUtil.h"
+#include <wtf/ListHashSet.h>
+#include <wtf/Range.h>
+
+using WTF::Range;
+
+namespace WebCore {
+namespace Layout {
+
+static inline LayoutUnit marginLeft(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
+{
+    return isLeftToRightDirection ? boxGeometry.marginStart() : boxGeometry.marginEnd();
+}
+
+static inline LayoutUnit marginRight(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
+{
+    return isLeftToRightDirection ? boxGeometry.marginEnd() : boxGeometry.marginStart();
+}
+
+static inline LayoutUnit borderLeft(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
+{
+    return isLeftToRightDirection ? boxGeometry.borderStart() : boxGeometry.borderEnd();
+}
+
+static inline LayoutUnit borderRight(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
+{
+    return isLeftToRightDirection ? boxGeometry.borderEnd() : boxGeometry.borderStart();
+}
+
+static inline LayoutUnit paddingLeft(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
+{
+    return isLeftToRightDirection ? boxGeometry.paddingStart().value_or(0_lu) : boxGeometry.paddingEnd().value_or(0_lu);
+}
+
+static inline LayoutUnit paddingRight(const Layout::BoxGeometry& boxGeometry, bool isLeftToRightDirection)
+{
+    return isLeftToRightDirection ? boxGeometry.paddingEnd().value_or(0_lu) : boxGeometry.paddingStart().value_or(0_lu);
+}
+
+static inline OptionSet<InlineDisplay::Box::PositionWithinInlineLevelBox> isFirstLastBox(const InlineLevelBox& inlineBox)
+{
+    auto positionWithinInlineLevelBox = OptionSet<InlineDisplay::Box::PositionWithinInlineLevelBox> { };
+    if (inlineBox.isFirstBox())
+        positionWithinInlineLevelBox.add(InlineDisplay::Box::PositionWithinInlineLevelBox::First);
+    if (inlineBox.isLastBox())
+        positionWithinInlineLevelBox.add(InlineDisplay::Box::PositionWithinInlineLevelBox::Last);
+    return positionWithinInlineLevelBox;
+}
+
+InlineDisplayContentBuilder::InlineDisplayContentBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState& formattingState)
+    : m_formattingContextRoot(formattingContextRoot)
+    , m_formattingState(formattingState)
+{
+}
+
+DisplayBoxes InlineDisplayContentBuilder::build(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineRect& lineBoxLogicalRect, const size_t lineIndex)
+{
+    DisplayBoxes boxes;
+    boxes.reserveInitialCapacity(lineContent.runs.size() + lineBox.nonRootInlineLevelBoxes().size() + 1);
+
+    m_lineIndex = lineIndex;
+    // Every line starts with a root box, even the empty ones.
+    auto rootInlineBoxRect = lineBox.logicalRectForRootInlineBox();
+    rootInlineBoxRect.moveBy(lineBoxLogicalRect.topLeft());
+    boxes.append({ m_lineIndex, InlineDisplay::Box::Type::RootInlineBox, root(), UBIDI_DEFAULT_LTR, rootInlineBoxRect, rootInlineBoxRect, { }, { }, lineBox.rootInlineBox().hasContent() });
+
+    auto contentNeedsBidiReordering = !lineContent.visualOrderList.isEmpty();
+    if (contentNeedsBidiReordering)
+        processBidiContent(lineContent, lineBox, lineBoxLogicalRect.topLeft(), boxes);
+    else
+        processNonBidiContent(lineContent, lineBox, lineBoxLogicalRect.topLeft(), boxes);
+    processOverflownRunsForEllipsis(boxes, lineBoxLogicalRect.right());
+    collectInkOverflowForInlineBoxes(boxes);
+    return boxes;
+}
+
+static inline bool computeBoxShadowInkOverflow(const RenderStyle& style, InlineRect& inkOverflow)
+{
+    auto topBoxShadow = LayoutUnit { };
+    auto bottomBoxShadow = LayoutUnit { };
+    style.getBoxShadowBlockDirectionExtent(topBoxShadow, bottomBoxShadow);
+
+    auto leftBoxShadow = LayoutUnit { };
+    auto rightBoxShadow = LayoutUnit { };
+    style.getBoxShadowInlineDirectionExtent(leftBoxShadow, rightBoxShadow);
+    if (!topBoxShadow && !bottomBoxShadow && !leftBoxShadow && !rightBoxShadow)
+        return false;
+    inkOverflow.inflate(InlineLayoutUnit { topBoxShadow }, InlineLayoutUnit { rightBoxShadow }, InlineLayoutUnit { bottomBoxShadow }, InlineLayoutUnit { leftBoxShadow });
+    return true;
+}
+
+void InlineDisplayContentBuilder::appendTextDisplayBox(const Line::Run& lineRun, const InlineRect& textRunRect, DisplayBoxes& boxes)
+{
+    ASSERT(lineRun.textContent() && is<InlineTextBox>(lineRun.layoutBox()));
+
+    auto& layoutBox = lineRun.layoutBox();
+    auto& style = !m_lineIndex ? layoutBox.firstLineStyle() : layoutBox.style();
+
+    auto inkOverflow = [&] {
+        auto initialContaingBlockSize = RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()
+            ? formattingState().layoutState().viewportSize()
+            : formattingState().layoutState().geometryForBox(layoutBox.initialContainingBlock()).contentBox().size();
+        auto strokeOverflow = ceilf(style.computedStrokeWidth(ceiledIntSize(initialContaingBlockSize)));
+        auto inkOverflow = textRunRect;
+        inkOverflow.inflate(strokeOverflow);
+        auto letterSpacing = style.fontCascade().letterSpacing();
+        if (letterSpacing < 0) {
+            // Last letter's negative spacing shrinks logical rect. Push it to ink overflow.
+            inkOverflow.expand(-letterSpacing, { });
+        }
+        return inkOverflow;
+    };
+    auto content = downcast<InlineTextBox>(layoutBox).content();
+    auto text = lineRun.textContent();
+    auto adjustedContentToRender = [&] {
+        return text->needsHyphen ? makeString(content.substring(text->start, text->length), style.hyphenString()) : String();
+    };
+    boxes.append({ m_lineIndex
+        , InlineDisplay::Box::Type::Text
+        , layoutBox
+        , lineRun.bidiLevel()
+        , textRunRect
+        , inkOverflow()
+        , lineRun.expansion()
+        , InlineDisplay::Box::Text { text->start, text->length, content, adjustedContentToRender(), text->needsHyphen }
+        , true
+        , { }
+    });
+}
+
+void InlineDisplayContentBuilder::appendSoftLineBreakDisplayBox(const Line::Run& lineRun, const InlineRect& softLineBreakRunRect, DisplayBoxes& boxes)
+{
+    ASSERT(lineRun.textContent() && is<InlineTextBox>(lineRun.layoutBox()));
+
+    auto& layoutBox = lineRun.layoutBox();
+    auto& text = lineRun.textContent();
+
+    boxes.append({ m_lineIndex
+        , InlineDisplay::Box::Type::SoftLineBreak
+        , layoutBox
+        , lineRun.bidiLevel()
+        , softLineBreakRunRect
+        , softLineBreakRunRect
+        , lineRun.expansion()
+        , InlineDisplay::Box::Text { text->start, text->length, downcast<InlineTextBox>(layoutBox).content() }
+    });
+}
+
+void InlineDisplayContentBuilder::appendHardLineBreakDisplayBox(const Line::Run& lineRun, const InlineRect& lineBreakBoxRect, DisplayBoxes& boxes)
+{
+    auto& layoutBox = lineRun.layoutBox();
+
+    boxes.append({ m_lineIndex
+        , InlineDisplay::Box::Type::LineBreakBox
+        , layoutBox
+        , lineRun.bidiLevel()
+        , lineBreakBoxRect
+        , lineBreakBoxRect
+        , lineRun.expansion()
+        , { }
+    });
+
+    auto& boxGeometry = formattingState().boxGeometry(layoutBox);
+    boxGeometry.setLogicalTopLeft(toLayoutPoint(lineBreakBoxRect.topLeft()));
+    boxGeometry.setContentBoxHeight(toLayoutUnit(lineBreakBoxRect.height()));
+}
+
+void InlineDisplayContentBuilder::appendAtomicInlineLevelDisplayBox(const Line::Run& lineRun, const InlineRect& borderBoxRect, DisplayBoxes& boxes)
+{
+    ASSERT(lineRun.layoutBox().isAtomicInlineLevelBox());
+
+    auto& layoutBox = lineRun.layoutBox();
+    auto inkOverflow = [&] {
+        auto inkOverflow = borderBoxRect;
+        computeBoxShadowInkOverflow(!m_lineIndex ? layoutBox.firstLineStyle() : layoutBox.style(), inkOverflow);
+        // Atomic inline box contribute to their inline box parents ink overflow at all times (e.g. <span><img></span>).
+        m_contentHasInkOverflow = m_contentHasInkOverflow || &layoutBox.parent() != &root();
+        return inkOverflow;
+    };
+    boxes.append({ m_lineIndex
+        , InlineDisplay::Box::Type::AtomicInlineLevelBox
+        , layoutBox
+        , lineRun.bidiLevel()
+        , borderBoxRect
+        , inkOverflow()
+        , lineRun.expansion()
+        , { }
+    });
+    // Note that inline boxes are relative to the line and their top position can be negative.
+    // Atomic inline boxes are all set. Their margin/border/content box geometries are already computed. We just have to position them here.
+    formattingState().boxGeometry(layoutBox).setLogicalTopLeft(toLayoutPoint(borderBoxRect.topLeft()));
+}
+
+void InlineDisplayContentBuilder::setInlineBoxGeometry(const Box& layoutBox, const InlineRect& rect, bool isFirstInlineBoxFragment)
+{
+    auto adjustedSize = LayoutSize { LayoutUnit::fromFloatCeil(rect.width()), LayoutUnit::fromFloatCeil(rect.height()) };
+    auto adjustedRect = Rect { LayoutPoint { rect.topLeft() }, adjustedSize };
+    auto& boxGeometry = formattingState().boxGeometry(layoutBox);
+    if (!isFirstInlineBoxFragment) {
+        auto enclosingBorderBoxRect = BoxGeometry::borderBoxRect(boxGeometry);
+        enclosingBorderBoxRect.expandToContain(adjustedRect);
+        adjustedRect = enclosingBorderBoxRect;
+    }
+    boxGeometry.setLogicalTopLeft(adjustedRect.topLeft());
+    auto contentBoxHeight = adjustedRect.height() - (boxGeometry.verticalBorder() + boxGeometry.verticalPadding().value_or(0_lu));
+    auto contentBoxWidth = adjustedRect.width() - (boxGeometry.horizontalBorder() + boxGeometry.horizontalPadding().value_or(0_lu));
+    boxGeometry.setContentBoxHeight(contentBoxHeight);
+    boxGeometry.setContentBoxWidth(contentBoxWidth);
+}
+
+void InlineDisplayContentBuilder::appendInlineBoxDisplayBox(const Line::Run& lineRun, const InlineLevelBox& inlineBox, const InlineRect& inlineBoxBorderBox, bool linehasContent, DisplayBoxes& boxes)
+{
+    ASSERT(lineRun.layoutBox().isInlineBox());
+
+    auto& layoutBox = lineRun.layoutBox();
+
+    if (!linehasContent) {
+        // FIXME: It's expected to not have any boxes on empty lines. We should reconsider this.
+        setInlineBoxGeometry(layoutBox, inlineBoxBorderBox, true);
+        return;
+    }
+
+    auto inkOverflow = [&] {
+        auto inkOverflow = inlineBoxBorderBox;
+        m_contentHasInkOverflow = computeBoxShadowInkOverflow(!m_lineIndex ? layoutBox.firstLineStyle() : layoutBox.style(), inkOverflow) || m_contentHasInkOverflow;
+        return inkOverflow;
+    };
+    ASSERT(inlineBox.isInlineBox());
+    ASSERT(inlineBox.isFirstBox());
+    boxes.append({ m_lineIndex
+        , InlineDisplay::Box::Type::NonRootInlineBox
+        , layoutBox
+        , lineRun.bidiLevel()
+        , inlineBoxBorderBox
+        , inkOverflow()
+        , { }
+        , { }
+        , inlineBox.hasContent()
+        , isFirstLastBox(inlineBox)
+    });
+    // This inline box showed up first on this line.
+    setInlineBoxGeometry(layoutBox, inlineBoxBorderBox, true);
+}
+
+void InlineDisplayContentBuilder::appendSpanningInlineBoxDisplayBox(const Line::Run& lineRun, const InlineLevelBox& inlineBox, const InlineRect& inlineBoxBorderBox, DisplayBoxes& boxes)
+{
+    ASSERT(lineRun.layoutBox().isInlineBox());
+
+    auto& layoutBox = lineRun.layoutBox();
+    auto inkOverflow = [&] {
+        auto inkOverflow = inlineBoxBorderBox;
+        m_contentHasInkOverflow = computeBoxShadowInkOverflow(!m_lineIndex ? layoutBox.firstLineStyle() : layoutBox.style(), inkOverflow) || m_contentHasInkOverflow;
+        return inkOverflow;
+    };
+    ASSERT(!inlineBox.isFirstBox());
+    boxes.append({ m_lineIndex
+        , InlineDisplay::Box::Type::NonRootInlineBox
+        , layoutBox
+        , lineRun.bidiLevel()
+        , inlineBoxBorderBox
+        , inkOverflow()
+        , { }
+        , { }
+        , inlineBox.hasContent()
+        , isFirstLastBox(inlineBox)
+    });
+    // Middle or end of the inline box. Let's stretch the box as needed.
+    setInlineBoxGeometry(layoutBox, inlineBoxBorderBox, false);
+}
+
+void InlineDisplayContentBuilder::appendInlineDisplayBoxAtBidiBoundary(const Box& layoutBox, DisplayBoxes& boxes)
+{
+    // Geometries for inline boxes at bidi boundaries are computed at a post-process step.
+    boxes.append({ m_lineIndex
+        , InlineDisplay::Box::Type::NonRootInlineBox
+        , layoutBox
+        , UBIDI_DEFAULT_LTR
+        , { }
+        , { }
+        , { }
+        , { }
+    });
+}
+
+void InlineDisplayContentBuilder::processNonBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxLogicalTopLeft, DisplayBoxes& boxes)
+{
+    auto rootInlineBoxWidth = lineBox.logicalRectForRootInlineBox().width();
+    auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();
+    auto needsDirectionAdjustment = !root().style().isLeftToRightDirection();
+
+    for (auto& lineRun : lineContent.runs) {
+        auto& layoutBox = lineRun.layoutBox();
+
+        auto visualRectRelativeToRoot = [&](auto logicalRect) {
+            // When the logical order == visual order, RTL inline direction is just an offset.
+            auto horizontalOffset = needsDirectionAdjustment ? lineContent.lineLogicalWidth - rootInlineBoxWidth - rootInlineBoxAlignmentOffset : rootInlineBoxAlignmentOffset;
+            logicalRect.moveBy({ lineBoxLogicalTopLeft.x() + horizontalOffset, lineBoxLogicalTopLeft.y() });
+            return logicalRect;
+        };
+
+        if (lineRun.isText()) {
+            appendTextDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)), boxes);
+            continue;
+        }
+        if (lineRun.isSoftLineBreak()) {
+            appendSoftLineBreakDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)), boxes);
+            continue;
+        }
+        if (lineRun.isHardLineBreak()) {
+            appendHardLineBreakDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForLineBreakBox(layoutBox)), boxes);
+            continue;
+        }
+        if (lineRun.isBox()) {
+            appendAtomicInlineLevelDisplayBox(lineRun
+                , visualRectRelativeToRoot(lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, formattingState().boxGeometry(layoutBox)))
+                , boxes);
+            continue;
+        }
+        if (lineRun.isInlineBoxStart()) {
+            appendInlineBoxDisplayBox(lineRun
+                , lineBox.inlineLevelBoxForLayoutBox(lineRun.layoutBox())
+                , visualRectRelativeToRoot(lineBox.logicalBorderBoxForInlineBox(layoutBox, formattingState().boxGeometry(layoutBox)))
+                , lineBox.hasContent()
+                , boxes);
+            continue;
+        }
+        if (lineRun.isLineSpanningInlineBoxStart()) {
+            if (!lineBox.hasContent()) {
+                // When a spanning inline box (e.g. <div>text<span><br></span></div>) lands on an empty line
+                // (empty here means no content at all including line breaks, not just visually empty) then we
+                // don't extend the spanning line box over to this line -also there is no next line in cases like this.
+                continue;
+            }
+            appendSpanningInlineBoxDisplayBox(lineRun
+                , lineBox.inlineLevelBoxForLayoutBox(lineRun.layoutBox())
+                , visualRectRelativeToRoot(lineBox.logicalBorderBoxForInlineBox(layoutBox, formattingState().boxGeometry(layoutBox)))
+                , boxes);
+            continue;
+        }
+        ASSERT(lineRun.isInlineBoxEnd() || lineRun.isWordBreakOpportunity());
+    }
+}
+
+struct DisplayBoxTree {
+public:
+    struct Node {
+        // Node's parent index in m_displayBoxNodes.
+        std::optional<size_t> parentIndex;
+        // Associated display box index in DisplayBoxes.
+        size_t displayBoxIndex { 0 };
+        // Child indexes in m_displayBoxNodes.
+        Vector<size_t> children { };
+    };
+
+    DisplayBoxTree()
+    {
+        m_displayBoxNodes.append({ });
+    }
+
+    bool hasInlineBox() const { return m_displayBoxNodes.size() > 1; }
+    const Node& root() const { return m_displayBoxNodes.first(); }
+    Node& at(size_t index) { return m_displayBoxNodes[index]; }
+    const Node& at(size_t index) const { return m_displayBoxNodes[index]; }
+
+    size_t append(size_t parentNodeIndex, size_t childDisplayBoxIndex)
+    {
+        auto childDisplayBoxNodeIndex = m_displayBoxNodes.size();
+        m_displayBoxNodes.append({ parentNodeIndex, childDisplayBoxIndex });
+        at(parentNodeIndex).children.append(childDisplayBoxNodeIndex);
+        return childDisplayBoxNodeIndex;
+    }
+
+private:
+    Vector<Node, 10> m_displayBoxNodes;
+};
+
+struct AncestorStack {
+    std::optional<size_t> unwind(const ContainerBox& containerBox)
+    {
+        // Unwind the stack all the way to container box.
+        if (!m_set.contains(&containerBox))
+            return { };
+        while (m_set.last() != &containerBox) {
+            m_stack.removeLast();
+            m_set.removeLast();
+        }
+        // Root is always a common ancestor.
+        ASSERT(!m_stack.isEmpty());
+        return m_stack.last();
+    }
+
+    void push(size_t displayBoxNodeIndexForContainerBox, const ContainerBox& containerBox)
+    {
+        m_stack.append(displayBoxNodeIndexForContainerBox);
+        ASSERT(!m_set.contains(&containerBox));
+        m_set.add(&containerBox);
+    }
+
+private:
+    Vector<size_t> m_stack;
+    ListHashSet<const ContainerBox*> m_set;
+};
+
+static inline size_t createdDisplayBoxNodeForContainerBoxAndPushToAncestorStack(const ContainerBox& containerBox, size_t displayBoxIndex, size_t parentDisplayBoxNodeIndex, DisplayBoxTree& displayBoxTree, AncestorStack& ancestorStack)
+{
+    auto displayBoxNodeIndex = displayBoxTree.append(parentDisplayBoxNodeIndex, displayBoxIndex);
+    ancestorStack.push(displayBoxNodeIndex, containerBox);
+    return displayBoxNodeIndex;
+}
+
+size_t InlineDisplayContentBuilder::ensureDisplayBoxForContainer(const ContainerBox& containerBox, DisplayBoxTree& displayBoxTree, AncestorStack& ancestorStack, DisplayBoxes& boxes)
+{
+    ASSERT(containerBox.isInlineBox() || &containerBox == &root());
+    if (auto lowestCommonAncestorIndex = ancestorStack.unwind(containerBox))
+        return *lowestCommonAncestorIndex;
+    auto enclosingDisplayBoxNodeIndexForContainer = ensureDisplayBoxForContainer(containerBox.parent(), displayBoxTree, ancestorStack, boxes);
+    appendInlineDisplayBoxAtBidiBoundary(containerBox, boxes);
+    return createdDisplayBoxNodeForContainerBoxAndPushToAncestorStack(containerBox, boxes.size() - 1, enclosingDisplayBoxNodeIndexForContainer, displayBoxTree, ancestorStack);
+}
+
+struct IsFirstLastIndex {
+    std::optional<size_t> first;
+    std::optional<size_t> last;
+};
+using IsFirstLastIndexesMap = HashMap<const Box*, IsFirstLastIndex>;
+void InlineDisplayContentBuilder::adjustVisualGeometryForDisplayBox(size_t displayBoxNodeIndex, InlineLayoutUnit& contentRightInVisualOrder, InlineLayoutUnit lineBoxLogicalTop, const DisplayBoxTree& displayBoxTree, DisplayBoxes& boxes, const LineBox& lineBox, const IsFirstLastIndexesMap& isFirstLastIndexesMap)
+{
+    // Non-inline box display boxes just need a horizontal adjustment while
+    // inline box type of display boxes need
+    // 1. horizontal adjustment and margin/border/padding start offsetting on the first box
+    // 2. right edge computation including descendant content width and margin/border/padding end offsetting on the last box
+    auto& displayBox = boxes[displayBoxTree.at(displayBoxNodeIndex).displayBoxIndex];
+    auto& layoutBox = displayBox.layoutBox();
+
+    if (!displayBox.isNonRootInlineBox()) {
+        if (displayBox.isAtomicInlineLevelBox() || displayBox.isGenericInlineLevelBox()) {
+            auto isLeftToRightDirection = layoutBox.parent().style().isLeftToRightDirection();
+            auto& boxGeometry = formattingState().boxGeometry(layoutBox);
+            auto boxMarginLeft = marginLeft(boxGeometry, isLeftToRightDirection);
+            auto boxMarginRight = marginRight(boxGeometry, isLeftToRightDirection);
+
+            auto borderBoxLeft = LayoutUnit { contentRightInVisualOrder + boxMarginLeft };
+            boxGeometry.setLogicalLeft(borderBoxLeft);
+            displayBox.setLeft(borderBoxLeft);
+
+            contentRightInVisualOrder += boxMarginLeft + displayBox.width() + boxMarginRight;
+        } else {
+            displayBox.setLeft(contentRightInVisualOrder);
+            contentRightInVisualOrder += displayBox.width();
+        }
+        return;
+    }
+
+    auto& boxGeometry = formattingState().boxGeometry(layoutBox);
+    auto isLeftToRightDirection = layoutBox.style().isLeftToRightDirection();
+    auto isFirstLastIndexes = isFirstLastIndexesMap.get(&layoutBox);
+    auto isFirstBox = isFirstLastIndexes.first && *isFirstLastIndexes.first == displayBoxNodeIndex;
+    auto isLastBox = isFirstLastIndexes.last && *isFirstLastIndexes.last == displayBoxNodeIndex;
+    auto beforeInlineBoxContent = [&] {
+        auto logicalRect = lineBox.logicalBorderBoxForInlineBox(layoutBox, boxGeometry);
+        auto visualRect = InlineRect { lineBoxLogicalTop + logicalRect.top(), contentRightInVisualOrder, { }, logicalRect.height() };
+        auto shouldApplyLeftSide = (isLeftToRightDirection && isFirstBox) || (!isLeftToRightDirection && isLastBox);
+        if (!shouldApplyLeftSide)
+            return displayBox.setRect(visualRect, visualRect);
+
+        contentRightInVisualOrder += marginLeft(boxGeometry, isLeftToRightDirection);
+        auto visualRectWithMarginLeft = InlineRect { visualRect.top(), contentRightInVisualOrder, visualRect.width(), visualRect.height() };
+        displayBox.setRect(visualRectWithMarginLeft, visualRectWithMarginLeft);
+        contentRightInVisualOrder += borderLeft(boxGeometry, isLeftToRightDirection) + paddingLeft(boxGeometry, isLeftToRightDirection);
+    };
+    beforeInlineBoxContent();
+
+    for (auto childDisplayBoxNodeIndex : displayBoxTree.at(displayBoxNodeIndex).children)
+        adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBoxLogicalTop, displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
+
+    auto afterInlineBoxContent = [&] {
+        auto shouldApplyRightSide = (isLeftToRightDirection && isLastBox) || (!isLeftToRightDirection && isFirstBox);
+        if (!shouldApplyRightSide)
+            return displayBox.setRight(contentRightInVisualOrder);
+
+        contentRightInVisualOrder += borderRight(boxGeometry, isLeftToRightDirection) + paddingRight(boxGeometry, isLeftToRightDirection);
+        displayBox.setRight(contentRightInVisualOrder);
+        contentRightInVisualOrder += marginRight(boxGeometry, isLeftToRightDirection);
+    };
+    afterInlineBoxContent();
+
+    auto computeInkOverflow = [&] {
+        auto inkOverflow = displayBox.rect();
+        m_contentHasInkOverflow = computeBoxShadowInkOverflow(!m_lineIndex ? layoutBox.firstLineStyle() : layoutBox.style(), inkOverflow) || m_contentHasInkOverflow;
+        displayBox.adjustInkOverflow(inkOverflow);
+    };
+    computeInkOverflow();
+
+    setInlineBoxGeometry(layoutBox, displayBox.rect(), isFirstBox);
+    if (lineBox.inlineLevelBoxForLayoutBox(layoutBox).hasContent())
+        displayBox.setHasContent();
+}
+
+void InlineDisplayContentBuilder::processBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxLogicalTopLeft, DisplayBoxes& boxes)
+{
+    ASSERT(lineContent.visualOrderList.size() <= lineContent.runs.size());
+
+    AncestorStack ancestorStack;
+    auto displayBoxTree = DisplayBoxTree { };
+    ancestorStack.push({ }, root());
+
+    auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();
+    auto contentStartInVisualOrder = rootInlineBoxAlignmentOffset;
+    auto createDisplayBoxesInVisualOrder = [&] {
+        // First visual run's initial content position depends on the block's inline direction.
+        if (!root().style().isLeftToRightDirection())
+            contentStartInVisualOrder = lineContent.lineLogicalWidth - lineBox.logicalRectForRootInlineBox().width() - rootInlineBoxAlignmentOffset;
+
+        auto contentRightInVisualOrder = contentStartInVisualOrder;
+        auto& runs = lineContent.runs;
+        for (auto visualOrder : lineContent.visualOrderList) {
+            ASSERT(runs[visualOrder].bidiLevel() != InlineItem::opaqueBidiLevel);
+
+            auto& lineRun = runs[visualOrder];
+            auto& layoutBox = lineRun.layoutBox();
+
+            auto needsDisplayBox = !lineRun.isWordBreakOpportunity() && !lineRun.isInlineBoxEnd();
+            if (!needsDisplayBox)
+                continue;
+
+            auto visualRectRelativeToRoot = [&](auto logicalRect) {
+                logicalRect.setLeft(contentRightInVisualOrder);
+                logicalRect.moveBy(lineBoxLogicalTopLeft);
+                return logicalRect;
+            };
+
+            auto parentDisplayBoxNodeIndex = ensureDisplayBoxForContainer(layoutBox.parent(), displayBoxTree, ancestorStack, boxes);
+            if (lineRun.isText()) {
+                auto visualRect = visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun));
+                appendTextDisplayBox(lineRun, visualRect, boxes);
+                contentRightInVisualOrder += visualRect.width();
+                displayBoxTree.append(parentDisplayBoxNodeIndex, boxes.size() - 1);
+                continue;
+            }
+            if (lineRun.isSoftLineBreak()) {
+                ASSERT(!visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)).width());
+                appendSoftLineBreakDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun)), boxes);
+                displayBoxTree.append(parentDisplayBoxNodeIndex, boxes.size() - 1);
+                continue;
+            }
+            if (lineRun.isHardLineBreak()) {
+                ASSERT(!visualRectRelativeToRoot(lineBox.logicalRectForLineBreakBox(layoutBox)).width());
+                appendHardLineBreakDisplayBox(lineRun, visualRectRelativeToRoot(lineBox.logicalRectForLineBreakBox(layoutBox)), boxes);
+                displayBoxTree.append(parentDisplayBoxNodeIndex, boxes.size() - 1);
+                continue;
+            }
+            if (lineRun.isBox()) {
+                auto& boxGeometry = formattingState().boxGeometry(layoutBox);
+                auto visualRect = visualRectRelativeToRoot(lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, boxGeometry));
+
+                auto isLeftToRightDirection = layoutBox.parent().style().isLeftToRightDirection();
+                auto boxMarginLeft = marginLeft(boxGeometry, isLeftToRightDirection);
+                visualRect.moveHorizontally(boxMarginLeft);
+                appendAtomicInlineLevelDisplayBox(lineRun, visualRect, boxes);
+                contentRightInVisualOrder += boxMarginLeft + visualRect.width() + marginRight(boxGeometry, isLeftToRightDirection);
+                displayBoxTree.append(parentDisplayBoxNodeIndex, boxes.size() - 1);
+                continue;
+            }
+            if (lineRun.isInlineBoxStart() || lineRun.isLineSpanningInlineBoxStart()) {
+                // FIXME: While we should only get here with empty inline boxes, there are
+                // some cases where the inline box has some content on the paragraph level (at bidi split) but line breaking renders it empty
+                // or their content is completely collapsed.
+                // Such inline boxes should also be handled here.
+                appendInlineDisplayBoxAtBidiBoundary(layoutBox, boxes);
+                createdDisplayBoxNodeForContainerBoxAndPushToAncestorStack(downcast<ContainerBox>(layoutBox), boxes.size() - 1, parentDisplayBoxNodeIndex, displayBoxTree, ancestorStack);
+                continue;
+            }
+            ASSERT_NOT_REACHED();
+        }
+    };
+    createDisplayBoxesInVisualOrder();
+
+    if (displayBoxTree.hasInlineBox()) {
+        IsFirstLastIndexesMap isFirstLastIndexesMap;
+        auto computeIsFirstIsLastBox = [&] {
+            ASSERT(boxes[0].isRootInlineBox());
+            for (size_t index = 1; index < boxes.size(); ++index) {
+                if (!boxes[index].isNonRootInlineBox())
+                    continue;
+                auto& layoutBox = boxes[index].layoutBox();
+                auto isFirstBox = lineBox.inlineLevelBoxForLayoutBox(layoutBox).isFirstBox();
+                auto isLastBox = lineBox.inlineLevelBoxForLayoutBox(layoutBox).isLastBox();
+                if (!isFirstBox && !isLastBox)
+                    continue;
+                if (isFirstBox) {
+                    auto isFirstLastIndexes = isFirstLastIndexesMap.get(&layoutBox);
+                    if (!isFirstLastIndexes.first || isLastBox)
+                        isFirstLastIndexesMap.set(&layoutBox, IsFirstLastIndex { isFirstLastIndexes.first.value_or(index), isLastBox ? index : isFirstLastIndexes.last });
+                    continue;
+                }
+                if (isLastBox) {
+                    ASSERT(!isFirstBox);
+                    isFirstLastIndexesMap.set(&layoutBox, IsFirstLastIndex { { }, index });
+                    continue;
+                }
+            }
+        };
+        computeIsFirstIsLastBox();
+
+        auto adjustVisualGeometryWithInlineBoxes = [&] {
+            auto contentRightInVisualOrder = lineBoxLogicalTopLeft.x() + contentStartInVisualOrder;
+
+            for (auto childDisplayBoxNodeIndex : displayBoxTree.root().children)
+                adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBoxLogicalTopLeft.y(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
+        };
+        adjustVisualGeometryWithInlineBoxes();
+    }
+}
+
+void InlineDisplayContentBuilder::processOverflownRunsForEllipsis(DisplayBoxes& boxes, InlineLayoutUnit lineBoxLogicalRight)
+{
+    if (root().style().textOverflow() != TextOverflow::Ellipsis)
+        return;
+    auto& rootInlineBox = boxes[0];
+    ASSERT(rootInlineBox.isRootInlineBox());
+
+    auto rootInlineBoxRect = rootInlineBox.rect();
+    if (rootInlineBoxRect.right() <= lineBoxLogicalRight) {
+        ASSERT(boxes.last().right() <= lineBoxLogicalRight);
+        return;
+    }
+
+    static MainThreadNeverDestroyed<const AtomString> ellipsisStr(&horizontalEllipsis, 1);
+    auto ellipsisRun = WebCore::TextRun { ellipsisStr->string() };
+    auto ellipsisWidth = !m_lineIndex ? root().firstLineStyle().fontCascade().width(ellipsisRun) : root().style().fontCascade().width(ellipsisRun);
+    auto firstTruncatedBoxIndex = boxes.size();
+
+    for (auto index = boxes.size(); index--;) {
+        auto& displayBox = boxes[index];
+
+        if (displayBox.left() >= lineBoxLogicalRight) {
+            // Fully overflown boxes are collapsed.
+            displayBox.truncate();
+            continue;
+        }
+
+        // We keep truncating content until after we can accommodate the ellipsis content
+        // 1. fully truncate in case of inline level boxes (ie non-text content) or if ellipsis content is wider than the overflowing one.
+        // 2. partially truncated to make room for the ellipsis box.
+        auto availableRoomForEllipsis = lineBoxLogicalRight - displayBox.left();
+        if (availableRoomForEllipsis <= ellipsisWidth) {
+            // Can't accommodate the ellipsis content here. We need to truncate non-overflowing boxes too.
+            displayBox.truncate();
+            continue;
+        }
+
+        auto truncatedWidth = InlineLayoutUnit { };
+        if (displayBox.isText()) {
+            auto text = *displayBox.text();
+            // FIXME: Check if it needs adjustment for RTL direction.
+            truncatedWidth = TextUtil::breakWord(downcast<InlineTextBox>(displayBox.layoutBox()), text.start(), text.length(), displayBox.width(), availableRoomForEllipsis - ellipsisWidth, { }, displayBox.style().fontCascade()).logicalWidth;
+        }
+        displayBox.truncate(truncatedWidth);
+        firstTruncatedBoxIndex = index;
+        break;
+    }
+    ASSERT(firstTruncatedBoxIndex < boxes.size());
+    // Collapse truncated runs.
+    auto contentRight = boxes[firstTruncatedBoxIndex].right();
+    for (auto index = firstTruncatedBoxIndex + 1; index < boxes.size(); ++index)
+        boxes[index].moveHorizontally(contentRight - boxes[index].left());
+    // And append the ellipsis box as the trailing item.
+    auto ellispisBoxRect = InlineRect { rootInlineBoxRect.top(), contentRight, ellipsisWidth, rootInlineBoxRect.height() };
+    boxes.append({ m_lineIndex
+        , InlineDisplay::Box::Type::Ellipsis
+        , root()
+        , UBIDI_DEFAULT_LTR
+        , ellispisBoxRect
+        , ellispisBoxRect
+        , { }
+        , InlineDisplay::Box::Text { 0, 1, ellipsisStr->string() } });
+}
+
+void InlineDisplayContentBuilder::collectInkOverflowForInlineBoxes(DisplayBoxes& boxes)
+{
+    if (!m_contentHasInkOverflow)
+        return;
+    // Visit the inline boxes and propagate ink overflow to their parents -except to the root inline box.
+    // (e.g. <span style="font-size: 10px;">Small font size<span style="font-size: 300px;">Larger font size. This overflows the top most span.</span></span>).
+    auto accumulatedInkOverflowRect = InlineRect { { }, { } };
+    for (size_t index = boxes.size(); index--;) {
+        auto& displayBox = boxes[index];
+
+        auto mayHaveInkOverflow = displayBox.isAtomicInlineLevelBox() || displayBox.isGenericInlineLevelBox() || displayBox.isNonRootInlineBox();
+        if (!mayHaveInkOverflow)
+            continue;
+        if (displayBox.isNonRootInlineBox() && !accumulatedInkOverflowRect.isEmpty())
+            displayBox.adjustInkOverflow(accumulatedInkOverflowRect);
+
+        // We stop collecting ink overflow for at root inline box (i.e. don't inflate the root inline box with the inline content here).
+        auto parentBoxIsRoot = &displayBox.layoutBox().parent() == &root();
+        if (parentBoxIsRoot)
+            accumulatedInkOverflowRect = InlineRect { { }, { } };
+        else if (accumulatedInkOverflowRect.isEmpty())
+            accumulatedInkOverflowRect = displayBox.inkOverflow();
+        else
+            accumulatedInkOverflowRect.expandToContain(displayBox.inkOverflow());
+    }
+}
+
+void InlineDisplayContentBuilder::computeIsFirstIsLastBoxForInlineContent(DisplayBoxes& boxes)
+{
+    HashMap<const Box*, size_t> lastDisplayBoxForLayoutBoxIndexes;
+
+    ASSERT(boxes[0].isRootInlineBox());
+    boxes[0].setIsFirstForLayoutBox(true);
+    size_t lastRootInlineBoxIndex = 0;
+
+    for (size_t index = 1; index < boxes.size(); ++index) {
+        auto& displayBox = boxes[index];
+        if (displayBox.isRootInlineBox()) {
+            lastRootInlineBoxIndex = index;
+            continue;
+        }
+        auto& layoutBox = displayBox.layoutBox();
+        if (lastDisplayBoxForLayoutBoxIndexes.set(&layoutBox, index).isNewEntry)
+            displayBox.setIsFirstForLayoutBox(true);
+    }
+    for (auto index : lastDisplayBoxForLayoutBoxIndexes.values())
+        boxes[index].setIsLastForLayoutBox(true);
+
+    boxes[lastRootInlineBoxIndex].setIsLastForLayoutBox(true);
+}
+
+}
+}
+
+#endif

Copied: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h (from rev 287270, trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.h) (0 => 287271)


--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h	2021-12-20 20:17:09 UTC (rev 287271)
@@ -0,0 +1,81 @@
+/*
+ * 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 "InlineLineBuilder.h"
+#include "LayoutUnits.h"
+
+namespace WebCore {
+namespace Layout {
+
+struct AncestorStack;
+class ContainerBox;
+struct DisplayBoxTree;
+struct IsFirstLastIndex;
+class InlineFormattingState;
+class LineBox;
+
+class InlineDisplayContentBuilder {
+public:
+    InlineDisplayContentBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState&);
+
+    DisplayBoxes build(const LineBuilder::LineContent&, const LineBox&, const InlineRect& lineBoxLogicalRect, const size_t lineIndex);
+
+    static void computeIsFirstIsLastBoxForInlineContent(DisplayBoxes&);
+
+private:
+    void processNonBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineLayoutPoint& lineBoxLogicalTopLeft, DisplayBoxes&);
+    void processBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineLayoutPoint& lineBoxLogicalTopLeft, DisplayBoxes&);
+    void processOverflownRunsForEllipsis(DisplayBoxes&, InlineLayoutUnit lineBoxLogicalRight);
+    void collectInkOverflowForInlineBoxes(DisplayBoxes&);
+
+    void appendTextDisplayBox(const Line::Run&, const InlineRect&, DisplayBoxes&);
+    void appendSoftLineBreakDisplayBox(const Line::Run&, const InlineRect&, DisplayBoxes&);
+    void appendHardLineBreakDisplayBox(const Line::Run&, const InlineRect&, DisplayBoxes&);
+    void appendAtomicInlineLevelDisplayBox(const Line::Run&, const InlineRect& , DisplayBoxes&);
+    void appendInlineBoxDisplayBox(const Line::Run&, const InlineLevelBox&, const InlineRect&, bool linehasContent, DisplayBoxes&);
+    void appendSpanningInlineBoxDisplayBox(const Line::Run&, const InlineLevelBox&, const InlineRect&, DisplayBoxes&);
+    void appendInlineDisplayBoxAtBidiBoundary(const Box&, DisplayBoxes&);
+
+    void setInlineBoxGeometry(const Box&, const InlineRect&, bool isFirstInlineBoxFragment);
+    void adjustVisualGeometryForDisplayBox(size_t displayBoxNodeIndex, InlineLayoutUnit& accumulatedOffset, InlineLayoutUnit lineBoxLogicalTop, const DisplayBoxTree&, DisplayBoxes&, const LineBox&, const HashMap<const Box*, IsFirstLastIndex>&);
+    size_t ensureDisplayBoxForContainer(const ContainerBox&, DisplayBoxTree&, AncestorStack&, DisplayBoxes&);
+
+    const ContainerBox& root() const { return m_formattingContextRoot; }
+    InlineFormattingState& formattingState() const { return m_formattingState; } 
+
+    const ContainerBox& m_formattingContextRoot;
+    InlineFormattingState& m_formattingState;
+    size_t m_lineIndex { 0 };
+    bool m_contentHasInkOverflow { false };
+};
+
+}
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to