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'; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 Future _refresh() async { | 78 Future _refresh() async { |
79 _path = null; | 79 _path = null; |
80 _path = await _retainingPaths.get(_isolate, _object.id); | 80 _path = await _retainingPaths.get(_isolate, _object.id); |
81 _r.dirty(); | 81 _r.dirty(); |
82 } | 82 } |
83 | 83 |
84 List<Element> _createContent() { | 84 List<Element> _createContent() { |
85 if (_path == null) { | 85 if (_path == null) { |
86 return [new SpanElement()..text = 'Loading']; | 86 return [new SpanElement()..text = 'Loading']; |
87 } | 87 } |
88 return _path.elements.map(_createItem).toList(); | 88 |
| 89 var elements = new List(); |
| 90 bool first = true; |
| 91 for (var item in _path.elements) { |
| 92 elements.add(_createItem(item, first)); |
| 93 first = false; |
| 94 } |
| 95 elements.add(_createGCRootItem()); |
| 96 return elements; |
89 } | 97 } |
90 | 98 |
91 Element _createItem(M.RetainingPathItem item) { | 99 Element _createItem(M.RetainingPathItem item, bool first) { |
92 final content = <Element>[]; | 100 final content = <Element>[]; |
93 | 101 |
94 if (item.parentField != null) { | 102 if (first) { |
| 103 // No prefix. |
| 104 } else if (item.parentField != null) { |
95 content.add(new SpanElement() | 105 content.add(new SpanElement() |
96 ..children = [ | 106 ..children = [ |
97 new SpanElement()..text = 'from ', | 107 new SpanElement()..text = 'retained by ', |
98 anyRef(_isolate, item.parentField, _instances, queue: _r.queue), | 108 anyRef(_isolate, item.parentField, _instances, queue: _r.queue), |
99 new SpanElement()..text = ' of ', | 109 new SpanElement()..text = ' of ', |
100 ]); | 110 ]); |
101 } else if (item.parentListIndex != null) { | 111 } else if (item.parentListIndex != null) { |
102 content.add( | 112 content.add(new SpanElement() |
103 new SpanElement()..text = 'from [ ${item.parentListIndex} ] of '); | 113 ..text = 'retained by [ ${item.parentListIndex} ] of '); |
104 } else if (item.parentWordOffset != null) { | 114 } else if (item.parentWordOffset != null) { |
105 content.add(new SpanElement() | 115 content.add(new SpanElement() |
106 ..text = 'from word [ ${item.parentWordOffset} ] of '); | 116 ..text = 'retained by offset ${item.parentWordOffset} of '); |
107 } else { | 117 } else { |
108 content.add(new SpanElement()..text = 'from '); | 118 content.add(new SpanElement()..text = 'retained by '); |
109 } | 119 } |
110 | 120 |
111 content.add(anyRef(_isolate, item.source, _instances, queue: _r.queue)); | 121 content.add(anyRef(_isolate, item.source, _instances, queue: _r.queue)); |
112 | 122 |
113 return new DivElement() | 123 return new DivElement() |
114 ..classes = ['indent'] | 124 ..classes = ['indent'] |
115 ..children = content; | 125 ..children = content; |
116 } | 126 } |
| 127 |
| 128 Element _createGCRootItem() { |
| 129 return new DivElement() |
| 130 ..classes = ['indent'] |
| 131 ..text = 'retained by a GC root'; |
| 132 } |
117 } | 133 } |
OLD | NEW |