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