Title: [252316] trunk/Source/WebCore
Revision
252316
Author
[email protected]
Date
2019-11-10 20:09:59 -0800 (Sun, 10 Nov 2019)

Log Message

[LFC][IFC] Move Line::Run's line layout specific logic to InlineItemRun
https://bugs.webkit.org/show_bug.cgi?id=204055
<rdar://problem/57053232>

Reviewed by Antti Koivisto.

Line::Run started getting a bit overloaded through supporting the line layout logic and providing the 'run' interface
to the caller (e.g. merging multiple runs happens at the very end of the line layout, when the line is being closed. When a run
is expanded some of the properties do not make sense anymore. It makes part of the Run's logic unnecessarily complicated).
This patch introduces the InlineItemRun structure to support the line layout logic. We construct InlineItemRuns
as InlineItems are getting appended to the line and when the line is getting closed, we turn them into Line::Runs (InlineItems are never merged, only Line::Runs are).

* layout/displaytree/DisplayRun.h:
(WebCore::Display::Run::TextContext::setExpansion):
(WebCore::Display::Run::Run):
(WebCore::Display::Run::TextContext::resetExpansion): Deleted.
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):
* layout/inlineformatting/InlineFormattingContextQuirks.cpp:
(WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing const):
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::InlineItemRun::layoutBox const):
(WebCore::Layout::InlineItemRun::logicalRect const):
(WebCore::Layout::InlineItemRun::textContext const):
(WebCore::Layout::InlineItemRun::isText const):
(WebCore::Layout::InlineItemRun::isBox const):
(WebCore::Layout::InlineItemRun::isContainerStart const):
(WebCore::Layout::InlineItemRun::isContainerEnd const):
(WebCore::Layout::InlineItemRun::type const):
(WebCore::Layout::InlineItemRun::setIsCollapsed):
(WebCore::Layout::InlineItemRun::isCollapsed const):
(WebCore::Layout::InlineItemRun::isCollapsedToZeroAdvanceWidth const):
(WebCore::Layout::InlineItemRun::isCollapsible const):
(WebCore::Layout::InlineItemRun::isWhitespace const):
(WebCore::Layout::InlineItemRun::hasExpansionOpportunity const):
(WebCore::Layout::InlineItemRun::InlineItemRun):
(WebCore::Layout::InlineItemRun::setCollapsesToZeroAdvanceWidth):
(WebCore::Layout::Line::Run::Run):
(WebCore::Layout::Line::Run::adjustExpansionBehavior):
(WebCore::Layout::Line::Run::expansionBehavior const):
(WebCore::Layout::Line::Run::setHasExpansionOpportunity):
(WebCore::Layout::Line::Run::setComputedHorizontalExpansion):
(WebCore::Layout::Line::Run::expand):
(WebCore::Layout::Line::~Line):
(WebCore::Layout::Line::isVisuallyEmpty const):
(WebCore::Layout::Line::close):
(WebCore::Layout::Line::alignContentVertically const):
(WebCore::Layout::Line::justifyRuns const):
(WebCore::Layout::Line::alignContentHorizontally const):
(WebCore::Layout::Line::removeTrailingTrimmableContent):
(WebCore::Layout::Line::trailingTrimmableWidth const):
(WebCore::Layout::Line::appendNonBreakableSpace):
(WebCore::Layout::Line::appendTextContent):
(WebCore::Layout::Line::appendNonReplacedInlineBox):
(WebCore::Layout::Line::appendReplacedInlineBox): Need to find a better place for setImage.
(WebCore::Layout::Line::appendLineBreak):
(WebCore::Layout::Line::alignContentVertically): Deleted.
(WebCore::Layout::Line::justifyRuns): Deleted.
(WebCore::Layout::Line::alignContentHorizontally): Deleted.
* layout/inlineformatting/InlineLine.h:
(WebCore::Layout::Line::Run::layoutBox const):
(WebCore::Layout::Line::Run::logicalRect const):
(WebCore::Layout::Line::Run::textContext const):
(WebCore::Layout::Line::Run::isCollapsedToVisuallyEmpty const):
(WebCore::Layout::Line::Run::adjustLogicalTop):
(WebCore::Layout::Line::Run::moveHorizontally):
(WebCore::Layout::Line::Run::moveVertically):
(WebCore::Layout::Line::Run::setTextContext):
(WebCore::Layout::Line::Run::setIsCollapsedToVisuallyEmpty):
(WebCore::Layout::Line::Run::hasExpansionOpportunity const):
(WebCore::Layout::Line::Run::expansionOpportunityCount const):
(WebCore::Layout::Line::Run::displayRun const): Deleted.
(WebCore::Layout::Line::Run::isCollapsed const): Deleted.
(WebCore::Layout::Line::Run::isCollapsible const): Deleted.
(WebCore::Layout::Line::Run::hasTrailingCollapsedContent const): Deleted.
(WebCore::Layout::Line::Run::isWhitespace const): Deleted.
(WebCore::Layout::Line::Run::setIsCollapsed): Deleted.
(WebCore::Layout::Line::Run::isCollapsedToZeroAdvanceWidth const): Deleted.
(WebCore::Layout::Line::Run::setCollapsesToZeroAdvanceWidth): Deleted.
(WebCore::Layout::Line::Run::expansionBehavior const): Deleted.
(WebCore::Layout::Line::Run::setHasExpansionOpportunity): Deleted.
(WebCore::Layout::Line::Run::adjustExpansionBehavior): Deleted.
(WebCore::Layout::Line::Run::setComputedHorizontalExpansion): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (252315 => 252316)


