Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(782)

Side by Side Diff: runtime/observatory/lib/src/elements/library_view.dart

Issue 2289953003: Converted Observatory library-view element (Closed)
Patch Set: Fixed inspect page pattern matching Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 'observatory_element.dart'; 8 import 'dart:html';
9 import 'package:observatory/service.dart'; 9 import 'package:observatory/models.dart' as M;
10 import 'package:polymer/polymer.dart'; 10 import 'package:observatory/src/elements/class_ref.dart';
11 11 import 'package:observatory/src/elements/curly_block.dart';
12 12 import 'package:observatory/src/elements/eval_box.dart';
13 @CustomTag('library-view') 13 import 'package:observatory/src/elements/field_ref.dart';
14 class LibraryViewElement extends ObservatoryElement { 14 import 'package:observatory/src/elements/function_ref.dart';
15 @published Library library; 15 import 'package:observatory/src/elements/helpers/any_ref.dart';
16 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
17 import 'package:observatory/src/elements/helpers/tag.dart';
18 import 'package:observatory/src/elements/library_ref.dart';
19 import 'package:observatory/src/elements/nav/bar.dart';
20 import 'package:observatory/src/elements/nav/isolate_menu.dart';
21 import 'package:observatory/src/elements/nav/menu.dart';
22 import 'package:observatory/src/elements/nav/notify.dart';
23 import 'package:observatory/src/elements/nav/refresh.dart';
24 import 'package:observatory/src/elements/nav/top_menu.dart';
25 import 'package:observatory/src/elements/nav/vm_menu.dart';
26 import 'package:observatory/src/elements/object_common.dart';
27 import 'package:observatory/src/elements/script_ref.dart';
28 import 'package:observatory/src/elements/script_inset.dart';
29 import 'package:observatory/src/elements/view_footer.dart';
30
31 class LibraryViewElement extends HtmlElement implements Renderable {
32 static const tag = const Tag<LibraryViewElement>('library-view',
33 dependencies: const [
34 ClassRefElement.tag,
35 CurlyBlockElement.tag,
36 EvalBoxElement.tag,
37 FieldRefElement.tag,
38 FunctionRefElement.tag,
39 LibraryRefElement.tag,
40 NavBarElement.tag,
41 NavTopMenuElement.tag,
42 NavVMMenuElement.tag,
43 NavIsolateMenuElement.tag,
44 NavMenuElement.tag,
45 NavRefreshElement.tag,
46 NavNotifyElement.tag,
47 ObjectCommonElement.tag,
48 ScriptRefElement.tag,
49 ScriptInsetElement.tag,
50 ViewFooterElement.tag
51 ]);
52
53 RenderingScheduler<LibraryViewElement> _r;
54
55 Stream<RenderedEvent<LibraryViewElement>> get onRendered => _r.onRendered;
56
57 M.VM _vm;
58 M.IsolateRef _isolate;
59 M.EventRepository _events;
60 M.NotificationRepository _notifications;
61 M.Library _library;
62 M.LibraryRepository _libraries;
63 M.FieldRepository _fields;
64 M.RetainedSizeRepository _retainedSizes;
65 M.ReachableSizeRepository _reachableSizes;
66 M.InboundReferencesRepository _references;
67 M.RetainingPathRepository _retainingPaths;
68 M.ScriptRepository _scripts;
69 M.InstanceRepository _instances;
70 M.EvalRepository _eval;
71 Iterable<M.Field> _variables;
72
73
74 M.VMRef get vm => _vm;
75 M.IsolateRef get isolate => _isolate;
76 M.NotificationRepository get notifications => _notifications;
77 M.Library get library => _library;
78
79 factory LibraryViewElement(M.VM vm, M.IsolateRef isolate, M.Library library,
80 M.EventRepository events,
81 M.NotificationRepository notifications,
82 M.LibraryRepository libraries,
83 M.FieldRepository fields,
84 M.RetainedSizeRepository retainedSizes,
85 M.ReachableSizeRepository reachableSizes,
86 M.InboundReferencesRepository references,
87 M.RetainingPathRepository retainingPaths,
88 M.ScriptRepository scripts,
89 M.InstanceRepository instances,
90 M.EvalRepository eval,
91 {RenderingQueue queue}) {
92 assert(vm != null);
93 assert(isolate != null);
94 assert(events != null);
95 assert(notifications != null);
96 assert(library != null);
97 assert(libraries != null);
98 assert(fields != null);
99 assert(retainedSizes != null);
100 assert(reachableSizes != null);
101 assert(references != null);
102 assert(retainingPaths != null);
103 assert(scripts != null);
104 assert(instances != null);
105 assert(eval != null);
106 LibraryViewElement e = document.createElement(tag.name);
107 e._r = new RenderingScheduler(e, queue: queue);
108 e._vm = vm;
109 e._isolate = isolate;
110 e._events = events;
111 e._notifications = notifications;
112 e._library = library;
113 e._libraries = libraries;
114 e._fields = fields;
115 e._retainedSizes = retainedSizes;
116 e._reachableSizes = reachableSizes;
117 e._references = references;
118 e._retainingPaths = retainingPaths;
119 e._scripts = scripts;
120 e._instances = instances;
121 e._eval = eval;
122 return e;
123 }
16 124
17 LibraryViewElement.created() : super.created(); 125 LibraryViewElement.created() : super.created();
18 126
19 Future<ServiceObject> evaluate(String expression) { 127 @override
20 return library.evaluate(expression); 128 attached() {
21 } 129 super.attached();
22 130 _r.enable();
23 void attached() { 131 _refresh();
24 library.variables.forEach((variable) => variable.reload()); 132 }
25 } 133
26 134 @override
27 Future refresh() { 135 detached() {
28 var loads = []; 136 super.detached();
29 loads.add(library.reload()); 137 _r.disable(notify: true);
30 library.variables.forEach((variable) => loads.add(variable.reload())); 138 children = [];
31 return Future.wait(loads); 139 }
140
141 void render() {
142 children = [
143 new NavBarElement(queue: _r.queue)
144 ..children = [
145 new NavTopMenuElement(queue: _r.queue),
146 new NavVMMenuElement(_vm, _events, queue: _r.queue),
147 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue),
148 new NavMenuElement('instance', last: true, queue: _r.queue),
149 new NavRefreshElement(queue: _r.queue)
150 ..onRefresh.listen((e) async {
151 e.element.disabled = true;
152 _refresh();
153 }),
154 new NavNotifyElement(_notifications, queue: _r.queue)
155 ],
156
157 new DivElement()..classes = const ['content-centered-big']
158 ..children = [
159 new HeadingElement.h2()..text = 'ICData',
160 new HRElement(),
161 new ObjectCommonElement(_isolate, _library, _retainedSizes,
162 _reachableSizes, _references, _retainingPaths,
163 _instances, queue: _r.queue),
164 new DivElement()..classes = ['memberList']
165 ..children = [
166 new DivElement()..classes = ['memberItem']
167 ..children = [
168 new DivElement()..classes = ['memberName']
169 ..text = 'uri',
170 new DivElement()..classes = ['memberValue']
171 ..text = _library.uri
172 ],
173 new DivElement()..classes = ['memberItem']
174 ..children = [
175 new DivElement()..classes = ['memberName']
176 ..text = 'vm name',
177 new DivElement()..classes = ['memberValue']
178 ..text = _library.vmName
179 ]
180 ],
181 new HRElement(),
182 new EvalBoxElement(_isolate, _library, _instances, _eval,
183 queue: _r.queue),
184 new HRElement(),
185 _createDependencies(),
186 new BRElement(),
187 _createScripts(),
188 new BRElement(),
189 _createClasses(),
190 new BRElement(),
191 _createVariables(),
192 new BRElement(),
193 _createFunctions(),
194 new HRElement(),
195 new ScriptInsetElement(_isolate, _library.rootScript, _scripts,
196 _instances, _events, queue: _r.queue),
197 new HRElement(),
198 new ViewFooterElement(queue: _r.queue)
199 ]
200 ];
201 }
202
203 Future _refresh() async {
204 _library = await _libraries.get(_isolate, _library.id);
205 _variables = null;
206 _r.dirty();
207 _variables = await Future.wait(_library.variables.map((field) =>
208 _fields.get(_isolate, field.id)));
209 _r.dirty();
210 }
211
212 Element _createDependencies() {
213 if (_library.dependencies.isEmpty) {
214 return new SpanElement();
215 }
216 final dependencies = _library.dependencies.toList();
217 return new DivElement()
218 ..children = [
219 new SpanElement()..text = 'dependencies (${dependencies.length}) ',
220 new CurlyBlockElement(queue: _r.queue)
221 ..children = dependencies.map((d) =>
222 new DivElement()..classes = const ['indent']
223 ..children = [
224 new SpanElement()..text = d.isImport ? 'import ' : 'export ',
225 new LibraryRefElement(_isolate, d.target, queue: _r.queue),
226 new SpanElement()..text = d.prefix == null ? ''
227 : ' as ${d.prefix}',
228 new SpanElement()..text = d.isDeferred ? ' deferred' : '',
229 ]).toList()
230 ];
231 }
232
233 Element _createScripts() {
234 if (_library.scripts.isEmpty) {
235 return new SpanElement();
236 }
237 final scripts = _library.scripts.toList();
238 return new DivElement()
239 ..children = [
240 new SpanElement()..text = 'scripts (${scripts.length}) ',
241 new CurlyBlockElement(queue: _r.queue)
242 ..children = scripts.map((s) =>
243 new DivElement()..classes = const ['indent']
244 ..children = [
245 new ScriptRefElement(_isolate, s, queue: _r.queue)
246 ]).toList()
247 ];
248 }
249
250 Element _createClasses() {
251 if (_library.classes.isEmpty) {
252 return new SpanElement();
253 }
254 final classes = _library.classes.toList();
255 return new DivElement()
256 ..children = [
257 new SpanElement()..text = 'classes (${classes.length}) ',
258 new CurlyBlockElement(queue: _r.queue)
259 ..children = classes.map((c) =>
260 new DivElement()..classes = const ['indent']
261 ..children = [
262 new ClassRefElement(_isolate, c, queue: _r.queue)
263 ]).toList()
264 ];
265 }
266
267 Element _createVariables() {
268 if (_library.variables.isEmpty) {
269 return new SpanElement();
270 }
271 final variables = _library.variables.toList();
272 return new DivElement()
273 ..children = [
274 new SpanElement()..text = 'variables (${variables.length}) ',
275 new CurlyBlockElement(queue: _r.queue)
276 ..children = [
277 _variables == null
278 ? (new SpanElement()..text = 'loading...')
279 : (new DivElement()..classes = const ['indent', 'memberList']
280 ..children = _variables.map((f) =>
281 new DivElement()..classes = const ['memberItem']
282 ..children = [
283 new DivElement()..classes = const ['memberName']
284 ..children = [
285 new FieldRefElement(_isolate, f, _instances,
286 queue: _r.queue)
287 ],
288 new DivElement()..classes = const ['memberValue']
289 ..children = [
290 new SpanElement()..text = ' = ',
291 anyRef(_isolate, f.staticValue, _instances,
292 queue: _r.queue)
293 ]
294 ]).toList())
295 ]
296 ];
297 }
298
299 Element _createFunctions() {
300 if (_library.functions.isEmpty) {
301 return new SpanElement();
302 }
303 final functions = _library.functions.toList();
304 return new DivElement()
305 ..children = [
306 new SpanElement()..text = 'functions (${functions.length}) ',
307 new CurlyBlockElement(queue: _r.queue)
308 ..children = functions.map((f) =>
309 new DivElement()..classes = const ['indent']
310 ..children = [
311 new FunctionRefElement(_isolate, f, queue: _r.queue)
312 ]).toList()
313 ];
32 } 314 }
33 } 315 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/field_view.dart ('k') | runtime/observatory/lib/src/elements/library_view.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698