Title: [269145] trunk/Source/WebCore
Revision
269145
Author
[email protected]
Date
2020-10-29 06:17:05 -0700 (Thu, 29 Oct 2020)

Log Message

[LFC][Integration] Implement outputLineTreeAndMark for IFC
https://bugs.webkit.org/show_bug.cgi?id=218310

Reviewed by Antti Koivisto.

Add a legacy like inline tree output. This helps when comparing legacy and modern line tree geometries.

"<div>before<img>after<div>" generates the following output:

DIV RenderBlock at (x, y) size width x height renderer->(address) node->(address)
  line at (x, y) size (width x height) baseline (y)
    Inline level boxes:
      Root inline box at (x, y) size (width x height) baseline (y) ascent (ascent/layout bounds ascent) descent (descent/layout bounds descent)
      Atomic inline level box at (x, y) size (width x height) baseline (y) ascent (ascent/layout bounds ascent) descent (descent/layout bounds descent)
    Runs:
      text run at (x, y) size (width x height) run(start, end)
      box run at (x, y) size (width x height)
      text run at (x, y) size (width x height) run(start, end)

* layout/inlineformatting/InlineLineBox.h:
(WebCore::Layout::LineBox::InlineLevelBox::LayoutBounds::height const):
(WebCore::Layout::LineBox::InlineLevelBox::layoutBounds const):
(WebCore::Layout::LineBox::InlineLevelBox::isRootInlineBox const):
* layout/integration/LayoutIntegrationCoverage.cpp:
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::outputLineTree const):
* layout/integration/LayoutIntegrationLineLayout.h:
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::showInlineTreeAndRuns):
(WebCore::Layout::outputLayoutTree):
(WebCore::Layout::outputInlineRuns): Deleted.
* layout/layouttree/LayoutTreeBuilder.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::outputLineTreeAndMark const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (269144 => 269145)


--- trunk/Source/WebCore/ChangeLog	2020-10-29 11:37:18 UTC (rev 269144)
+++ trunk/Source/WebCore/ChangeLog	2020-10-29 13:17:05 UTC (rev 269145)
@@ -1,3 +1,41 @@
+2020-10-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][Integration] Implement outputLineTreeAndMark for IFC
+        https://bugs.webkit.org/show_bug.cgi?id=218310
+
+        Reviewed by Antti Koivisto.
+
+        Add a legacy like inline tree output. This helps when comparing legacy and modern line tree geometries.
+
+        "<div>before<img>after<div>" generates the following output:
+
+        DIV RenderBlock at (x, y) size width x height renderer->(address) node->(address)
+          line at (x, y) size (width x height) baseline (y)
+            Inline level boxes:
+              Root inline box at (x, y) size (width x height) baseline (y) ascent (ascent/layout bounds ascent) descent (descent/layout bounds descent)
+              Atomic inline level box at (x, y) size (width x height) baseline (y) ascent (ascent/layout bounds ascent) descent (descent/layout bounds descent)
+            Runs:
+              text run at (x, y) size (width x height) run(start, end)
+              box run at (x, y) size (width x height)
+              text run at (x, y) size (width x height) run(start, end)
+
+
+        * layout/inlineformatting/InlineLineBox.h:
+        (WebCore::Layout::LineBox::InlineLevelBox::LayoutBounds::height const):
+        (WebCore::Layout::LineBox::InlineLevelBox::layoutBounds const):
+        (WebCore::Layout::LineBox::InlineLevelBox::isRootInlineBox const):
+        * layout/integration/LayoutIntegrationCoverage.cpp:
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::outputLineTree const):
+        * layout/integration/LayoutIntegrationLineLayout.h:
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::showInlineTreeAndRuns):
+        (WebCore::Layout::outputLayoutTree):
+        (WebCore::Layout::outputInlineRuns): Deleted.
+        * layout/layouttree/LayoutTreeBuilder.h:
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::outputLineTreeAndMark const):
+
 2020-10-29  Martin Robinson  <[email protected]>
 
         Make scroll-margin independent of scroll snapping and have it apply when scrolling to anchors

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h (269144 => 269145)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2020-10-29 11:37:18 UTC (rev 269144)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2020-10-29 13:17:05 UTC (rev 269145)
@@ -75,7 +75,15 @@
 
         InlineLayoutUnit baseline() const { return m_baseline; }
         Optional<InlineLayoutUnit> descent() const { return m_descent; }
