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 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 IsolateRef, MegamorphicCacheRef; | 8 show IsolateRef, MegamorphicCacheRef; |
9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
10 import 'package:observatory/src/elements/helpers/tag.dart'; | 10 import 'package:observatory/src/elements/helpers/tag.dart'; |
11 import 'package:observatory/src/elements/helpers/uris.dart'; | 11 import 'package:observatory/src/elements/helpers/uris.dart'; |
12 | 12 |
13 class MegamorphicCacheRefElement extends HtmlElement implements Renderable { | 13 class MegamorphicCacheRefElement extends HtmlElement implements Renderable { |
14 static const tag = | 14 static const tag = |
15 const Tag<MegamorphicCacheRefElement>('megamorphic-cache-ref'); | 15 const Tag<MegamorphicCacheRefElement>('megamorphic-cache-ref'); |
16 | 16 |
17 RenderingScheduler<MegamorphicCacheRefElement> _r; | 17 RenderingScheduler<MegamorphicCacheRefElement> _r; |
18 | 18 |
19 Stream<RenderedEvent<MegamorphicCacheRefElement>> get onRendered => | 19 Stream<RenderedEvent<MegamorphicCacheRefElement>> get onRendered => |
20 _r.onRendered; | 20 _r.onRendered; |
21 | 21 |
22 M.IsolateRef _isolate; | 22 M.IsolateRef _isolate; |
23 M.MegamorphicCacheRef _cache; | 23 M.MegamorphicCacheRef _cache; |
24 | 24 |
25 M.IsolateRef get isolate => _isolate; | 25 M.IsolateRef get isolate => _isolate; |
26 M.MegamorphicCacheRef get cache => _cache; | 26 M.MegamorphicCacheRef get cache => _cache; |
27 | 27 |
28 factory MegamorphicCacheRefElement(M.IsolateRef isolate, | 28 factory MegamorphicCacheRefElement( |
29 M.MegamorphicCacheRef cache, {RenderingQueue queue}) { | 29 M.IsolateRef isolate, M.MegamorphicCacheRef cache, |
| 30 {RenderingQueue queue}) { |
30 assert(isolate != null); | 31 assert(isolate != null); |
31 assert(cache != null); | 32 assert(cache != null); |
32 MegamorphicCacheRefElement e = document.createElement(tag.name); | 33 MegamorphicCacheRefElement e = document.createElement(tag.name); |
33 e._r = new RenderingScheduler(e, queue: queue); | 34 e._r = new RenderingScheduler(e, queue: queue); |
34 e._isolate = isolate; | 35 e._isolate = isolate; |
35 e._cache = cache; | 36 e._cache = cache; |
36 return e; | 37 return e; |
37 } | 38 } |
38 | 39 |
39 MegamorphicCacheRefElement.created() : super.created(); | 40 MegamorphicCacheRefElement.created() : super.created(); |
40 | 41 |
41 @override | 42 @override |
42 void attached() { | 43 void attached() { |
43 super.attached(); | 44 super.attached(); |
44 _r.enable(); | 45 _r.enable(); |
45 } | 46 } |
46 | 47 |
47 @override | 48 @override |
48 void detached() { | 49 void detached() { |
49 super.detached(); | 50 super.detached(); |
50 _r.disable(notify: true); | 51 _r.disable(notify: true); |
51 children = []; | 52 children = []; |
52 } | 53 } |
53 | 54 |
54 void render() { | 55 void render() { |
55 children = [ | 56 children = [ |
56 new AnchorElement(href: Uris.inspect(_isolate, object: _cache)) | 57 new AnchorElement(href: Uris.inspect(_isolate, object: _cache)) |
57 ..children = [ | 58 ..children = [ |
58 new SpanElement()..classes = ['emphasize'] | 59 new SpanElement() |
| 60 ..classes = ['emphasize'] |
59 ..text = 'MegarmorphicCache', | 61 ..text = 'MegarmorphicCache', |
60 new SpanElement()..text = ' (${_cache.selector})' | 62 new SpanElement()..text = ' (${_cache.selector})' |
61 ] | 63 ] |
62 ]; | 64 ]; |
63 } | 65 } |
64 } | 66 } |
OLD | NEW |