Title: [250429] trunk/Source/WebCore
Revision
250429
Author
[email protected]
Date
2019-09-27 09:49:54 -0700 (Fri, 27 Sep 2019)

Log Message

[LFC][IFC] Replace Line::Run's logicalRect/textContext with Display::Run
https://bugs.webkit.org/show_bug.cgi?id=202313
<rdar://problem/55782430>

Reviewed by Antti Koivisto.

Display::Run is a container for logical rect and text context. Let's replace Line::Run's logical rect/text context with Display::Run.

* layout/Verification.cpp:
(WebCore::Layout::outputMismatchingSimpleLineInformationIfNeeded):
(WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded):
* layout/displaytree/DisplayRun.h:
(WebCore::Display::Run::logicalRect const):
* layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
(WebCore::Layout::InlineFormattingContext::InlineLayout::createDisplayRuns):
(WebCore::Layout::InlineFormattingContext::InlineLayout::alignRuns const):
* layout/inlineformatting/InlineFormattingContextQuirks.cpp:
(WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing const):
* layout/inlineformatting/InlineFormattingState.h:
(WebCore::Layout::InlineFormattingState::addInlineRun):
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::Run::Run):
(WebCore::Layout::Line::isVisuallyEmpty const):
(WebCore::Layout::Line::appendNonBreakableSpace):
(WebCore::Layout::Line::appendTextContent):
(WebCore::Layout::Line::appendNonReplacedInlineBox):
(WebCore::Layout::Line::appendHardLineBreak):
* layout/inlineformatting/InlineLine.h:
(WebCore::Layout::Line::Run::displayRun const):
(WebCore::Layout::Line::Run::logicalRect const):
(WebCore::Layout::Line::Run::adjustLogicalTop):
(WebCore::Layout::Line::Run::moveVertically):
(WebCore::Layout::Line::Run::moveHorizontally):
(WebCore::Layout::Line::Run::textContext const): Deleted.
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::outputInlineRuns):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (250428 => 250429)


--- trunk/Source/WebCore/ChangeLog	2019-09-27 16:27:45 UTC (rev 250428)
+++ trunk/Source/WebCore/ChangeLog	2019-09-27 16:49:54 UTC (rev 250429)
@@ -1,3 +1,42 @@
+2019-09-27  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Replace Line::Run's logicalRect/textContext with Display::Run
+        https://bugs.webkit.org/show_bug.cgi?id=202313
+        <rdar://problem/55782430>
+
+        Reviewed by Antti Koivisto.
+
+        Display::Run is a container for logical rect and text context. Let's replace Line::Run's logical rect/text context with Display::Run.
+
+        * layout/Verification.cpp:
+        (WebCore::Layout::outputMismatchingSimpleLineInformationIfNeeded):
+        (WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded):
+        * layout/displaytree/DisplayRun.h:
+        (WebCore::Display::Run::logicalRect const):
+        * layout/inlineformatting/InlineFormattingContextLineLayout.cpp:
+        (WebCore::Layout::InlineFormattingContext::InlineLayout::createDisplayRuns):
+        (WebCore::Layout::InlineFormattingContext::InlineLayout::alignRuns const):
+        * layout/inlineformatting/InlineFormattingContextQuirks.cpp:
+        (WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing const):
+        * layout/inlineformatting/InlineFormattingState.h:
+        (WebCore::Layout::InlineFormattingState::addInlineRun):
+        * layout/inlineformatting/InlineLine.cpp:
+        (WebCore::Layout::Line::Run::Run):
+        (WebCore::Layout::Line::isVisuallyEmpty const):
+        (WebCore::Layout::Line::appendNonBreakableSpace):
+        (WebCore::Layout::Line::appendTextContent):
+        (WebCore::Layout::Line::appendNonReplacedInlineBox):
+        (WebCore::Layout::Line::appendHardLineBreak):
+        * layout/inlineformatting/InlineLine.h:
+        (WebCore::Layout::Line::Run::displayRun const):
+        (WebCore::Layout::Line::Run::logicalRect const):
+        (WebCore::Layout::Line::Run::adjustLogicalTop):
+        (WebCore::Layout::Line::Run::moveVertically):
+        (WebCore::Layout::Line::Run::moveHorizontally):
+        (WebCore::Layout::Line::Run::textContext const): Deleted.
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::outputInlineRuns):
+
 2019-09-27  Truitt Savell  <[email protected]>
 
         Unreviewed, rolling out r250415.

Modified: trunk/Source/WebCore/layout/Verification.cpp (250428 => 250429)


--- trunk/Source/WebCore/layout/Verification.cpp	2019-09-27 16:27:45 UTC (rev 250428)
+++ trunk/Source/WebCore/layout/Verification.cpp	2019-09-27 16:49:54 UTC (rev 250429)
@@ -89,17 +89,17 @@
         auto& simpleRun = lineLayoutData->runAt(i);
         auto& inlineRun = inlineRunList[i];
 