+        // See https://www.w3.org/TR/css-inline-3/#layout-bounds
+        struct LayoutBounds {
+            InlineLayoutUnit height() const { return ascent + descent; }
 
+            InlineLayoutUnit ascent { 0 };
+            InlineLayoutUnit descent { 0 };
+        };
+        LayoutBounds layoutBounds() const { return m_layoutBounds; }
+
         bool isEmpty() const { return m_isEmpty; }
         void setIsNonEmpty() { m_isEmpty = false; }
 
@@ -84,6 +92,7 @@
         const Box& layoutBox() const { return *m_layoutBox; }
 
         bool isInlineBox() const { return m_type == Type::InlineBox || m_type == Type::RootInlineBox; }
+        bool isRootInlineBox() const { return m_type == Type::RootInlineBox; }
         bool isAtomicInlineLevelBox() const { return m_type == Type::AtomicInlineLevelBox; }
         bool isLineBreakBox() const { return m_type == Type::LineBreakBox; }
         bool hasLineBoxRelativeAlignment() const;
@@ -106,16 +115,7 @@
         void setLogicalHeight(InlineLayoutUnit logicalHeight) { m_logicalRect.setHeight(logicalHeight); }
         void setBaseline(InlineLayoutUnit);
         void setDescent(InlineLayoutUnit);
-
-        // See https://www.w3.org/TR/css-inline-3/#layout-bounds
-        struct LayoutBounds {
-            InlineLayoutUnit height() const { return ascent + descent; }
-
-            InlineLayoutUnit ascent { 0 };
-            InlineLayoutUnit descent { 0 };
-        };
         void setLayoutBounds(const LayoutBounds&);
-        LayoutBounds layoutBounds() const { return m_layoutBounds; }
 
     private:
         WeakPtr<const Box> m_layoutBox;

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (269144 => 269145)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-10-29 11:37:18 UTC (rev 269144)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-10-29 13:17:05 UTC (rev 269145)
@@ -587,6 +587,12 @@
     m_inlineFormattingState.inlineItems().clear();
 }
 
+#if ENABLE(TREE_DEBUGGING)
+void LineLayout::outputLineTree(WTF::TextStream& stream, size_t depth) const
+{
+    showInlineTreeAndRuns(stream, m_layoutState, rootLayoutBox(), depth);
+}
+#endif
 
 }
 }

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (269144 => 269145)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2020-10-29 11:37:18 UTC (rev 269144)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2020-10-29 13:17:05 UTC (rev 269145)
@@ -92,6 +92,10 @@
 
     static void releaseCaches(RenderView&);
 
+#if ENABLE(TREE_DEBUGGING)
+    void outputLineTree(WTF::TextStream&, size_t depth) const;
+#endif
+
 private:
     void prepareLayoutState();
     void prepareFloatingState();

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (269144 => 269145)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2020-10-29 11:37:18 UTC (rev 269144)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2020-10-29 13:17:05 UTC (rev 269145)
@@ -378,24 +378,59 @@
 }
 
 #if ENABLE(TREE_DEBUGGING)
