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

Unified 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: Converted Observatory source-link & script-ref elements 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 side-by-side diff with in-line comments
Download patch
Index: runtime/observatory/lib/src/elements/script_ref.dart
diff --git a/runtime/observatory/lib/src/elements/script_ref.dart b/runtime/observatory/lib/src/elements/script_ref.dart
index c11f26d7f3146d37d8f88e430b59fef6812a7657..8cc2f6877ef6f97645a49ad4ddc7bf320adeea3c 100644
--- a/runtime/observatory/lib/src/elements/script_ref.dart
+++ b/runtime/observatory/lib/src/elements/script_ref.dart
@@ -4,69 +4,59 @@
library script_ref_element;
-import 'package:polymer/polymer.dart';
-import 'package:observatory/service.dart';
-import 'service_ref.dart';
+import 'dart:html';
+import 'dart:async';
+import 'package:observatory/models.dart' as M show IsolateRef, ScriptRef;
+import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
+import 'package:observatory/src/elements/helpers/tag.dart';
+import 'package:observatory/src/elements/helpers/uris.dart';
-@CustomTag('script-ref')
-class ScriptRefElement extends ServiceRefElement {
- @published int pos;
+class ScriptRefElement extends HtmlElement implements Renderable {
+ static const tag = const Tag<ScriptRefElement>('script-ref-wrapped');
- String get hoverText {
- if (ref == null) {
- return super.hoverText;
- }
- return ref.vmName;
- }
+ RenderingScheduler _r;
- void posChanged(oldValue) {
- _updateProperties(null);
- }
+ Stream<RenderedEvent<ScriptRefElement>> get onRendered => _r.onRendered;
- void _updateProperties(_) {
- if (ref != null && ref.loaded) {
- notifyPropertyChange(#name, 0, 1);
- notifyPropertyChange(#url, 0, 1);
- }
- }
- String get name {
- if (ref == null) {
- return super.name;
- }
- if ((pos != null) && (pos >= 0)) {
- if (ref.loaded) {
- // Script is loaded, get the line number.
- Script script = ref;
- return '${super.name}:${script.tokenToLine(pos)}:'
- '${script.tokenToCol(pos)}';
- } else {
- ref.load().then(_updateProperties);
- }
- }
- return super.name;
- }
+ M.IsolateRef _isolate;
+ M.ScriptRef _script;
+
+ M.IsolateRef get isolate => _isolate;
+ M.ScriptRef get script => _script;
- String get url {
- if (ref == null) {
- return super.url;
- }
- if ((pos != null) && (pos >= 0)) {
- if (ref.loaded) {
- return '${super.url}---pos=${pos}';
- } else {
- ref.load().then(_updateProperties);
- }
- }
- return super.url;
+ factory ScriptRefElement(M.IsolateRef isolate, M.ScriptRef script,
+ {RenderingQueue queue}) {
+ assert(isolate != null);
+ assert(script != null);
+ ScriptRefElement e = document.createElement(tag.name);
+ e._r = new RenderingScheduler(e, queue: queue);
+ e._isolate = isolate;
+ e._script = script;
+ return e;
}
ScriptRefElement.created() : super.created();
-}
-@CustomTag('source-link')
-class SourceLinkElement extends PolymerElement {
- SourceLinkElement.created() : super.created();
+ @override
+ void attached() {
+ super.attached();
+ assert(script != null);
+ _r.enable();
+ }
- @published SourceLocation location;
+ @override
+ void detached() {
+ super.detached();
+ children = [];
+ _r.disable(notify: true);
+ }
+
+ void render() {
+ children = [
+ new AnchorElement(href: Uris.inspect(isolate, object: script))
+ ..title = script.uri
+ ..text = script.uri.split('/').last
+ ];
+ }
}
« no previous file with comments | « runtime/observatory/lib/src/elements/objectstore_view.html ('k') | runtime/observatory/lib/src/elements/script_ref.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698