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 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
9 import 'package:observatory/src/elements/helpers/tag.dart'; | 9 import 'package:observatory/src/elements/helpers/tag.dart'; |
10 import 'package:observatory/src/elements/helpers/uris.dart'; | 10 import 'package:observatory/src/elements/helpers/uris.dart'; |
11 import 'package:observatory/src/elements/instance_ref.dart'; | 11 import 'package:observatory/src/elements/instance_ref.dart'; |
12 | 12 |
13 class FieldRefElement extends HtmlElement implements Renderable { | 13 class FieldRefElement extends HtmlElement implements Renderable { |
14 static const tag = const Tag<FieldRefElement>('field-ref', | 14 static const tag = const Tag<FieldRefElement>('field-ref', |
15 dependencies: const [ | 15 dependencies: const [InstanceRefElement.tag]); |
16 InstanceRefElement.tag | |
17 ]); | |
18 | 16 |
19 RenderingScheduler<FieldRefElement> _r; | 17 RenderingScheduler<FieldRefElement> _r; |
20 | 18 |
21 Stream<RenderedEvent<FieldRefElement>> get onRendered => _r.onRendered; | 19 Stream<RenderedEvent<FieldRefElement>> get onRendered => _r.onRendered; |
22 | 20 |
23 M.IsolateRef _isolate; | 21 M.IsolateRef _isolate; |
24 M.FieldRef _field; | 22 M.FieldRef _field; |
25 M.InstanceRepository _instances; | 23 M.InstanceRepository _instances; |
26 | 24 |
27 M.IsolateRef get isolate => _isolate; | 25 M.IsolateRef get isolate => _isolate; |
28 M.FieldRef get field => _field; | 26 M.FieldRef get field => _field; |
29 | 27 |
30 factory FieldRefElement(M.IsolateRef isolate, M.FieldRef field, | 28 factory FieldRefElement( |
31 M.InstanceRepository instances, {RenderingQueue queue}) { | 29 M.IsolateRef isolate, M.FieldRef field, M.InstanceRepository instances, |
| 30 {RenderingQueue queue}) { |
32 assert(isolate != null); | 31 assert(isolate != null); |
33 assert(field != null); | 32 assert(field != null); |
34 assert(instances != null); | 33 assert(instances != null); |
35 FieldRefElement e = document.createElement(tag.name); | 34 FieldRefElement e = document.createElement(tag.name); |
36 e._r = new RenderingScheduler(e, queue: queue); | 35 e._r = new RenderingScheduler(e, queue: queue); |
37 e._isolate = isolate; | 36 e._isolate = isolate; |
38 e._field = field; | 37 e._field = field; |
39 e._instances = instances; | 38 e._instances = instances; |
40 return e; | 39 return e; |
41 } | 40 } |
(...skipping 19 matching lines...) Expand all Loading... |
61 if (_field.dartOwner is M.ClassRef) { | 60 if (_field.dartOwner is M.ClassRef) { |
62 header += 'static '; | 61 header += 'static '; |
63 } else { | 62 } else { |
64 header += 'top-level '; | 63 header += 'top-level '; |
65 } | 64 } |
66 } | 65 } |
67 if (_field.isFinal) { | 66 if (_field.isFinal) { |
68 header += 'final '; | 67 header += 'final '; |
69 } else if (_field.isConst) { | 68 } else if (_field.isConst) { |
70 header += 'const '; | 69 header += 'const '; |
71 } else if (_field.declaredType.name == 'dynamic'){ | 70 } else if (_field.declaredType.name == 'dynamic') { |
72 header += 'var '; | 71 header += 'var '; |
73 } | 72 } |
74 if (_field.declaredType.name == 'dynamic') { | 73 if (_field.declaredType.name == 'dynamic') { |
75 children = [ | 74 children = [ |
76 new SpanElement()..text = header, | 75 new SpanElement()..text = header, |
77 new AnchorElement(href: Uris.inspect(_isolate, object: _field)) | 76 new AnchorElement(href: Uris.inspect(_isolate, object: _field)) |
78 ..text = _field.name | 77 ..text = _field.name |
79 ]; | 78 ]; |
80 }else { | 79 } else { |
81 children = [ | 80 children = [ |
82 new SpanElement()..text = header, | 81 new SpanElement()..text = header, |
83 new InstanceRefElement(_isolate, _field.declaredType, _instances, | 82 new InstanceRefElement(_isolate, _field.declaredType, _instances, |
84 queue: _r.queue), | 83 queue: _r.queue), |
85 new SpanElement()..text = ' ', | 84 new SpanElement()..text = ' ', |
86 new AnchorElement(href: Uris.inspect(_isolate, object: _field)) | 85 new AnchorElement(href: Uris.inspect(_isolate, object: _field)) |
87 ..text = _field.name | 86 ..text = _field.name |
88 ]; | 87 ]; |
89 } | 88 } |
90 } | 89 } |
91 } | 90 } |
OLD | NEW |