Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.cc

Issue 2854993002: [LayoutNG] Add NGLayoutInputNode::ShowNodeTree (Closed)
Patch Set: Use forward declaration for LayoutObject Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.cc b/third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fb4269a185d92a7bb4fc71e7232d989fd3e3293a
--- /dev/null
+++ b/third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.cc
@@ -0,0 +1,66 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/layout/ng/ng_layout_input_node.h"
+#include "core/layout/ng/inline/ng_inline_node.h"
+#include "core/layout/ng/ng_block_node.h"
+#include "platform/wtf/text/StringBuilder.h"
+
+namespace blink {
+namespace {
+
+#ifndef NDEBUG
+void AppendNodeToString(const NGLayoutInputNode* node,
+ StringBuilder* string_builder,
+ unsigned indent = 2) {
+ if (!node)
+ return;
+ DCHECK(string_builder);
+
+ string_builder->Append(node->ToString());
+ string_builder->Append("\n");
+
+ StringBuilder indent_builder;
+ for (unsigned i = 0; i < indent; i++)
+ indent_builder.Append(" ");
+
+ if (node->IsBlock()) {
+ auto* first_child =
+ ToNGBlockNode(const_cast<NGLayoutInputNode*>(node))->FirstChild();
+ for (NGLayoutInputNode* node_runner = first_child; node_runner;
+ node_runner = node_runner->NextSibling()) {
+ string_builder->Append(indent_builder.ToString());
+ AppendNodeToString(node_runner, string_builder, indent + 2);
+ }
+ }
+
+ if (node->IsInline()) {
+ for (const NGInlineItem& inline_item : ToNGInlineNode(node)->Items()) {
+ string_builder->Append(indent_builder.ToString());
+ string_builder->Append(inline_item.ToString());
+ string_builder->Append("\n");
+ }
+ auto* next_sibling =
+ ToNGInlineNode(const_cast<NGLayoutInputNode*>(node))->NextSibling();
+ for (NGLayoutInputNode* node_runner = next_sibling; node_runner;
+ node_runner = node_runner->NextSibling()) {
+ string_builder->Append(indent_builder.ToString());
+ AppendNodeToString(node_runner, string_builder, indent + 2);
+ }
+ }
+}
+#endif
+
+} // namespace
+
+#ifndef NDEBUG
+void NGLayoutInputNode::ShowNodeTree() const {
+ StringBuilder string_builder;
+ string_builder.Append("\n.:: LayoutNG Node Tree ::.\n\n");
+ AppendNodeToString(this, &string_builder);
+ fprintf(stderr, "%s\n", string_builder.ToString().Utf8().data());
+}
+#endif
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/ng/ng_layout_input_node.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698