[LFC][IFC] Add inline runs to showLayoutTree
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2018 16:58:05 +0000 (16:58 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Oct 2018 16:58:05 +0000 (16:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190718

Reviewed by Antti Koivisto.

* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::outputInlineRuns):
(WebCore::Layout::outputLayoutBox):
(WebCore::Layout::outputLayoutTree):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237290 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp

index 3ec12ab..f221111 100644 (file)
@@ -1,5 +1,17 @@
 2018-10-19  Zalan Bujtas  <zalan@apple.com>
 
 2018-10-19  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC][IFC] Add inline runs to showLayoutTree
+        https://bugs.webkit.org/show_bug.cgi?id=190718
+
+        Reviewed by Antti Koivisto.
+
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::outputInlineRuns):
+        (WebCore::Layout::outputLayoutBox):
+        (WebCore::Layout::outputLayoutTree):
+
+2018-10-19  Zalan Bujtas  <zalan@apple.com>
+
         [LFC][IFC] Remove the previous version of inline content handling.
         https://bugs.webkit.org/show_bug.cgi?id=190716
 
         [LFC][IFC] Remove the previous version of inline content handling.
         https://bugs.webkit.org/show_bug.cgi?id=190716
 
index 3a4aedd..8ee3ca3 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
 #include "DisplayBox.h"
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
 #include "DisplayBox.h"
+#include "InlineFormattingState.h"
 #include "LayoutBlockContainer.h"
 #include "LayoutBox.h"
 #include "LayoutChildIterator.h"
 #include "LayoutBlockContainer.h"
 #include "LayoutBox.h"
 #include "LayoutChildIterator.h"
@@ -128,6 +129,24 @@ void TreeBuilder::createSubTree(const RenderElement& rootRenderer, Container& ro
 }
 
 #if ENABLE(TREE_DEBUGGING)
 }
 
 #if ENABLE(TREE_DEBUGGING)
+static void outputInlineRuns(TextStream& stream, const LayoutContext& layoutContext, const Container& inlineFormattingRoot, unsigned depth)
+{
+    auto& inlineFormattingState = layoutContext.establishedFormattingState(inlineFormattingRoot);
+    ASSERT(is<InlineFormattingState>(inlineFormattingState));
+    auto& inlineRuns = downcast<InlineFormattingState>(inlineFormattingState).inlineRuns();
+
+    for (auto& inlineRun : inlineRuns) {
+        unsigned printedCharacters = 0;
+        while (++printedCharacters <= depth * 2)
+            stream << " ";
+        stream << "run";
+        if (inlineRun.textContext())
+            stream << "(" << inlineRun.textContext()->position() << ", " << inlineRun.textContext()->position() + inlineRun.textContext()->length() << ") ";
+        stream << "(" << inlineRun.logicalLeft() << ", " << inlineRun.logicalRight() << ")";
+        stream.nextLine();
+    }
+}
+
 static void outputLayoutBox(TextStream& stream, const Box& layoutBox, const Display::Box* displayBox, unsigned depth)
 {
     unsigned printedCharacters = 0;
 static void outputLayoutBox(TextStream& stream, const Box& layoutBox, const Display::Box* displayBox, unsigned depth)
 {
     unsigned printedCharacters = 0;
@@ -145,8 +164,13 @@ static void outputLayoutBox(TextStream& stream, const Box& layoutBox, const Disp
     } else
         stream << "box";
     // FIXME: Inline text runs don't create display boxes yet.
     } else
         stream << "box";
     // FIXME: Inline text runs don't create display boxes yet.
-    if (displayBox)
-        stream << " at [" << displayBox->left() << " " << displayBox->top() << "] size [" << displayBox->width() << " " << displayBox->height() << "]";
+    if (displayBox) {
+        if (is<InlineBox>(layoutBox) || is<InlineContainer>(layoutBox)) {
+            // FIXME: display box is not completely set yet.
+            stream << " at [" << "." << " " << "." << "] size [" << displayBox->width() << " " << displayBox->height() << "]";
+        } else
+            stream << " at [" << displayBox->left() << " " << displayBox->top() << "] size [" << displayBox->width() << " " << displayBox->height() << "]";
+    }
     stream << " object [" << &layoutBox << "]";
 
     stream.nextLine();
     stream << " object [" << &layoutBox << "]";
 
     stream.nextLine();
@@ -155,7 +179,15 @@ static void outputLayoutBox(TextStream& stream, const Box& layoutBox, const Disp
 static void outputLayoutTree(const LayoutContext* layoutContext, TextStream& stream, const Container& rootContainer, unsigned depth)
 {
     for (auto& child : childrenOfType<Box>(rootContainer)) {
 static void outputLayoutTree(const LayoutContext* layoutContext, TextStream& stream, const Container& rootContainer, unsigned depth)
 {
     for (auto& child : childrenOfType<Box>(rootContainer)) {
-        outputLayoutBox(stream, child, layoutContext ? &layoutContext->displayBoxForLayoutBox(child) : nullptr, depth);
+        Display::Box* displayBox = nullptr;
+        // Not all boxes generate display boxes.
+        if (layoutContext && layoutContext->hasDisplayBox(child))
+            displayBox = &layoutContext->displayBoxForLayoutBox(child);
+
+        outputLayoutBox(stream, child, displayBox, depth);
+        if (layoutContext && child.establishesInlineFormattingContext())
+            outputInlineRuns(stream, *layoutContext, downcast<Container>(child), depth + 1);
+
         if (is<Container>(child))
             outputLayoutTree(layoutContext, stream, downcast<Container>(child), depth + 1);
     }
         if (is<Container>(child))
             outputLayoutTree(layoutContext, stream, downcast<Container>(child), depth + 1);
     }