Title: [250411] trunk/Source/WebCore
Revision
250411
Author
za...@apple.com
Date
2019-09-26 20:23:32 -0700 (Thu, 26 Sep 2019)

Log Message

[LFC][IFC] Remove redundant Line::Content
https://bugs.webkit.org/show_bug.cgi?id=202284
<rdar://problem/55757187>

Reviewed by Antti Koivisto.

Line::Content is really just a list or runs at this point.

* layout/inlineformatting/InlineFormattingContext.h:
* layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
(WebCore::Layout::InlineFormattingContext::InlineLayout::createDisplayRuns):
* layout/inlineformatting/InlineFormattingContextQuirks.cpp:
(WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing const):
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::Run::Run):
(WebCore::Layout::Line::Line):
(WebCore::Layout::Line::isVisuallyEmpty const):
(WebCore::Layout::Line::close):
(WebCore::Layout::Line::appendNonBreakableSpace):
(WebCore::Layout::Line::appendTextContent):
(WebCore::Layout::Line::appendNonReplacedInlineBox):
(WebCore::Layout::Line::appendHardLineBreak):
(WebCore::Layout::Line::Content::Run::Run): 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::type const):
(WebCore::Layout::Line::Run::isText const):
(WebCore::Layout::Line::Run::isBox const):
(WebCore::Layout::Line::Run::isLineBreak const):
(WebCore::Layout::Line::Run::isContainerStart const):
(WebCore::Layout::Line::Run::isContainerEnd const):
(WebCore::Layout::Line::Run::adjustLogicalTop):
(WebCore::Layout::Line::Run::moveVertically):
(WebCore::Layout::Line::Run::moveHorizontally):
(WebCore::Layout::Line::Run::setTextIsCollapsed):
(WebCore::Layout::Line::Content::Run::layoutBox const): Deleted.
(WebCore::Layout::Line::Content::Run::logicalRect const): Deleted.
(WebCore::Layout::Line::Content::Run::textContext const): Deleted.
(WebCore::Layout::Line::Content::Run::type const): Deleted.
(WebCore::Layout::Line::Content::Run::isText const): Deleted.
(WebCore::Layout::Line::Content::Run::isBox const): Deleted.
(WebCore::Layout::Line::Content::Run::isLineBreak const): Deleted.
(WebCore::Layout::Line::Content::Run::isContainerStart const): Deleted.
(WebCore::Layout::Line::Content::Run::isContainerEnd const): Deleted.
(WebCore::Layout::Line::Content::Run::adjustLogicalTop): Deleted.
(WebCore::Layout::Line::Content::Run::moveVertically): Deleted.
(WebCore::Layout::Line::Content::Run::moveHorizontally): Deleted.
(WebCore::Layout::Line::Content::Run::setTextIsCollapsed): Deleted.
(WebCore::Layout::Line::Content::runs const): Deleted.
(WebCore::Layout::Line::Content::runs): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (250410 => 250411)


--- trunk/Source/WebCore/ChangeLog	2019-09-27 03:00:10 UTC (rev 250410)
+++ trunk/Source/WebCore/ChangeLog	2019-09-27 03:23:32 UTC (rev 250411)
@@ -1,5 +1,60 @@
 2019-09-26  Zalan Bujtas  <za...@apple.com>
 