--- trunk/Source/WebCore/ChangeLog	2019-11-11 00:16:47 UTC (rev 252315)
+++ trunk/Source/WebCore/ChangeLog	2019-11-11 04:09:59 UTC (rev 252316)
@@ -1,3 +1,89 @@
+2019-11-10  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Move Line::Run's line layout specific logic to InlineItemRun
+        https://bugs.webkit.org/show_bug.cgi?id=204055
+        <rdar://problem/57053232>
+
+        Reviewed by Antti Koivisto.
+
+        Line::Run started getting a bit overloaded through supporting the line layout logic and providing the 'run' interface
+        to the caller (e.g. merging multiple runs happens at the very end of the line layout, when the line is being closed. When a run
+        is expanded some of the properties do not make sense anymore. It makes part of the Run's logic unnecessarily complicated).
+        This patch introduces the InlineItemRun structure to support the line layout logic. We construct InlineItemRuns
+        as InlineItems are getting appended to the line and when the line is getting closed, we turn them into Line::Runs (InlineItems are never merged, only Line::Runs are).
+
+        * layout/displaytree/DisplayRun.h:
+        (WebCore::Display::Run::TextContext::setExpansion):
+        (WebCore::Display::Run::Run):
+        (WebCore::Display::Run::TextContext::resetExpansion): Deleted.
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine):
+        * layout/inlineformatting/InlineFormattingContextQuirks.cpp:
+        (WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing const):
+        * layout/inlineformatting/InlineLine.cpp:
+        (WebCore::Layout::InlineItemRun::layoutBox const):
+        (WebCore::Layout::InlineItemRun::logicalRect const):
+        (WebCore::Layout::InlineItemRun::textContext const):
+        (WebCore::Layout::InlineItemRun::isText const):
+        (WebCore::Layout::InlineItemRun::isBox const):
+        (WebCore::Layout::InlineItemRun::isContainerStart const):
+        (WebCore::Layout::InlineItemRun::isContainerEnd const):
+        (WebCore::Layout::InlineItemRun::type const):
+        (WebCore::Layout::InlineItemRun::setIsCollapsed):
+        (WebCore::Layout::InlineItemRun::isCollapsed const):
+        (WebCore::Layout::InlineItemRun::isCollapsedToZeroAdvanceWidth const):
+        (WebCore::Layout::InlineItemRun::isCollapsible const):
+        (WebCore::Layout::InlineItemRun::isWhitespace const):
+        (WebCore::Layout::InlineItemRun::hasExpansionOpportunity const):
+        (WebCore::Layout::InlineItemRun::InlineItemRun):
+        (WebCore::Layout::InlineItemRun::setCollapsesToZeroAdvanceWidth):
+        (WebCore::Layout::Line::Run::Run):
+        (WebCore::Layout::Line::Run::adjustExpansionBehavior):
+        (WebCore::Layout::Line::Run::expansionBehavior const):
+        (WebCore::Layout::Line::Run::setHasExpansionOpportunity):
+        (WebCore::Layout::Line::Run::setComputedHorizontalExpansion):
+        (WebCore::Layout::Line::Run::expand):
+        (WebCore::Layout::Line::~Line):
+        (WebCore::Layout::Line::isVisuallyEmpty const):
+        (WebCore::Layout::Line::close):
+        (WebCore::Layout::Line::alignContentVertically const):
+        (WebCore::Layout::Line::justifyRuns const):
+        (WebCore::Layout::Line::alignContentHorizontally const):
+        (WebCore::Layout::Line::removeTrailingTrimmableContent):
+        (WebCore::Layout::Line::trailingTrimmableWidth const):
+        (WebCore::Layout::Line::appendNonBreakableSpace):
+        (WebCore::Layout::Line::appendTextContent):
+        (WebCore::Layout::Line::appendNonReplacedInlineBox):
+        (WebCore::Layout::Line::appendReplacedInlineBox): Need to find a better place for setImage.
+        (WebCore::Layout::Line::appendLineBreak):
+        (WebCore::Layout::Line::alignContentVertically): Deleted.
+        (WebCore::Layout::Line::justifyRuns): Deleted.
+        (WebCore::Layout::Line::alignContentHorizontally): Deleted.
+        * layout/inlineformatting/InlineLine.h:
+        (WebCore::Layout::Line::Run::layoutBox const):
+        (WebCore::Layout::Line::Run::logicalRect const):
+        (WebCore::Layout::Line::Run::textContext const):
+        (WebCore::Layout::Line::Run::isCollapsedToVisuallyEmpty const):
+        (WebCore::Layout::Line::Run::adjustLogicalTop):
+        (WebCore::Layout::Line::Run::moveHorizontally):
+        (WebCore::Layout::Line::Run::moveVertically):
+        (WebCore::Layout::Line::Run::setTextContext):
+        (WebCore::Layout::Line::Run::setIsCollapsedToVisuallyEmpty):
+        (WebCore::Layout::Line::Run::hasExpansionOpportunity const):
+        (WebCore::Layout::Line::Run::expansionOpportunityCount const):
+        (WebCore::Layout::Line::Run::displayRun const): Deleted.
+        (WebCore::Layout::Line::Run::isCollapsed const): Deleted.
+        (WebCore::Layout::Line::Run::isCollapsible const): Deleted.
+        (WebCore::Layout::Line::Run::hasTrailingCollapsedContent const): Deleted.
+        (WebCore::Layout::Line::Run::isWhitespace const): Deleted.
+        (WebCore::Layout::Line::Run::setIsCollapsed): Deleted.
+        (WebCore::Layout::Line::Run::isCollapsedToZeroAdvanceWidth const): Deleted.
+        (WebCore::Layout::Line::Run::setCollapsesToZeroAdvanceWidth): Deleted.
+        (WebCore::Layout::Line::Run::expansionBehavior const): Deleted.
+        (WebCore::Layout::Line::Run::setHasExpansionOpportunity): Deleted.
+        (WebCore::Layout::Line::Run::adjustExpansionBehavior): Deleted.
+        (WebCore::Layout::Line::Run::setComputedHorizontalExpansion): Deleted.
+
 2019-11-10  Wenson Hsieh  <[email protected]>
 
         [Clipboard API] Add some infrastructure to resolve ClipboardItems into pasteboard data for writing

Modified: trunk/Source/WebCore/layout/displaytree/DisplayRun.h (252315 => 252316)


--- trunk/Source/WebCore/layout/displaytree/DisplayRun.h	2019-11-11 00:16:47 UTC (rev 252315)
+++ trunk/Source/WebCore/layout/displaytree/DisplayRun.h	2019-11-11 04:09:59 UTC (rev 252316)
@@ -56,7 +56,6 @@
             LayoutUnit horizontalExpansion;
         };
         void setExpansion(ExpansionContext expansionContext) { m_expansionContext = expansionContext; }
-        void resetExpansion() { m_expansionContext = WTF::nullopt; }
         Optional<ExpansionContext> expansion() const { return m_expansionContext; }
 
         void expand(const TextContext& other);
@@ -69,7 +68,7 @@
         String m_content;
     };
 
