Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: runtime/observatory/lib/src/elements/source_link.dart

Issue 2180553002: Converted Observatory source-link & script-ref elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Converted Observatory source-link & script-ref elements Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016, 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 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 {
16 static const tag = const Tag<SourceLinkElement>('source-link-wrapped');
17
18 RenderingScheduler _r;
19
20 Stream<RenderedEvent<SourceLinkElement>> get onRendered => _r.onRendered;
21
22 IsolateRef _isolate;
23 SourceLocation _location;
24 Script _script;
25 ScriptRepository _repository;
26
27 IsolateRef get isolate => _isolate;
28 SourceLocation get location => _location;
29
30 factory SourceLinkElement(IsolateRef isolate, SourceLocation location,
31 ScriptRepository repository, {RenderingQueue queue}) {
32 assert(isolate != null);
33 assert(location != null);
34 SourceLinkElement e = document.createElement(tag.name);
35 e._r = new RenderingScheduler(e, queue: queue);
36 e._isolate = isolate;
37 e._location = location;
38 e._repository = repository;
39 return e;
40 }
41
42 SourceLinkElement.created() : super.created();
43
44 @override
45 void attached() {
46 super.attached();
47 assert(location != null);
48 _r.enable();
49 _repository.get(_location.script.id).then((script) {
50 _script = script;
51 _r.dirty();
52 });
53 }
54
55 @override
56 void detached() { super.detached(); children = []; _r.disable(notify: true); }
57
58 Future render() async {
59 if (_script == null) {
60 children = [new SpanElement()..text = '<LOADING>'];
61 } else {
62 String label = _script.uri.split('/').last;
63 int token = _location.tokenPos;
64 int line = _script.tokenToLine(token);
65 int column = _script.tokenToCol(token);
66 children = [
67 new AnchorElement(
68 href: Uris.inspect(isolate, object: _script, pos: token))
69 ..title = _script.uri
70 ..text = '${label}:${line}:${column}'
71 ];
72 }
73 }
74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698