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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/ng/ng_layout_opportunity_iterator.h" 5 #include "core/layout/ng/ng_layout_opportunity_iterator.h"
6 6
7 #include "core/layout/ng/ng_constraint_space.h" 7 #include "core/layout/ng/ng_constraint_space.h"
8 #include "core/layout/ng/ng_exclusion.h" 8 #include "core/layout/ng/ng_exclusion.h"
9 #include "wtf/NonCopyingSort.h" 9 #include "wtf/NonCopyingSort.h"
10 #include "wtf/text/StringBuilder.h"
10 11
11 namespace blink { 12 namespace blink {
12 namespace { 13 namespace {
13 14
15 void AppendNodeToString(const NGLayoutOpportunityTreeNode* node,
16 StringBuilder* string_builder,
17 unsigned indent = 0) {
18 DCHECK(string_builder);
19 if (!node) {
20 string_builder->append("'null'\n");
21 return;
22 }
23
24 string_builder->append(node->ToString());
25 string_builder->append("\n");
26
27 StringBuilder indent_builder;
28 for (unsigned i = 0; i < indent; i++)
29 indent_builder.append("\t");
30
31 if (!node->exclusion)
32 return;
33
34 string_builder->append(indent_builder.toString());
35 string_builder->append("Left:\t");
36 AppendNodeToString(node->left, string_builder, indent + 2);
37 string_builder->append(indent_builder.toString());
38 string_builder->append("Right:\t");
39 AppendNodeToString(node->right, string_builder, indent + 2);
40 string_builder->append(indent_builder.toString());
41 string_builder->append("Bottom:\t");
42 AppendNodeToString(node->bottom, string_builder, indent + 2);
43 }
44
14 // Collects all opportunities from leaves of Layout Opportunity spatial tree. 45 // Collects all opportunities from leaves of Layout Opportunity spatial tree.
15 void CollectAllOpportunities(const NGLayoutOpportunityTreeNode* node, 46 void CollectAllOpportunities(const NGLayoutOpportunityTreeNode* node,
16 NGLayoutOpportunities& opportunities) { 47 NGLayoutOpportunities& opportunities) {
17 if (!node) 48 if (!node)
18 return; 49 return;
19 if (node->IsLeafNode()) 50 if (node->IsLeafNode())
20 opportunities.push_back(node->opportunity); 51 opportunities.push_back(node->opportunity);
21 CollectAllOpportunities(node->left, opportunities); 52 CollectAllOpportunities(node->left, opportunities);
22 CollectAllOpportunities(node->bottom, opportunities); 53 CollectAllOpportunities(node->bottom, opportunities);
23 CollectAllOpportunities(node->right, opportunities); 54 CollectAllOpportunities(node->right, opportunities);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 300 }
270 301
271 const NGLayoutOpportunity NGLayoutOpportunityIterator::Next() { 302 const NGLayoutOpportunity NGLayoutOpportunityIterator::Next() {
272 if (opportunity_iter_ == opportunities_.end()) 303 if (opportunity_iter_ == opportunities_.end())
273 return NGLayoutOpportunity(); 304 return NGLayoutOpportunity();
274 auto* opportunity = opportunity_iter_; 305 auto* opportunity = opportunity_iter_;
275 opportunity_iter_++; 306 opportunity_iter_++;
276 return NGLayoutOpportunity(*opportunity); 307 return NGLayoutOpportunity(*opportunity);
277 } 308 }
278 309
310 #ifndef NDEBUG
311 void NGLayoutOpportunityIterator::ShowLayoutOpportunityTree() const {
312 StringBuilder string_builder;
313 string_builder.append("\n.:: LayoutOpportunity Tree ::.\n\nRoot Node: ");
314 AppendNodeToString(opportunity_tree_root_.get(), &string_builder);
315 fprintf(stderr, "%s\n", string_builder.toString().utf8().data());
316 }
317 #endif
318
279 } // namespace blink 319 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698