Title: [253770] trunk/Source/WebCore
Revision
253770
Author
[email protected]
Date
2019-12-19 11:20:26 -0800 (Thu, 19 Dec 2019)

Log Message

Unreviewed, rolling out r253711.

Broke two tests on Mac and iOS

Reverted changeset:

"[LFC][IFC] LineLayoutContext::m_uncommittedList is not always
a continuous list of runs"
https://bugs.webkit.org/show_bug.cgi?id=205404
https://trac.webkit.org/changeset/253711

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (253769 => 253770)


--- trunk/Source/WebCore/ChangeLog	2019-12-19 18:51:37 UTC (rev 253769)
+++ trunk/Source/WebCore/ChangeLog	2019-12-19 19:20:26 UTC (rev 253770)
@@ -1,3 +1,16 @@
+2019-12-19  Alan Bujtas  <[email protected]>
+
+        Unreviewed, rolling out r253711.
+
+        Broke two tests on Mac and iOS
+
+        Reverted changeset:
+
+        "[LFC][IFC] LineLayoutContext::m_uncommittedList is not always
+        a continuous list of runs"
+        https://bugs.webkit.org/show_bug.cgi?id=205404
+        https://trac.webkit.org/changeset/253711
+
 2019-12-19  Andres Gonzalez  <[email protected]>
 
         AXIsolatedObject::findMatchingObjects implementation.

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp (253769 => 253770)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp	2019-12-19 18:51:37 UTC (rev 253769)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp	2019-12-19 19:20:26 UTC (rev 253770)
@@ -54,7 +54,7 @@
     return isTextContentWrappingAllowed(run.inlineItem.style());
 }
 
-static inline bool shouldKeepEndOfLineWhitespace(const LineBreaker::ContinousContent& candidateRuns)
+static inline bool shouldKeepEndOfLineWhitespace(const LineBreaker::Content& candidateRuns)
 {
     // Grab the style and check for white-space property to decided whether we should let this whitespace content overflow the current line.
     // Note that the "keep" in the context means we let the whitespace content sit on the current line.
@@ -64,7 +64,7 @@
     return whitespace == WhiteSpace::Normal || whitespace == WhiteSpace::NoWrap || whitespace == WhiteSpace::PreWrap || whitespace == WhiteSpace::PreLine;
 }
 
-LineBreaker::BreakingContext LineBreaker::breakingContextForInlineContent(const ContinousContent& candidateRuns, const LineStatus& lineStatus)
+LineBreaker::BreakingContext LineBreaker::breakingContextForInlineContent(const Content& candidateRuns, const LineStatus& lineStatus)
 {
     ASSERT(!candidateRuns.isEmpty());
     if (candidateRuns.width() <= lineStatus.availableWidth)
@@ -386,42 +386,49 @@
     return true;
 }
 
