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

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

Powered by Google App Engine
This is Rietveld 408576698