-    Run(const RenderStyle&, Rect logicalRect, Optional<TextContext> = WTF::nullopt);
+    Run(const RenderStyle&, const Rect& logicalRect, Optional<TextContext> = WTF::nullopt);
 
     const Rect& logicalRect() const { return m_logicalRect; }
 
@@ -108,7 +107,7 @@
     Optional<TextContext> m_textContext;
 };
 
-inline Run::Run(const RenderStyle& style, Rect logicalRect, Optional<TextContext> textContext)
+inline Run::Run(const RenderStyle& style, const Rect& logicalRect, Optional<TextContext> textContext)
     : m_style(style)
     , m_logicalRect(logicalRect)
     , m_textContext(textContext)

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (252315 => 252316)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2019-11-11 00:16:47 UTC (rev 252315)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2019-11-11 04:09:59 UTC (rev 252316)
@@ -432,13 +432,13 @@
     // FIXME: This is tempoary.
     auto& currentLine = *formattingState.lineBoxes().last();
     for (auto& lineRun : lineContent.runList) {
-        // Inline level containers (<span>) don't generate inline runs.
-        if (lineRun->isContainerStart() || lineRun->isContainerEnd())
+        // Inline level containers (<span>) don't generate display runs.
+        if (lineRun.isContainerStart() || lineRun.isContainerEnd())
             continue;
-        // Completely collapsed line runs don't generate display runs.
-        if (lineRun->isCollapsedToZeroAdvanceWidth())
+        // Completely collapsed line runs don't generate display runs either.
+        if (lineRun.isCollapsedToVisuallyEmpty())
             continue;
-        formattingState.addInlineRun(lineRun->displayRun(), currentLine);
+        formattingState.addInlineRun({ lineRun.layoutBox().style(), lineRun.logicalRect(), lineRun.textContext() }, currentLine);
     }
 
     // Compute box final geometry.