-LineBreaker::ContinousContent::ContinousContent(const RunList& runs)
-    : m_runs(runs)
+void LineBreaker::Content::append(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
 {
+    ASSERT(!inlineItem.isFloat());
+    m_continousRuns.append({ inlineItem, logicalWidth });
+    m_width += logicalWidth;
     // Figure out the trailing collapsible state.
-    for (auto& run : WTF::makeReversedRange(m_runs)) {
-        auto& inlineItem = run.inlineItem;
-        if (inlineItem.isBox() || inlineItem.isLineBreak()) {
-            // We did reach a non-collapsible content. We have all the trailing whitespace now.
-            break;
-        }
-        if (inlineItem.isText()) {
-            auto& inlineTextItem = downcast<InlineTextItem>(inlineItem);
-            auto isFullyCollapsible = [&] {
-                return inlineTextItem.isWhitespace() && !TextUtil::shouldPreserveTrailingWhitespace(inlineTextItem.style());
-            };
-            if (isFullyCollapsible()) {
-                m_trailingCollapsibleContent.width += run.logicalWidth;
-                m_trailingCollapsibleContent.isFullyCollapsible = true;
-                // Let's see if we've got more trailing whitespace content.
-                continue;
-            }
-            if (auto collapsibleWidth = inlineTextItem.style().letterSpacing()) {
-                m_trailingCollapsibleContent.width += collapsibleWidth;
-                m_trailingCollapsibleContent.isFullyCollapsible = false;
-            }
-            // End of whitspace content.
-            break;
-        }
+    if (inlineItem.isBox() || inlineItem.isLineBreak())
+        m_trailingCollapsibleContent.reset();
+    else if (inlineItem.isText()) {
+        auto& inlineTextItem = downcast<InlineTextItem>(inlineItem);
+        auto isFullyCollapsible = [&] {
+            return inlineTextItem.isWhitespace() && !TextUtil::shouldPreserveTrailingWhitespace(inlineTextItem.style());
+        };
+        if (isFullyCollapsible()) {
+            m_trailingCollapsibleContent.width += logicalWidth;
+            m_trailingCollapsibleContent.isFullyCollapsible = true;
+        } else if (auto collapsibleWidth = inlineTextItem.style().letterSpacing()) {
+            m_trailingCollapsibleContent.width = collapsibleWidth;
+            m_trailingCollapsibleContent.isFullyCollapsible = false;
+        } else
+            m_trailingCollapsibleContent.reset();
     }
 }
 
-bool LineBreaker::ContinousContent::hasTextContentOnly() const
+void LineBreaker::Content::reset()
 {
+    m_continousRuns.clear();
+    m_trailingCollapsibleContent.reset();
+    m_width = 0_lu;
+}
+
+void LineBreaker::Content::shrink(unsigned newSize)
+{
+    for (auto i = m_continousRuns.size(); i--;)
+        m_width -= m_continousRuns[i].logicalWidth;
+    m_continousRuns.shrink(newSize);
+}
+
+bool LineBreaker::Content::hasTextContentOnly() const
+{
     // <span>text</span> is considered a text run even with the [container start][container end] inline items.
     // Due to commit boundary rules, we just need to check the first non-typeless inline item (can't have both [img] and [text])
-    for (auto& run : m_runs) {
+    for (auto& run : m_continousRuns) {
         auto& inlineItem = run.inlineItem;
         if (inlineItem.isContainerStart() || inlineItem.isContainerEnd())
             continue;
@@ -430,12 +437,12 @@
     return false;
 }
 
-bool LineBreaker::ContinousContent::isVisuallyEmptyWhitespaceContentOnly() const
+bool LineBreaker::Content::isVisuallyEmptyWhitespaceContentOnly() const
 {
     // [<span></span> ] [<span> </span>] [ <span style="padding: 0px;"></span>] are all considered visually empty whitespace content.
     // [<span style="border: 1px solid red"></span> ] while this is whitespace content only, it is not considered visually empty.
     // Due to commit boundary rules, we just need to check the first non-typeless inline item (can't have both [img] and [text])
-    for (auto& run : m_runs) {
+    for (auto& run : m_continousRuns) {
         auto& inlineItem = run.inlineItem;
         // FIXME: check for padding border etc.
         if (inlineItem.isContainerStart() || inlineItem.isContainerEnd())
@@ -445,19 +452,19 @@
     return false;
 }
 
-Optional<unsigned> LineBreaker::ContinousContent::firstTextRunIndex() const
+Optional<unsigned> LineBreaker::Content::firstTextRunIndex() const
 {
-    for (size_t index = 0; index < m_runs.size(); ++index) {
-        if (m_runs[index].inlineItem.isText())
+    for (size_t index = 0; index < m_continousRuns.size(); ++index) {
+        if (m_continousRuns[index].inlineItem.isText())
             return index;
     }
     return { };
 }
 
-bool LineBreaker::ContinousContent::hasNonContentRunsOnly() const
+bool LineBreaker::Content::hasNonContentRunsOnly() const
 {
     // <span></span> <- non content runs.
-    for (auto& run : m_runs) {
+    for (auto& run : m_continousRuns) {
         auto& inlineItem = run.inlineItem;
         if (inlineItem.isContainerStart() || inlineItem.isContainerEnd())
             continue;
@@ -466,7 +473,7 @@
     return true;
 }
 
-void LineBreaker::ContinousContent::TrailingCollapsibleContent::reset()
+void LineBreaker::Content::TrailingCollapsibleContent::reset()
 {
     isFullyCollapsible = false;
     width = 0_lu;

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h (253769 => 253770)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h	2019-12-19 18:51:37 UTC (rev 253769)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.h	2019-12-19 19:20:26 UTC (rev 253770)
@@ -72,15 +72,18 @@
     // [content]
     // [container start][span1][container end][between][container start][span2][container end]
     // see https://drafts.csswg.org/css-text-3/#line-break-details
-    struct ContinousContent {
-        ContinousContent(const RunList&);
+    struct Content {
+        void append(const InlineItem&, InlineLayoutUnit logicalWidth);
+        void reset();
+        void shrink(unsigned newSize);
 
-        const RunList& runs() const { return m_runs; }
-        bool isEmpty() const { return m_runs.isEmpty(); }
+        RunList& runs() { return m_continousRuns; }
+        const RunList& runs() const { return m_continousRuns; }
+        bool isEmpty() const { return m_continousRuns.isEmpty(); }
         bool hasTextContentOnly() const;
         bool isVisuallyEmptyWhitespaceContentOnly() const;
         bool hasNonContentRunsOnly() const;
-        size_t size() const { return m_runs.size(); }
+        unsigned size() const { return m_continousRuns.size(); }
         InlineLayoutUnit width() const { return m_width; }
         InlineLayoutUnit nonCollapsibleWidth() const { return m_width - m_trailingCollapsibleContent.width; }
 
@@ -90,7 +93,7 @@
         Optional<unsigned> firstTextRunIndex() const;
 
     private:
-        RunList m_runs;
+        RunList m_continousRuns;
         struct TrailingCollapsibleContent {
             void reset();
 
@@ -107,7 +110,7 @@
         bool lineHasFullyCollapsibleTrailingRun { false };
         bool lineIsEmpty { true };
     };
-    BreakingContext breakingContextForInlineContent(const ContinousContent& candidateRuns, const LineStatus&);
+    BreakingContext breakingContextForInlineContent(const Content& candidateRuns, const LineStatus&);
     bool shouldWrapFloatBox(InlineLayoutUnit floatLogicalWidth, InlineLayoutUnit availableWidth, bool lineIsEmpty);
 
     void setHyphenationDisabled() { n_hyphenationIsDisabled = true; }

Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp (253769 => 253770)


--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp	2019-12-19 18:51:37 UTC (rev 253769)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.cpp	2019-12-19 19:20:26 UTC (rev 253770)
@@ -208,7 +208,7 @@
     if (shouldDisableHyphenation())
         lineBreaker.setHyphenationDisabled();
     auto lineStatus = LineBreaker::LineStatus { line.availableWidth(), line.trailingCollapsibleWidth(), line.isTrailingRunFullyCollapsible(), lineIsConsideredEmpty };
-    auto breakingContext = lineBreaker.breakingContextForInlineContent(LineBreaker::ContinousContent { m_uncommittedContent.runs() }, lineStatus);
+    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.contentWrappingRule == LineBreaker::BreakingContext::ContentWrappingRule::Keep)
         commitPendingContent(line);
@@ -248,30 +248,7 @@
     return breakingContext.contentWrappingRule == LineBreaker::BreakingContext::ContentWrappingRule::Keep ? IsEndOfLine::No : IsEndOfLine::Yes;
 }
 
-void LineLayoutContext::UncommittedContent::append(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
-{
-    ASSERT(!inlineItem.isFloat());
-    m_uncommittedList.append({ inlineItem, logicalWidth });
-    m_width += logicalWidth;
 }
-
-void LineLayoutContext::UncommittedContent::reset()
-{
-    m_uncommittedList.clear();
-    m_width = 0_lu;
 }
 
-void LineLayoutContext::UncommittedContent::shrink(size_t newSize)
-{
-    ASSERT(newSize);
-    ASSERT(m_uncommittedList.size());
-    ASSERT(newSize < m_uncommittedList.size());
-    for (size_t i = m_uncommittedList.size() - 1; i >= newSize ; --i)
-        m_width -= m_uncommittedList[i].logicalWidth;
-    m_uncommittedList.shrink(newSize);
-}
-
-}
-}
-
 #endif

Modified: trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h (253769 => 253770)


--- trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h	2019-12-19 18:51:37 UTC (rev 253769)
+++ trunk/Source/WebCore/layout/inlineformatting/LineLayoutContext.h	2019-12-19 19:20:26 UTC (rev 253770)
@@ -62,21 +62,7 @@
     const InlineFormattingContext& m_inlineFormattingContext;
     const Container& m_formattingContextRoot;
     const InlineItems& m_inlineItems;
-
-    struct UncommittedContent {
-        void append(const InlineItem&, InlineLayoutUnit logicalWidth);
-        InlineLayoutUnit width() const { return m_width; }
-        size_t size() { return runs().size(); }
-        bool isEmpty() { return runs().isEmpty(); }
-        void reset();
-        void shrink(size_t newSize);
-        const LineBreaker::RunList& runs() const { return m_uncommittedList; }
-
-    private:
-        LineBreaker::RunList m_uncommittedList;
-        InlineLayoutUnit m_width;
-    };
-    UncommittedContent m_uncommittedContent;
+    LineBreaker::Content m_uncommittedContent;
     unsigned m_committedInlineItemCount { 0 };
     Vector<WeakPtr<InlineItem>> m_floats;
     std::unique_ptr<InlineTextItem> m_partialLeadingTextItem;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to