[LFC][IFC] Rename trailing collapsible content to trailing trimmable
https://bugs.webkit.org/show_bug.cgi?id=206447
<rdar://problem/58697414>

Reviewed by Antti Koivisto.

Trimming is the spec term for removing trailing inline content (also this helps to not confuse
trailing trimming and whitespace collapsing.)

* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::LineBuilder):
(WebCore::Layout::LineBuilder::initialize):
(WebCore::Layout::LineBuilder::close):
(WebCore::Layout::LineBuilder::revert):
(WebCore::Layout::LineBuilder::removeTrailingTrimmableContent):
(WebCore::Layout::LineBuilder::visuallyCollapsePreWrapOverflowContent):
(WebCore::Layout::LineBuilder::collectHangingContent):
(WebCore::Layout::LineBuilder::appendInlineContainerEnd):
(WebCore::Layout::LineBuilder::appendTextContent):
(WebCore::Layout::LineBuilder::appendNonReplacedInlineBox):
(WebCore::Layout::LineBuilder::TrimmableTrailingContent::TrimmableTrailingContent):
(WebCore::Layout::LineBuilder::TrimmableTrailingContent::append):
(WebCore::Layout::LineBuilder::TrimmableTrailingContent::remove):
(WebCore::Layout::LineBuilder::TrimmableTrailingContent::removeTrailingRun):
(WebCore::Layout::LineBuilder::InlineItemRun::isTrimmableWhitespace const):
(WebCore::Layout::LineBuilder::removeTrailingCollapsibleContent): Deleted.
(WebCore::Layout::LineBuilder::CollapsibleContent::CollapsibleContent): Deleted.
(WebCore::Layout::LineBuilder::CollapsibleContent::append): Deleted.
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse): Deleted.
(WebCore::Layout::LineBuilder::CollapsibleContent::collapseTrailingRun): Deleted.
(WebCore::Layout::LineBuilder::InlineItemRun::isCollapsibleWhitespace const): Deleted.
* layout/inlineformatting/InlineLineBuilder.h:
(WebCore::Layout::LineBuilder::trimmableTrailingWidth const):
(WebCore::Layout::LineBuilder::isTrailingRunFullyTrimmable const):
(WebCore::Layout::LineBuilder::TrimmableTrailingContent::isTrailingRunFullyTrimmable const):
(WebCore::Layout::LineBuilder::TrimmableTrailingContent::isTrailingRunPartiallyTrimmable const):
(WebCore::Layout::LineBuilder::TrimmableTrailingContent::reset):
(WebCore::Layout::LineBuilder::trailingCollapsibleWidth const): Deleted.
(WebCore::Layout::LineBuilder::isTrailingRunFullyCollapsible const): Deleted.
(WebCore::Layout::LineBuilder::CollapsibleContent::width const): Deleted.
(WebCore::Layout::LineBuilder::CollapsibleContent::firstRunIndex): Deleted.
(WebCore::Layout::LineBuilder::CollapsibleContent::isEmpty const): Deleted.
(WebCore::Layout::LineBuilder::CollapsibleContent::isTrailingRunFullyCollapsible const): Deleted.
(WebCore::Layout::LineBuilder::CollapsibleContent::isTrailingRunPartiallyCollapsible const): Deleted.
(WebCore::Layout::LineBuilder::CollapsibleContent::reset): Deleted.
* layout/inlineformatting/LineLayoutContext.cpp:
(WebCore::Layout::LineLayoutContext::tryAddingFloatItems):
(WebCore::Layout::LineLayoutContext::tryAddingInlineItems):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@254796 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index d3e84df..650ba10 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,54 @@
+2020-01-18  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Rename trailing collapsible content to trailing trimmable
+        https://bugs.webkit.org/show_bug.cgi?id=206447
+        <rdar://problem/58697414>
+
+        Reviewed by Antti Koivisto.
+
+        Trimming is the spec term for removing trailing inline content (also this helps to not confuse
+        trailing trimming and whitespace collapsing.)
+
+        * layout/inlineformatting/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::LineBuilder):
+        (WebCore::Layout::LineBuilder::initialize):
+        (WebCore::Layout::LineBuilder::close):
+        (WebCore::Layout::LineBuilder::revert):
+        (WebCore::Layout::LineBuilder::removeTrailingTrimmableContent):
+        (WebCore::Layout::LineBuilder::visuallyCollapsePreWrapOverflowContent):
+        (WebCore::Layout::LineBuilder::collectHangingContent):
+        (WebCore::Layout::LineBuilder::appendInlineContainerEnd):
+        (WebCore::Layout::LineBuilder::appendTextContent):
+        (WebCore::Layout::LineBuilder::appendNonReplacedInlineBox):
+        (WebCore::Layout::LineBuilder::TrimmableTrailingContent::TrimmableTrailingContent):
+        (WebCore::Layout::LineBuilder::TrimmableTrailingContent::append):
+        (WebCore::Layout::LineBuilder::TrimmableTrailingContent::remove):
+        (WebCore::Layout::LineBuilder::TrimmableTrailingContent::removeTrailingRun):
+        (WebCore::Layout::LineBuilder::InlineItemRun::isTrimmableWhitespace const):
+        (WebCore::Layout::LineBuilder::removeTrailingCollapsibleContent): Deleted.
+        (WebCore::Layout::LineBuilder::CollapsibleContent::CollapsibleContent): Deleted.
+        (WebCore::Layout::LineBuilder::CollapsibleContent::append): Deleted.
+        (WebCore::Layout::LineBuilder::CollapsibleContent::collapse): Deleted.
+        (WebCore::Layout::LineBuilder::CollapsibleContent::collapseTrailingRun): Deleted.
+        (WebCore::Layout::LineBuilder::InlineItemRun::isCollapsibleWhitespace const): Deleted.
+        * layout/inlineformatting/InlineLineBuilder.h:
+        (WebCore::Layout::LineBuilder::trimmableTrailingWidth const):
+        (WebCore::Layout::LineBuilder::isTrailingRunFullyTrimmable const):
+        (WebCore::Layout::LineBuilder::TrimmableTrailingContent::isTrailingRunFullyTrimmable const):
+        (WebCore::Layout::LineBuilder::TrimmableTrailingContent::isTrailingRunPartiallyTrimmable const):
+        (WebCore::Layout::LineBuilder::TrimmableTrailingContent::reset):
+        (WebCore::Layout::LineBuilder::trailingCollapsibleWidth const): Deleted.
+        (WebCore::Layout::LineBuilder::isTrailingRunFullyCollapsible const): Deleted.
+        (WebCore::Layout::LineBuilder::CollapsibleContent::width const): Deleted.
+        (WebCore::Layout::LineBuilder::CollapsibleContent::firstRunIndex): Deleted.
+        (WebCore::Layout::LineBuilder::CollapsibleContent::isEmpty const): Deleted.
+        (WebCore::Layout::LineBuilder::CollapsibleContent::isTrailingRunFullyCollapsible const): Deleted.
+        (WebCore::Layout::LineBuilder::CollapsibleContent::isTrailingRunPartiallyCollapsible const): Deleted.
+        (WebCore::Layout::LineBuilder::CollapsibleContent::reset): Deleted.
+        * layout/inlineformatting/LineLayoutContext.cpp:
+        (WebCore::Layout::LineLayoutContext::tryAddingFloatItems):
+        (WebCore::Layout::LineLayoutContext::tryAddingInlineItems):
+
 2020-01-18  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r254780.