-static void outputInlineRuns(TextStream& stream, const LayoutState& layoutState, const ContainerBox& inlineFormattingRoot, unsigned depth)
+void showInlineTreeAndRuns(TextStream& stream, const LayoutState& layoutState, const ContainerBox& inlineFormattingRoot, size_t depth)
 {
     auto& inlineFormattingState = layoutState.establishedInlineFormattingState(inlineFormattingRoot);
     auto& lines = inlineFormattingState.lines();
+    auto& lineBoxes = inlineFormattingState.lineBoxes();
 
     for (size_t lineIndex = 0; lineIndex < lines.size(); ++lineIndex) {
-        size_t printedCharacters = 0;
-        while (++printedCharacters <= depth * 2)
-            stream << " ";
+        auto addSpacing = [&] {
+            size_t printedCharacters = 0;
+            stream << "-------- --";
+            while (++printedCharacters <= depth * 2)
+                stream << " ";
+
+        };
+        addSpacing();
         auto& line = lines[lineIndex];
-        stream << "line at (" << line.logicalLeft() << "," << line.logicalTop() << ") size " << line.logicalWidth() << "x" << line.logicalHeight() << " baseline at (" << line.baseline() << ")";
+        stream << "line at (" << line.logicalLeft() << "," << line.logicalTop() << ") size (" << line.logicalWidth() << "x" << line.logicalHeight() << ") baseline (" << line.baseline() << ")";
         stream.nextLine();
+
+        addSpacing();
+        stream << "  Inline level boxes:";
+        stream.nextLine();
+        auto& lineBox = lineBoxes[lineIndex];
+        for (auto& inlineLevelBox : lineBox.inlineLevelBoxList()) {
+            addSpacing();
+            stream << "    ";
+            if (inlineLevelBox->isRootInlineBox())
+                stream << "Root inline box";
+            else if (inlineLevelBox->isAtomicInlineLevelBox())
+                stream << "Atomic inline level box";
+            else if (inlineLevelBox->isLineBreakBox())
+                stream << "Line break box";
+            else if (inlineLevelBox->isInlineBox())
+                stream << "Generic inline box";
+            else
+                stream << "Generic inline level box";
+            auto logicalRect = lineBox.logicalRectForInlineLevelBox(inlineLevelBox->layoutBox());
+            stream
+                << " at (" << logicalRect.left() << "," << logicalRect.top() << ")"
+                << " size (" << logicalRect.width() << "x" << logicalRect.height() << ")"
+                << " baseline (" << logicalRect.top() + inlineLevelBox->baseline() << ")"
+                << " ascent (" << inlineLevelBox->baseline() << "/" << inlineLevelBox->layoutBounds().ascent << ")"
+                << " descent (" << inlineLevelBox->descent().valueOr(0.0f) << "/" << inlineLevelBox->layoutBounds().descent << ")";
+            stream.nextLine();
+        }
+
+        addSpacing();
+        stream << "  Runs:";
+        stream.nextLine();
         for (auto& run : inlineFormattingState.lineRuns()) {
             if (run.lineIndex() != lineIndex)
                 continue;
-            unsigned printedCharacters = 0;
-            while (++printedCharacters <= depth * 2)
-                stream << " ";
+            addSpacing();
             stream << "    ";
             if (run.text())
                 stream << "text run";
@@ -501,7 +536,7 @@
             else
                 outputLayoutBox(stream, child, nullptr, depth);
             if (child.establishesInlineFormattingContext())
-                outputInlineRuns(stream, *layoutState, downcast<ContainerBox>(child), depth + 1);
+                showInlineTreeAndRuns(stream, *layoutState, downcast<ContainerBox>(child), depth + 1);
         } else
             outputLayoutBox(stream, child, nullptr, depth);
 

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h (269144 => 269145)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h	2020-10-29 11:37:18 UTC (rev 269144)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h	2020-10-29 13:17:05 UTC (rev 269145)
@@ -80,6 +80,7 @@
 String layoutTreeAsText(const Box&, const LayoutState*);
 void showLayoutTree(const Box&, const LayoutState*);
 void showLayoutTree(const Box&);
+void showInlineTreeAndRuns(TextStream&, const LayoutState&, const ContainerBox& inlineFormattingRoot, size_t depth);
 void printLayoutTreeForLiveDocuments();
 #endif
 

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (269144 => 269145)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2020-10-29 11:37:18 UTC (rev 269144)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2020-10-29 13:17:05 UTC (rev 269145)
@@ -3699,6 +3699,12 @@
 #if ENABLE(TREE_DEBUGGING)
 void RenderBlockFlow::outputLineTreeAndMark(WTF::TextStream& stream, const InlineBox* markedBox, int depth) const
 {
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+    if (auto* modernLineLayout = this->modernLineLayout()) {
+        modernLineLayout->outputLineTree(stream, depth);
+        return;
+    }
+#endif
     for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox())
         root->outputLineTreeAndMark(stream, markedBox, depth);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to