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 'package:polymer/polymer.dart'; | 8 import 'package:polymer/polymer.dart'; |
| 9 import 'package:observatory/service.dart'; |
8 import 'service_ref.dart'; | 10 import 'service_ref.dart'; |
9 | 11 |
10 @CustomTag('function-ref') | 12 @CustomTag('function-ref') |
11 class FunctionRefElement extends ServiceRefElement { | 13 class FunctionRefElement extends ServiceRefElement { |
12 @published bool qualified = true; | 14 @published bool qualified = true; |
13 | 15 |
14 FunctionRefElement.created() : super.created(); | 16 FunctionRefElement.created() : super.created(); |
15 } | 17 |
| 18 refChanged(oldValue) { |
| 19 super.refChanged(oldValue); |
| 20 _updateShadowDom(); |
| 21 } |
| 22 |
| 23 ServiceFunction get function => ref; |
| 24 void _updateShadowDom() { |
| 25 clearShadowRoot(); |
| 26 if (ref == null) { |
| 27 return; |
| 28 } |
| 29 if (function.isDart) { |
| 30 if (qualified) { |
| 31 // Add class-name or parent-function-name followed by a dot. |
| 32 if ((function.parent == null) && (function.owningClass != null)) { |
| 33 var classRef = new Element.tag('class-ref'); |
| 34 classRef.ref = function.owningClass; |
| 35 shadowRoot.children.add(classRef); |
| 36 insertTextSpanIntoShadowRoot('.'); |
| 37 } else if (function.parent != null) { |
| 38 var functionRef = new Element.tag('function-ref'); |
| 39 functionRef.ref = function.parent; |
| 40 functionRef.qualified = true; |
| 41 shadowRoot.children.add(functionRef); |
| 42 insertTextSpanIntoShadowRoot('.'); |
| 43 } |
| 44 } |
| 45 insertLinkIntoShadowRoot(name, url, hoverText); |
| 46 } else { |
| 47 insertTextSpanIntoShadowRoot(name); |
| 48 } |
| 49 } |
| 50 } |
OLD | NEW |