Title: [234924] trunk/Source/WebCore
Revision
234924
Author
[email protected]
Date
2018-08-16 07:35:24 -0700 (Thu, 16 Aug 2018)

Log Message

[LFC] Add showLayoutTree() that does not require LayoutContext.
https://bugs.webkit.org/show_bug.cgi?id=188631

Reviewed by Antti Koivisto.

* layout/layouttree/LayoutBox.cpp:
(WebCore::Layout::Box::formattingContextRoot const):
(WebCore::Layout::Box::initialContainingBlock const):
* layout/layouttree/LayoutBox.h:
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::outputLayoutTree):
(WebCore::Layout::showLayoutTree):
(WebCore::Layout::TreeBuilder::showLayoutTree): Deleted.
* layout/layouttree/LayoutTreeBuilder.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (234923 => 234924)


--- trunk/Source/WebCore/ChangeLog	2018-08-16 14:32:46 UTC (rev 234923)
+++ trunk/Source/WebCore/ChangeLog	2018-08-16 14:35:24 UTC (rev 234924)
@@ -1,5 +1,22 @@
 2018-08-16  Zalan Bujtas  <[email protected]>
 
+        [LFC] Add showLayoutTree() that does not require LayoutContext.
+        https://bugs.webkit.org/show_bug.cgi?id=188631
+
+        Reviewed by Antti Koivisto.
+
+        * layout/layouttree/LayoutBox.cpp:
+        (WebCore::Layout::Box::formattingContextRoot const):
+        (WebCore::Layout::Box::initialContainingBlock const):
+        * layout/layouttree/LayoutBox.h:
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::outputLayoutTree):
+        (WebCore::Layout::showLayoutTree):
+        (WebCore::Layout::TreeBuilder::showLayoutTree): Deleted.
+        * layout/layouttree/LayoutTreeBuilder.h:
+
+2018-08-16  Zalan Bujtas  <[email protected]>
+
         [LFC] Tree builder should construct block and inline containers based on the display type.
         https://bugs.webkit.org/show_bug.cgi?id=188632
 

Modified: trunk/Source/WebCore/layout/Verification.cpp (234923 => 234924)


--- trunk/Source/WebCore/layout/Verification.cpp	2018-08-16 14:32:46 UTC (rev 234923)
+++ trunk/Source/WebCore/layout/Verification.cpp	2018-08-16 14:35:24 UTC (rev 234924)
@@ -201,7 +201,7 @@
         return;
 #if ENABLE(TREE_DEBUGGING)
     showRenderTree(&renderView);
-    TreeBuilder::showLayoutTree(*this, *m_root.get());
+    showLayoutTree(*m_root.get(), this);
 #endif
     WTFLogAlways("%s", stream.release().utf8().data());
 }

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (234923 => 234924)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2018-08-16 14:32:46 UTC (rev 234923)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2018-08-16 14:35:24 UTC (rev 234924)
@@ -162,9 +162,21 @@
     // Initial containing block always establishes a formatting context.
     if (isInitialContainingBlock())
         return downcast<Container>(*this);
+
     RELEASE_ASSERT_NOT_REACHED();
 }
 
+const Container& Box::initialContainingBlock() const
+{
+    if (isInitialContainingBlock())
+        return downcast<Container>(*this);
+
+    auto* parent = this->parent();
+    for (; parent->parent(); parent = parent->parent()) { }
+
+    return *parent;
+}
+
 bool Box::isDescendantOf(const Container& container) const
 { 
     for (auto* ancestor = containingBlock(); ancestor; ancestor = ancestor->containingBlock()) {

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (234923 => 234924)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2018-08-16 14:32:46 UTC (rev 234923)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2018-08-16 14:35:24 UTC (rev 234924)
@@ -68,6 +68,8 @@
 
     const Container* containingBlock() const;
     const Container& formattingContextRoot() const;
+    const Container& initialContainingBlock() const;
+
     bool isDescendantOf(const Container&) const;
 
     bool isAnonymous() const { return !m_elementAttributes; }

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (234923 => 234924)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-08-16 14:32:46 UTC (rev 234923)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-08-16 14:35:24 UTC (rev 234924)
@@ -152,23 +152,30 @@
     stream.nextLine();
 }
 
-static void outputLayoutTree(const LayoutContext& layoutContext, TextStream& stream, const Container& rootContainer, unsigned depth)
+static void outputLayoutTree(const LayoutContext* layoutContext, TextStream& stream, const Container& rootContainer, unsigned depth)
 {
     for (auto& child : childrenOfType<Box>(rootContainer)) {
-        outputLayoutBox(stream, child, layoutContext.displayBoxForLayoutBox(child), depth);
+        outputLayoutBox(stream, child, layoutContext ? layoutContext->displayBoxForLayoutBox(child) : nullptr, depth);
         if (is<Container>(child))
             outputLayoutTree(layoutContext, stream, downcast<Container>(child), depth + 1);
     }
 }
 
-void TreeBuilder::showLayoutTree(const LayoutContext& layoutContext, const Container& layoutBox)
+void showLayoutTree(const Box& layoutBox, const LayoutContext* layoutContext)
 {
     TextStream stream(TextStream::LineMode::MultipleLine, TextStream::Formatting::SVGStyleRect);
-    outputLayoutBox(stream, layoutBox, layoutContext.displayBoxForLayoutBox(layoutBox), 0);
-    outputLayoutTree(layoutContext, stream, layoutBox, 1);
+
+    auto& initialContainingBlock = layoutBox.initialContainingBlock();
+    outputLayoutBox(stream, initialContainingBlock, layoutContext ? layoutContext->displayBoxForLayoutBox(initialContainingBlock) : nullptr, 0);
+    outputLayoutTree(layoutContext, stream, initialContainingBlock, 1);
     WTFLogAlways("%s", stream.release().utf8().data());
 }
 
+void showLayoutTree(const Box& layoutBox)
+{
+    showLayoutTree(layoutBox, nullptr);
+}
+
 void printLayoutTreeForLiveDocuments()
 {
     for (const auto* document : Document::allDocuments()) {

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h (234923 => 234924)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h	2018-08-16 14:32:46 UTC (rev 234923)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h	2018-08-16 14:35:24 UTC (rev 234924)
@@ -34,6 +34,7 @@
 
 namespace Layout {
 
+class Box;
 class Container;
 class LayoutContext;
 
@@ -40,7 +41,6 @@
 class TreeBuilder {
 public:
     static std::unique_ptr<Container> createLayoutTree(const RenderView&);
-    static void showLayoutTree(const LayoutContext&, const Container&);
 
 private:
     static void createSubTree(const RenderElement& rootRenderer, Container& rootContainer);
@@ -47,6 +47,8 @@
 };
 
 #if ENABLE(TREE_DEBUGGING)
+void showLayoutTree(const Box&, const LayoutContext*);
+void showLayoutTree(const Box&);
 void printLayoutTreeForLiveDocuments();
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to