+        [LFC][IFC] Remove redundant Line::Content
+        https://bugs.webkit.org/show_bug.cgi?id=202284
+        <rdar://problem/55757187>
+
+        Reviewed by Antti Koivisto.
+
+        Line::Content is really just a list or runs at this point.
+
+        * layout/inlineformatting/InlineFormattingContext.h:
+        * layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
+        (WebCore::Layout::InlineFormattingContext::InlineLayout::createDisplayRuns):
+        * layout/inlineformatting/InlineFormattingContextQuirks.cpp:
+        (WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing const):
+        * layout/inlineformatting/InlineLine.cpp:
+        (WebCore::Layout::Line::Run::Run):
+        (WebCore::Layout::Line::Line):
+        (WebCore::Layout::Line::isVisuallyEmpty const):
+        (WebCore::Layout::Line::close):
+        (WebCore::Layout::Line::appendNonBreakableSpace):
+        (WebCore::Layout::Line::appendTextContent):
+        (WebCore::Layout::Line::appendNonReplacedInlineBox):
+        (WebCore::Layout::Line::appendHardLineBreak):
+        (WebCore::Layout::Line::Content::Run::Run): 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::type const):
+        (WebCore::Layout::Line::Run::isText const):
+        (WebCore::Layout::Line::Run::isBox const):
+        (WebCore::Layout::Line::Run::isLineBreak const):
+        (WebCore::Layout::Line::Run::isContainerStart const):
+        (WebCore::Layout::Line::Run::isContainerEnd const):
+        (WebCore::Layout::Line::Run::adjustLogicalTop):
+        (WebCore::Layout::Line::Run::moveVertically):
+        (WebCore::Layout::Line::Run::moveHorizontally):
+        (WebCore::Layout::Line::Run::setTextIsCollapsed):
+        (WebCore::Layout::Line::Content::Run::layoutBox const): Deleted.
+        (WebCore::Layout::Line::Content::Run::logicalRect const): Deleted.
+        (WebCore::Layout::Line::Content::Run::textContext const): Deleted.
+        (WebCore::Layout::Line::Content::Run::type const): Deleted.
+        (WebCore::Layout::Line::Content::Run::isText const): Deleted.
+        (WebCore::Layout::Line::Content::Run::isBox const): Deleted.
+        (WebCore::Layout::Line::Content::Run::isLineBreak const): Deleted.
+        (WebCore::Layout::Line::Content::Run::isContainerStart const): Deleted.
+        (WebCore::Layout::Line::Content::Run::isContainerEnd const): Deleted.
+        (WebCore::Layout::Line::Content::Run::adjustLogicalTop): Deleted.
+        (WebCore::Layout::Line::Content::Run::moveVertically): Deleted.
+        (WebCore::Layout::Line::Content::Run::moveHorizontally): Deleted.
+        (WebCore::Layout::Line::Content::Run::setTextIsCollapsed): Deleted.
+        (WebCore::Layout::Line::Content::runs const): Deleted.
+        (WebCore::Layout::Line::Content::runs): Deleted.
+
+2019-09-26  Zalan Bujtas  <za...@apple.com>
+
         [LFC][IFC] Move Line::Content::m_lineBox to Line.
         https://bugs.webkit.org/show_bug.cgi?id=202280
         <rdar://problem/55755798>

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h (250410 => 250411)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h	2019-09-27 03:00:10 UTC (rev 250410)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h	2019-09-27 03:23:32 UTC (rev 250411)
@@ -77,7 +77,7 @@
 
     class Quirks : public FormattingContext::Quirks {
     public:
-        bool lineDescentNeedsCollapsing(const Line::Content&) const;
+        bool lineDescentNeedsCollapsing(const Line::RunList&) const;
         Line::InitialConstraints::HeightAndBaseline lineHeightConstraints(const Box& formattingRoot) const;
 
     private:

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp (250410 => 250411)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp	2019-09-27 03:00:10 UTC (rev 250410)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp	2019-09-27 03:23:32 UTC (rev 250411)
@@ -94,7 +94,7 @@
 struct LineContent {
     Optional<IndexAndRange> lastCommitted;
     Vector<WeakPtr<InlineItem>> floats;
-    std::unique_ptr<const Line::Content> runs;
+    const Line::RunList runList;
     const LineBox lineBox;
 };
 
@@ -382,7 +382,7 @@
     // A line box is always tall enough for all of the boxes it contains.
 
     // Create final display runs.
-    auto& lineRuns = lineContent.runs->runs();
+    auto& lineRuns = lineContent.runList;
     for (unsigned index = 0; index < lineRuns.size(); ++index) {
         auto& run = lineRuns.at(index);
         // Inline level containers (<span>) don't generate inline runs.
@@ -400,7 +400,7 @@
             if (textContext->isCollapsed)
                 continue;
             // Try to join multiple text runs when possible.
-            const Line::Content::Run* previousRun = !index ? nullptr : lineRuns[index - 1].get();
+            const Line::Run* previousRun = !index ? nullptr : lineRuns[index - 1].get();
             auto previousRunCanBeExtended = previousRun && previousRun->textContext() ? previousRun->textContext()->canBeExtended : false;
             auto currentRunCanBeMergedWithPrevious = !previousRun || &run->layoutBox() == &previousRun->layoutBox();
 
@@ -462,7 +462,7 @@
         // Text content. Try to join multiple text runs when possible.
         if (lineRun->isText()) {
             auto textContext = lineRun->textContext();
-            const Line::Content::Run* previousLineRun = !index ? nullptr : lineRuns[index - 1].get();
+            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) {

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp (250410 => 250411)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2019-09-27 03:00:10 UTC (rev 250410)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2019-09-27 03:23:32 UTC (rev 250411)
@@ -36,7 +36,7 @@
 namespace WebCore {
 namespace Layout {
 
-bool InlineFormattingContext::Quirks::lineDescentNeedsCollapsing(const Line::Content& lineContent) const
+bool InlineFormattingContext::Quirks::lineDescentNeedsCollapsing(const Line::RunList& runList) const
 {
     // Collapse line descent in limited and full quirk mode when there's no baseline aligned content or
     // the baseline aligned content has no descent.
@@ -44,7 +44,7 @@
     if (!layoutState.inQuirksMode() && !layoutState.inLimitedQuirksMode())
         return false;
 
-    for (auto& run : lineContent.runs()) {
+    for (auto& run : runList) {
         auto& layoutBox = run->layoutBox();
         if (layoutBox.style().verticalAlign() != VerticalAlign::Baseline)
             continue;

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (250410 => 250411)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2019-09-27 03:00:10 UTC (rev 250410)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2019-09-27 03:23:32 UTC (rev 250411)
@@ -37,7 +37,7 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(Line);
 
-Line::Content::Run::Run(const InlineItem& inlineItem, const Display::Rect& logicalRect)
+Line::Run::Run(const InlineItem& inlineItem, const Display::Rect& logicalRect)
     : m_layoutBox(inlineItem.layoutBox())
     , m_type(inlineItem.type())
     , m_logicalRect(logicalRect)
@@ -44,7 +44,7 @@
 {
 }
 
-Line::Content::Run::Run(const InlineItem& inlineItem, const TextContext& textContext, const Display::Rect& logicalRect)
+Line::Run::Run(const InlineItem& inlineItem, const TextContext& textContext, const Display::Rect& logicalRect)
     : m_layoutBox(inlineItem.layoutBox())
     , m_type(inlineItem.type())
     , m_logicalRect(logicalRect)
@@ -54,7 +54,6 @@
 
 Line::Line(const InlineFormattingContext& inlineFormattingContext, const InitialConstraints& initialConstraints, SkipVerticalAligment skipVerticalAligment)
     : m_inlineFormattingContext(inlineFormattingContext)
-    , m_content(makeUnique<Line::Content>())
     , m_initialStrut(initialConstraints.heightAndBaseline.strut)
     , m_lineLogicalWidth(initialConstraints.availableLogicalWidth)
     , m_skipVerticalAligment(skipVerticalAligment == SkipVerticalAligment::Yes)
@@ -76,7 +75,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_content->runs()) {
+    for (auto& run : m_runList) {
         if (run->isContainerStart()) {
             if (!isInlineContainerConsideredEmpty(formattingContext, run->layoutBox()))
                 return false;
@@ -99,7 +98,7 @@
     return true;
 }
 
-std::unique_ptr<Line::Content> Line::close()
+Line::RunList Line::close()
 {
     removeTrailingTrimmableContent();
     if (!m_skipVerticalAligment) {
@@ -110,7 +109,7 @@
         }
 
         // Remove descent when all content is baseline aligned but none of them have descent.
-        if (formattingContext().quirks().lineDescentNeedsCollapsing(*m_content)) {
+        if (formattingContext().quirks().lineDescentNeedsCollapsing(m_runList)) {
             m_lineBox.shrinkVertically(m_lineBox.baseline().descent());
             m_lineBox.baseline().setDescent({ });
         }
@@ -117,7 +116,7 @@
 
         auto& layoutState = this->layoutState();
         auto& formattingContext = this->formattingContext();
-        for (auto& run : m_content->runs()) {
+        for (auto& run : m_runList) {
             LayoutUnit logicalTop;
             auto& layoutBox = run->layoutBox();
             auto verticalAlign = layoutBox.style().verticalAlign();
@@ -155,7 +154,7 @@
             run->moveHorizontally(this->logicalLeft());
         }
     }
-    return WTFMove(m_content);
+    return WTFMove(m_runList);
 }
 
 void Line::removeTrailingTrimmableContent()
@@ -212,7 +211,7 @@
 
 void Line::appendNonBreakableSpace(const InlineItem& inlineItem, const Display::Rect& logicalRect)
 {
-    m_content->runs().append(makeUnique<Content::Run>(inlineItem, logicalRect));
+    m_runList.append(makeUnique<Run>(inlineItem, logicalRect));
     m_lineBox.expandHorizontally(logicalRect.width());
 }
 
@@ -252,12 +251,11 @@
         if (!isTrimmable)
             return false;
         // Leading whitespace.
-        auto& runs = m_content->runs();
-        if (runs.isEmpty())
+        if (m_runList.isEmpty())
             return true;
         // Check if the last item is trimmable as well.
-        for (int index = runs.size() - 1; index >= 0; --index) {
-            auto& run = runs[index];
+        for (int index = m_runList.size() - 1; index >= 0; --index) {
+            auto& run = m_runList[index];
             if (run->isBox())
                 return false;
             if (run->isText())
@@ -280,12 +278,12 @@
         adjustBaselineAndLineHeight(inlineItem, runHeight);
     }
 
-    auto textContext = Content::Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length(), isCompletelyCollapsed, inlineItem.isWhitespace(), canBeExtended };
-    auto lineItem = makeUnique<Content::Run>(inlineItem, textContext, logicalRect);
+    auto textContext = Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length(), isCompletelyCollapsed, inlineItem.isWhitespace(), canBeExtended };
+    auto lineItem = makeUnique<Run>(inlineItem, textContext, logicalRect);
     if (isTrimmable && !isCompletelyCollapsed)
         m_trimmableContent.add(lineItem.get());
 
-    m_content->runs().append(WTFMove(lineItem));
+    m_runList.append(WTFMove(lineItem));
     if (!isCompletelyCollapsed)
         m_lineBox.expandHorizontally(logicalWidth);
 }
@@ -303,7 +301,7 @@
         logicalRect.setHeight(inlineItemContentHeight(inlineItem));
     }
 
-    m_content->runs().append(makeUnique<Content::Run>(inlineItem, logicalRect));
+    m_runList.append(makeUnique<Run>(inlineItem, logicalRect));
     m_lineBox.expandHorizontally(logicalWidth + horizontalMargin.start + horizontalMargin.end);
     m_trimmableContent.clear();
 }
@@ -323,7 +321,7 @@
         adjustBaselineAndLineHeight(inlineItem, { });
         logicalRect.setHeight(logicalHeight());
     }
-    m_content->runs().append(makeUnique<Content::Run>(inlineItem, logicalRect));
+    m_runList.append(makeUnique<Run>(inlineItem, logicalRect));
 }
 
 void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem, LayoutUnit runHeight)

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (250410 => 250411)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h	2019-09-27 03:00:10 UTC (rev 250410)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h	2019-09-27 03:23:32 UTC (rev 250411)
@@ -54,65 +54,54 @@
     enum class SkipVerticalAligment { No, Yes };
     Line(const InlineFormattingContext&, const InitialConstraints&, SkipVerticalAligment);
 
-    class Content {
-        WTF_MAKE_FAST_ALLOCATED;
-    public:
-        struct Run {
-            WTF_MAKE_STRUCT_FAST_ALLOCATED;
-            struct TextContext {
-                unsigned start { 0 };
-                unsigned length { 0 };
-                bool isCollapsed { false };
-                bool isWhitespace { false };
-                bool canBeExtended { false };
-            };
-            Run(const InlineItem&, const Display::Rect&);
-            Run(const InlineItem&, const TextContext&, const Display::Rect&);
+    void append(const InlineItem&, LayoutUnit logicalWidth);
+    bool hasContent() const { return !isVisuallyEmpty(); }
+    LayoutUnit availableWidth() const { return logicalWidth() - contentLogicalWidth(); }
 
-            const Box& layoutBox() const { return m_layoutBox; }
-            const Display::Rect& logicalRect() const { return m_logicalRect; }
-            const Optional<TextContext> textContext() const { return m_textContext; }
-            InlineItem::Type type() const { return m_type; }
+    LayoutUnit trailingTrimmableWidth() const;
 
-            bool isText() const { return m_type == InlineItem::Type::Text; }
-            bool isBox() const { return m_type == InlineItem::Type::Box; }
-            bool isLineBreak() const { return m_type == InlineItem::Type::HardLineBreak; }
-            bool isContainerStart() const { return m_type == InlineItem::Type::ContainerStart; }
-            bool isContainerEnd() const { return m_type == InlineItem::Type::ContainerEnd; }
+    const LineBox& lineBox() const { return m_lineBox; }
+    void moveLogicalLeft(LayoutUnit);
+    void moveLogicalRight(LayoutUnit);
 
-        private:
-            friend class Line;
-            void adjustLogicalTop(LayoutUnit logicalTop) { m_logicalRect.setTop(logicalTop); }
-            void moveVertically(LayoutUnit offset) { m_logicalRect.moveVertically(offset); }
-            void moveHorizontally(LayoutUnit offset) { m_logicalRect.moveHorizontally(offset); }
-            void setTextIsCollapsed() { m_textContext->isCollapsed = true; }
-
-            const Box& m_layoutBox;
-            const InlineItem::Type m_type;
-            Display::Rect m_logicalRect;
-            Optional<TextContext> m_textContext;
+    struct Run {
+        WTF_MAKE_STRUCT_FAST_ALLOCATED;
+        struct TextContext {
+            unsigned start { 0 };
+            unsigned length { 0 };
+            bool isCollapsed { false };
+            bool isWhitespace { false };
+            bool canBeExtended { false };
         };
-        using Runs = Vector<std::unique_ptr<Run>>;
-        const Runs& runs() const { return m_runs; }
+        Run(const InlineItem&, const Display::Rect&);
+        Run(const InlineItem&, const TextContext&, const Display::Rect&);
 
+        const Box& layoutBox() const { return m_layoutBox; }
+        const Display::Rect& logicalRect() const { return m_logicalRect; }
+        const Optional<TextContext> textContext() const { return m_textContext; }
+        InlineItem::Type type() const { return m_type; }
+
+        bool isText() const { return m_type == InlineItem::Type::Text; }
+        bool isBox() const { return m_type == InlineItem::Type::Box; }
+        bool isLineBreak() const { return m_type == InlineItem::Type::HardLineBreak; }
+        bool isContainerStart() const { return m_type == InlineItem::Type::ContainerStart; }
+        bool isContainerEnd() const { return m_type == InlineItem::Type::ContainerEnd; }
+
     private:
         friend class Line;
-        Runs& runs() { return m_runs; }
+        void adjustLogicalTop(LayoutUnit logicalTop) { m_logicalRect.setTop(logicalTop); }
+        void moveVertically(LayoutUnit offset) { m_logicalRect.moveVertically(offset); }
+        void moveHorizontally(LayoutUnit offset) { m_logicalRect.moveHorizontally(offset); }
+        void setTextIsCollapsed() { m_textContext->isCollapsed = true; }
 
-        Runs m_runs;
+        const Box& m_layoutBox;
+        const InlineItem::Type m_type;
+        Display::Rect m_logicalRect;
+        Optional<TextContext> m_textContext;
     };
-    std::unique_ptr<Content> close();
+    using RunList = Vector<std::unique_ptr<Run>>;
+    RunList close();
 
-    void append(const InlineItem&, LayoutUnit logicalWidth);
-    bool hasContent() const { return !isVisuallyEmpty(); }
-    LayoutUnit availableWidth() const { return logicalWidth() - contentLogicalWidth(); }
-
-    LayoutUnit trailingTrimmableWidth() const;
-
-    const LineBox& lineBox() const { return m_lineBox; }
-    void moveLogicalLeft(LayoutUnit);
-    void moveLogicalRight(LayoutUnit);
-
     static LineBox::Baseline halfLeadingMetrics(const FontMetrics&, LayoutUnit lineLogicalHeight);
 
 private:
@@ -147,8 +136,8 @@
     const InlineFormattingContext& formattingContext() const; 
 
     const InlineFormattingContext& m_inlineFormattingContext;
-    std::unique_ptr<Content> m_content;
-    ListHashSet<Content::Run*> m_trimmableContent;
+    RunList m_runList;
+    ListHashSet<Run*> m_trimmableContent;
 
     Optional<LineBox::Baseline> m_initialStrut;
     LayoutUnit m_lineLogicalWidth;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to