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

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

Issue 2731893003: Add ShowLayoutOpportunityTree to NGLayoutOpportunityIterator (Closed)
Patch Set: git rebase v2 Created 3 years, 9 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
Index: third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.cc b/third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.cc
index ac2930618bc1d1910990bc6705fbb430d7650ae1..f95d51d176ef7445381c363cce38b3fa787a9741 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_layout_opportunity_iterator.cc
@@ -7,10 +7,41 @@
#include "core/layout/ng/ng_constraint_space.h"
#include "core/layout/ng/ng_exclusion.h"
#include "wtf/NonCopyingSort.h"
+#include "wtf/text/StringBuilder.h"
namespace blink {
namespace {
+void AppendNodeToString(const NGLayoutOpportunityTreeNode* node,
+ StringBuilder* string_builder,
+ unsigned indent = 0) {
+ DCHECK(string_builder);
+ if (!node) {
+ string_builder->append("'null'\n");
+ return;
+ }
+
+ string_builder->append(node->ToString());
+ string_builder->append("\n");
+
+ StringBuilder indent_builder;
+ for (unsigned i = 0; i < indent; i++)
+ indent_builder.append("\t");
+
+ if (!node->exclusion)
+ return;
+
+ string_builder->append(indent_builder.toString());
+ string_builder->append("Left:\t");
+ AppendNodeToString(node->left, string_builder, indent + 2);
+ string_builder->append(indent_builder.toString());
+ string_builder->append("Right:\t");
+ AppendNodeToString(node->right, string_builder, indent + 2);
+ string_builder->append(indent_builder.toString());
+ string_builder->append("Bottom:\t");
+ AppendNodeToString(node->bottom, string_builder, indent + 2);
+}
+
// Collects all opportunities from leaves of Layout Opportunity spatial tree.
void CollectAllOpportunities(const NGLayoutOpportunityTreeNode* node,
NGLayoutOpportunities& opportunities) {
@@ -276,4 +307,13 @@ const NGLayoutOpportunity NGLayoutOpportunityIterator::Next() {
return NGLayoutOpportunity(*opportunity);
}
+#ifndef NDEBUG
+void NGLayoutOpportunityIterator::ShowLayoutOpportunityTree() const {
+ StringBuilder string_builder;
+ string_builder.append("\n.:: LayoutOpportunity Tree ::.\n\nRoot Node: ");
+ AppendNodeToString(opportunity_tree_root_.get(), &string_builder);
+ fprintf(stderr, "%s\n", string_builder.toString().utf8().data());
+}
+#endif
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698