| 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 part of dart.dom.html; | 5 part of dart.dom.html; |
| 6 | 6 |
| 7 _callCreated(receiver) { | 7 _callCreated(receiver) { |
| 8 return receiver.createdCallback(); | 8 return receiver.createdCallback(); |
| 9 } | 9 } |
| 10 | 10 |
| 11 _callEnteredView(receiver) { | 11 _callEnteredView(receiver) { |
| 12 return receiver.enteredView(); | 12 return receiver.enteredView(); |
| 13 } | 13 } |
| 14 | 14 |
| 15 _callLeftView(receiver) { | 15 _callLeftView(receiver) { |
| 16 return receiver.leftView(); | 16 return receiver.leftView(); |
| 17 } | 17 } |
| 18 _callAttributeChanged(receiver, name, oldValue, newValue) { |
| 19 return receiver.attributeChanged(name, oldValue, newValue); |
| 20 } |
| 18 | 21 |
| 19 _makeCallbackMethod(callback) { | 22 _makeCallbackMethod(callback) { |
| 20 return JS('', | 23 return JS('', |
| 21 '''((function(invokeCallback) { | 24 '''((function(invokeCallback) { |
| 22 return function() { | 25 return function() { |
| 23 return invokeCallback(this); | 26 return invokeCallback(this); |
| 24 }; | 27 }; |
| 25 })(#))''', | 28 })(#))''', |
| 26 convertDartClosureToJS(callback, 1)); | 29 convertDartClosureToJS(callback, 1)); |
| 27 } | 30 } |
| 28 | 31 |
| 32 _makeCallbackMethod3(callback) { |
| 33 return JS('', |
| 34 '''((function(invokeCallback) { |
| 35 return function(arg1, arg2, arg3) { |
| 36 return invokeCallback(this, arg1, arg2, arg3); |
| 37 }; |
| 38 })(#))''', |
| 39 convertDartClosureToJS(callback, 4)); |
| 40 } |
| 41 |
| 29 const _typeNameToTag = const { | 42 const _typeNameToTag = const { |
| 30 'HTMLAnchorElement': 'a', | 43 'HTMLAnchorElement': 'a', |
| 31 'HTMLAudioElement': 'audio', | 44 'HTMLAudioElement': 'audio', |
| 32 'HTMLButtonElement': 'button', | 45 'HTMLButtonElement': 'button', |
| 33 'HTMLCanvasElement': 'canvas', | 46 'HTMLCanvasElement': 'canvas', |
| 34 'HTMLDivElement': 'div', | 47 'HTMLDivElement': 'div', |
| 35 'HTMLImageElement': 'img', | 48 'HTMLImageElement': 'img', |
| 36 'HTMLInputElement': 'input', | 49 'HTMLInputElement': 'input', |
| 37 'HTMLLIElement': 'li', | 50 'HTMLLIElement': 'li', |
| 38 'HTMLLabelElement': 'label', | 51 'HTMLLabelElement': 'label', |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 var baseConstructor = JS('=Object', '#[#]', context, baseClassName); | 97 var baseConstructor = JS('=Object', '#[#]', context, baseClassName); |
| 85 | 98 |
| 86 var properties = JS('=Object', '{}'); | 99 var properties = JS('=Object', '{}'); |
| 87 | 100 |
| 88 JS('void', '#.createdCallback = #', properties, | 101 JS('void', '#.createdCallback = #', properties, |
| 89 JS('=Object', '{value: #}', _makeCallbackMethod(_callCreated))); | 102 JS('=Object', '{value: #}', _makeCallbackMethod(_callCreated))); |
| 90 JS('void', '#.enteredViewCallback = #', properties, | 103 JS('void', '#.enteredViewCallback = #', properties, |
| 91 JS('=Object', '{value: #}', _makeCallbackMethod(_callEnteredView))); | 104 JS('=Object', '{value: #}', _makeCallbackMethod(_callEnteredView))); |
| 92 JS('void', '#.leftViewCallback = #', properties, | 105 JS('void', '#.leftViewCallback = #', properties, |
| 93 JS('=Object', '{value: #}', _makeCallbackMethod(_callLeftView))); | 106 JS('=Object', '{value: #}', _makeCallbackMethod(_callLeftView))); |
| 107 JS('void', '#.attributeChangedCallback = #', properties, |
| 108 JS('=Object', '{value: #}', _makeCallbackMethod3(_callAttributeChanged))); |
| 94 | 109 |
| 95 // TODO(blois): Bug 13220- remove once transition is complete | 110 // TODO(blois): Bug 13220- remove once transition is complete |
| 96 JS('void', '#.enteredDocumentCallback = #', properties, | 111 JS('void', '#.enteredDocumentCallback = #', properties, |
| 97 JS('=Object', '{value: #}', _makeCallbackMethod(_callEnteredView))); | 112 JS('=Object', '{value: #}', _makeCallbackMethod(_callEnteredView))); |
| 98 JS('void', '#.leftDocumentCallback = #', properties, | 113 JS('void', '#.leftDocumentCallback = #', properties, |
| 99 JS('=Object', '{value: #}', _makeCallbackMethod(_callLeftView))); | 114 JS('=Object', '{value: #}', _makeCallbackMethod(_callLeftView))); |
| 100 | 115 |
| 101 var baseProto = JS('=Object', '#.prototype', baseConstructor); | 116 var baseProto = JS('=Object', '#.prototype', baseConstructor); |
| 102 var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties); | 117 var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties); |
| 103 | 118 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 115 } | 130 } |
| 116 } | 131 } |
| 117 | 132 |
| 118 JS('void', '#.register(#, #)', document, tag, options); | 133 JS('void', '#.register(#, #)', document, tag, options); |
| 119 } | 134 } |
| 120 | 135 |
| 121 //// Called by Element.created to do validation & initialization. | 136 //// Called by Element.created to do validation & initialization. |
| 122 void _initializeCustomElement(Element e) { | 137 void _initializeCustomElement(Element e) { |
| 123 // TODO(blois): Add validation that this is only in response to an upgrade. | 138 // TODO(blois): Add validation that this is only in response to an upgrade. |
| 124 } | 139 } |
| OLD | NEW |