Diff
Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog (235030 => 235031)
--- releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog 2018-08-20 09:30:46 UTC (rev 235030)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/ChangeLog 2018-08-20 09:30:53 UTC (rev 235031)
@@ -1,5 +1,22 @@
2018-08-16 Zalan Bujtas <za...@apple.com>
+ [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 <za...@apple.com>
+
[LFC] Tree builder should construct block and inline containers based on the display type.
https://bugs.webkit.org/show_bug.cgi?id=188632
Modified: releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/Verification.cpp (235030 => 235031)
--- releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/Verification.cpp 2018-08-20 09:30:46 UTC (rev 235030)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/Verification.cpp 2018-08-20 09:30:53 UTC (rev 235031)
@@ -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: releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutBox.cpp (235030 => 235031)
--- releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutBox.cpp 2018-08-20 09:30:46 UTC (rev 235030)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutBox.cpp 2018-08-20 09:30:53 UTC (rev 235031)
@@ -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: releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutBox.h (235030 => 235031)
--- releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutBox.h 2018-08-20 09:30:46 UTC (rev 235030)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutBox.h 2018-08-20 09:30:53 UTC (rev 235031)
@@ -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: releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (235030 => 235031)
--- releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2018-08-20 09:30:46 UTC (rev 235030)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp 2018-08-20 09:30:53 UTC (rev 235031)
@@ -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: releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h (235030 => 235031)
--- releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2018-08-20 09:30:46 UTC (rev 235030)
+++ releases/WebKitGTK/webkit-2.22/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h 2018-08-20 09:30:53 UTC (rev 235031)
@@ -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