[LFC][IFC] Rename ContentBreak to ContentWrappingRule and ContentBreak::wrap to ContentWrappingRule::push
https://bugs.webkit.org/show_bug.cgi?id=204966
<rdar://problem/57717049>

Reviewed by Sam Weinig.

Use the term "push" instead of "wrap" to move a run to the next line without breaking it.
This is mainly to avoid spec term confusion.
ContentWrappingRule::Keep -> keep the run (or continuous runs) on the current line.
ContentWrappingRule::Split -> keep the run (or continuous runs) partially on the current line (see BreakingContext::PartialTrailingContent).
ContentWrappingRule::Push -> move the run (or continuous runs) completely to the next line.

* layout/inlineformatting/InlineLineBreaker.cpp:
(WebCore::Layout::LineBreaker::breakingContextForInlineContent):
* layout/inlineformatting/InlineLineBreaker.h:
* layout/inlineformatting/LineLayoutContext.cpp:
(WebCore::Layout::LineLayoutContext::processUncommittedContent):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@253238 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 0cd4719..2a2b1d7 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,23 @@
+2019-12-06  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Rename ContentBreak to ContentWrappingRule and ContentBreak::wrap to ContentWrappingRule::push
+        https://bugs.webkit.org/show_bug.cgi?id=204966
+        <rdar://problem/57717049>
+
+        Reviewed by Sam Weinig.
+
+        Use the term "push" instead of "wrap" to move a run to the next line without breaking it.
+        This is mainly to avoid spec term confusion.
+        ContentWrappingRule::Keep -> keep the run (or continuous runs) on the current line.
+        ContentWrappingRule::Split -> keep the run (or continuous runs) partially on the current line (see BreakingContext::PartialTrailingContent).
+        ContentWrappingRule::Push -> move the run (or continuous runs) completely to the next line.
+
+        * layout/inlineformatting/InlineLineBreaker.cpp:
+        (WebCore::Layout::LineBreaker::breakingContextForInlineContent):
+        * layout/inlineformatting/InlineLineBreaker.h:
+        * layout/inlineformatting/LineLayoutContext.cpp:
+        (WebCore::Layout::LineLayoutContext::processUncommittedContent):
+
 2019-12-06  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r253218.
diff --git a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp
index 4a32727..608e873 100644
--- a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp
+++ b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp
@@ -53,41 +53,40 @@
 {
     ASSERT(!candidateRuns.isEmpty());
     if (candidateRuns.width() <= lineStatus.availableWidth)
-        return { BreakingContext::ContentBreak::Keep, { } };
+        return { BreakingContext::ContentWrappingRule::Keep, { } };
     if (candidateRuns.hasTrailingTrimmableContent()) {
         // First check if the content fits without the trailing trimmable part.
         if (candidateRuns.nonTrimmableWidth() <= lineStatus.availableWidth)
-            return { BreakingContext::ContentBreak::Keep, { } };
+            return { BreakingContext::ContentWrappingRule::Keep, { } };
         // Now check if we can trim the line too.
         if (lineStatus.lineHasFullyTrimmableTrailingRun && candidateRuns.isTrailingContentFullyTrimmable()) {
             // If this new content is fully trimmable, it shoud surely fit.
-            return { BreakingContext::ContentBreak::Keep, { } };
+            return { BreakingContext::ContentWrappingRule::Keep, { } };
         }
     } else if (lineStatus.trimmableWidth && candidateRuns.hasNonContentRunsOnly()) {
         // Let's see if the non-content runs fit when the line has trailing trimmable content
         // "text content <span style="padding: 1px"></span>" <- the <span></span> runs could fit after trimming the trailing whitespace.
         if (candidateRuns.width() <= lineStatus.availableWidth + lineStatus.trimmableWidth)
-            return { BreakingContext::ContentBreak::Keep, { } };
+            return { BreakingContext::ContentWrappingRule::Keep, { } };
     }
 
     if (candidateRuns.hasTextContentOnly()) {
         auto& runs = candidateRuns.runs();
         if (auto partialTrailingContent = wordBreakingBehavior(runs, lineStatus.availableWidth))
-            return { BreakingContext::ContentBreak::Split, partialTrailingContent };
+            return { BreakingContext::ContentWrappingRule::Split, partialTrailingContent };
         // If we did not manage to break this content, we still need to decide whether keep it or wrap it to the next line.
         // FIXME: Keep tracking the last breaking opportunity where we can wrap the content:
         // <span style="white-space: pre;">this fits</span> <span style="white-space: pre;">this does not fit but does not wrap either</span>
         // ^^ could wrap at the whitespace position between the 2 inline containers.
-        auto contentShouldWrap = !lineStatus.lineIsEmpty && isContentWrappingAllowed(runs[0].inlineItem.style());
+        auto contentShouldOverflow = lineStatus.lineIsEmpty || !isContentWrappingAllowed(runs[0].inlineItem.style());
         // FIXME: white-space: pre-wrap needs clarification. According to CSS Text Module Level 3, content wrapping is as 'normal' but apparently
         // we need to keep the overlapping whitespace on the line (and hang it I'd assume).
         if (isTrailingWhitespaceWithPreWrap(runs.last().inlineItem))
-            contentShouldWrap = false;
-        return { contentShouldWrap ? BreakingContext::ContentBreak::Wrap : BreakingContext::ContentBreak::Keep, { } };
+            contentShouldOverflow = true;
+        return { contentShouldOverflow ? BreakingContext::ContentWrappingRule::Keep : BreakingContext::ContentWrappingRule::Push, { } };
     }
-
     // First non-text inline content always stays on line.
-    return { lineStatus.lineIsEmpty ? BreakingContext::ContentBreak::Keep : BreakingContext::ContentBreak::Wrap, { } };
+    return { lineStatus.lineIsEmpty ? BreakingContext::ContentWrappingRule::Keep : BreakingContext::ContentWrappingRule::Push, { } };
 }
 
 bool LineBreaker::shouldWrapFloatBox(LayoutUnit floatLogicalWidth, LayoutUnit availableWidth, bool lineIsEmpty)
