OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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:html'; | 5 import 'dart:html'; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
8 import 'package:observatory/src/elements/curly_block.dart'; | 8 import 'package:observatory/src/elements/curly_block.dart'; |
9 import 'package:observatory/src/elements/instance_ref.dart'; | 9 import 'package:observatory/src/elements/instance_ref.dart'; |
10 import 'package:observatory/src/elements/helpers/any_ref.dart'; | 10 import 'package:observatory/src/elements/helpers/any_ref.dart'; |
11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
12 import 'package:observatory/src/elements/helpers/tag.dart'; | 12 import 'package:observatory/src/elements/helpers/tag.dart'; |
13 | 13 |
14 class RetainingPathElement extends HtmlElement implements Renderable { | 14 class RetainingPathElement extends HtmlElement implements Renderable { |
15 static const tag = const Tag<RetainingPathElement>('retaining-path', | 15 static const tag = const Tag<RetainingPathElement>('retaining-path', |
16 dependencies: const [ | 16 dependencies: const [CurlyBlockElement.tag, InstanceRefElement.tag]); |
17 CurlyBlockElement.tag, | |
18 InstanceRefElement.tag | |
19 ]); | |
20 | 17 |
21 RenderingScheduler<RetainingPathElement> _r; | 18 RenderingScheduler<RetainingPathElement> _r; |
22 | 19 |
23 Stream<RenderedEvent<RetainingPathElement>> get onRendered => | 20 Stream<RenderedEvent<RetainingPathElement>> get onRendered => _r.onRendered; |
24 _r.onRendered; | |
25 | 21 |
26 M.IsolateRef _isolate; | 22 M.IsolateRef _isolate; |
27 M.ObjectRef _object; | 23 M.ObjectRef _object; |
28 M.RetainingPathRepository _retainingPaths; | 24 M.RetainingPathRepository _retainingPaths; |
29 M.InstanceRepository _instances; | 25 M.InstanceRepository _instances; |
30 M.RetainingPath _path; | 26 M.RetainingPath _path; |
31 bool _expanded = false; | 27 bool _expanded = false; |
32 | 28 |
33 M.IsolateRef get isolate => _isolate; | 29 M.IsolateRef get isolate => _isolate; |
34 M.ObjectRef get object => _object; | 30 M.ObjectRef get object => _object; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 76 } |
81 | 77 |
82 Future _refresh() async { | 78 Future _refresh() async { |
83 _path = null; | 79 _path = null; |
84 _path = await _retainingPaths.get(_isolate, _object.id); | 80 _path = await _retainingPaths.get(_isolate, _object.id); |
85 _r.dirty(); | 81 _r.dirty(); |
86 } | 82 } |
87 | 83 |
88 List<Element> _createContent() { | 84 List<Element> _createContent() { |
89 if (_path == null) { | 85 if (_path == null) { |
90 return [ | 86 return [new SpanElement()..text = 'Loading']; |
91 new SpanElement()..text = 'Loading' | |
92 ]; | |
93 } | 87 } |
94 return _path.elements.map(_createItem).toList(); | 88 return _path.elements.map(_createItem).toList(); |
95 } | 89 } |
96 | 90 |
97 Element _createItem(M.RetainingPathItem item) { | 91 Element _createItem(M.RetainingPathItem item) { |
98 final content = <Element>[]; | 92 final content = <Element>[]; |
99 | 93 |
100 if (item.parentField != null) { | 94 if (item.parentField != null) { |
101 content.add( | 95 content.add(new SpanElement() |
102 new SpanElement() | 96 ..children = [ |
103 ..children = [ | 97 new SpanElement()..text = 'from ', |
104 new SpanElement()..text = 'from ', | 98 anyRef(_isolate, item.parentField, _instances, queue: _r.queue), |
105 anyRef(_isolate, item.parentField, _instances, queue: _r.queue), | 99 new SpanElement()..text = ' of ', |
106 new SpanElement()..text = ' of ', | 100 ]); |
107 ]); | |
108 } else if (item.parentListIndex != null) { | 101 } else if (item.parentListIndex != null) { |
109 content.add( | 102 content.add( |
110 new SpanElement() | 103 new SpanElement()..text = 'from [ ${item.parentListIndex} ] of '); |
111 ..text = 'from [ ${item.parentListIndex} ] of '); | |
112 } else if (item.parentWordOffset != null) { | 104 } else if (item.parentWordOffset != null) { |
113 content.add( | 105 content.add(new SpanElement() |
114 new SpanElement() | 106 ..text = 'from word [ ${item.parentWordOffset} ] of '); |
115 ..text = 'from word [ ${item.parentWordOffset} ] of '); | |
116 } else { | 107 } else { |
117 content.add(new SpanElement()..text = 'from '); | 108 content.add(new SpanElement()..text = 'from '); |
118 } | 109 } |
119 | 110 |
120 content.add( | 111 content.add(anyRef(_isolate, item.source, _instances, queue: _r.queue)); |
121 anyRef(_isolate, item.source, _instances, queue: _r.queue) | |
122 ); | |
123 | 112 |
124 return new DivElement()..classes = ['indent'] | 113 return new DivElement() |
125 ..children = content; | 114 ..classes = ['indent'] |
| 115 ..children = content; |
126 } | 116 } |
127 } | 117 } |
OLD | NEW |