| 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.created(); | 8 return receiver.created(); |
| 9 } | 9 } |
| 10 | 10 |
| 11 _callEnteredView(receiver) { | 11 _makeCreatedCallbackMethod() { |
| 12 return receiver.enteredView(); | |
| 13 } | |
| 14 | |
| 15 _callLeftView(receiver) { | |
| 16 return receiver.leftView(); | |
| 17 } | |
| 18 | |
| 19 _makeCallbackMethod(callback) { | |
| 20 return JS('', | 12 return JS('', |
| 21 '''((function(invokeCallback) { | 13 '''((function(invokeCallback) { |
| 22 return function() { | 14 return function() { |
| 23 return invokeCallback(this); | 15 return invokeCallback(this); |
| 24 }; | 16 }; |
| 25 })(#))''', | 17 })(#))''', |
| 26 convertDartClosureToJS(callback, 1)); | 18 convertDartClosureToJS(_callCreated, 1)); |
| 27 } | 19 } |
| 28 | 20 |
| 29 const _typeNameToTag = const { | 21 const _typeNameToTag = const { |
| 30 'HTMLAnchorElement': 'a', | 22 'HTMLAnchorElement': 'a', |
| 31 'HTMLAudioElement': 'audio', | 23 'HTMLAudioElement': 'audio', |
| 32 'HTMLButtonElement': 'button', | 24 'HTMLButtonElement': 'button', |
| 33 'HTMLCanvasElement': 'canvas', | 25 'HTMLCanvasElement': 'canvas', |
| 34 'HTMLDivElement': 'div', | 26 'HTMLDivElement': 'div', |
| 35 'HTMLImageElement': 'img', | 27 'HTMLImageElement': 'img', |
| 36 'HTMLInputElement': 'input', | 28 'HTMLInputElement': 'input', |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 String baseClassName = findDispatchTagForInterceptorClass(interceptorClass); | 70 String baseClassName = findDispatchTagForInterceptorClass(interceptorClass); |
| 79 if (baseClassName == null) { | 71 if (baseClassName == null) { |
| 80 throw new ArgumentError(type); | 72 throw new ArgumentError(type); |
| 81 } | 73 } |
| 82 if (baseClassName == 'Element') baseClassName = 'HTMLElement'; | 74 if (baseClassName == 'Element') baseClassName = 'HTMLElement'; |
| 83 | 75 |
| 84 var baseConstructor = JS('=Object', '#[#]', context, baseClassName); | 76 var baseConstructor = JS('=Object', '#[#]', context, baseClassName); |
| 85 | 77 |
| 86 var properties = JS('=Object', '{}'); | 78 var properties = JS('=Object', '{}'); |
| 87 | 79 |
| 80 var jsCreatedCallback = _makeCreatedCallbackMethod(); |
| 81 |
| 88 JS('void', '#.createdCallback = #', properties, | 82 JS('void', '#.createdCallback = #', properties, |
| 89 JS('=Object', '{value: #}', _makeCallbackMethod(_callCreated))); | 83 JS('=Object', '{value: #}', jsCreatedCallback)); |
| 90 JS('void', '#.enteredViewCallback = #', properties, | |
| 91 JS('=Object', '{value: #}', _makeCallbackMethod(_callEnteredView))); | |
| 92 JS('void', '#.leftViewCallback = #', properties, | |
| 93 JS('=Object', '{value: #}', _makeCallbackMethod(_callLeftView))); | |
| 94 | |
| 95 // TODO(blois): Bug 13220- remove once transition is complete | |
| 96 JS('void', '#.enteredDocumentCallback = #', properties, | |
| 97 JS('=Object', '{value: #}', _makeCallbackMethod(_callEnteredView))); | |
| 98 JS('void', '#.leftDocumentCallback = #', properties, | |
| 99 JS('=Object', '{value: #}', _makeCallbackMethod(_callLeftView))); | |
| 100 | 84 |
| 101 var baseProto = JS('=Object', '#.prototype', baseConstructor); | 85 var baseProto = JS('=Object', '#.prototype', baseConstructor); |
| 102 var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties); | 86 var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties); |
| 103 | 87 |
| 104 var interceptor = JS('=Object', '#.prototype', interceptorClass); | 88 var interceptor = JS('=Object', '#.prototype', interceptorClass); |
| 105 | 89 |
| 106 setNativeSubclassDispatchRecord(proto, interceptor); | 90 setNativeSubclassDispatchRecord(proto, interceptor); |
| 107 | 91 |
| 108 var options = JS('=Object', '{prototype: #}', proto); | 92 var options = JS('=Object', '{prototype: #}', proto); |
| 109 | 93 |
| 110 if (baseClassName != 'HTMLElement') { | 94 if (baseClassName != 'HTMLElement') { |
| 111 if (extendsTagName != null) { | 95 if (extendsTagName != null) { |
| 112 JS('=Object', '#.extends = #', options, extendsTagName); | 96 JS('=Object', '#.extends = #', options, extendsTagName); |
| 113 } else if (_typeNameToTag.containsKey(baseClassName)) { | 97 } else if (_typeNameToTag.containsKey(baseClassName)) { |
| 114 JS('=Object', '#.extends = #', options, _typeNameToTag[baseClassName]); | 98 JS('=Object', '#.extends = #', options, _typeNameToTag[baseClassName]); |
| 115 } | 99 } |
| 116 } | 100 } |
| 117 | 101 |
| 118 JS('void', '#.register(#, #)', document, tag, options); | 102 JS('void', '#.register(#, #)', document, tag, options); |
| 119 } | 103 } |
| OLD | NEW |