@@ -445,11 +445,11 @@
     auto& lineRuns = lineContent.runList;
     for (unsigned index = 0; index < lineRuns.size(); ++index) {
         auto& lineRun = lineRuns.at(index);
-        auto& logicalRect = lineRun->logicalRect();
-        auto& layoutBox = lineRun->layoutBox();
+        auto& logicalRect = lineRun.logicalRect();
+        auto& layoutBox = lineRun.layoutBox();
         auto& displayBox = formattingState.displayBox(layoutBox);
 
-        if (lineRun->isForcedLineBreak()) {
+        if (lineRun.isForcedLineBreak()) {
             displayBox.setTopLeft(logicalRect.topLeft());
             displayBox.setContentBoxWidth(logicalRect.width());
             displayBox.setContentBoxHeight(logicalRect.height());
@@ -457,7 +457,7 @@
         }
 
         // Inline level box (replaced or inline-block)
-        if (lineRun->isBox()) {
+        if (lineRun.isBox()) {
             auto topLeft = logicalRect.topLeft();
             if (layoutBox.isInFlowPositioned())
                 topLeft += geometry().inFlowPositionedPositionOffset(layoutBox, usedHorizontalValues);
@@ -466,13 +466,13 @@
         }
 
         // Inline level container start (<span>)
-        if (lineRun->isContainerStart()) {
+        if (lineRun.isContainerStart()) {
             displayBox.setTopLeft(logicalRect.topLeft());
             continue;
         }
 
         // Inline level container end (</span>)
-        if (lineRun->isContainerEnd()) {
+        if (lineRun.isContainerEnd()) {
             if (layoutBox.isInFlowPositioned()) {
                 auto inflowOffset = geometry().inFlowPositionedPositionOffset(layoutBox, usedHorizontalValues);
                 displayBox.moveHorizontally(inflowOffset.width());
@@ -486,11 +486,9 @@
             continue;
         }
 
-        if (lineRun->isText()) {
-            const Line::Run* previousLineRun = !index ? nullptr : lineRuns[index - 1].get();
-            // FIXME take content breaking into account when part of the layout box is on the previous line.
-            auto firstInlineRunForLayoutBox = !previousLineRun || &previousLineRun->layoutBox() != &layoutBox;
-            if (firstInlineRunForLayoutBox) {
+        if (lineRun.isText()) {
+            auto firstRunForLayoutBox = !index || &lineRuns[index - 1].layoutBox() != &layoutBox; 
+            if (firstRunForLayoutBox) {
                 // Setup display box for the associated layout box.
                 displayBox.setTopLeft(logicalRect.topLeft());
                 displayBox.setContentBoxWidth(logicalRect.width());

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp (252315 => 252316)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2019-11-11 00:16:47 UTC (rev 252315)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2019-11-11 04:09:59 UTC (rev 252316)
@@ -43,24 +43,24 @@
         return false;
 
     for (auto& run : runList) {
-        auto& layoutBox = run->layoutBox();
-        if (run->isContainerEnd() || layoutBox.style().verticalAlign() != VerticalAlign::Baseline)
+        auto& layoutBox = run.layoutBox();
+        if (run.isContainerEnd() || layoutBox.style().verticalAlign() != VerticalAlign::Baseline)
             continue;
 
-        if (run->isForcedLineBreak())
+        if (run.isForcedLineBreak())
             return false;
-        if (run->isText()) {
-            if (!run->isCollapsedToZeroAdvanceWidth())
+        if (run.isText()) {
+            if (!run.isCollapsedToVisuallyEmpty())
                 return false;
             continue;
         }
-        if (run->isContainerStart()) {
+        if (run.isContainerStart()) {
             auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
             if (boxGeometry.horizontalBorder() || (boxGeometry.horizontalPadding() && boxGeometry.horizontalPadding().value()))
                 return false;
             continue;
         }
-        if (run->isBox()) {
+        if (run.isBox()) {
             if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) {
                 auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(downcast<Container>(layoutBox)));
                 ASSERT(!formattingState.lineBoxes().isEmpty());

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (252315 => 252316)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2019-11-11 00:16:47 UTC (rev 252315)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2019-11-11 04:09:59 UTC (rev 252316)
@@ -37,39 +37,109 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(Line);
 
-Line::Run::Run(const InlineItem& inlineItem, const Display::Run& displayRun)
-    : m_layoutBox(inlineItem.layoutBox())
-    , m_displayRun(displayRun)
-    , m_type(inlineItem.type())
-    , m_isWhitespace(is<InlineTextItem>(inlineItem) && downcast<InlineTextItem>(inlineItem).isWhitespace())
-    , m_isCollapsible(is<InlineTextItem>(inlineItem) && downcast<InlineTextItem>(inlineItem).isCollapsible())
+class InlineItemRun {
+WTF_MAKE_ISO_ALLOCATED_INLINE(InlineItemRun);
+public:
+    InlineItemRun(const InlineItem&, const Display::Rect&, WTF::Optional<Display::Run::TextContext> = WTF::nullopt);
+
+    const Box& layoutBox() const { return m_inlineItem.layoutBox(); }
+    const Display::Rect& logicalRect() const { return m_logicalRect; }
+    Optional<Display::Run::TextContext> textContext() const { return m_textContext; }
+
+    bool isText() const { return m_inlineItem.isText(); }
+    bool isBox() const { return m_inlineItem.isBox(); }
+    bool isContainerStart() const { return m_inlineItem.isContainerStart(); }
+    bool isContainerEnd() const { return m_inlineItem.isContainerEnd(); }
+    InlineItem::Type type() const { return m_inlineItem.type(); }
+
+    void setIsCollapsed() { m_isCollapsed = true; }
+    bool isCollapsed() const { return m_isCollapsed; }
+
+    void setCollapsesToZeroAdvanceWidth();
+    bool isCollapsedToZeroAdvanceWidth() const { return m_collapsedToZeroAdvanceWidth; }
+
+    bool isCollapsible() const { return is<InlineTextItem>(m_inlineItem) && downcast<InlineTextItem>(m_inlineItem).isCollapsible(); }
+    bool isWhitespace() const { return is<InlineTextItem>(m_inlineItem) && downcast<InlineTextItem>(m_inlineItem).isWhitespace(); }
+
+    bool hasExpansionOpportunity() const { return isWhitespace() && !isCollapsedToZeroAdvanceWidth(); }
+
+private:
+    const InlineItem& m_inlineItem;
+    Display::Rect m_logicalRect;
+    const Optional<Display::Run::TextContext> m_textContext;
+    bool m_isCollapsed { false };
+    bool m_collapsedToZeroAdvanceWidth { false };
+};
+
+InlineItemRun::InlineItemRun(const InlineItem& inlineItem, const Display::Rect& logicalRect, WTF::Optional<Display::Run::TextContext> textContext)
+    : m_inlineItem(inlineItem)
+    , m_logicalRect(logicalRect)
+    , m_textContext(textContext)
 {
 }
 
-void Line::Run::expand(const Run& other)
+void InlineItemRun::setCollapsesToZeroAdvanceWidth()
 {
+    m_collapsedToZeroAdvanceWidth = true;
+    m_logicalRect.setWidth({ });
+}
+
+Line::Run::Run(const Box& layoutBox, InlineItem::Type type, const Display::Rect& logicalRect)
+    : m_layoutBox(layoutBox)
+    , m_type(type)
+    , m_logicalRect(logicalRect)
+{
+}
+
+void Line::Run::adjustExpansionBehavior(ExpansionBehavior expansionBehavior)
+{
     ASSERT(isText());
-    ASSERT(other.isText());
-    ASSERT(!isCollapsedToZeroAdvanceWidth());
-    ASSERT(!hasTrailingCollapsedContent());
+    ASSERT(hasExpansionOpportunity());
+    m_textContext->setExpansion({ expansionBehavior, m_textContext->expansion()->horizontalExpansion });
+}
 
-    auto& otherDisplayRun = other.displayRun();
-    m_displayRun.expandHorizontally(otherDisplayRun.logicalWidth());
-    m_displayRun.textContext()->expand(*otherDisplayRun.textContext());
-    m_hasTrailingCollapsedContent = other.isCollapsed();
-    m_isWhitespace &= other.isWhitespace();
-    m_isCollapsible = false;
+inline Optional<ExpansionBehavior> Line::Run::expansionBehavior() const
+{
+    ASSERT(isText());
+    if (auto expansionContext = m_textContext->expansion())
+        return expansionContext->behavior;
+    return { };
+}
 
+void Line::Run::setHasExpansionOpportunity(ExpansionBehavior expansionBehavior)
+{
+    ASSERT(isText());
+    ASSERT(!hasExpansionOpportunity());
+    m_expansionOpportunityCount = 1;
+    m_textContext->setExpansion({ expansionBehavior, { } });
+}
+
+void Line::Run::setComputedHorizontalExpansion(LayoutUnit logicalExpansion)
+{
+    ASSERT(isText());
+    ASSERT(hasExpansionOpportunity());
+    m_logicalRect.expandHorizontally(logicalExpansion);
+    m_textContext->setExpansion({ m_textContext->expansion()->behavior, logicalExpansion });
+}
+
+void Line::Run::expand(const InlineItemRun& nextRun)
+{
+    ASSERT(isText());
+    ASSERT(nextRun.isText());
+    ASSERT(!isCollapsedToVisuallyEmpty());
+
+    m_logicalRect.expandHorizontally(nextRun.logicalRect().width());
+    m_textContext->expand(*nextRun.textContext());
+
     // FIXME: This is a very simple expansion merge. We should eventually switch over to FontCascade::expansionOpportunityCount. 
-    if (hasExpansionOpportunity() && other.hasExpansionOpportunity()) {
+    if (hasExpansionOpportunity() && nextRun.hasExpansionOpportunity()) {
         // Run is expanded with a whitespace content.
         adjustExpansionBehavior(ForbidLeadingExpansion | AllowTrailingExpansion);
-        m_expansionOpportunityCount = *m_expansionOpportunityCount + *other.expansionOpportunityCount();
-    } else if (!hasExpansionOpportunity() && other.hasExpansionOpportunity()) {
+        ++m_expansionOpportunityCount;
+    } else if (!hasExpansionOpportunity() && nextRun.hasExpansionOpportunity()) {
         // Nonwhitespace runs is expanded with whitespace.
         setHasExpansionOpportunity(ForbidLeadingExpansion | AllowTrailingExpansion);
-        m_expansionOpportunityCount = other.expansionOpportunityCount();
-    } else if (hasExpansionOpportunity() && !other.hasExpansionOpportunity()) {
+    } else if (hasExpansionOpportunity() && !nextRun.hasExpansionOpportunity()) {
         // Run is expanded with a nonwhitespace content.
         adjustExpansionBehavior(AllowLeadingExpansion | AllowTrailingExpansion);
     }
@@ -90,6 +160,10 @@
     m_lineBox = LineBox { lineRect, baseline, initialBaselineOffset };
 }
 
+Line::~Line()
+{
+}
+
 static bool isInlineContainerConsideredEmpty(const FormattingContext& formattingContext, const Box& layoutBox)
 {
     // Note that this does not check whether the inline container has content. It simply checks if the container itself is considered empty.
@@ -118,7 +192,7 @@
     // FIXME: This should be cached instead -as the inline items are being added.
     // Return true for empty inline containers like <span></span>.
     auto& formattingContext = this->formattingContext();
-    for (auto& run : m_runList) {
+    for (auto& run : m_inlineItemRuns) {
         if (run->isContainerStart()) {
             if (!isInlineContainerConsideredEmpty(formattingContext, run->layoutBox()))
                 return false;
@@ -143,75 +217,90 @@
 
 Line::RunList Line::close(IsLastLineWithInlineContent isLastLineWithInlineContent)
 {
+    // 1. Remove trimmable trailing content.
+    // 2. Join text runs together when possible [foo][ ][bar] -> [foo bar].
+    // 3. Align merged runs both vertically and horizontally.
     removeTrailingTrimmableContent();
-    // Join text runs together when possible.
-    unsigned index = 1;
-    while (index < m_runList.size()) {
-        auto canMergeRuns = [](const auto& previousRun, const auto& currentRun) {
-            // Do not merge runs across inline boxes (<span>foo</span><span>bar</span>)
-            if (&previousRun->layoutBox() !=  &currentRun->layoutBox())
-                return false;
-            // Only text content can be merged.
-            if (!previousRun->isText() || !currentRun->isText())
-                return false;
-            // Merged content needs to be continuous.
-            if (previousRun->hasTrailingCollapsedContent())
-                return false;
-            // Visually empty runs are ignored.
-            if (currentRun->isCollapsedToZeroAdvanceWidth() || previousRun->isCollapsedToZeroAdvanceWidth())
-                return false;
-            return true;
+    RunList runList;
+    for (unsigned i = 0; i < m_inlineItemRuns.size(); ++i) {
+
+        auto constructRun = [&] (const auto& inlineItemRun) {
+            runList.append(Run { inlineItemRun.layoutBox(), inlineItemRun.type(), inlineItemRun.logicalRect() });
+            if (!inlineItemRun.isText())
+                return;
+
+            auto& run = runList.last();
+            if (inlineItemRun.isCollapsedToZeroAdvanceWidth())
+                run.setIsCollapsedToVisuallyEmpty();
+            if (auto textContext = inlineItemRun.textContext()) {
+                run.setTextContext(*textContext);
+                if (isTextAlignJustify() && inlineItemRun.hasExpansionOpportunity())
+                    run.setHasExpansionOpportunity(DefaultExpansion);
+            }
         };
-        auto& previousRun = m_runList[index - 1];
-        auto& currentRun = m_runList[index];
-        if (canMergeRuns(previousRun, currentRun)) {
-            previousRun->expand(*currentRun);
-            m_runList.remove(index);
-            continue;
+
+        constructRun(*m_inlineItemRuns[i]);
+        // Merge eligible runs.
+        while (i < m_inlineItemRuns.size() - 1) {
+            auto canMergeRuns = [] (const auto& currentRun, const auto& nextRun) {
+                // Do not merge runs across inline boxes (<span>foo</span><span>bar</span>)
+                if (&currentRun.layoutBox() != &nextRun.layoutBox())
+                    return false;
+                // Only text content can be merged.
+                if (!currentRun.isText() || !nextRun.isText())
+                    return false;
+                // Merged content needs to be continuous.
+                if (currentRun.isCollapsed())
+                    return false;
+                // Visually empty runs are ignored.
+                if (currentRun.isCollapsedToZeroAdvanceWidth() || nextRun.isCollapsedToZeroAdvanceWidth())
+                    return false;
+                return true;
+            };
+            auto& currentRun = m_inlineItemRuns[i];
+            auto& nextRun = m_inlineItemRuns[i + 1];
+            if (!canMergeRuns(*currentRun, *nextRun))
+                break;
+            runList.last().expand(*nextRun);
+            // Skip the merged run.
+            ++i;
         }
-        ++index;
     }
 
     if (!m_skipAlignment) {
-        alignContentVertically();
-        alignContentHorizontally(isLastLineWithInlineContent);
+        if (isVisuallyEmpty()) {
+            m_lineBox.resetBaseline();
+            m_lineBox.setLogicalHeight({ });
+        }
+        // Remove descent when all content is baseline aligned but none of them have descent.
+        if (formattingContext().quirks().lineDescentNeedsCollapsing(runList)) {
+            m_lineBox.shrinkVertically(m_lineBox.baseline().descent());
+            m_lineBox.resetDescent();
+        }
+        alignContentVertically(runList);
+        alignContentHorizontally(runList, isLastLineWithInlineContent);
     }
-
-    return WTFMove(m_runList);
+    return runList;
 }
 
-void Line::alignContentVertically()
+void Line::alignContentVertically(RunList& runList) const
 {
     ASSERT(!m_skipAlignment);
-
-    if (isVisuallyEmpty()) {
-        m_lineBox.resetBaseline();
-        m_lineBox.setLogicalHeight({ });
-    }
-
-    // Remove descent when all content is baseline aligned but none of them have descent.
-    if (formattingContext().quirks().lineDescentNeedsCollapsing(m_runList)) {
-        m_lineBox.shrinkVertically(m_lineBox.baseline().descent());
-        m_lineBox.resetDescent();
-    }
-
-    auto& layoutState = this->layoutState();
-    auto& formattingContext = this->formattingContext();
-    for (auto& run : m_runList) {
+    for (auto& run : runList) {
         LayoutUnit logicalTop;
-        auto& layoutBox = run->layoutBox();
+        auto& layoutBox = run.layoutBox();
         auto verticalAlign = layoutBox.style().verticalAlign();
         auto ascent = layoutBox.style().fontMetrics().ascent();
 
         switch (verticalAlign) {
         case VerticalAlign::Baseline:
-            if (run->isForcedLineBreak() || run->isText())
+            if (run.isForcedLineBreak() || run.isText())
                 logicalTop = baselineOffset() - ascent;
-            else if (run->isContainerStart()) {
-                auto& boxGeometry = formattingContext.geometryForBox(layoutBox);
+            else if (run.isContainerStart()) {
+                auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
                 logicalTop = baselineOffset() - ascent - boxGeometry.borderTop() - boxGeometry.paddingTop().valueOr(0);
             } else if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) {
-                auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(downcast<Container>(layoutBox)));
+                auto& formattingState = downcast<InlineFormattingState>(layoutState().establishedFormattingState(downcast<Container>(layoutBox)));
                 // Spec makes us generate at least one line -even if it is empty.
                 ASSERT(!formattingState.lineBoxes().isEmpty());
                 auto inlineBlockBaselineOffset = formattingState.lineBoxes().last()->baselineOffset();
@@ -229,44 +318,41 @@
                 //     text | | |   v text
                 //     -----|-|-|---------- <- baseline
                 //
-                auto& boxGeometry = formattingContext.geometryForBox(layoutBox);
+                auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
                 auto baselineOffsetFromMarginBox = boxGeometry.marginBefore() + boxGeometry.borderTop() + boxGeometry.paddingTop().valueOr(0) + inlineBlockBaselineOffset;
                 logicalTop = baselineOffset() - baselineOffsetFromMarginBox;
             } else
-                logicalTop = baselineOffset() - run->logicalRect().height();
+                logicalTop = baselineOffset() - run.logicalRect().height();
             break;
         case VerticalAlign::Top:
             logicalTop = { };
             break;
         case VerticalAlign::Bottom:
-            logicalTop = logicalBottom() - run->logicalRect().height();
+            logicalTop = logicalBottom() - run.logicalRect().height();
             break;
         default:
             ASSERT_NOT_IMPLEMENTED_YET();
             break;
         }
-        run->adjustLogicalTop(logicalTop);
+        run.adjustLogicalTop(logicalTop);
         // Convert runs from relative to the line top/left to the formatting root's border box top/left.
-        run->moveVertically(this->logicalTop());
-        run->moveHorizontally(this->logicalLeft());
+        run.moveVertically(this->logicalTop());
+        run.moveHorizontally(this->logicalLeft());
     }
 }
 
-void Line::justifyRuns()
+void Line::justifyRuns(RunList& runList) const
 {
-    ASSERT(!m_runList.isEmpty());
+    ASSERT(!runList.isEmpty());
     ASSERT(availableWidth() > 0);
     // Need to fix up the last run first.
-    auto& lastRun = m_runList.last();
-    if (lastRun->hasExpansionOpportunity())
-        lastRun->adjustExpansionBehavior(*lastRun->expansionBehavior() | ForbidTrailingExpansion);
+    auto& lastRun = runList.last();
+    if (lastRun.hasExpansionOpportunity())
+        lastRun.adjustExpansionBehavior(*lastRun.expansionBehavior() | ForbidTrailingExpansion);
     // Collect the expansion opportunity numbers.
     auto expansionOpportunityCount = 0;
-    for (auto& run : m_runList) {
-        if (!run->hasExpansionOpportunity())
-            continue;
-        expansionOpportunityCount += *run->expansionOpportunityCount();
-    }
+    for (auto& run : runList)
+        expansionOpportunityCount += run.expansionOpportunityCount();
     // Nothing to distribute?
     if (!expansionOpportunityCount)
         return;
@@ -273,29 +359,30 @@
     // Distribute the extra space.
     auto expansionToDistribute = availableWidth() / expansionOpportunityCount;
     LayoutUnit accumulatedExpansion;
-    for (auto& run : m_runList) {
+    for (auto& run : runList) {
         // Expand and moves runs by the accumulated expansion.
-        if (!run->hasExpansionOpportunity()) {
-            run->moveHorizontally(accumulatedExpansion);
+        if (!run.hasExpansionOpportunity()) {
+            run.moveHorizontally(accumulatedExpansion);
             continue;
         }
-        auto computedExpansion = expansionToDistribute * *run->expansionOpportunityCount();
-        run->setComputedHorizontalExpansion(computedExpansion);
-        run->moveHorizontally(accumulatedExpansion);
+        ASSERT(run.expansionOpportunityCount());
+        auto computedExpansion = expansionToDistribute * run.expansionOpportunityCount();
+        run.setComputedHorizontalExpansion(computedExpansion);
+        run.moveHorizontally(accumulatedExpansion);
         accumulatedExpansion += computedExpansion;
     }
 }
 
-void Line::alignContentHorizontally(IsLastLineWithInlineContent lastLine)
+void Line::alignContentHorizontally(RunList& runList, IsLastLineWithInlineContent lastLine) const
 {
     ASSERT(!m_skipAlignment);
-    if (m_runList.isEmpty() || availableWidth() <= 0)
+    if (runList.isEmpty() || availableWidth() <= 0)
         return;
 
     if (isTextAlignJustify()) {
         // Do not justify align the last line.
         if (lastLine == IsLastLineWithInlineContent::No)
-            justifyRuns();
+            justifyRuns(runList);
         return;
     }
 
@@ -324,9 +411,8 @@
     if (!adjustment)
         return;
 
-    for (auto& run : m_runList)
-        run->moveHorizontally(*adjustment);
-    // FIXME: Find out if m_lineBox needs adjustmnent as well.
+    for (auto& run : runList)
+        run.moveHorizontally(*adjustment);
 }
 
 void Line::removeTrailingTrimmableContent()
@@ -333,7 +419,7 @@
 {
     // Collapse trimmable trailing content
     LayoutUnit trimmableWidth;
-    for (auto* trimmableRun : m_trimmableContent) {
+    for (auto* trimmableRun : m_trimmableRuns) {
         ASSERT(trimmableRun->isText());
         // FIXME: We might need to be able to differentiate between trimmed and collapsed runs.
         trimmableWidth += trimmableRun->logicalRect().width();
@@ -360,7 +446,7 @@
 LayoutUnit Line::trailingTrimmableWidth() const
 {
     LayoutUnit trimmableWidth;
-    for (auto* trimmableRun : m_trimmableContent)
+    for (auto* trimmableRun : m_trimmableRuns)
         trimmableWidth += trimmableRun->logicalRect().width();
     return trimmableWidth;
 }
@@ -382,7 +468,7 @@
 
 void Line::appendNonBreakableSpace(const InlineItem& inlineItem, const Display::Rect& logicalRect)
 {
-    m_runList.append(makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect }));
+    m_inlineItemRuns.append(makeUnique<InlineItemRun>(inlineItem, logicalRect));
     m_lineBox.expandHorizontally(logicalRect.width());
     if (logicalRect.width())
         m_lineBox.setIsConsideredNonEmpty();
@@ -411,7 +497,7 @@
 {
     auto isTrimmable = !shouldPreserveTrailingContent(inlineItem);
     if (!isTrimmable)
-        m_trimmableContent.clear();
+        m_trimmableRuns.clear();
 
     auto willCollapseCompletely = [&] {
         // Empty run.
@@ -420,14 +506,14 @@
             return true;
         }
         // Leading whitespace.
-        if (m_runList.isEmpty())
+        if (m_inlineItemRuns.isEmpty())
             return !shouldPreserveLeadingContent(inlineItem);
 
         if (!inlineItem.isCollapsible())
             return false;
         // Check if the last item is collapsed as well.
-        for (auto i = m_runList.size(); i--;) {
-            auto& run = m_runList[i];
+        for (auto i = m_inlineItemRuns.size(); i--;) {
+            auto& run = m_inlineItemRuns[i];
             if (run->isBox())
                 return false;
             // https://drafts.csswg.org/css-text-3/#white-space-phase-1
@@ -454,14 +540,8 @@
     auto contentStart = inlineItem.start();
     auto contentLength =  collapsedRun ? 1 : inlineItem.length();
     auto textContent = inlineItem.layoutBox().textContent().substring(contentStart, contentLength);
-    auto lineRun = makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect, Display::Run::TextContext { contentStart, contentLength, textContent } });
+    auto lineRun = makeUnique<InlineItemRun>(inlineItem, logicalRect, Display::Run::TextContext { contentStart, contentLength, textContent });
 
-    if (isTextAlignJustify()) {
-        // Register expansion opportunity for whitespace runs.
-        if (inlineItem.isWhitespace())
-            lineRun->setHasExpansionOpportunity(DefaultExpansion);
-    }
-
     auto collapsesToZeroAdvanceWidth = willCollapseCompletely();
     if (collapsesToZeroAdvanceWidth)
         lineRun->setCollapsesToZeroAdvanceWidth();
@@ -471,10 +551,10 @@
     if (collapsedRun)
         lineRun->setIsCollapsed();
     if (isTrimmable)
-        m_trimmableContent.add(lineRun.get());
+        m_trimmableRuns.add(lineRun.get());
 
     m_lineBox.expandHorizontally(lineRun->logicalRect().width());
-    m_runList.append(WTFMove(lineRun));
+    m_inlineItemRuns.append(WTFMove(lineRun));
 }
 
 void Line::appendNonReplacedInlineBox(const InlineItem& inlineItem, LayoutUnit logicalWidth)
@@ -491,10 +571,10 @@
         logicalRect.setHeight(runHeight);
     }
 
-    m_runList.append(makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect }));
+    m_inlineItemRuns.append(makeUnique<InlineItemRun>(inlineItem, logicalRect));
     m_lineBox.expandHorizontally(logicalWidth + horizontalMargin.start + horizontalMargin.end);
     m_lineBox.setIsConsideredNonEmpty();
-    m_trimmableContent.clear();
+    m_trimmableRuns.clear();
 }
 
 void Line::appendReplacedInlineBox(const InlineItem& inlineItem, LayoutUnit logicalWidth)
@@ -503,8 +583,6 @@
     // FIXME: Surely replaced boxes behave differently.
     appendNonReplacedInlineBox(inlineItem, logicalWidth);
     m_lineBox.setIsConsideredNonEmpty();
-    if (auto* replaced = inlineItem.layoutBox().replaced(); replaced && replaced->cachedImage())
-        m_runList.last()->m_displayRun.setImage(*replaced->cachedImage());
 }
 
 void Line::appendLineBreak(const InlineItem& inlineItem)
@@ -517,7 +595,7 @@
         logicalRect.setHeight(logicalHeight());
     }
     m_lineBox.setIsConsideredNonEmpty();
-    m_runList.append(makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect }));
+    m_inlineItemRuns.append(makeUnique<InlineItemRun>(inlineItem, logicalRect));
 }
 
 void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem)

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (252315 => 252316)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h	2019-11-11 00:16:47 UTC (rev 252315)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h	2019-11-11 04:09:59 UTC (rev 252316)
@@ -37,6 +37,7 @@
 namespace Layout {
 
 class InlineFormattingContext;
+class InlineItemRun;
 
 class Line {
     WTF_MAKE_ISO_ALLOCATED(Line);
@@ -54,6 +55,7 @@
     };
     enum class SkipAlignment { No, Yes };
     Line(const InlineFormattingContext&, const InitialConstraints&, Optional<TextAlignMode>, SkipAlignment);
+    ~Line();
 
     void append(const InlineItem&, LayoutUnit logicalWidth);
     bool hasContent() const { return !isVisuallyEmpty(); }
@@ -66,16 +68,6 @@
     void moveLogicalRight(LayoutUnit);
 
     struct Run {
-        WTF_MAKE_STRUCT_FAST_ALLOCATED;
-        Run(const InlineItem&, const Display::Run&);
-
-        const Display::Run& displayRun() const { return m_displayRun; }
-        const Box& layoutBox() const { return m_layoutBox; }
-
-        const Display::Rect& logicalRect() const { return m_displayRun.logicalRect(); }
-        bool isCollapsedToZeroAdvanceWidth() const;
-        bool isCollapsed() const { return m_isCollapsed; }
-
         bool isText() const { return m_type == InlineItem::Type::Text; }
         bool isBox() const { return m_type == InlineItem::Type::Box; }
         bool isForcedLineBreak() const { return m_type == InlineItem::Type::ForcedLineBreak; }
@@ -82,39 +74,38 @@
         bool isContainerStart() const { return m_type == InlineItem::Type::ContainerStart; }
         bool isContainerEnd() const { return m_type == InlineItem::Type::ContainerEnd; }
 
+        const Box& layoutBox() const { return m_layoutBox; }
+        const Display::Rect& logicalRect() const { return m_logicalRect; }
+        Optional<Display::Run::TextContext> textContext() const { return m_textContext; }
+        bool isCollapsedToVisuallyEmpty() const { return m_isCollapsedToVisuallyEmpty; }
+
     private:
         friend class Line;
-        void adjustLogicalTop(LayoutUnit logicalTop) { m_displayRun.setLogicalTop(logicalTop); }
-        void moveVertically(LayoutUnit offset) { m_displayRun.moveVertically(offset); }
-        void moveHorizontally(LayoutUnit offset) { m_displayRun.moveHorizontally(offset); }
+        Run(const Box&, InlineItem::Type, const Display::Rect&);
 
-        void expand(const Run&);
+        void expand(const InlineItemRun&);
+        void adjustLogicalTop(LayoutUnit logicalTop) { m_logicalRect.setTop(logicalTop); }
+        void moveHorizontally(LayoutUnit offset) { m_logicalRect.moveHorizontally(offset); }
+        void moveVertically(LayoutUnit offset) { m_logicalRect.moveVertically(offset); }
 
-        void setIsCollapsed();
-        void setCollapsesToZeroAdvanceWidth();
+        void setTextContext(const Display::Run::TextContext textContext) { m_textContext = textContext; }
+        void setIsCollapsedToVisuallyEmpty() { m_isCollapsedToVisuallyEmpty = true; }
 
         void setHasExpansionOpportunity(ExpansionBehavior);
-        bool hasExpansionOpportunity() const { return m_expansionOpportunityCount.hasValue(); }
+        bool hasExpansionOpportunity() const { return m_expansionOpportunityCount; }
         Optional<ExpansionBehavior> expansionBehavior() const;
-        Optional<unsigned> expansionOpportunityCount() const { return m_expansionOpportunityCount; }
+        unsigned expansionOpportunityCount() const { return m_expansionOpportunityCount; }
+        void setComputedHorizontalExpansion(LayoutUnit logicalExpansion);
         void adjustExpansionBehavior(ExpansionBehavior);
-        void setComputedHorizontalExpansion(LayoutUnit logicalExpansion);
 
-        bool isCollapsible() const { return m_isCollapsible; }
-        bool hasTrailingCollapsedContent() const { return m_hasTrailingCollapsedContent; }
-        bool isWhitespace() const { return m_isWhitespace; }
-
         const Box& m_layoutBox;
-        Display::Run m_displayRun;
         const InlineItem::Type m_type;
-        bool m_isWhitespace { false };
-        bool m_isCollapsible { false };
-        bool m_isCollapsed { false };
-        bool m_collapsedToZeroAdvanceWidth { false };
-        bool m_hasTrailingCollapsedContent { false };
-        Optional<unsigned> m_expansionOpportunityCount;
+        Display::Rect m_logicalRect;
+        Optional<Display::Run::TextContext> m_textContext;
+        unsigned m_expansionOpportunityCount { 0 };
+        bool m_isCollapsedToVisuallyEmpty { false };
     };
-    using RunList = Vector<std::unique_ptr<Run>>;
+    using RunList = Vector<Run>;
     enum class IsLastLineWithInlineContent { No, Yes };
     RunList close(IsLastLineWithInlineContent = IsLastLineWithInlineContent::No);
 
@@ -143,8 +134,8 @@
     void appendLineBreak(const InlineItem&);
 
     void removeTrailingTrimmableContent();
-    void alignContentHorizontally(IsLastLineWithInlineContent);
-    void alignContentVertically();
+    void alignContentHorizontally(RunList&, IsLastLineWithInlineContent) const;
+    void alignContentVertically(RunList&) const;
 
     void adjustBaselineAndLineHeight(const InlineItem&);
     LayoutUnit inlineItemContentHeight(const InlineItem&) const;
@@ -151,15 +142,14 @@
     bool isVisuallyEmpty() const;
 
     bool isTextAlignJustify() const { return m_horizontalAlignment == TextAlignMode::Justify; };
-    void justifyRuns();
+    void justifyRuns(RunList&) const;
 
     LayoutState& layoutState() const;
     const InlineFormattingContext& formattingContext() const; 
 
     const InlineFormattingContext& m_inlineFormattingContext;
-    RunList m_runList;
-    ListHashSet<Run*> m_trimmableContent;
-
+    Vector<std::unique_ptr<InlineItemRun>> m_inlineItemRuns;
+    ListHashSet<InlineItemRun*> m_trimmableRuns;
     Optional<LineBox::Baseline> m_initialStrut;
     LayoutUnit m_lineLogicalWidth;
     Optional<TextAlignMode> m_horizontalAlignment;
@@ -167,59 +157,6 @@
     LineBox m_lineBox;
 };
 
-inline void Line::Run::setIsCollapsed()
-{
-    ASSERT(isWhitespace());
-    m_isCollapsed = true;
-    m_hasTrailingCollapsedContent = true;
 }
-
-inline bool Line::Run::isCollapsedToZeroAdvanceWidth() const
-{
-    ASSERT(!m_collapsedToZeroAdvanceWidth || !m_displayRun.logicalWidth());
-    return m_collapsedToZeroAdvanceWidth;
 }
-
-inline void Line::Run::setCollapsesToZeroAdvanceWidth()
-{
-    m_collapsedToZeroAdvanceWidth = true;
-    m_displayRun.setLogicalWidth({ });
-    m_expansionOpportunityCount = { };
-    m_displayRun.textContext()->resetExpansion();
-}
-
-inline Optional<ExpansionBehavior> Line::Run::expansionBehavior() const
-{
-    ASSERT(isText());
-    if (auto expansionContext = m_displayRun.textContext()->expansion())
-        return expansionContext->behavior;
-    return { };
-}
-
-inline void Line::Run::setHasExpansionOpportunity(ExpansionBehavior expansionBehavior)
-{
-    ASSERT(isText());
-    ASSERT(!hasExpansionOpportunity());
-    m_expansionOpportunityCount = 1;
-    m_displayRun.textContext()->setExpansion({ expansionBehavior, { } });
-}
-
-inline void Line::Run::adjustExpansionBehavior(ExpansionBehavior expansionBehavior)
-{
-    ASSERT(isText());
-    ASSERT(hasExpansionOpportunity());
-    m_displayRun.textContext()->setExpansion({ expansionBehavior, m_displayRun.textContext()->expansion()->horizontalExpansion });
-}
-
-inline void Line::Run::setComputedHorizontalExpansion(LayoutUnit logicalExpansion)
-{
-    ASSERT(isText());
-    ASSERT(hasExpansionOpportunity());
-    ASSERT(m_displayRun.textContext()->expansion());
-    m_displayRun.expandHorizontally(logicalExpansion);
-    m_displayRun.textContext()->setExpansion({ m_displayRun.textContext()->expansion()->behavior, logicalExpansion });
-}
-
-}
-}
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to