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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 RenderingScheduler<CpuProfileVirtualTreeElement> _r; | 25 RenderingScheduler<CpuProfileVirtualTreeElement> _r; |
26 | 26 |
27 Stream<RenderedEvent<CpuProfileVirtualTreeElement>> get onRendered => | 27 Stream<RenderedEvent<CpuProfileVirtualTreeElement>> get onRendered => |
28 _r.onRendered; | 28 _r.onRendered; |
29 | 29 |
30 M.ProfileTreeDirection _direction; | 30 M.ProfileTreeDirection _direction; |
31 ProfileTreeMode _mode; | 31 ProfileTreeMode _mode; |
32 M.IsolateRef _isolate; | 32 M.IsolateRef _isolate; |
33 M.SampleProfile _profile; | 33 M.SampleProfile _profile; |
34 M.CallTreeNodeFilter _filter; | 34 Iterable<M.CallTreeNodeFilter> _filters; |
35 | 35 |
36 M.ProfileTreeDirection get direction => _direction; | 36 M.ProfileTreeDirection get direction => _direction; |
37 ProfileTreeMode get mode => _mode; | 37 ProfileTreeMode get mode => _mode; |
38 M.IsolateRef get isolate => _isolate; | 38 M.IsolateRef get isolate => _isolate; |
39 M.SampleProfile get profile => _profile; | 39 M.SampleProfile get profile => _profile; |
40 M.CallTreeNodeFilter get filter => _filter; | 40 Iterable<M.CallTreeNodeFilter> get filters => _filters; |
41 | 41 |
42 set direction(M.ProfileTreeDirection value) => | 42 set direction(M.ProfileTreeDirection value) => |
43 _direction = _r.checkAndReact(_direction, value); | 43 _direction = _r.checkAndReact(_direction, value); |
44 set mode(ProfileTreeMode value) => _mode = _r.checkAndReact(_mode, value); | 44 set mode(ProfileTreeMode value) => _mode = _r.checkAndReact(_mode, value); |
45 set filter(M.CallTreeNodeFilter value) => | 45 set filters(Iterable<M.CallTreeNodeFilter> value) { |
46 _filter = _r.checkAndReact(_filter, value); | 46 _filters = new List.unmodifiable(value); |
| 47 _r.dirty(); |
| 48 } |
47 | 49 |
48 factory CpuProfileVirtualTreeElement(M.IsolateRef isolate, | 50 factory CpuProfileVirtualTreeElement(M.IsolateRef isolate, |
49 M.SampleProfile profile, {ProfileTreeMode mode: ProfileTreeMode.function, | 51 M.SampleProfile profile, {ProfileTreeMode mode: ProfileTreeMode.function, |
50 M.ProfileTreeDirection direction: M.ProfileTreeDirection.exclusive, | 52 M.ProfileTreeDirection direction: M.ProfileTreeDirection.exclusive, |
51 RenderingQueue queue}) { | 53 RenderingQueue queue}) { |
52 assert(isolate != null); | 54 assert(isolate != null); |
53 assert(profile != null); | 55 assert(profile != null); |
54 assert(mode != null); | 56 assert(mode != null); |
55 assert(direction != null); | 57 assert(direction != null); |
56 CpuProfileVirtualTreeElement e = document.createElement(tag.name); | 58 CpuProfileVirtualTreeElement e = document.createElement(tag.name); |
(...skipping 30 matching lines...) Expand all Loading... |
87 tree = _profile.loadCodeTree(_direction); | 89 tree = _profile.loadCodeTree(_direction); |
88 update = _updateCodeRow; | 90 update = _updateCodeRow; |
89 break; | 91 break; |
90 case ProfileTreeMode.function: | 92 case ProfileTreeMode.function: |
91 tree = _profile.loadFunctionTree(_direction); | 93 tree = _profile.loadFunctionTree(_direction); |
92 update = _updateFunctionRow; | 94 update = _updateFunctionRow; |
93 break; | 95 break; |
94 default: | 96 default: |
95 throw new Exception('Unknown ProfileTreeMode: $mode'); | 97 throw new Exception('Unknown ProfileTreeMode: $mode'); |
96 } | 98 } |
| 99 if (filters != null) { |
| 100 tree = filters.fold(tree, (tree, filter) { |
| 101 return tree?.filtered(filter); |
| 102 }); |
| 103 } |
97 if (tree == null) { | 104 if (tree == null) { |
98 children = [ | 105 children = [ |
99 new HeadingElement.h1()..text = 'No Results' | 106 new HeadingElement.h1()..text = 'No Results' |
100 ]; | 107 ]; |
101 return; | 108 return; |
102 } | 109 } |
103 if (filter != null) { | |
104 tree = tree.filtered(filter); | |
105 } | |
106 _tree = new VirtualTreeElement(_createRow, update, _getChildren, | 110 _tree = new VirtualTreeElement(_createRow, update, _getChildren, |
107 items: tree.root.children, queue: _r.queue); | 111 items: tree.root.children, queue: _r.queue); |
108 if (tree.root.children.length == 1) { | 112 if (tree.root.children.length == 1) { |
109 _tree.expand(tree.root.children.first, autoExpandSingleChildNodes: true); | 113 _tree.expand(tree.root.children.first, autoExpandSingleChildNodes: true); |
110 } | 114 } |
111 children = [_tree]; | 115 children = [_tree]; |
112 } | 116 } |
113 | 117 |
114 static Element _createRow(toggle) { | 118 static Element _createRow(toggle) { |
115 return new DivElement() | 119 return new DivElement() |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 static _updateLines(List<Element> lines, int n) { | 174 static _updateLines(List<Element> lines, int n) { |
171 n = Math.max(0, n); | 175 n = Math.max(0, n); |
172 while (lines.length > n) { | 176 while (lines.length > n) { |
173 lines.removeLast(); | 177 lines.removeLast(); |
174 } | 178 } |
175 while (lines.length < n) { | 179 while (lines.length < n) { |
176 lines.add(new SpanElement()); | 180 lines.add(new SpanElement()); |
177 } | 181 } |
178 } | 182 } |
179 } | 183 } |
OLD | NEW |