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 library class_view_element; | 5 library class_view_element; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'package:observatory/models.dart' as M; | 9 import 'package:observatory/models.dart' as M; |
10 import 'package:observatory/src/elements/class_allocation_profile.dart'; | 10 import 'package:observatory/src/elements/class_allocation_profile.dart'; |
11 import 'package:observatory/src/elements/class_instances.dart'; | 11 import 'package:observatory/src/elements/class_instances.dart'; |
12 import 'package:observatory/src/elements/class_ref.dart'; | 12 import 'package:observatory/src/elements/class_ref.dart'; |
13 import 'package:observatory/src/elements/curly_block.dart'; | 13 import 'package:observatory/src/elements/curly_block.dart'; |
14 import 'package:observatory/src/elements/error_ref.dart'; | 14 import 'package:observatory/src/elements/error_ref.dart'; |
15 import 'package:observatory/src/elements/eval_box.dart'; | 15 import 'package:observatory/src/elements/eval_box.dart'; |
16 import 'package:observatory/src/elements/field_ref.dart'; | 16 import 'package:observatory/src/elements/field_ref.dart'; |
17 import 'package:observatory/src/elements/function_ref.dart'; | 17 import 'package:observatory/src/elements/function_ref.dart'; |
18 import 'package:observatory/src/elements/helpers/any_ref.dart'; | 18 import 'package:observatory/src/elements/helpers/any_ref.dart'; |
| 19 import 'package:observatory/src/elements/helpers/nav_bar.dart'; |
| 20 import 'package:observatory/src/elements/helpers/nav_menu.dart'; |
19 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 21 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
20 import 'package:observatory/src/elements/helpers/tag.dart'; | 22 import 'package:observatory/src/elements/helpers/tag.dart'; |
21 import 'package:observatory/src/elements/instance_ref.dart'; | 23 import 'package:observatory/src/elements/instance_ref.dart'; |
22 import 'package:observatory/src/elements/library_ref.dart'; | 24 import 'package:observatory/src/elements/library_ref.dart'; |
23 import 'package:observatory/src/elements/nav/bar.dart'; | |
24 import 'package:observatory/src/elements/nav/class_menu.dart'; | 25 import 'package:observatory/src/elements/nav/class_menu.dart'; |
25 import 'package:observatory/src/elements/nav/isolate_menu.dart'; | 26 import 'package:observatory/src/elements/nav/isolate_menu.dart'; |
26 import 'package:observatory/src/elements/nav/menu.dart'; | |
27 import 'package:observatory/src/elements/nav/notify.dart'; | 27 import 'package:observatory/src/elements/nav/notify.dart'; |
28 import 'package:observatory/src/elements/nav/refresh.dart'; | 28 import 'package:observatory/src/elements/nav/refresh.dart'; |
29 import 'package:observatory/src/elements/nav/top_menu.dart'; | 29 import 'package:observatory/src/elements/nav/top_menu.dart'; |
30 import 'package:observatory/src/elements/nav/vm_menu.dart'; | 30 import 'package:observatory/src/elements/nav/vm_menu.dart'; |
31 import 'package:observatory/src/elements/object_common.dart'; | 31 import 'package:observatory/src/elements/object_common.dart'; |
32 import 'package:observatory/src/elements/source_inset.dart'; | 32 import 'package:observatory/src/elements/source_inset.dart'; |
33 import 'package:observatory/src/elements/source_link.dart'; | 33 import 'package:observatory/src/elements/source_link.dart'; |
34 import 'package:observatory/src/elements/view_footer.dart'; | 34 import 'package:observatory/src/elements/view_footer.dart'; |
35 | 35 |
36 class ClassViewElement extends HtmlElement implements Renderable { | 36 class ClassViewElement extends HtmlElement implements Renderable { |
37 static const tag = const Tag<ClassViewElement>('class-view', | 37 static const tag = const Tag<ClassViewElement>('class-view', |
38 dependencies: const [ | 38 dependencies: const [ |
39 ClassInstancesElement.tag, | 39 ClassInstancesElement.tag, |
40 ClassRefElement.tag, | 40 ClassRefElement.tag, |
41 CurlyBlockElement.tag, | 41 CurlyBlockElement.tag, |
42 ErrorRefElement.tag, | 42 ErrorRefElement.tag, |
43 EvalBoxElement.tag, | 43 EvalBoxElement.tag, |
44 FieldRefElement.tag, | 44 FieldRefElement.tag, |
45 FunctionRefElement.tag, | 45 FunctionRefElement.tag, |
46 InstanceRefElement.tag, | 46 InstanceRefElement.tag, |
47 LibraryRefElement.tag, | 47 LibraryRefElement.tag, |
48 NavBarElement.tag, | |
49 NavClassMenuElement.tag, | 48 NavClassMenuElement.tag, |
50 NavTopMenuElement.tag, | 49 NavTopMenuElement.tag, |
51 NavVMMenuElement.tag, | 50 NavVMMenuElement.tag, |
52 NavIsolateMenuElement.tag, | 51 NavIsolateMenuElement.tag, |
53 NavMenuElement.tag, | |
54 NavRefreshElement.tag, | 52 NavRefreshElement.tag, |
55 NavNotifyElement.tag, | 53 NavNotifyElement.tag, |
56 ObjectCommonElement.tag, | 54 ObjectCommonElement.tag, |
57 SourceInsetElement.tag, | 55 SourceInsetElement.tag, |
58 SourceLinkElement.tag, | 56 SourceLinkElement.tag, |
59 ViewFooterElement.tag | 57 ViewFooterElement.tag |
60 ]); | 58 ]); |
61 | 59 |
62 RenderingScheduler<ClassViewElement> _r; | 60 RenderingScheduler<ClassViewElement> _r; |
63 | 61 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 _cls, _retainedSizes, _reachableSizes, _stronglyReachableInstances, | 169 _cls, _retainedSizes, _reachableSizes, _stronglyReachableInstances, |
172 _topRetainedInstances, _instances, queue: _r.queue); | 170 _topRetainedInstances, _instances, queue: _r.queue); |
173 var header = ''; | 171 var header = ''; |
174 if (_cls.isAbstract) { | 172 if (_cls.isAbstract) { |
175 header += 'abstract '; | 173 header += 'abstract '; |
176 } | 174 } |
177 if (_cls.isPatch) { | 175 if (_cls.isPatch) { |
178 header += 'patch '; | 176 header += 'patch '; |
179 } | 177 } |
180 children = [ | 178 children = [ |
181 new NavBarElement(queue: _r.queue) | 179 navBar([ |
182 ..children = [ | 180 new NavTopMenuElement(queue: _r.queue), |
183 new NavTopMenuElement(queue: _r.queue), | 181 new NavVMMenuElement(_vm, _events, queue: _r.queue), |
184 new NavVMMenuElement(_vm, _events, queue: _r.queue), | 182 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), |
185 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), | 183 new NavClassMenuElement(_isolate, _cls, queue: _r.queue), |
186 new NavClassMenuElement(_isolate, _cls, queue: _r.queue), | 184 new NavRefreshElement(label: 'Refresh Allocation Profile', |
187 new NavRefreshElement(label: 'Refresh Allocation Profile', | 185 queue: _r.queue) |
188 queue: _r.queue) | 186 ..onRefresh.listen((e) { |
189 ..onRefresh.listen((e) { | 187 e.element.disabled = true; |
190 e.element.disabled = true; | 188 _loadProfile = true; |
191 _loadProfile = true; | 189 _r.dirty(); |
192 _r.dirty(); | 190 }), |
193 }), | 191 new NavRefreshElement(queue: _r.queue) |
194 new NavRefreshElement(queue: _r.queue) | 192 ..onRefresh.listen((e) { |
195 ..onRefresh.listen((e) { | 193 e.element.disabled = true; |
196 e.element.disabled = true; | 194 _common = null; |
197 _common = null; | 195 _classInstances = null; |
198 _classInstances = null; | 196 _fieldsExpanded = null; |
199 _fieldsExpanded = null; | 197 _functionsExpanded = null; |
200 _functionsExpanded = null; | 198 _refresh(); |
201 _refresh(); | 199 }), |
202 }), | 200 new NavNotifyElement(_notifications, queue: _r.queue) |
203 new NavNotifyElement(_notifications, queue: _r.queue) | 201 ]), |
204 ], | |
205 new DivElement()..classes = ['content-centered-big'] | 202 new DivElement()..classes = ['content-centered-big'] |
206 ..children = [ | 203 ..children = [ |
207 new HeadingElement.h2()..text = '$header class ${_cls.name}', | 204 new HeadingElement.h2()..text = '$header class ${_cls.name}', |
208 new HRElement(), | 205 new HRElement(), |
209 _common, | 206 _common, |
210 new BRElement(), | 207 new BRElement(), |
211 new DivElement()..classes = ['memberList'] | 208 new DivElement()..classes = ['memberList'] |
212 ..children = _createMembers(), | 209 ..children = _createMembers(), |
213 new DivElement() | 210 new DivElement() |
214 ..children = _cls.error == null | 211 ..children = _cls.error == null |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 _fieldsExpanded = _fieldsExpanded ?? (fields.length <= 8); | 398 _fieldsExpanded = _fieldsExpanded ?? (fields.length <= 8); |
402 members.add( | 399 members.add( |
403 new DivElement()..classes = ['memberItem'] | 400 new DivElement()..classes = ['memberItem'] |
404 ..children = [ | 401 ..children = [ |
405 new DivElement()..classes = ['memberName'] | 402 new DivElement()..classes = ['memberName'] |
406 ..text = 'fields ${fields.length}', | 403 ..text = 'fields ${fields.length}', |
407 new DivElement()..classes = ['memberValue'] | 404 new DivElement()..classes = ['memberValue'] |
408 ..children =[ | 405 ..children =[ |
409 new CurlyBlockElement(expanded: _fieldsExpanded) | 406 new CurlyBlockElement(expanded: _fieldsExpanded) |
410 ..onToggle.listen((e) => _fieldsExpanded = e.control.expanded) | 407 ..onToggle.listen((e) => _fieldsExpanded = e.control.expanded) |
411 ..children = [ | 408 ..content = [ |
412 new DivElement()..classes = ['memberList'] | 409 new DivElement()..classes = ['memberList'] |
413 ..children = (fields.map((f) => | 410 ..children = (fields.map((f) => |
414 new DivElement()..classes = ['memberItem'] | 411 new DivElement()..classes = ['memberItem'] |
415 ..children = [ | 412 ..children = [ |
416 new DivElement()..classes = ['memberName'] | 413 new DivElement()..classes = ['memberName'] |
417 ..children =[ | 414 ..children =[ |
418 new FieldRefElement(_isolate, f, _instances, | 415 new FieldRefElement(_isolate, f, _instances, |
419 queue: _r.queue) | 416 queue: _r.queue) |
420 ], | 417 ], |
421 new DivElement()..classes = ['memberValue'] | 418 new DivElement()..classes = ['memberValue'] |
(...skipping 17 matching lines...) Expand all Loading... |
439 members.add( | 436 members.add( |
440 new DivElement()..classes = ['memberItem'] | 437 new DivElement()..classes = ['memberItem'] |
441 ..children = [ | 438 ..children = [ |
442 new DivElement()..classes = ['memberName'] | 439 new DivElement()..classes = ['memberName'] |
443 ..text = 'functions (${functions.length})', | 440 ..text = 'functions (${functions.length})', |
444 new DivElement()..classes = ['memberValue'] | 441 new DivElement()..classes = ['memberValue'] |
445 ..children =[ | 442 ..children =[ |
446 new CurlyBlockElement(expanded: _functionsExpanded) | 443 new CurlyBlockElement(expanded: _functionsExpanded) |
447 ..onToggle.listen((e) => | 444 ..onToggle.listen((e) => |
448 _functionsExpanded = e.control.expanded) | 445 _functionsExpanded = e.control.expanded) |
449 ..children = (functions.map((f) => | 446 ..content = (functions.map((f) => |
450 new DivElement()..classes = ['indent'] | 447 new DivElement()..classes = ['indent'] |
451 ..children = [ | 448 ..children = [ |
452 new FunctionRefElement(_isolate, f, queue: _r.queue) | 449 new FunctionRefElement(_isolate, f, queue: _r.queue) |
453 ] | 450 ] |
454 ).toList()) | 451 ).toList()) |
455 ] | 452 ] |
456 ] | 453 ] |
457 ); | 454 ); |
458 } | 455 } |
459 return members; | 456 return members; |
460 } | 457 } |
461 | 458 |
462 Future _refresh() async { | 459 Future _refresh() async { |
463 _cls = await _classes.get(_isolate, _cls.id); | 460 _cls = await _classes.get(_isolate, _cls.id); |
464 await _loadAdditionalData(); | 461 await _loadAdditionalData(); |
465 _r.dirty(); | 462 _r.dirty(); |
466 } | 463 } |
467 | 464 |
468 Future _loadAdditionalData() async { | 465 Future _loadAdditionalData() async { |
469 _classFields = await Future.wait(_cls.fields.map((f) | 466 _classFields = await Future.wait(_cls.fields.map((f) |
470 => _fields.get(_isolate, f.id))); | 467 => _fields.get(_isolate, f.id))); |
471 _r.dirty(); | 468 _r.dirty(); |
472 } | 469 } |
473 } | 470 } |
OLD | NEW |