Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 context_ref_element; | 5 import 'dart:html'; |
| 6 import 'dart:async'; | |
| 7 import 'package:observatory/models.dart' as M | |
| 8 show IsolateRef, ContextRef; | |
| 9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | |
| 10 import 'package:observatory/src/elements/helpers/tag.dart'; | |
| 11 import 'package:observatory/src/elements/helpers/uris.dart'; | |
| 6 | 12 |
| 7 import 'package:polymer/polymer.dart'; | 13 class ContextRefElement extends HtmlElement implements Renderable { |
| 8 import 'package:observatory/service.dart'; | 14 static const tag = const Tag<ContextRefElement>('context-ref-wrapped'); |
| 9 import 'service_ref.dart'; | |
| 10 | 15 |
| 11 @CustomTag('context-ref') | 16 RenderingScheduler<ContextRefElement> _r; |
| 12 class ContextRefElement extends ServiceRefElement { | 17 |
| 18 Stream<RenderedEvent<ContextRefElement>> get onRendered => _r.onRendered; | |
| 19 | |
| 20 M.IsolateRef _isolate; | |
| 21 M.ContextRef _context; | |
| 22 | |
| 23 M.IsolateRef get isolate => _isolate; | |
| 24 M.ContextRef get context => _context; | |
| 25 | |
| 26 factory ContextRefElement(M.IsolateRef isolate, M.ContextRef context, | |
| 27 {RenderingQueue queue}) { | |
| 28 assert(isolate != null); | |
| 29 assert(context != null); | |
| 30 ContextRefElement e = document.createElement(tag.name); | |
| 31 e._r = new RenderingScheduler(e, queue: queue); | |
| 32 e._isolate = isolate; | |
| 33 e._context = context; | |
| 34 return e; | |
| 35 } | |
| 36 | |
| 13 ContextRefElement.created() : super.created(); | 37 ContextRefElement.created() : super.created(); |
| 14 | 38 |
| 15 // TODO(turnidge): This is here to workaround vm/dart2js differences. | 39 @override |
| 16 dynamic expander() { | 40 void attached() { |
| 17 return expandEvent; | 41 super.attached(); |
| 42 _r.enable(); | |
| 18 } | 43 } |
| 19 | 44 |
| 20 void expandEvent(bool expand, Function onDone) { | 45 @override |
| 21 assert(ref is Context); | 46 void detached() { |
| 22 if (expand) { | 47 super.detached(); |
| 23 ref.reload().then((result) { | 48 _r.disable(notify: true); |
| 24 ref = result; | 49 children = []; |
| 25 notifyPropertyChange(#ref, 0, 1); | 50 } |
| 26 }).whenComplete(onDone); | 51 |
| 27 } else { | 52 void render() { |
| 28 Context refMap = ref; | 53 children = [ |
| 29 refMap.variables = null; | 54 new AnchorElement(href: Uris.inspect(_isolate, object: _context)) |
| 30 onDone(); | 55 ..children = [ |
| 31 } | 56 new SpanElement()..classes = ['empathize']..text = 'Context', |
| 57 new SpanElement()..text = ' (${_context.length})' | |
| 58 ] | |
| 59 ]; | |
| 32 } | 60 } |
| 33 } | 61 } |
| 62 | |
| 63 /* | |
|
Cutch
2016/08/15 23:27:07
remove delete code.
cbernaschina
2016/08/16 00:01:43
Done.
| |
| 64 <curly-block callback="{{ expander() }}"> | |
| 65 <div class="memberList"> | |
| 66 <div class="memberItem"> | |
| 67 <div class="memberName">parent</div> | |
| 68 <div class="memberValue"> | |
| 69 <any-service-ref ref="{{ ref.parentContext }}"></any-service-ref> | |
| 70 </div> | |
| 71 </div> | |
| 72 <template repeat="{{ index in ref.variables.asMap().keys }}"> | |
| 73 <div class="memberItem"> | |
| 74 <div class="memberName">[{{ index }}]</div> | |
| 75 <div class="memberValue"> | |
| 76 <any-service-ref ref="{{ ref.variables[index]['value'] }}"> | |
| 77 </any-service-ref> | |
| 78 </div> | |
| 79 </div> | |
| 80 </template> | |
| 81 </div> | |
| 82 </curly-block> | |
| 83 */ | |
| OLD | NEW |