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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/observatory/view_model.dart

Issue 168833005: Add callers and callees to profiler output (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of observatory;
6
7 abstract class TableTreeRow {
8 final TableTreeRow parent;
9 final int depth;
10 final List<TableTreeRow> children = new List<TableTreeRow>();
11 final List<String> columns = [];
12
13 TableTreeRow(TableTreeRow parent) :
14 parent = parent,
15 depth = parent != null ? parent.depth+1 : 0;
16
17 bool _expanded = false;
18 bool get expanded => _expanded;
19 set expanded(bool expanded) {
20 _expanded = expanded;
21 if (_expanded) {
22 onShow();
23 } else {
24 onHide();
25 }
26 }
27
28 bool toggle() {
29 expanded = !expanded;
30 return expanded;
31 }
32
33 /// Fired when the tree row is expanded. Add children rows here.
34 void onShow();
35
36 /// Fired when the tree row is collapsed.
37 void onHide();
38 }
39
40 class TableTree {
41 final List<String> columnHeaders = [];
42 final List<TableTreeRow> _children = new List<TableTreeRow>();
turnidge 2014/02/24 20:13:00 Remove _children? I'm not sure that it is needed.
Cutch 2014/02/25 16:44:47 Done.
43 final List<TableTreeRow> rows = toObservable([]);
44
45 /// Create a table tree with column [headers].
46 TableTree(List<String> headers) {
47 columnHeaders.addAll(headers);
48 }
49
50 /// Initialize the table tree with the list of root children.
51 void initialize(List<TableTreeRow> children) {
52 _children.clear();
53 rows.clear();
54 _children.addAll(children);
55 rows.addAll(children);
56 }
57
58 /// Toggle expansion of row at [rowIndex].
59 void toggle(int rowIndex) {
60 assert(rowIndex >= 0);
61 assert(rowIndex < rows.length);
62 var row = rows[rowIndex];
63 if (row.toggle()) {
64 _expand(row);
65 } else {
66 _collapse(row);
67 }
68 }
69
70 int _index(TableTreeRow row) => rows.indexOf(row);
71
72 void _insertRow(int index, TableTreeRow row) {
73 if (index == -1) {
74 rows.add(row);
75 } else {
76 rows.insert(index, row);
77 }
78 }
79
80 void _expand(TableTreeRow row) {
81 int index = _index(row);
82 assert(index != -1);
83 for (var i = 0; i < row.children.length; i++) {
84 _insertRow(index + i + 1, row.children[i]);
85 }
86 }
87
88 void _collapse(TableTreeRow row) {
89 var childCount = row.children.length;
90 if (childCount == 0) {
91 return;
92 }
93 for (var i = 0; i < childCount; i++) {
94 // Close all inner rows.
95 if (row.children[i].expanded) {
96 _collapse(row.children[i]);
97 }
98 }
99 // Collapse this row.
100 row.expanded = false;
101 // Remove all children.
102 int index = _index(row);
103 for (var i = 0; i < childCount; i++) {
104 rows.removeAt(index + 1);
105 }
106 }
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698