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

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

Issue 2119733003: Wrapping leaf nodes in non polymer elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Converted vm-connect Created 4 years, 5 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) 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 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/tag.dart';
12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
13
14 class SourceLinkElement extends HtmlElement implements Renderable{
15 static const tag = const Tag<SourceLinkElement>('source-link-wrapped');
16
17 RenderingScheduler _r;
18
19 Stream<RenderedEvent<SourceLinkElement>> get onRendered => _r.onRendered;
20
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(href: '#/inspect?'
68 'isolateId=${Uri.encodeComponent(isolate.id)}&'
69 'objectId=${Uri.encodeComponent(_script.id)}'
70 '---pos=${token}')
71 ..title = _script.uri
72 ..text = '${label}:${line}:${column}'
73 ];
74 }
75 }
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698