diff --git a/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp b/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp
index 7abf426..fe663aa 100644
--- a/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp
+++ b/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp
@@ -186,7 +186,7 @@
 
 LineBuilder::LineBuilder(const InlineFormattingContext& inlineFormattingContext, Optional<TextAlignMode> horizontalAlignment, IntrinsicSizing intrinsicSizing)
     : m_inlineFormattingContext(inlineFormattingContext)
-    , m_collapsibleContent(m_inlineItemRuns)
+    , m_trimmableTrailingContent(m_inlineItemRuns)
     , m_horizontalAlignment(horizontalAlignment)
     , m_isIntrinsicSizing(intrinsicSizing == IntrinsicSizing::Yes)
     , m_shouldIgnoreTrailingLetterSpacing(RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled())
@@ -217,8 +217,8 @@
     m_hasIntrusiveFloat = constraints.lineIsConstrainedByFloat;
 
     m_inlineItemRuns.clear();
-    m_collapsibleContent.reset();
-    m_lineIsVisuallyEmptyBeforeCollapsibleContent = { };
+    m_trimmableTrailingContent.reset();
+    m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent = { };
 }
 
 static inline bool shouldPreserveLeadingContent(const InlineTextItem& inlineTextItem)
@@ -231,10 +231,10 @@
 
 LineBuilder::RunList LineBuilder::close(IsLastLineWithInlineContent isLastLineWithInlineContent)
 {
-    // 1. Remove collapsible trailing content.
+    // 1. Remove trimmable trailing content.
     // 2. Join text runs together when possible [foo][ ][bar] -> [foo bar].
     // 3. Align merged runs both vertically and horizontally.
-    removeTrailingCollapsibleContent();
+    removeTrailingTrimmableContent();
     visuallyCollapsePreWrapOverflowContent();
     auto hangingContent = collectHangingContent(isLastLineWithInlineContent);
 
@@ -286,7 +286,7 @@
         return { };
     }
     // 1. Remove and shrink the trailing content.
