| 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 _callConstructor(constructor, interceptor) { | 7 _callConstructor(constructor, interceptor) { |
| 8 return (receiver) { | 8 return (receiver) { |
| 9 setNativeSubclassDispatchRecord(receiver, interceptor); | 9 setNativeSubclassDispatchRecord(receiver, interceptor); |
| 10 | 10 |
| 11 // Mirrors uses the constructor property to cache lookups, so we need it to | 11 // Mirrors uses the constructor property to cache lookups, so we need it to |
| 12 // be set correctly, including on IE where it is not automatically picked | 12 // be set correctly, including on IE where it is not automatically picked |
| 13 // up from the __proto__. | 13 // up from the __proto__. |
| 14 JS('', '#.constructor = #.__proto__.constructor', receiver, receiver); | 14 JS('', '#.constructor = #.__proto__.constructor', receiver, receiver); |
| 15 return JS('', '#(#)', constructor, receiver); | 15 return JS('', '#(#)', constructor, receiver); |
| 16 }; | 16 }; |
| 17 } | 17 } |
| 18 | 18 |
| 19 _callEnteredView(receiver) { | 19 _callAttached(receiver) { |
| 20 return receiver.enteredView(); | 20 return receiver.attached(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 _callLeftView(receiver) { | 23 _callDetached(receiver) { |
| 24 return receiver.leftView(); | 24 return receiver.detached(); |
| 25 } | 25 } |
| 26 _callAttributeChanged(receiver, name, oldValue, newValue) { | 26 _callAttributeChanged(receiver, name, oldValue, newValue) { |
| 27 return receiver.attributeChanged(name, oldValue, newValue); | 27 return receiver.attributeChanged(name, oldValue, newValue); |
| 28 } | 28 } |
| 29 | 29 |
| 30 _makeCallbackMethod(callback) { | 30 _makeCallbackMethod(callback) { |
| 31 return JS('', | 31 return JS('', |
| 32 '''((function(invokeCallback) { | 32 '''((function(invokeCallback) { |
| 33 return function() { | 33 return function() { |
| 34 return invokeCallback(this); | 34 return invokeCallback(this); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 var baseConstructor = JS('=Object', '#[#]', context, baseClassName); | 99 var baseConstructor = JS('=Object', '#[#]', context, baseClassName); |
| 100 | 100 |
| 101 var properties = JS('=Object', '{}'); | 101 var properties = JS('=Object', '{}'); |
| 102 | 102 |
| 103 JS('void', '#.createdCallback = #', properties, | 103 JS('void', '#.createdCallback = #', properties, |
| 104 JS('=Object', '{value: #}', | 104 JS('=Object', '{value: #}', |
| 105 _makeCallbackMethod(_callConstructor(constructor, interceptor)))); | 105 _makeCallbackMethod(_callConstructor(constructor, interceptor)))); |
| 106 JS('void', '#.attachedCallback = #', properties, | 106 JS('void', '#.attachedCallback = #', properties, |
| 107 JS('=Object', '{value: #}', _makeCallbackMethod(_callEnteredView))); | 107 JS('=Object', '{value: #}', _makeCallbackMethod(_callAttached))); |
| 108 JS('void', '#.detachedCallback = #', properties, | 108 JS('void', '#.detachedCallback = #', properties, |
| 109 JS('=Object', '{value: #}', _makeCallbackMethod(_callLeftView))); | 109 JS('=Object', '{value: #}', _makeCallbackMethod(_callDetached))); |
| 110 JS('void', '#.attributeChangedCallback = #', properties, | 110 JS('void', '#.attributeChangedCallback = #', properties, |
| 111 JS('=Object', '{value: #}', _makeCallbackMethod3(_callAttributeChanged))); | 111 JS('=Object', '{value: #}', _makeCallbackMethod3(_callAttributeChanged))); |
| 112 | 112 |
| 113 var baseProto = JS('=Object', '#.prototype', baseConstructor); | 113 var baseProto = JS('=Object', '#.prototype', baseConstructor); |
| 114 var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties); | 114 var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties); |
| 115 | 115 |
| 116 setNativeSubclassDispatchRecord(proto, interceptor); | 116 setNativeSubclassDispatchRecord(proto, interceptor); |
| 117 | 117 |
| 118 var options = JS('=Object', '{prototype: #}', proto); | 118 var options = JS('=Object', '{prototype: #}', proto); |
| 119 | 119 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Only exact type matches are supported- cannot be a subclass. | 178 // Only exact type matches are supported- cannot be a subclass. |
| 179 if (element.runtimeType != _nativeType) { | 179 if (element.runtimeType != _nativeType) { |
| 180 throw new ArgumentError('element is not subclass of $_nativeType'); | 180 throw new ArgumentError('element is not subclass of $_nativeType'); |
| 181 } | 181 } |
| 182 | 182 |
| 183 setNativeSubclassDispatchRecord(element, _interceptor); | 183 setNativeSubclassDispatchRecord(element, _interceptor); |
| 184 JS('', '#(#)', _constructor, element); | 184 JS('', '#(#)', _constructor, element); |
| 185 return element; | 185 return element; |
| 186 } | 186 } |
| 187 } | 187 } |
| OLD | NEW |