OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:html'; | 6 import 'dart:html'; |
7 import 'dart:math' as Math; | 7 import 'dart:math' as Math; |
8 import 'package:observatory/models.dart' as M; | 8 import 'package:observatory/models.dart' as M; |
9 import 'package:observatory/src/elements/stack_trace_tree_config.dart' | 9 import 'package:observatory/src/elements/stack_trace_tree_config.dart' |
10 show ProfileTreeMode; | 10 show ProfileTreeMode; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 _tree = new VirtualTreeElement(_createRow, update, _getChildren, | 110 _tree = new VirtualTreeElement(_createRow, update, _getChildren, |
111 items: tree.root.children, queue: _r.queue); | 111 items: tree.root.children, queue: _r.queue); |
112 if (tree.root.children.length == 1) { | 112 if (tree.root.children.length == 1) { |
113 _tree.expand(tree.root.children.first, autoExpandSingleChildNodes: true); | 113 _tree.expand(tree.root.children.first, autoExpandSingleChildNodes: true); |
114 } | 114 } |
115 children = [_tree]; | 115 children = [_tree]; |
116 } | 116 } |
117 | 117 |
118 static Element _createRow(toggle) { | 118 static Element _createRow(toggle) { |
119 return new DivElement() | 119 return new DivElement() |
120 ..classes = const ['tree-item'] | 120 ..classes = ['tree-item'] |
121 ..children = [ | 121 ..children = [ |
122 new SpanElement()..classes = const ['inclusive'] | 122 new SpanElement()..classes = ['inclusive'] |
123 ..title = 'global % on stack', | 123 ..title = 'global % on stack', |
124 new SpanElement()..classes = const ['exclusive'] | 124 new SpanElement()..classes = ['exclusive'] |
125 ..title = 'global % executing', | 125 ..title = 'global % executing', |
126 new SpanElement()..classes = const ['lines'], | 126 new SpanElement()..classes = ['lines'], |
127 new ButtonElement()..classes = const ['expander'] | 127 new ButtonElement()..classes = ['expander'] |
128 ..onClick.listen((_) => toggle(autoToggleSingleChildNodes: true)), | 128 ..onClick.listen((_) => toggle(autoToggleSingleChildNodes: true)), |
129 new SpanElement()..classes = const ['percentage'] | 129 new SpanElement()..classes = ['percentage'] |
130 ..title = 'tree node %', | 130 ..title = 'tree node %', |
131 new SpanElement()..classes = const ['name'] | 131 new SpanElement()..classes = ['name'] |
132 ]; | 132 ]; |
133 } | 133 } |
134 | 134 |
135 static _getChildren(M.CallTreeNode node) => node.children; | 135 static _getChildren(M.CallTreeNode node) => node.children; |
136 | 136 |
137 void _updateFunctionRow(HtmlElement element, M.FunctionCallTreeNode item, | 137 void _updateFunctionRow(HtmlElement element, M.FunctionCallTreeNode item, |
138 int depth) { | 138 int depth) { |
139 element.children[0].text = Utils.formatPercentNormalized( | 139 element.children[0].text = Utils.formatPercentNormalized( |
140 item.profileFunction.normalizedInclusiveTicks); | 140 item.profileFunction.normalizedInclusiveTicks); |
141 element.children[1].text = Utils.formatPercentNormalized( | 141 element.children[1].text = Utils.formatPercentNormalized( |
142 item.profileFunction.normalizedExclusiveTicks); | 142 item.profileFunction.normalizedExclusiveTicks); |
143 _updateLines(element.children[2].children, depth); | 143 _updateLines(element.children[2].children, depth); |
144 if (item.children.isNotEmpty) { | 144 if (item.children.isNotEmpty) { |
145 element.children[3].text = _tree.isExpanded(item) ? '▼' : '►'; | 145 element.children[3].text = _tree.isExpanded(item) ? '▼' : '►'; |
146 } else { | 146 } else { |
147 element.children[3].text = ''; | 147 element.children[3].text = ''; |
148 } | 148 } |
149 element.children[4].text = Utils.formatPercentNormalized( | 149 element.children[4].text = Utils.formatPercentNormalized( |
150 item.percentage); | 150 item.percentage); |
151 element.children[5] = new FunctionRefElement(_isolate, | 151 element.children[5] = new FunctionRefElement(_isolate, |
152 item.profileFunction.function, queue: _r.queue) | 152 item.profileFunction.function, queue: _r.queue) |
153 ..classes = const ['name']; | 153 ..classes = ['name']; |
154 } | 154 } |
155 | 155 |
156 void _updateCodeRow(HtmlElement element, M.CodeCallTreeNode item, int depth) { | 156 void _updateCodeRow(HtmlElement element, M.CodeCallTreeNode item, int depth) { |
157 element.children[0].text = Utils.formatPercentNormalized( | 157 element.children[0].text = Utils.formatPercentNormalized( |
158 item.profileCode.normalizedInclusiveTicks); | 158 item.profileCode.normalizedInclusiveTicks); |
159 element.children[1].text = Utils.formatPercentNormalized( | 159 element.children[1].text = Utils.formatPercentNormalized( |
160 item.profileCode.normalizedExclusiveTicks); | 160 item.profileCode.normalizedExclusiveTicks); |
161 _updateLines(element.children[2].children, depth); | 161 _updateLines(element.children[2].children, depth); |
162 if (item.children.isNotEmpty) { | 162 if (item.children.isNotEmpty) { |
163 element.children[3].text = _tree.isExpanded(item) ? '▼' : '►'; | 163 element.children[3].text = _tree.isExpanded(item) ? '▼' : '►'; |
164 } else { | 164 } else { |
165 element.children[3].text = ''; | 165 element.children[3].text = ''; |
166 } | 166 } |
167 element.children[4].text = Utils.formatPercentNormalized( | 167 element.children[4].text = Utils.formatPercentNormalized( |
168 item.percentage); | 168 item.percentage); |
169 element.children[5] = new CodeRefElement(_isolate, | 169 element.children[5] = new CodeRefElement(_isolate, |
170 item.profileCode.code, queue: _r.queue) | 170 item.profileCode.code, queue: _r.queue) |
171 ..classes = const ['name']; | 171 ..classes = ['name']; |
172 } | 172 } |
173 | 173 |
174 static _updateLines(List<Element> lines, int n) { | 174 static _updateLines(List<Element> lines, int n) { |
175 n = Math.max(0, n); | 175 n = Math.max(0, n); |
176 while (lines.length > n) { | 176 while (lines.length > n) { |
177 lines.removeLast(); | 177 lines.removeLast(); |
178 } | 178 } |
179 while (lines.length < n) { | 179 while (lines.length < n) { |
180 lines.add(new SpanElement()); | 180 lines.add(new SpanElement()); |
181 } | 181 } |
182 } | 182 } |
183 } | 183 } |
OLD | NEW |