Chromium Code Reviews| Index: runtime/observatory/lib/src/elements/source_link.dart |
| diff --git a/runtime/observatory/lib/src/elements/source_link.dart b/runtime/observatory/lib/src/elements/source_link.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ded47ab7eed2462ea6ed8833d576038c940668b5 |
| --- /dev/null |
| +++ b/runtime/observatory/lib/src/elements/source_link.dart |
| @@ -0,0 +1,75 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
|
turnidge
2016/07/28 17:15:55
Update date here and in all other files you are ad
cbernaschina
2016/07/28 17:33:20
Done.
|
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library source_link_element; |
| + |
| +import 'dart:html'; |
| +import 'dart:async'; |
| +import 'package:observatory/models.dart' |
| + show IsolateRef, SourceLocation, Script, ScriptRepository; |
| +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'; |
| + |
| +class SourceLinkElement extends HtmlElement implements Renderable{ |
|
turnidge
2016/07/28 17:15:55
Add space between Renderable and {.
cbernaschina
2016/07/28 17:33:19
Done.
|
| + static const tag = const Tag<SourceLinkElement>('source-link-wrapped'); |
| + |
| + RenderingScheduler _r; |
| + |
| + Stream<RenderedEvent<SourceLinkElement>> get onRendered => _r.onRendered; |
| + |
|
turnidge
2016/07/28 17:15:56
Remove extra blank line.
cbernaschina
2016/07/28 17:33:20
Done.
|
| + |
| + IsolateRef _isolate; |
| + SourceLocation _location; |
| + Script _script; |
| + ScriptRepository _repository; |
| + |
| + IsolateRef get isolate => _isolate; |
| + SourceLocation get location => _location; |
| + |
| + factory SourceLinkElement(IsolateRef isolate, SourceLocation location, |
| + ScriptRepository repository, {RenderingQueue queue}) { |
|
turnidge
2016/07/28 17:15:56
Fix indentation. One parameter per line?
Maybe t
|
| + assert(isolate != null); |
| + assert(location != null); |
| + SourceLinkElement e = document.createElement(tag.name); |
| + e._r = new RenderingScheduler(e, queue: queue); |
| + e._isolate = isolate; |
| + e._location = location; |
| + e._repository = repository; |
| + return e; |
| + } |
| + |
| + SourceLinkElement.created() : super.created(); |
| + |
| + @override |
| + void attached() { |
| + super.attached(); |
| + assert(location != null); |
| + _r.enable(); |
| + _repository.get(_location.script.id).then((script) { |
| + _script = script; |
| + _r.dirty(); |
| + }); |
| + } |
| + |
| + @override |
| + void detached() { super.detached(); children = []; _r.disable(notify: true); } |
|
turnidge
2016/07/28 17:15:56
Can this detached/RenderingScheduler/onRendered bo
cbernaschina
2016/07/28 17:33:20
It is possible to move the properties to a mixin.
|
| + |
| + Future render() async { |
| + if (_script == null) { |
| + children = [new SpanElement()..text = '<LOADING>']; |
| + } else { |
| + String label = _script.uri.split('/').last; |
|
turnidge
2016/07/28 17:15:56
pathSegments
cbernaschina
2016/07/28 17:33:20
That is not an actual Uri, it is a String.
|
| + int token = _location.tokenPos; |
| + int line = _script.tokenToLine(token); |
| + int column = _script.tokenToCol(token); |
| + children = [ |
| + new AnchorElement( |
| + href: Uris.inspect(isolate, object: _script, pos: token)) |
| + ..title = _script.uri |
| + ..text = '${label}:${line}:${column}' |
| + ]; |
| + } |
| + } |
| +} |