-        auto matchingRuns = areEssentiallyEqual(simpleRun.logicalLeft, inlineRun->logicalLeft()) && areEssentiallyEqual(simpleRun.logicalRight, inlineRun->logicalRight());
-        if (matchingRuns && inlineRun->textContext()) {
-            matchingRuns = simpleRun.start == inlineRun->textContext()->start() && simpleRun.end == inlineRun->textContext()->end();
+        auto matchingRuns = areEssentiallyEqual(simpleRun.logicalLeft, inlineRun.logicalLeft()) && areEssentiallyEqual(simpleRun.logicalRight, inlineRun.logicalRight());
+        if (matchingRuns && inlineRun.textContext()) {
+            matchingRuns = simpleRun.start == inlineRun.textContext()->start() && simpleRun.end == inlineRun.textContext()->end();
             // SLL handles strings in a more concatenated format <div>foo<br>bar</div> -> foo -> 0,3 bar -> 3,6 vs. 0,3 and 0,3
             if (!matchingRuns)
-                matchingRuns = (simpleRun.end - simpleRun.start) == (inlineRun->textContext()->end() - inlineRun->textContext()->start()); 
+                matchingRuns = (simpleRun.end - simpleRun.start) == (inlineRun.textContext()->end() - inlineRun.textContext()->start()); 
         }
         if (matchingRuns)
             continue;
 
-        stream << "Mismatching: simple run(" << simpleRun.start << ", " << simpleRun.end << ") (" << simpleRun.logicalLeft << ", " << simpleRun.logicalRight << ") layout run(" << inlineRun->textContext()->start() << ", " << inlineRun->textContext()->end() << ") (" << inlineRun->logicalLeft() << ", " << inlineRun->logicalRight() << ")";
+        stream << "Mismatching: simple run(" << simpleRun.start << ", " << simpleRun.end << ") (" << simpleRun.logicalLeft << ", " << simpleRun.logicalRight << ") layout run(" << inlineRun.textContext()->start() << ", " << inlineRun.textContext()->end() << ") (" << inlineRun.logicalLeft() << ", " << inlineRun.logicalRight() << ")";
         stream.nextLine();
         mismatched = true;
     }
@@ -172,7 +172,7 @@
         auto& inlineRun = inlineRunList[runIndex];
         auto* inlineBox = inlineBoxes[inlineBoxIndex];
         auto* inlineTextBox = is<InlineTextBox>(inlineBox) ? downcast<InlineTextBox>(inlineBox) : nullptr;
-        bool matchingRuns = inlineTextBox ? checkForMatchingTextRuns(*inlineRun, *inlineTextBox) : matchingRuns = checkForMatchingNonTextRuns(*inlineRun, *inlineBox);
+        bool matchingRuns = inlineTextBox ? checkForMatchingTextRuns(inlineRun, *inlineTextBox) : matchingRuns = checkForMatchingNonTextRuns(inlineRun, *inlineBox);
 
         if (!matchingRuns) {
             
@@ -190,9 +190,9 @@
             stream << " (" << inlineBox->logicalLeft() << ", " << inlineBox->logicalTop() << ") (" << inlineBox->logicalWidth() << "x" << inlineBox->logicalHeight() << ")";
 
             stream << " inline run";
-            if (inlineRun->textContext())
-                stream << " (" << inlineRun->textContext()->start() << ", " << inlineRun->textContext()->end() << ")";
-            stream << " (" << inlineRun->logicalLeft() << ", " << inlineRun->logicalTop() << ") (" << inlineRun->logicalWidth() << "x" << inlineRun->logicalHeight() << ")";
+            if (inlineRun.textContext())
+                stream << " (" << inlineRun.textContext()->start() << ", " << inlineRun.textContext()->end() << ")";
+            stream << " (" << inlineRun.logicalLeft() << ", " << inlineRun.logicalTop() << ") (" << inlineRun.logicalWidth() << "x" << inlineRun.logicalHeight() << ")";
             stream.nextLine();
             mismatched = true;
         }

Modified: trunk/Source/WebCore/layout/displaytree/DisplayRun.h (250428 => 250429)


--- trunk/Source/WebCore/layout/displaytree/DisplayRun.h	2019-09-27 16:27:45 UTC (rev 250428)
+++ trunk/Source/WebCore/layout/displaytree/DisplayRun.h	2019-09-27 16:49:54 UTC (rev 250429)
@@ -57,6 +57,8 @@
     Run(Rect logicalRect, TextContext);
     Run(const Run&);
 