-    // 2. Rebuild collapsible trailing whitespace content.
+    // 2. Rebuild trimmable trailing whitespace content.
     ASSERT(!m_inlineItemRuns.isEmpty());
     auto revertedWidth = InlineLayoutUnit { };
     auto originalSize = m_inlineItemRuns.size();
@@ -298,36 +298,36 @@
     // Should never need to clear the line.
     ASSERT(!m_inlineItemRuns.isEmpty());
 
-    // It's easier just to rebuild trailing collapsible content.
-    m_collapsibleContent.reset();
-    m_lineIsVisuallyEmptyBeforeCollapsibleContent = isVisuallyEmpty();
-    // Find the first collapsible run.
-    Optional<size_t> firstCollapsibleRunIndex;
+    // It's easier just to rebuild trailing trimmable content.
+    m_trimmableTrailingContent.reset();
+    m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent = isVisuallyEmpty();
+    // Find the first trimmable run.
+    Optional<size_t> firstTrimmableRunIndex;
     for (auto index = m_inlineItemRuns.size(); index--;) {
         auto& inlineItemRun = m_inlineItemRuns[index];
         if (inlineItemRun.isContainerStart() || inlineItemRun.isContainerEnd())
             continue;
-        auto hasCollapsibleContent = inlineItemRun.isCollapsibleWhitespace() || inlineItemRun.hasTrailingLetterSpacing();
-        if (!hasCollapsibleContent)
+        auto hasTrailingTrimmableContent = inlineItemRun.isTrimmableWhitespace() || inlineItemRun.hasTrailingLetterSpacing();
+        if (!hasTrailingTrimmableContent)
             break;
-        if (inlineItemRun.isCollapsibleWhitespace()) {
-            firstCollapsibleRunIndex = index;
+        if (inlineItemRun.isTrimmableWhitespace()) {
+            firstTrimmableRunIndex = index;
             continue;
         }
         if (inlineItemRun.hasTrailingLetterSpacing()) {
-            // While trailing letter spacing is considered collapsible, it is supposed to be last one in the list.
-            firstCollapsibleRunIndex = index;
+            // While trailing letter spacing is considered trimmable, it is supposed to be last one in the list.
+            firstTrimmableRunIndex = index;
             break;
         }
     }
-    // Forward-append runs to m_collapsibleContent. 
-    if (firstCollapsibleRunIndex) {
-        for (auto index = *firstCollapsibleRunIndex; index < m_inlineItemRuns.size(); ++index) {
+    // Forward-append runs to m_trimmableTrailingContent. 
+    if (firstTrimmableRunIndex) {
+        for (auto index = *firstTrimmableRunIndex; index < m_inlineItemRuns.size(); ++index) {
             auto& inlineItemRun = m_inlineItemRuns[index];
             if (inlineItemRun.isContainerStart() || inlineItemRun.isContainerEnd())
                 continue;
             ASSERT(inlineItemRun.isText());
-            m_collapsibleContent.append(index);
+            m_trimmableTrailingContent.append(index);
         }
     }
     // Consider alternative solutions if the (edge case)revert gets overly complicated.
@@ -478,24 +478,24 @@
         run.moveHorizontally(*adjustment);
 }
 
-void LineBuilder::removeTrailingCollapsibleContent()
+void LineBuilder::removeTrailingTrimmableContent()
 {
-    if (m_collapsibleContent.isEmpty() || m_inlineItemRuns.isEmpty())
+    if (m_trimmableTrailingContent.isEmpty() || m_inlineItemRuns.isEmpty())
         return;
 
     // Complex line layout quirk: keep the trailing whitespace around when it is followed by a line break, unless the content overflows the line.
     if (RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextIntegrationEnabled()) {
         if (m_inlineItemRuns.last().isLineBreak() && availableWidth() >= 0 && !isTextAlignRight()) {
-            m_collapsibleContent.reset();
+            m_trimmableTrailingContent.reset();
             return;
         }
     }
 
-    m_lineBox.shrinkHorizontally(m_collapsibleContent.collapse());
-    // If we collapsed the first visible run on the line, we need to re-check the visibility status.
-    if (!m_lineIsVisuallyEmptyBeforeCollapsibleContent)
+    m_lineBox.shrinkHorizontally(m_trimmableTrailingContent.remove());
+    // If we removed the first visible run on the line, we need to re-check the visibility status.
+    if (!m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent)
         return;
-    // Just because the line was visually empty before the collapsed content, it does not necessarily mean it is still visually empty.
+    // Just because the line was visually empty before the removed content, it does not necessarily mean it is still visually empty.
     // <span>  </span><span style="padding-left: 10px"></span>  <- non-empty
     auto lineIsVisuallyEmpty = [&] {
         for (auto& run : m_inlineItemRuns) {
@@ -504,15 +504,15 @@
         }
         return true;
     };
-    // We could only go from visually non empty -> to visually empty. Collapsed runs should never make the line visible.
+    // We could only go from visually non empty -> to visually empty. Trimmed runs should never make the line visible.
     if (lineIsVisuallyEmpty())
         m_lineBox.setIsConsideredEmpty();
-    m_lineIsVisuallyEmptyBeforeCollapsibleContent = { };
+    m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent = { };
 }
 
 void LineBuilder::visuallyCollapsePreWrapOverflowContent()
 {
-    ASSERT(m_collapsibleContent.isEmpty());
+    ASSERT(m_trimmableTrailingContent.isEmpty());
     // If white-space is set to pre-wrap, the UA must
     // ...
     // It may also visually collapse the character advance widths of any that would otherwise overflow.
@@ -549,7 +549,7 @@
 {
     auto hangingContent = HangingContent { };
     // Can't setup hanging content with removable trailing whitespace.
-    ASSERT(m_collapsibleContent.isEmpty());
+    ASSERT(m_trimmableTrailingContent.isEmpty());
     if (isLastLineWithInlineContent == IsLastLineWithInlineContent::Yes)
         hangingContent.setIsConditional();
     for (auto& inlineItemRun : WTF::makeReversedRange(m_inlineItemRuns)) {
@@ -623,14 +623,14 @@
 void LineBuilder::appendInlineContainerEnd(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
 {
     // This is really just a placeholder to mark the end of the inline level container </span>.
-    auto collapseTrailingLetterSpacing = [&] {
-        if (!m_collapsibleContent.isTrailingRunPartiallyCollapsible())
+    auto removeTrailingLetterSpacing = [&] {
+        if (!m_trimmableTrailingContent.isTrailingRunPartiallyTrimmable())
             return;
-        m_lineBox.shrinkHorizontally(m_collapsibleContent.collapseTrailingRun());
+        m_lineBox.shrinkHorizontally(m_trimmableTrailingContent.removeTrailingRun());
     };
     // Prevent trailing letter-spacing from spilling out of the inline container.
     // https://drafts.csswg.org/css-text-3/#letter-spacing-property See example 21.
-    collapseTrailingLetterSpacing();
+    removeTrailingLetterSpacing();
     appendNonBreakableSpace(inlineItem, contentLogicalRight(), logicalWidth);
 }
 
@@ -666,14 +666,14 @@
 
     if (isCollapsible && !TextUtil::shouldPreserveTrailingWhitespace(inlineItem.style())) {
         // If we ever collapse this content, we need to know if the line visibility state needs to be recomputed.
-        if (m_collapsibleContent.isEmpty())
-            m_lineIsVisuallyEmptyBeforeCollapsibleContent = isVisuallyEmpty();
-        m_collapsibleContent.append(m_inlineItemRuns.size() - 1);
+        if (m_trimmableTrailingContent.isEmpty())
+            m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent = isVisuallyEmpty();
+        m_trimmableTrailingContent.append(m_inlineItemRuns.size() - 1);
     } else {
         // Existing trailing collapsible content can only be expanded if the current run is fully collapsible.
-        m_collapsibleContent.reset();
+        m_trimmableTrailingContent.reset();
         if (!m_shouldIgnoreTrailingLetterSpacing && !inlineItem.isWhitespace() && inlineItem.style().letterSpacing() > 0)
-            m_collapsibleContent.append(m_inlineItemRuns.size() - 1);
+            m_trimmableTrailingContent.append(m_inlineItemRuns.size() - 1);
     }
 }
 
@@ -684,7 +684,7 @@
     auto horizontalMargin = boxGeometry.horizontalMargin();
     m_inlineItemRuns.append({ inlineItem, contentLogicalWidth() + horizontalMargin.start, logicalWidth });
     m_lineBox.expandHorizontally(logicalWidth + horizontalMargin.start + horizontalMargin.end);
-    m_collapsibleContent.reset();
+    m_trimmableTrailingContent.reset();
 }
 
 void LineBuilder::appendReplacedInlineBox(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
@@ -866,90 +866,90 @@
     return m_inlineFormattingContext;
 }
 
-LineBuilder::CollapsibleContent::CollapsibleContent(InlineItemRunList& inlineItemRunList)
+LineBuilder::TrimmableTrailingContent::TrimmableTrailingContent(InlineItemRunList& inlineItemRunList)
     : m_inlineitemRunList(inlineItemRunList)
 {
 }
 
-void LineBuilder::CollapsibleContent::append(size_t runIndex)
+void LineBuilder::TrimmableTrailingContent::append(size_t runIndex)
 {
-    auto& collapsibleRun = m_inlineitemRunList[runIndex];
-    InlineLayoutUnit collapsibleWidth = 0;
-    auto isFullyCollapsible = collapsibleRun.isCollapsibleWhitespace();
-    if (isFullyCollapsible)
-        collapsibleWidth = collapsibleRun.logicalWidth();
+    auto& trimmableRun = m_inlineitemRunList[runIndex];
+    InlineLayoutUnit trimmableWidth = 0;
+    auto isFullyTrimmable = trimmableRun.isTrimmableWhitespace();
+    if (isFullyTrimmable)
+        trimmableWidth = trimmableRun.logicalWidth();
     else {
-        ASSERT(collapsibleRun.hasTrailingLetterSpacing());
-        collapsibleWidth = collapsibleRun.trailingLetterSpacing();
+        ASSERT(trimmableRun.hasTrailingLetterSpacing());
+        trimmableWidth = trimmableRun.trailingLetterSpacing();
     }
-    m_width += collapsibleWidth;
-    m_lastRunIsFullyCollapsible = isFullyCollapsible;
+    m_width += trimmableWidth;
+    m_lastRunIsFullyTrimmable = isFullyTrimmable;
     m_firstRunIndex = m_firstRunIndex.valueOr(runIndex);
 }
 
-InlineLayoutUnit LineBuilder::CollapsibleContent::collapse()
+InlineLayoutUnit LineBuilder::TrimmableTrailingContent::remove()
 {
     ASSERT(!isEmpty());
 #if ASSERT_ENABLED
     auto hasSeenNonWhitespaceTextContent = false;
 #endif
-    // Collapse collapsible trailing content and move all the other trailing runs.
+    // Remove trimmable trailing content and move all the other trailing runs.
     // <span> </span><span></span> ->
     // [whitespace][container end][container start][container end]
-    // Collapse the whitespace run and move the trailing inline container runs to the left.
-    InlineLayoutUnit accumulatedCollapsedWidth = 0;
+    // Remove the whitespace run and move the trailing inline container runs to the left.
+    InlineLayoutUnit accumulatedTrimmedWidth = 0;
     for (auto index = *m_firstRunIndex; index < m_inlineitemRunList.size(); ++index) {
         auto& run = m_inlineitemRunList[index];
-        run.moveHorizontally(-accumulatedCollapsedWidth);
+        run.moveHorizontally(-accumulatedTrimmedWidth);
         if (!run.isText()) {
             ASSERT(run.isContainerStart() || run.isContainerEnd() || run.isLineBreak());
             continue;
         }
         if (run.isWhitespace()) {
-            accumulatedCollapsedWidth += run.logicalWidth();
+            accumulatedTrimmedWidth += run.logicalWidth();
             run.setCollapsesToZeroAdvanceWidth();
         } else {
             ASSERT(!hasSeenNonWhitespaceTextContent);
 #if ASSERT_ENABLED
             hasSeenNonWhitespaceTextContent = true;
 #endif
-            // Must be a letter spacing collapse.
+            // Must be a letter spacing trimming.
             ASSERT(run.hasTrailingLetterSpacing());
-            accumulatedCollapsedWidth += run.trailingLetterSpacing();
+            accumulatedTrimmedWidth += run.trailingLetterSpacing();
             run.removeTrailingLetterSpacing();
         }
     }
-    ASSERT(accumulatedCollapsedWidth == width());
+    ASSERT(accumulatedTrimmedWidth == width());
     reset();
-    return accumulatedCollapsedWidth;
+    return accumulatedTrimmedWidth;
 }
 
-InlineLayoutUnit LineBuilder::CollapsibleContent::collapseTrailingRun()
+InlineLayoutUnit LineBuilder::TrimmableTrailingContent::removeTrailingRun()
 {
     ASSERT(!isEmpty());
-    // Find the last collapsible run (it is not necessarily the last run e.g [container start][whitespace][container end])
+    // Find the last trimmable run (it is not necessarily the last run e.g [container start][whitespace][container end])
     for (auto index = m_inlineitemRunList.size(); index-- && *m_firstRunIndex >= index;) {
         auto& run = m_inlineitemRunList[index];
         if (!run.isText()) {
             ASSERT(run.isContainerStart() || run.isContainerEnd());
             continue;
         }
-        InlineLayoutUnit collapsedWidth = 0;
+        InlineLayoutUnit trimmedWidth = 0;
         if (run.isWhitespace()) {
-            collapsedWidth = run.logicalWidth();
+            trimmedWidth = run.logicalWidth();
             run.setCollapsesToZeroAdvanceWidth();
         } else {
             ASSERT(run.hasTrailingLetterSpacing());
-            collapsedWidth = run.trailingLetterSpacing();
+            trimmedWidth = run.trailingLetterSpacing();
             run.removeTrailingLetterSpacing();
         }
-        m_width -= collapsedWidth;
-        // We managed to remove the last collapsible run.
+        m_width -= trimmedWidth;
+        // We managed to remove the last trimmable run.
         if (index == *m_firstRunIndex) {
             ASSERT(!m_width);
             m_firstRunIndex = { };
         }
-        return collapsedWidth;
+        return trimmedWidth;
     }
     ASSERT_NOT_REACHED();
     return 0_lu;
@@ -972,7 +972,7 @@
 {
 }
 
-bool LineBuilder::InlineItemRun::isCollapsibleWhitespace() const
+bool LineBuilder::InlineItemRun::isTrimmableWhitespace() const
 {
     // Return true if the "end-of-line spaces" can be removed.
     // See https://www.w3.org/TR/css-text-3/#white-space-property matrix.
diff --git a/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h b/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h
index f78a614..8ff59cc 100644
--- a/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h
+++ b/Source/WebCore/layout/inlineformatting/InlineLineBuilder.h
@@ -65,8 +65,8 @@
     bool hasIntrusiveFloat() const { return m_hasIntrusiveFloat; }
     InlineLayoutUnit availableWidth() const { return logicalWidth() - contentLogicalWidth(); }
 
-    InlineLayoutUnit trailingCollapsibleWidth() const { return m_collapsibleContent.width(); }
-    bool isTrailingRunFullyCollapsible() const { return m_collapsibleContent.isTrailingRunFullyCollapsible(); }
+    InlineLayoutUnit trimmableTrailingWidth() const { return m_trimmableTrailingContent.width(); }
+    bool isTrailingRunFullyTrimmable() const { return m_trimmableTrailingContent.isTrailingRunFullyTrimmable(); }
 
     const Display::LineBox& lineBox() const { return m_lineBox; }
     void moveLogicalLeft(InlineLayoutUnit);
@@ -141,7 +141,7 @@
     void appendInlineContainerEnd(const InlineItem&, InlineLayoutUnit logicalWidth);
     void appendLineBreak(const InlineItem&);
 
-    void removeTrailingCollapsibleContent();
+    void removeTrailingTrimmableContent();
     void visuallyCollapsePreWrapOverflowContent();
     HangingContent collectHangingContent(IsLastLineWithInlineContent);
     void alignHorizontally(RunList&, const HangingContent&, IsLastLineWithInlineContent);
@@ -182,7 +182,7 @@
         void moveHorizontally(InlineLayoutUnit offset) { m_logicalLeft += offset; }
         void adjustLogicalWidth(InlineLayoutUnit adjustedWidth) { m_logicalWidth = adjustedWidth; }
 
-        bool isCollapsibleWhitespace() const;
+        bool isTrimmableWhitespace() const;
         bool hasTrailingLetterSpacing() const;
 
         InlineLayoutUnit trailingLetterSpacing() const;
@@ -211,45 +211,45 @@
 
     using InlineItemRunList = Vector<InlineItemRun, 50>;
 
-    struct CollapsibleContent {
-        CollapsibleContent(InlineItemRunList&);
+    struct TrimmableTrailingContent {
+        TrimmableTrailingContent(InlineItemRunList&);
 
         void append(size_t runIndex);
-        InlineLayoutUnit collapse();
-        InlineLayoutUnit collapseTrailingRun();
+        InlineLayoutUnit remove();
+        InlineLayoutUnit removeTrailingRun();
         void reset();
 
         InlineLayoutUnit width() const { return m_width; }
         Optional<size_t> firstRunIndex() { return m_firstRunIndex; }
         bool isEmpty() const { return !m_firstRunIndex.hasValue(); }
-        bool isTrailingRunFullyCollapsible() const { return m_lastRunIsFullyCollapsible; }
-        bool isTrailingRunPartiallyCollapsible() const { return !isEmpty() && !isTrailingRunFullyCollapsible(); }
+        bool isTrailingRunFullyTrimmable() const { return m_lastRunIsFullyTrimmable; }
+        bool isTrailingRunPartiallyTrimmable() const { return !isEmpty() && !isTrailingRunFullyTrimmable(); }
 
     private:
         InlineItemRunList& m_inlineitemRunList;
         Optional<size_t> m_firstRunIndex;
         InlineLayoutUnit m_width { 0 };
-        bool m_lastRunIsFullyCollapsible { false };
+        bool m_lastRunIsFullyTrimmable { false };
     };
 
     const InlineFormattingContext& m_inlineFormattingContext;
     InlineItemRunList m_inlineItemRuns;
-    CollapsibleContent m_collapsibleContent;
+    TrimmableTrailingContent m_trimmableTrailingContent;
     Optional<Display::LineBox::Baseline> m_initialStrut;
     InlineLayoutUnit m_lineLogicalWidth { 0 };
     Optional<TextAlignMode> m_horizontalAlignment;
     bool m_isIntrinsicSizing { false };
     bool m_hasIntrusiveFloat { false };
     Display::LineBox m_lineBox;
-    Optional<bool> m_lineIsVisuallyEmptyBeforeCollapsibleContent;
+    Optional<bool> m_lineIsVisuallyEmptyBeforeTrimmableTrailingContent;
     bool m_shouldIgnoreTrailingLetterSpacing { false };
 };
 
-inline void LineBuilder::CollapsibleContent::reset()
+inline void LineBuilder::TrimmableTrailingContent::reset()
 {
     m_firstRunIndex = { };
     m_width = 0_lu;
-    m_lastRunIsFullyCollapsible = false;
+    m_lastRunIsFullyTrimmable = false;
 }
 
 }
diff --git a/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp b/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp
index b7aab31..80566a7 100644
--- a/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp
+++ b/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp
@@ -385,7 +385,7 @@
         auto logicalWidth = inlineItemWidth(*floatItem, { });
 
         auto lineIsConsideredEmpty = line.isVisuallyEmpty() && !line.hasIntrusiveFloat();
-        if (LineBreaker().shouldWrapFloatBox(logicalWidth, line.availableWidth() + line.trailingCollapsibleWidth(), lineIsConsideredEmpty))
+        if (LineBreaker().shouldWrapFloatBox(logicalWidth, line.availableWidth() + line.trimmableTrailingWidth(), lineIsConsideredEmpty))
             return { LineBreaker::IsEndOfLine::Yes, committedFloatItemCount };
         // This float can sit on the current line.
         ++committedFloatItemCount;
@@ -409,7 +409,7 @@
         return m_successiveHyphenatedLineCount >= limitLines;
     };
     // Check if this new content fits.
-    auto lineStatus = LineBreaker::LineStatus { line.availableWidth(), line.trailingCollapsibleWidth(), line.isTrailingRunFullyCollapsible(), isLineConsideredEmpty(line) };
+    auto lineStatus = LineBreaker::LineStatus { line.availableWidth(), line.trimmableTrailingWidth(), line.isTrailingRunFullyTrimmable(), isLineConsideredEmpty(line) };
 
     if (shouldDisableHyphenation())
         lineBreaker.setHyphenationDisabled();