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

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

Issue 2180553002: Converted Observatory source-link & script-ref elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixed bad merge 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
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' as M show IsolateRef, ScriptRef;
10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
11 import 'package:observatory/src/elements/helpers/tag.dart';
12 import 'package:observatory/src/elements/helpers/uris.dart';
10 13
11 @CustomTag('script-ref') 14 class ScriptRefElement extends HtmlElement implements Renderable{
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(_) {
27 if (ref != null && ref.loaded) {
28 notifyPropertyChange(#name, 0, 1);
29 notifyPropertyChange(#url, 0, 1);
30 }
31 }
32 21
33 String get name { 22 M.IsolateRef _isolate;
34 if (ref == null) { 23 M.ScriptRef _script;
35 return super.name;
36 }
37 if ((pos != null) && (pos >= 0)) {
38 if (ref.loaded) {
39 // Script is loaded, get the line number.
40 Script script = ref;
41 return '${super.name}:${script.tokenToLine(pos)}:'
42 '${script.tokenToCol(pos)}';
43 } else {
44 ref.load().then(_updateProperties);
45 }
46 }
47 return super.name;
48 }
49 24
50 String get url { 25 M.IsolateRef get isolate => _isolate;
51 if (ref == null) { 26 M.ScriptRef get script => _script;
52 return super.url; 27
53 } 28 factory ScriptRefElement(M.IsolateRef isolate, M.ScriptRef script,
Cutch 2016/07/25 20:29:42 what happened to the ---pos= parameter?
cbernaschina 2016/07/25 20:44:37 script-ref had an optional pos parameter that was
54 if ((pos != null) && (pos >= 0)) { 29 {RenderingQueue queue}) {
55 if (ref.loaded) { 30 assert(isolate != null);
56 return '${super.url}---pos=${pos}'; 31 assert(script != null);
57 } else { 32 ScriptRefElement e = document.createElement(tag.name);
58 ref.load().then(_updateProperties); 33 e._r = new RenderingScheduler(e, queue: queue);
59 } 34 e._isolate = isolate;
60 } 35 e._script = script;
61 return super.url; 36 return e;
62 } 37 }
63 38
64 ScriptRefElement.created() : super.created(); 39 ScriptRefElement.created() : super.created();
40
41 @override
42 void attached() {
43 super.attached();
44 assert(script != null);
45 _r.enable();
46 }
47
48 @override
49 void detached() {
50 super.detached();
51 children = [];
52 _r.disable(notify: true);
53 }
54
55 void render() {
56 children = [
57 new AnchorElement(href: Uris.inspect(isolate, object: script))
58 ..title = script.uri
59 ..text = script.uri.split('/').last
60 ];
61 }
65 } 62 }
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