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 function_ref_element; | 5 library function_ref_element; |
6 | 6 |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'package:observatory/models.dart' as M | 9 import 'package:observatory/models.dart' as M |
10 show | 10 show |
(...skipping 18 matching lines...) Expand all Loading... |
29 M.IsolateRef _isolate; | 29 M.IsolateRef _isolate; |
30 M.FunctionRef _function; | 30 M.FunctionRef _function; |
31 bool _qualified; | 31 bool _qualified; |
32 | 32 |
33 M.IsolateRef get isolate => _isolate; | 33 M.IsolateRef get isolate => _isolate; |
34 M.FunctionRef get function => _function; | 34 M.FunctionRef get function => _function; |
35 bool get qualified => _qualified; | 35 bool get qualified => _qualified; |
36 | 36 |
37 factory FunctionRefElement(M.IsolateRef isolate, M.FunctionRef function, | 37 factory FunctionRefElement(M.IsolateRef isolate, M.FunctionRef function, |
38 {bool qualified: true, RenderingQueue queue}) { | 38 {bool qualified: true, RenderingQueue queue}) { |
| 39 assert(isolate != null); |
39 assert(function != null); | 40 assert(function != null); |
40 assert(qualified != null); | 41 assert(qualified != null); |
41 FunctionRefElement e = document.createElement(tag.name); | 42 FunctionRefElement e = document.createElement(tag.name); |
42 e._r = new RenderingScheduler(e, queue: queue); | 43 e._r = new RenderingScheduler(e, queue: queue); |
43 e._isolate = isolate; | 44 e._isolate = isolate; |
44 e._function = function; | 45 e._function = function; |
45 e._qualified = qualified; | 46 e._qualified = qualified; |
46 return e; | 47 return e; |
47 } | 48 } |
48 | 49 |
49 FunctionRefElement.created() : super.created(); | 50 FunctionRefElement.created() : super.created(); |
50 | 51 |
51 @override | 52 @override |
52 void attached() { | 53 void attached() { |
53 super.attached(); | 54 super.attached(); |
54 _r.enable(); | 55 _r.enable(); |
55 } | 56 } |
56 | 57 |
57 @override | 58 @override |
58 void detached() { | 59 void detached() { |
59 super.detached(); | 60 super.detached(); |
60 children = []; | 61 children = []; |
61 title = ''; | 62 title = ''; |
62 _r.disable(notify: true); | 63 _r.disable(notify: true); |
63 } | 64 } |
64 | 65 |
65 void render() { | 66 void render() { |
66 var content = <Element>[ | 67 var content = <Element>[ |
67 new AnchorElement( | 68 new AnchorElement( |
68 href: (M.isSyntheticFunction(_function.kind) || (_isolate == null)) | 69 href: M.isSyntheticFunction(_function.kind) |
69 ? null | 70 ? null |
70 : Uris.inspect(_isolate, object: _function)) | 71 : Uris.inspect(_isolate, object: _function)) |
71 ..text = _function.name | 72 ..text = _function.name |
72 ]; | 73 ]; |
73 if (qualified) { | 74 if (qualified) { |
74 M.ObjectRef owner = _function.dartOwner; | 75 M.ObjectRef owner = _function.dartOwner; |
75 while (owner is M.FunctionRef) { | 76 while (owner is M.FunctionRef) { |
76 M.FunctionRef function = (owner as M.FunctionRef); | 77 M.FunctionRef function = (owner as M.FunctionRef); |
77 content.addAll([ | 78 content.addAll([ |
78 new SpanElement()..text = '.', | 79 new SpanElement()..text = '.', |
79 new AnchorElement( | 80 new AnchorElement( |
80 href: (M.isSyntheticFunction(function.kind) || (_isolate == null)) | 81 href: M.isSyntheticFunction(function.kind) |
81 ? null | 82 ? null |
82 : Uris.inspect(_isolate, object: function)) | 83 : Uris.inspect(_isolate, object: function)) |
83 ..text = function.name | 84 ..text = function.name |
84 ]); | 85 ]); |
85 owner = function.dartOwner; | 86 owner = function.dartOwner; |
86 } | 87 } |
87 if (owner is M.ClassRef) { | 88 if (owner is M.ClassRef) { |
88 content.addAll([ | 89 content.addAll([ |
89 new SpanElement()..text = '.', | 90 new SpanElement()..text = '.', |
90 new ClassRefElement(_isolate, owner, queue: _r.queue) | 91 new ClassRefElement(_isolate, owner, queue: _r.queue) |
91 ]); | 92 ]); |
92 } | 93 } |
93 } | 94 } |
94 children = content.reversed.toList(growable: false); | 95 children = content.reversed.toList(growable: false); |
95 title = M.getFunctionFullName(_function); | 96 title = M.getFunctionFullName(_function); |
96 } | 97 } |
97 } | 98 } |
OLD | NEW |