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

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

Issue 2119733003: Wrapping leaf nodes in non polymer elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Converted script-link 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
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 script_ref_element; 5 library script_ref_element;
6 6
7 import 'package:polymer/polymer.dart'; 7 import 'dart:html';
8 import 'package:observatory/service.dart'; 8 import 'dart:async';
9 import 'service_ref.dart'; 9 import 'package:observatory/models.dart'
10 show IsolateRef, ScriptRef, Script, ScriptRepository;
11 import 'package:observatory/src/elements/helpers/tag.dart';
12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
10 13
11 @CustomTag('script-ref') 14 class ScriptRefElement extends HtmlElement implements AsyncRenderable{
12 class ScriptRefElement extends ServiceRefElement { 15 static const tag = const Tag<ScriptRefElement>('script-ref-wrapped');
13 @published int pos;
14 16
15 String get hoverText { 17 RenderingScheduler _r;
16 if (ref == null) {
17 return super.hoverText;
18 }
19 return ref.vmName;
20 }
21 18
22 void posChanged(oldValue) { 19 Stream<RenderedEvent<ScriptRefElement>> get onRendered => _r.onRendered;
23 _updateProperties(null);
24 }
25 20
26 void _updateProperties(_) { 21
27 if (ref != null && ref.loaded) { 22 IsolateRef _isolate;
28 notifyPropertyChange(#name, 0, 1); 23 ScriptRef _script;
29 notifyPropertyChange(#url, 0, 1); 24 ScriptRepository _repository;
25 int _token;
26
27
28 IsolateRef get isolate => _isolate;
29 ScriptRef get script => _script;
30 int get token => _token;
31
32 set token(int token) {
33 if (_token != token) {
34 _token = token;
35 _r.dirty();
36 } else {
37 _r.scheduleNotification();
30 } 38 }
31 } 39 }
32 40
33 String get name { 41 factory ScriptRefElement(IsolateRef isolate, ScriptRef script,
34 if (ref == null) { 42 ScriptRepository repository, {int token: null}) {
35 return super.name; 43 assert(isolate != null);
36 } 44 assert(script != null);
37 if ((pos != null) && (pos >= 0)) { 45 ScriptRefElement e = document.createElement(tag.name);
Cutch 2016/07/12 16:24:36 script.load().then((_) => markAsDirty()); script.
38 if (ref.loaded) { 46 e._isolate = isolate;
39 // Script is loaded, get the line number. 47 e._script = script;
40 Script script = ref; 48 e._repository = repository;
41 return '${super.name}:${script.tokenToLine(pos)}:' 49 e._token = token;
42 '${script.tokenToCol(pos)}'; 50 return e;
43 } else {
44 ref.load().then(_updateProperties);
45 }
46 }
47 return super.name;
48 } 51 }
49 52
50 String get url { 53 ScriptRefElement.created() : super.created() {
51 if (ref == null) { 54 _r = new RenderingScheduler<ScriptRefElement>(this);
52 return super.url;
53 }
54 if ((pos != null) && (pos >= 0)) {
55 if (ref.loaded) {
56 return '${super.url}---pos=${pos}';
57 } else {
58 ref.load().then(_updateProperties);
59 }
60 }
61 return super.url;
62 } 55 }
63 56
64 ScriptRefElement.created() : super.created(); 57 @override
58 void attached() {
59 super.attached();
60 assert(script != null);
61 _r.scheduleRendering();
62 }
63
64 @override
65 void detached() {
66 super.detached();
67 children = [];
68 _r.scheduleNotification();
69 }
70
71 Future<RenderingCallback> render() async {
72 String href = '#/inspect?'
73 'isolateId=${Uri.encodeComponent(isolate.id)}&'
74 'objectId=${Uri.encodeComponent(script.id)}';
75 String text = script.uri.split('/').last;
76 if (token != null) {
77 final Script script = await _repository.get(_script.id);
78 int line = script.tokenToLine(token);
79 int column = script.tokenToCol(token);
80 text = '${text}:${line}:${column}';
81 href = '${href}---pos=${token}';
82 }
83 return () {
84 children = [
85 new AnchorElement(href: href)
86 ..title = script.uri
87 ..text = text
88 ];
89 };
90 }
65 } 91 }
66
67 @CustomTag('source-link')
68 class SourceLinkElement extends PolymerElement {
69 SourceLinkElement.created() : super.created();
70
71 @published SourceLocation location;
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698