OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
turnidge
2016/07/28 17:15:55
Update date here and in all other files you are ad
cbernaschina
2016/07/28 17:33:20
Done.
| |
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 library source_link_element; | |
6 | |
7 import 'dart:html'; | |
8 import 'dart:async'; | |
9 import 'package:observatory/models.dart' | |
10 show IsolateRef, SourceLocation, Script, ScriptRepository; | |
11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | |
12 import 'package:observatory/src/elements/helpers/tag.dart'; | |
13 import 'package:observatory/src/elements/helpers/uris.dart'; | |
14 | |
15 class SourceLinkElement extends HtmlElement implements Renderable{ | |
turnidge
2016/07/28 17:15:55
Add space between Renderable and {.
cbernaschina
2016/07/28 17:33:19
Done.
| |
16 static const tag = const Tag<SourceLinkElement>('source-link-wrapped'); | |
17 | |
18 RenderingScheduler _r; | |
19 | |
20 Stream<RenderedEvent<SourceLinkElement>> get onRendered => _r.onRendered; | |
21 | |
turnidge
2016/07/28 17:15:56
Remove extra blank line.
cbernaschina
2016/07/28 17:33:20
Done.
| |
22 | |
23 IsolateRef _isolate; | |
24 SourceLocation _location; | |
25 Script _script; | |
26 ScriptRepository _repository; | |
27 | |
28 IsolateRef get isolate => _isolate; | |
29 SourceLocation get location => _location; | |
30 | |
31 factory SourceLinkElement(IsolateRef isolate, SourceLocation location, | |
32 ScriptRepository repository, {RenderingQueue queue}) { | |
turnidge
2016/07/28 17:15:56
Fix indentation. One parameter per line?
Maybe t
| |
33 assert(isolate != null); | |
34 assert(location != null); | |
35 SourceLinkElement e = document.createElement(tag.name); | |
36 e._r = new RenderingScheduler(e, queue: queue); | |
37 e._isolate = isolate; | |
38 e._location = location; | |
39 e._repository = repository; | |
40 return e; | |
41 } | |
42 | |
43 SourceLinkElement.created() : super.created(); | |
44 | |
45 @override | |
46 void attached() { | |
47 super.attached(); | |
48 assert(location != null); | |
49 _r.enable(); | |
50 _repository.get(_location.script.id).then((script) { | |
51 _script = script; | |
52 _r.dirty(); | |
53 }); | |
54 } | |
55 | |
56 @override | |
57 void detached() { super.detached(); children = []; _r.disable(notify: true); } | |
turnidge
2016/07/28 17:15:56
Can this detached/RenderingScheduler/onRendered bo
cbernaschina
2016/07/28 17:33:20
It is possible to move the properties to a mixin.
| |
58 | |
59 Future render() async { | |
60 if (_script == null) { | |
61 children = [new SpanElement()..text = '<LOADING>']; | |
62 } else { | |
63 String label = _script.uri.split('/').last; | |
turnidge
2016/07/28 17:15:56
pathSegments
cbernaschina
2016/07/28 17:33:20
That is not an actual Uri, it is a String.
| |
64 int token = _location.tokenPos; | |
65 int line = _script.tokenToLine(token); | |
66 int column = _script.tokenToCol(token); | |
67 children = [ | |
68 new AnchorElement( | |
69 href: Uris.inspect(isolate, object: _script, pos: token)) | |
70 ..title = _script.uri | |
71 ..text = '${label}:${line}:${column}' | |
72 ]; | |
73 } | |
74 } | |
75 } | |
OLD | NEW |