+    const Rect& logicalRect() const { return m_logicalRect; }
+
     LayoutPoint logicalTopLeft() const { return m_logicalRect.topLeft(); }
     LayoutUnit logicalLeft() const { return m_logicalRect.left(); }
     LayoutUnit logicalRight() const { return m_logicalRect.right(); }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp (250428 => 250429)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp	2019-09-27 16:27:45 UTC (rev 250428)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp	2019-09-27 16:49:54 UTC (rev 250429)
@@ -391,12 +391,11 @@
         auto& logicalRect = run->logicalRect();
         // Inline level box (replaced or inline-block) or <br>/<wbr>
         if (run->isLineBreak() || run->isBox()) {
-            formattingState.addInlineRun(makeUnique<Display::Run>(logicalRect));
+            formattingState.addInlineRun(run->displayRun());
             continue;
         }
         if (run->isText()) {
             // Collapsed line runs don't generate display runs.
-            auto textContext = run->textContext();
             if (run->isVisuallyEmpty())
                 continue;
             // Try to join multiple text runs when possible.
@@ -406,10 +405,10 @@
 
             if (previousRunCanBeExtended && currentRunCanBeMergedWithPrevious) {
                 auto& previousDisplayRun = formattingState.inlineRuns().last();
-                previousDisplayRun->expandHorizontally(logicalRect.width());
-                previousDisplayRun->textContext()->expand(textContext->length);
+                previousDisplayRun.expandHorizontally(logicalRect.width());
+                previousDisplayRun.textContext()->expand(run->displayRun().textContext()->length());
             } else
-                formattingState.addInlineRun(makeUnique<Display::Run>(logicalRect, Display::Run::TextContext { textContext->start, textContext->length }));
+                formattingState.addInlineRun(run->displayRun());
             continue;
         }
         ASSERT_NOT_REACHED();
@@ -512,7 +511,7 @@
         return;
 
     for (unsigned index = firstRunIndex; index < inlineDisplayRuns.size(); ++index)
-        inlineDisplayRuns[index]->moveHorizontally(*adjustment);
+        inlineDisplayRuns[index].moveHorizontally(*adjustment);
 }
 
 }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp (250428 => 250429)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2019-09-27 16:27:45 UTC (rev 250428)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp	2019-09-27 16:49:54 UTC (rev 250429)
@@ -52,7 +52,7 @@
         if (run->isLineBreak())
             return false;
         if (run->isText()) {
-            if (!run->textContext() || !run->isVisuallyEmpty())
+            if (!run->isVisuallyEmpty())
                 return false;
             continue;
         }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h (250428 => 250429)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h	2019-09-27 16:27:45 UTC (rev 250428)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h	2019-09-27 16:49:54 UTC (rev 250429)
@@ -39,7 +39,7 @@
 
 // Temp
 using InlineItems = Vector<std::unique_ptr<InlineItem>>;
-using InlineRuns = Vector<std::unique_ptr<Display::Run>>;
+using InlineRuns = Vector<Display::Run>;
 using LineBoxes = Vector<LineBox>;
 // InlineFormattingState holds the state for a particular inline formatting context tree.
 class InlineFormattingState : public FormattingState {
@@ -52,7 +52,7 @@
     void addInlineItem(std::unique_ptr<InlineItem>&& inlineItem) { m_inlineItems.append(WTFMove(inlineItem)); }
 
     InlineRuns& inlineRuns() { return m_inlineRuns; }
-    void addInlineRun(std::unique_ptr<Display::Run>&& inlineRun) { m_inlineRuns.append(WTFMove(inlineRun)); }
+    void addInlineRun(const Display::Run& inlineRun) { m_inlineRuns.append(inlineRun); }
 
     LineBoxes& lineBoxes() { return m_lineBoxes; }
     void addLineBox(LineBox lineBox) { m_lineBoxes.append(lineBox); }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (250428 => 250429)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2019-09-27 16:27:45 UTC (rev 250428)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2019-09-27 16:49:54 UTC (rev 250429)
@@ -37,19 +37,12 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(Line);
 
-Line::Run::Run(const InlineItem& inlineItem, const Display::Rect& logicalRect)
+Line::Run::Run(const InlineItem& inlineItem, const Display::Run& displayRun)
     : m_inlineItem(inlineItem)
-    , m_logicalRect(logicalRect)
+    , m_displayRun(displayRun)
 {
 }
 
-Line::Run::Run(const InlineItem& inlineItem, const TextContext& textContext, const Display::Rect& logicalRect)
-    : m_inlineItem(inlineItem)
-    , m_logicalRect(logicalRect)
-    , m_textContext(textContext)
-{
-}
-
 bool Line::Run::isWhitespace() const
 {
     if (!isText())
@@ -104,7 +97,7 @@
                 return false;
             continue;
         }
-        if (!run->textContext() || !run->isVisuallyEmpty())
+        if (!run->isText() || !run->isVisuallyEmpty())
             return false;
     }
     return true;
