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 library_view_element; | 5 library library_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_ref.dart'; | 10 import 'package:observatory/src/elements/class_ref.dart'; |
(...skipping 10 matching lines...) Expand all Loading... |
21 import 'package:observatory/src/elements/nav/library_menu.dart'; | 21 import 'package:observatory/src/elements/nav/library_menu.dart'; |
22 import 'package:observatory/src/elements/nav/notify.dart'; | 22 import 'package:observatory/src/elements/nav/notify.dart'; |
23 import 'package:observatory/src/elements/nav/refresh.dart'; | 23 import 'package:observatory/src/elements/nav/refresh.dart'; |
24 import 'package:observatory/src/elements/nav/top_menu.dart'; | 24 import 'package:observatory/src/elements/nav/top_menu.dart'; |
25 import 'package:observatory/src/elements/nav/vm_menu.dart'; | 25 import 'package:observatory/src/elements/nav/vm_menu.dart'; |
26 import 'package:observatory/src/elements/object_common.dart'; | 26 import 'package:observatory/src/elements/object_common.dart'; |
27 import 'package:observatory/src/elements/script_ref.dart'; | 27 import 'package:observatory/src/elements/script_ref.dart'; |
28 import 'package:observatory/src/elements/script_inset.dart'; | 28 import 'package:observatory/src/elements/script_inset.dart'; |
29 import 'package:observatory/src/elements/view_footer.dart'; | 29 import 'package:observatory/src/elements/view_footer.dart'; |
30 | 30 |
31 class LibraryViewElement extends HtmlElement implements Renderable { | 31 class LibraryViewElement extends HtmlElement implements Renderable { |
32 static const tag = const Tag<LibraryViewElement>('library-view', | 32 static const tag = |
33 dependencies: const [ | 33 const Tag<LibraryViewElement>('library-view', dependencies: const [ |
34 ClassRefElement.tag, | 34 ClassRefElement.tag, |
35 CurlyBlockElement.tag, | 35 CurlyBlockElement.tag, |
36 EvalBoxElement.tag, | 36 EvalBoxElement.tag, |
37 FieldRefElement.tag, | 37 FieldRefElement.tag, |
38 FunctionRefElement.tag, | 38 FunctionRefElement.tag, |
39 LibraryRefElement.tag, | 39 LibraryRefElement.tag, |
40 NavTopMenuElement.tag, | 40 NavTopMenuElement.tag, |
41 NavVMMenuElement.tag, | 41 NavVMMenuElement.tag, |
42 NavIsolateMenuElement.tag, | 42 NavIsolateMenuElement.tag, |
43 NavLibraryMenuElement.tag, | 43 NavLibraryMenuElement.tag, |
44 NavRefreshElement.tag, | 44 NavRefreshElement.tag, |
45 NavNotifyElement.tag, | 45 NavNotifyElement.tag, |
46 ObjectCommonElement.tag, | 46 ObjectCommonElement.tag, |
47 ScriptRefElement.tag, | 47 ScriptRefElement.tag, |
48 ScriptInsetElement.tag, | 48 ScriptInsetElement.tag, |
49 ViewFooterElement.tag | 49 ViewFooterElement.tag |
50 ]); | 50 ]); |
51 | 51 |
52 RenderingScheduler<LibraryViewElement> _r; | 52 RenderingScheduler<LibraryViewElement> _r; |
53 | 53 |
54 Stream<RenderedEvent<LibraryViewElement>> get onRendered => _r.onRendered; | 54 Stream<RenderedEvent<LibraryViewElement>> get onRendered => _r.onRendered; |
55 | 55 |
56 M.VM _vm; | 56 M.VM _vm; |
57 M.IsolateRef _isolate; | 57 M.IsolateRef _isolate; |
58 M.EventRepository _events; | 58 M.EventRepository _events; |
59 M.NotificationRepository _notifications; | 59 M.NotificationRepository _notifications; |
60 M.Library _library; | 60 M.Library _library; |
61 M.LibraryRepository _libraries; | 61 M.LibraryRepository _libraries; |
62 M.FieldRepository _fields; | 62 M.FieldRepository _fields; |
63 M.RetainedSizeRepository _retainedSizes; | 63 M.RetainedSizeRepository _retainedSizes; |
64 M.ReachableSizeRepository _reachableSizes; | 64 M.ReachableSizeRepository _reachableSizes; |
65 M.InboundReferencesRepository _references; | 65 M.InboundReferencesRepository _references; |
66 M.RetainingPathRepository _retainingPaths; | 66 M.RetainingPathRepository _retainingPaths; |
67 M.ScriptRepository _scripts; | 67 M.ScriptRepository _scripts; |
68 M.InstanceRepository _instances; | 68 M.InstanceRepository _instances; |
69 M.EvalRepository _eval; | 69 M.EvalRepository _eval; |
70 Iterable<M.Field> _variables; | 70 Iterable<M.Field> _variables; |
71 | 71 |
72 | |
73 M.VMRef get vm => _vm; | 72 M.VMRef get vm => _vm; |
74 M.IsolateRef get isolate => _isolate; | 73 M.IsolateRef get isolate => _isolate; |
75 M.NotificationRepository get notifications => _notifications; | 74 M.NotificationRepository get notifications => _notifications; |
76 M.Library get library => _library; | 75 M.Library get library => _library; |
77 | 76 |
78 factory LibraryViewElement(M.VM vm, M.IsolateRef isolate, M.Library library, | 77 factory LibraryViewElement( |
79 M.EventRepository events, | 78 M.VM vm, |
80 M.NotificationRepository notifications, | 79 M.IsolateRef isolate, |
81 M.LibraryRepository libraries, | 80 M.Library library, |
82 M.FieldRepository fields, | 81 M.EventRepository events, |
83 M.RetainedSizeRepository retainedSizes, | 82 M.NotificationRepository notifications, |
84 M.ReachableSizeRepository reachableSizes, | 83 M.LibraryRepository libraries, |
85 M.InboundReferencesRepository references, | 84 M.FieldRepository fields, |
86 M.RetainingPathRepository retainingPaths, | 85 M.RetainedSizeRepository retainedSizes, |
87 M.ScriptRepository scripts, | 86 M.ReachableSizeRepository reachableSizes, |
88 M.InstanceRepository instances, | 87 M.InboundReferencesRepository references, |
89 M.EvalRepository eval, | 88 M.RetainingPathRepository retainingPaths, |
90 {RenderingQueue queue}) { | 89 M.ScriptRepository scripts, |
| 90 M.InstanceRepository instances, |
| 91 M.EvalRepository eval, |
| 92 {RenderingQueue queue}) { |
91 assert(vm != null); | 93 assert(vm != null); |
92 assert(isolate != null); | 94 assert(isolate != null); |
93 assert(events != null); | 95 assert(events != null); |
94 assert(notifications != null); | 96 assert(notifications != null); |
95 assert(library != null); | 97 assert(library != null); |
96 assert(libraries != null); | 98 assert(libraries != null); |
97 assert(fields != null); | 99 assert(fields != null); |
98 assert(retainedSizes != null); | 100 assert(retainedSizes != null); |
99 assert(reachableSizes != null); | 101 assert(reachableSizes != null); |
100 assert(references != null); | 102 assert(references != null); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 140 } |
139 | 141 |
140 void render() { | 142 void render() { |
141 children = [ | 143 children = [ |
142 navBar([ | 144 navBar([ |
143 new NavTopMenuElement(queue: _r.queue), | 145 new NavTopMenuElement(queue: _r.queue), |
144 new NavVMMenuElement(_vm, _events, queue: _r.queue), | 146 new NavVMMenuElement(_vm, _events, queue: _r.queue), |
145 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), | 147 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), |
146 new NavLibraryMenuElement(_isolate, _library, queue: _r.queue), | 148 new NavLibraryMenuElement(_isolate, _library, queue: _r.queue), |
147 new NavRefreshElement(queue: _r.queue) | 149 new NavRefreshElement(queue: _r.queue) |
148 ..onRefresh.listen((e) async { | 150 ..onRefresh.listen((e) async { |
149 e.element.disabled = true; | 151 e.element.disabled = true; |
150 _refresh(); | 152 _refresh(); |
151 }), | 153 }), |
152 new NavNotifyElement(_notifications, queue: _r.queue) | 154 new NavNotifyElement(_notifications, queue: _r.queue) |
153 ]), | 155 ]), |
154 new DivElement()..classes = ['content-centered-big'] | 156 new DivElement() |
| 157 ..classes = ['content-centered-big'] |
155 ..children = [ | 158 ..children = [ |
156 new HeadingElement.h2()..text = 'ICData', | 159 new HeadingElement.h2()..text = 'ICData', |
157 new HRElement(), | 160 new HRElement(), |
158 new ObjectCommonElement(_isolate, _library, _retainedSizes, | 161 new ObjectCommonElement(_isolate, _library, _retainedSizes, |
159 _reachableSizes, _references, _retainingPaths, | 162 _reachableSizes, _references, _retainingPaths, _instances, |
160 _instances, queue: _r.queue), | 163 queue: _r.queue), |
161 new DivElement()..classes = ['memberList'] | 164 new DivElement() |
| 165 ..classes = ['memberList'] |
162 ..children = [ | 166 ..children = [ |
163 new DivElement()..classes = ['memberItem'] | 167 new DivElement() |
| 168 ..classes = ['memberItem'] |
164 ..children = [ | 169 ..children = [ |
165 new DivElement()..classes = ['memberName'] | 170 new DivElement() |
| 171 ..classes = ['memberName'] |
166 ..text = 'uri', | 172 ..text = 'uri', |
167 new DivElement()..classes = ['memberValue'] | 173 new DivElement() |
| 174 ..classes = ['memberValue'] |
168 ..text = _library.uri | 175 ..text = _library.uri |
169 ], | 176 ], |
170 new DivElement()..classes = ['memberItem'] | 177 new DivElement() |
| 178 ..classes = ['memberItem'] |
171 ..children = [ | 179 ..children = [ |
172 new DivElement()..classes = ['memberName'] | 180 new DivElement() |
| 181 ..classes = ['memberName'] |
173 ..text = 'vm name', | 182 ..text = 'vm name', |
174 new DivElement()..classes = ['memberValue'] | 183 new DivElement() |
| 184 ..classes = ['memberValue'] |
175 ..text = _library.vmName | 185 ..text = _library.vmName |
176 ] | 186 ] |
177 ], | 187 ], |
178 new HRElement(), | 188 new HRElement(), |
179 new EvalBoxElement(_isolate, _library, _instances, _eval, | 189 new EvalBoxElement(_isolate, _library, _instances, _eval, |
180 queue: _r.queue), | 190 queue: _r.queue), |
181 new HRElement(), | 191 new HRElement(), |
182 _createDependencies(), | 192 _createDependencies(), |
183 new BRElement(), | 193 new BRElement(), |
184 _createScripts(), | 194 _createScripts(), |
185 new BRElement(), | 195 new BRElement(), |
186 _createClasses(), | 196 _createClasses(), |
187 new BRElement(), | 197 new BRElement(), |
188 _createVariables(), | 198 _createVariables(), |
189 new BRElement(), | 199 new BRElement(), |
190 _createFunctions(), | 200 _createFunctions(), |
191 new HRElement(), | 201 new HRElement(), |
192 new ScriptInsetElement(_isolate, _library.rootScript, _scripts, | 202 new ScriptInsetElement( |
193 _instances, _events, queue: _r.queue), | 203 _isolate, _library.rootScript, _scripts, _instances, _events, |
| 204 queue: _r.queue), |
194 new HRElement(), | 205 new HRElement(), |
195 new ViewFooterElement(queue: _r.queue) | 206 new ViewFooterElement(queue: _r.queue) |
196 ] | 207 ] |
197 ]; | 208 ]; |
198 } | 209 } |
199 | 210 |
200 Future _refresh() async { | 211 Future _refresh() async { |
201 _library = await _libraries.get(_isolate, _library.id); | 212 _library = await _libraries.get(_isolate, _library.id); |
202 _variables = null; | 213 _variables = null; |
203 _r.dirty(); | 214 _r.dirty(); |
204 _variables = await Future.wait(_library.variables.map((field) => | 215 _variables = await Future.wait( |
205 _fields.get(_isolate, field.id))); | 216 _library.variables.map((field) => _fields.get(_isolate, field.id))); |
206 _r.dirty(); | 217 _r.dirty(); |
207 } | 218 } |
208 | 219 |
209 Element _createDependencies() { | 220 Element _createDependencies() { |
210 if (_library.dependencies.isEmpty) { | 221 if (_library.dependencies.isEmpty) { |
211 return new SpanElement(); | 222 return new SpanElement(); |
212 } | 223 } |
213 final dependencies = _library.dependencies.toList(); | 224 final dependencies = _library.dependencies.toList(); |
214 return new DivElement() | 225 return new DivElement() |
215 ..children = [ | 226 ..children = [ |
216 new SpanElement()..text = 'dependencies (${dependencies.length}) ', | 227 new SpanElement()..text = 'dependencies (${dependencies.length}) ', |
217 new CurlyBlockElement(queue: _r.queue) | 228 new CurlyBlockElement(queue: _r.queue) |
218 ..content = dependencies.map((d) => | 229 ..content = dependencies |
219 new DivElement()..classes = ['indent'] | 230 .map((d) => new DivElement() |
220 ..children = [ | 231 ..classes = ['indent'] |
221 new SpanElement()..text = d.isImport ? 'import ' : 'export ', | 232 ..children = [ |
222 new LibraryRefElement(_isolate, d.target, queue: _r.queue), | 233 new SpanElement()..text = d.isImport ? 'import ' : 'export ', |
223 new SpanElement()..text = d.prefix == null ? '' | 234 new LibraryRefElement(_isolate, d.target, queue: _r.queue), |
224 : ' as ${d.prefix}', | 235 new SpanElement() |
225 new SpanElement()..text = d.isDeferred ? ' deferred' : '', | 236 ..text = d.prefix == null ? '' : ' as ${d.prefix}', |
226 ]).toList() | 237 new SpanElement()..text = d.isDeferred ? ' deferred' : '', |
| 238 ]) |
| 239 .toList() |
227 ]; | 240 ]; |
228 } | 241 } |
229 | 242 |
230 Element _createScripts() { | 243 Element _createScripts() { |
231 if (_library.scripts.isEmpty) { | 244 if (_library.scripts.isEmpty) { |
232 return new SpanElement(); | 245 return new SpanElement(); |
233 } | 246 } |
234 final scripts = _library.scripts.toList(); | 247 final scripts = _library.scripts.toList(); |
235 return new DivElement() | 248 return new DivElement() |
236 ..children = [ | 249 ..children = [ |
237 new SpanElement()..text = 'scripts (${scripts.length}) ', | 250 new SpanElement()..text = 'scripts (${scripts.length}) ', |
238 new CurlyBlockElement(queue: _r.queue) | 251 new CurlyBlockElement(queue: _r.queue) |
239 ..content = scripts.map((s) => | 252 ..content = scripts |
240 new DivElement()..classes = ['indent'] | 253 .map((s) => new DivElement() |
241 ..children = [ | 254 ..classes = ['indent'] |
242 new ScriptRefElement(_isolate, s, queue: _r.queue) | 255 ..children = [ |
243 ]).toList() | 256 new ScriptRefElement(_isolate, s, queue: _r.queue) |
| 257 ]) |
| 258 .toList() |
244 ]; | 259 ]; |
245 } | 260 } |
246 | 261 |
247 Element _createClasses() { | 262 Element _createClasses() { |
248 if (_library.classes.isEmpty) { | 263 if (_library.classes.isEmpty) { |
249 return new SpanElement(); | 264 return new SpanElement(); |
250 } | 265 } |
251 final classes = _library.classes.toList(); | 266 final classes = _library.classes.toList(); |
252 return new DivElement() | 267 return new DivElement() |
253 ..children = [ | 268 ..children = [ |
254 new SpanElement()..text = 'classes (${classes.length}) ', | 269 new SpanElement()..text = 'classes (${classes.length}) ', |
255 new CurlyBlockElement(queue: _r.queue) | 270 new CurlyBlockElement(queue: _r.queue) |
256 ..content = classes.map((c) => | 271 ..content = classes |
257 new DivElement()..classes = ['indent'] | 272 .map((c) => new DivElement() |
258 ..children = [ | 273 ..classes = ['indent'] |
259 new ClassRefElement(_isolate, c, queue: _r.queue) | 274 ..children = [ |
260 ]).toList() | 275 new ClassRefElement(_isolate, c, queue: _r.queue) |
| 276 ]) |
| 277 .toList() |
261 ]; | 278 ]; |
262 } | 279 } |
263 | 280 |
264 Element _createVariables() { | 281 Element _createVariables() { |
265 if (_library.variables.isEmpty) { | 282 if (_library.variables.isEmpty) { |
266 return new SpanElement(); | 283 return new SpanElement(); |
267 } | 284 } |
268 final variables = _library.variables.toList(); | 285 final variables = _library.variables.toList(); |
269 return new DivElement() | 286 return new DivElement() |
270 ..children = [ | 287 ..children = [ |
271 new SpanElement()..text = 'variables (${variables.length}) ', | 288 new SpanElement()..text = 'variables (${variables.length}) ', |
272 new CurlyBlockElement(queue: _r.queue) | 289 new CurlyBlockElement(queue: _r.queue) |
273 ..content = [ | 290 ..content = [ |
274 _variables == null | 291 _variables == null |
275 ? (new SpanElement()..text = 'loading...') | 292 ? (new SpanElement()..text = 'loading...') |
276 : (new DivElement()..classes = ['indent', 'memberList'] | 293 : (new DivElement() |
277 ..children = _variables.map((f) => | 294 ..classes = ['indent', 'memberList'] |
278 new DivElement()..classes = ['memberItem'] | 295 ..children = _variables |
279 ..children = [ | 296 .map((f) => new DivElement() |
280 new DivElement()..classes = ['memberName'] | 297 ..classes = ['memberItem'] |
281 ..children = [ | 298 ..children = [ |
282 new FieldRefElement(_isolate, f, _instances, | 299 new DivElement() |
283 queue: _r.queue) | 300 ..classes = ['memberName'] |
284 ], | 301 ..children = [ |
285 new DivElement()..classes = ['memberValue'] | 302 new FieldRefElement(_isolate, f, _instances, |
286 ..children = [ | 303 queue: _r.queue) |
287 new SpanElement()..text = ' = ', | 304 ], |
288 anyRef(_isolate, f.staticValue, _instances, | 305 new DivElement() |
289 queue: _r.queue) | 306 ..classes = ['memberValue'] |
290 ] | 307 ..children = [ |
291 ]).toList()) | 308 new SpanElement()..text = ' = ', |
| 309 anyRef(_isolate, f.staticValue, _instances, |
| 310 queue: _r.queue) |
| 311 ] |
| 312 ]) |
| 313 .toList()) |
292 ] | 314 ] |
293 ]; | 315 ]; |
294 } | 316 } |
295 | 317 |
296 Element _createFunctions() { | 318 Element _createFunctions() { |
297 if (_library.functions.isEmpty) { | 319 if (_library.functions.isEmpty) { |
298 return new SpanElement(); | 320 return new SpanElement(); |
299 } | 321 } |
300 final functions = _library.functions.toList(); | 322 final functions = _library.functions.toList(); |
301 return new DivElement() | 323 return new DivElement() |
302 ..children = [ | 324 ..children = [ |
303 new SpanElement()..text = 'functions (${functions.length}) ', | 325 new SpanElement()..text = 'functions (${functions.length}) ', |
304 new CurlyBlockElement(queue: _r.queue) | 326 new CurlyBlockElement(queue: _r.queue) |
305 ..content = functions.map((f) => | 327 ..content = functions |
306 new DivElement()..classes = ['indent'] | 328 .map((f) => new DivElement() |
307 ..children = [ | 329 ..classes = ['indent'] |
308 new FunctionRefElement(_isolate, f, queue: _r.queue) | 330 ..children = [ |
309 ]).toList() | 331 new FunctionRefElement(_isolate, f, queue: _r.queue) |
| 332 ]) |
| 333 .toList() |
310 ]; | 334 ]; |
311 } | 335 } |
312 } | 336 } |
OLD | NEW |