diff --git a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h
index 0d523ae..9f28643 100644
--- a/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h
+++ b/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h
@@ -38,8 +38,12 @@
 class LineBreaker {
 public:
     struct BreakingContext {
-        enum class ContentBreak { Keep, Split, Wrap };
-        ContentBreak contentBreak;
+        enum class ContentWrappingRule {
+            Keep, // Keep content on the current line.
+            Split, // Partial content is on the current line.
+            Push // Content is pushed to the next line.
+        };
+        ContentWrappingRule contentWrappingRule;
         struct PartialTrailingContent {
             unsigned runIndex { 0 };
             unsigned length { 0 };
diff --git a/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp b/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp
index 931f5f3..368ebe4 100644
--- a/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp
+++ b/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp
@@ -212,9 +212,9 @@
     auto lineStatus = LineBreaker::LineStatus { line.availableWidth(), line.trailingTrimmableWidth(), line.isTrailingRunFullyTrimmable(), lineIsConsideredEmpty };
     auto breakingContext = lineBreaker.breakingContextForInlineContent(m_uncommittedContent, lineStatus);
     // The uncommitted content can fully, partially fit the current line (commit/partial commit) or not at all (reset).
-    if (breakingContext.contentBreak == LineBreaker::BreakingContext::ContentBreak::Keep)
+    if (breakingContext.contentWrappingRule == LineBreaker::BreakingContext::ContentWrappingRule::Keep)
         commitPendingContent(line);
-    else if (breakingContext.contentBreak == LineBreaker::BreakingContext::ContentBreak::Split) {
+    else if (breakingContext.contentWrappingRule == LineBreaker::BreakingContext::ContentWrappingRule::Split) {
         ASSERT(breakingContext.partialTrailingContent);
         ASSERT(m_uncommittedContent.runs()[breakingContext.partialTrailingContent->runIndex].inlineItem.isText());
         // Turn the uncommitted trailing run into a partial trailing run.
@@ -230,13 +230,13 @@
         m_uncommittedContent.trim(overflowInlineTextItemIndex);
         m_uncommittedContent.append(*m_partialTrailingTextItem, breakingContext.partialTrailingContent->logicalWidth);
         commitPendingContent(line);
-    } else if (breakingContext.contentBreak == LineBreaker::BreakingContext::ContentBreak::Wrap)
+    } else if (breakingContext.contentWrappingRule == LineBreaker::BreakingContext::ContentWrappingRule::Push)
         m_uncommittedContent.reset();
     else
         ASSERT_NOT_REACHED();
     // Adjust hyphenated line count
     m_successiveHyphenatedLineCount = breakingContext.partialTrailingContent && breakingContext.partialTrailingContent->needsHyphen ? m_successiveHyphenatedLineCount + 1 : 0;
-    return breakingContext.contentBreak == LineBreaker::BreakingContext::ContentBreak::Keep ? IsEndOfLine::No :IsEndOfLine::Yes;
+    return breakingContext.contentWrappingRule == LineBreaker::BreakingContext::ContentWrappingRule::Keep ? IsEndOfLine::No :IsEndOfLine::Yes;
 }
 
 }