@@ -223,7 +216,7 @@
 
 void Line::appendNonBreakableSpace(const InlineItem& inlineItem, const Display::Rect& logicalRect)
 {
-    m_runList.append(makeUnique<Run>(inlineItem, logicalRect));
+    m_runList.append(makeUnique<Run>(inlineItem, Display::Run { logicalRect }));
     m_lineBox.expandHorizontally(logicalRect.width());
 }
 
@@ -286,8 +279,7 @@
         adjustBaselineAndLineHeight(inlineItem, runHeight);
     }
 
-    auto textContext = Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length() };
-    auto lineItem = makeUnique<Run>(inlineItem, textContext, logicalRect);
+    auto lineItem = makeUnique<Run>(inlineItem, Display::Run { logicalRect, Display::Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length() } });
     auto isVisuallyEmpty = willCollapseCompletely();
     if (isVisuallyEmpty)
         lineItem->setVisuallyIsEmpty();
@@ -313,7 +305,7 @@
         logicalRect.setHeight(inlineItemContentHeight(inlineItem));
     }
 
-    m_runList.append(makeUnique<Run>(inlineItem, logicalRect));
+    m_runList.append(makeUnique<Run>(inlineItem, Display::Run { logicalRect }));
     m_lineBox.expandHorizontally(logicalWidth + horizontalMargin.start + horizontalMargin.end);
     m_trimmableContent.clear();
 }
@@ -333,7 +325,7 @@
         adjustBaselineAndLineHeight(inlineItem, { });
         logicalRect.setHeight(logicalHeight());
     }
-    m_runList.append(makeUnique<Run>(inlineItem, logicalRect));
+    m_runList.append(makeUnique<Run>(inlineItem, Display::Run { logicalRect }));
 }
 
 void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem, LayoutUnit runHeight)

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.h (250428 => 250429)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.h	2019-09-27 16:27:45 UTC (rev 250428)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.h	2019-09-27 16:49:54 UTC (rev 250429)
@@ -66,17 +66,13 @@
 
     struct Run {
         WTF_MAKE_STRUCT_FAST_ALLOCATED;
-        struct TextContext {
-            unsigned start { 0 };
-            unsigned length { 0 };
-        };
-        Run(const InlineItem&, const Display::Rect&);
-        Run(const InlineItem&, const TextContext&, const Display::Rect&);
+        Run(const InlineItem&, const Display::Run&);
 
+        const Display::Run& displayRun() const { return m_displayRun; }
         const Box& layoutBox() const { return m_inlineItem.layoutBox(); }
-        const Display::Rect& logicalRect() const { return m_logicalRect; }
-        const Optional<TextContext> textContext() const { return m_textContext; }
 
+        const Display::Rect& logicalRect() const { return m_displayRun.logicalRect(); }
+
         bool isText() const { return m_inlineItem.isText(); }
         bool isBox() const { return m_inlineItem.isBox(); }
         bool isLineBreak() const { return m_inlineItem.isLineBreak(); }
@@ -89,15 +85,14 @@
 
     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 adjustLogicalTop(LayoutUnit logicalTop) { m_displayRun.setLogicalTop(logicalTop); }
+        void moveVertically(LayoutUnit offset) { m_displayRun.moveVertically(offset); }
+        void moveHorizontally(LayoutUnit offset) { m_displayRun.moveHorizontally(offset); }
         void setVisuallyIsEmpty() { m_isVisuallyEmpty = true; }
 
         const InlineItem& m_inlineItem;
-        Display::Rect m_logicalRect;
+        Display::Run m_displayRun;
         bool m_isVisuallyEmpty { false };
-        Optional<TextContext> m_textContext;
     };
     using RunList = Vector<std::unique_ptr<Run>>;
     RunList close();

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (250428 => 250429)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2019-09-27 16:27:45 UTC (rev 250428)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2019-09-27 16:49:54 UTC (rev 250429)
@@ -253,13 +253,13 @@
         while (++printedCharacters <= depth * 2)
             stream << " ";
         stream << "  ";
-        if (inlineRun->textContext())
+        if (inlineRun.textContext())
             stream << "inline text box";
         else
             stream << "inline box";
-        stream << " at (" << inlineRun->logicalLeft() << "," << inlineRun->logicalTop() << ") size " << inlineRun->logicalWidth() << "x" << inlineRun->logicalHeight();
-        if (inlineRun->textContext())
-            stream << " run(" << inlineRun->textContext()->start() << ", " << inlineRun->textContext()->end() << ")";
+        stream << " at (" << inlineRun.logicalLeft() << "," << inlineRun.logicalTop() << ") size " << inlineRun.logicalWidth() << "x" << inlineRun.logicalHeight();
+        if (inlineRun.textContext())
+            stream << " run(" << inlineRun.textContext()->start() << ", " << inlineRun.textContext()->end() << ")";
         stream.nextLine();
     }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to