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

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

Issue 2310003004: Removed polymer & mirror from Observatory (Closed)
Patch Set: Fixed crash in heap-map page 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) 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 show VM, EventRepository; 8 show VM, EventRepository;
9 import 'package:observatory/src/elements/helpers/nav_menu.dart';
9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
10 import 'package:observatory/src/elements/helpers/tag.dart'; 11 import 'package:observatory/src/elements/helpers/tag.dart';
11 import 'package:observatory/src/elements/helpers/uris.dart'; 12 import 'package:observatory/src/elements/helpers/uris.dart';
12 import 'package:observatory/src/elements/nav/menu.dart';
13 import 'package:observatory/src/elements/nav/menu_item.dart'; 13 import 'package:observatory/src/elements/nav/menu_item.dart';
14 14
15 class NavVMMenuElement extends HtmlElement implements Renderable { 15 class NavVMMenuElement extends HtmlElement implements Renderable {
16 static const tag = const Tag<NavVMMenuElement>('nav-vm-menu', 16 static const tag = const Tag<NavVMMenuElement>('nav-vm-menu',
17 dependencies: const [NavMenuElement.tag, 17 dependencies: const [NavMenuItemElement.tag]);
18 NavMenuItemElement.tag]);
19 18
20 RenderingScheduler _r; 19 RenderingScheduler _r;
21 20
22 Stream<RenderedEvent<NavVMMenuElement>> get onRendered => _r.onRendered; 21 Stream<RenderedEvent<NavVMMenuElement>> get onRendered => _r.onRendered;
23 22
24 bool _last;
25 M.VM _vm; 23 M.VM _vm;
26 M.EventRepository _events; 24 M.EventRepository _events;
27 StreamSubscription _updatesSubscription; 25 StreamSubscription _updatesSubscription;
26 Iterable<Element> _content = const [];
28 27
28 M.VM get vm => _vm;
29 Iterable<Element> get content => _content;
29 30
30 bool get last => _last; 31 set content(Iterable<Element> value) {
31 M.VM get vm => _vm; 32 _content = value.toList();
33 _r.dirty();
34 }
32 35
33 set last(bool value) => _last = _r.checkAndReact(_last, value); 36 factory NavVMMenuElement(M.VM vm, M.EventRepository events,
34 37 {RenderingQueue queue}) {
35 factory NavVMMenuElement(M.VM vm, M.EventRepository events, {bool last: false,
36 RenderingQueue queue}) {
37 assert(vm != null); 38 assert(vm != null);
38 assert(events != null); 39 assert(events != null);
39 assert(last != null);
40 NavVMMenuElement e = document.createElement(tag.name); 40 NavVMMenuElement e = document.createElement(tag.name);
41 e._r = new RenderingScheduler(e, queue: queue); 41 e._r = new RenderingScheduler(e, queue: queue);
42 e._vm = vm; 42 e._vm = vm;
43 e._events = events; 43 e._events = events;
44 e._last = last;
45 return e; 44 return e;
46 } 45 }
47 46
48 NavVMMenuElement.created() : super.created() { createShadowRoot(); } 47 NavVMMenuElement.created() : super.created();
49 48
50 @override 49 @override
51 void attached() { 50 void attached() {
52 super.attached(); 51 super.attached();
53 _updatesSubscription = _events.onVMUpdate 52 _updatesSubscription = _events.onVMUpdate
54 .listen((e) { _vm = e.vm; _r.dirty(); }); 53 .listen((e) { _vm = e.vm; _r.dirty(); });
55 _r.enable(); 54 _r.enable();
56 } 55 }
57 56
58 @override 57 @override
59 void detached() { 58 void detached() {
60 super.detached(); 59 super.detached();
61 shadowRoot.children = []; 60 children = [];
62 _r.disable(notify: true); 61 _r.disable(notify: true);
63 _updatesSubscription.cancel(); 62 _updatesSubscription.cancel();
64 } 63 }
65 64
66 void render() { 65 void render() {
67 shadowRoot.children = [ 66 final content = (
68 new NavMenuElement(vm.displayName, link: Uris.vm(), last: last, 67 _vm.isolates.map((isolate) {
69 queue: _r.queue) 68 return new NavMenuItemElement(isolate.name, queue: _r.queue,
70 ..children = ( 69 link: Uris.inspect(isolate));
71 _vm.isolates.map((isolate) { 70 }).toList()
72 return new NavMenuItemElement(isolate.name, queue: _r.queue, 71 ..addAll(_content)
73 link: Uris.inspect(isolate)); 72 );
74 }).toList() 73 children = [
75 ..add(new ContentElement()) 74 navMenu(vm.displayName, link: Uris.vm(), content: content)
76 )
77 ]; 75 ];
78 } 76 }
79 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698