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