Chromium Code Reviews| 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 _makeCreatedCallbackMethod() { | 11 _makeCreatedCallbackMethod() { |
| 12 return JS('', | 12 return JS('', |
| 13 '''((function(invokeCallback) { | 13 '''((function(invokeCallback) { |
| 14 return function() { | 14 return function() { |
| 15 return invokeCallback(this); | 15 return invokeCallback(this); |
| 16 }; | 16 }; |
| 17 })(#))''', | 17 })(#))''', |
| 18 convertDartClosureToJS(_callCreated, 1)); | 18 convertDartClosureToJS(_callCreated, 1)); |
| 19 } | 19 } |
| 20 | 20 |
| 21 const _typeNameToTag = const { | |
| 22 'HTMLAnchorElement': 'a', | |
| 23 'HTMLAppletElement': 'applet', | |
| 24 'HTMLAreaElement': 'area', | |
| 25 'HTMLAudioElement': 'audio', | |
| 26 'HTMLBRElement': 'br', | |
| 27 'HTMLBaseElement': 'base', | |
| 28 'HTMLBaseFontElement': 'basefont', | |
| 29 'HTMLBodyElement': 'body', | |
| 30 'HTMLButtonElement': 'button', | |
| 31 'HTMLCanvasElement': 'canvas', | |
| 32 'HTMLDListElement': 'dl', | |
| 33 'HTMLDataListElement': 'datalist', | |
| 34 'HTMLDirectoryElement': 'dir', | |
| 35 'HTMLDivElement': 'div', | |
| 36 'HTMLEmbedElement': 'embed', | |
| 37 'HTMLFieldSetElement': 'fieldset', | |
| 38 'HTMLFontElement': 'font', | |
| 39 'HTMLFormElement': 'form', | |
| 40 'HTMLFrameElement': 'frame', | |
| 41 'HTMLFrameSetElement': 'frameset', | |
| 42 'HTMLHRElement': 'hr', | |
| 43 'HTMLHeadElement': 'head', | |
| 44 'HTMLHeadingElement': 'h1', | |
| 45 'HTMLHtmlElement': 'html', | |
| 46 'HTMLIFrameElement': 'iframe', | |
| 47 'HTMLImageElement': 'image', | |
| 48 'HTMLImageElement': 'img', | |
| 49 'HTMLInputElement': 'input', | |
| 50 'HTMLKeygenElement': 'keygen', | |
| 51 'HTMLLIElement': 'li', | |
| 52 'HTMLLabelElement': 'label', | |
| 53 'HTMLLegendElement': 'legend', | |
| 54 'HTMLLinkElement': 'link', | |
| 55 'HTMLMapElement': 'map', | |
| 56 'HTMLMarqueeElement': 'marquee', | |
| 57 'HTMLMenuElement': 'menu', | |
| 58 'HTMLMetaElement': 'meta', | |
| 59 'HTMLMeterElement': 'meter', | |
| 60 'HTMLModElement': 'del', | |
|
Jennifer Messerly
2013/08/29 20:57:29
there are a few duplicate entries here. How do we
blois
2013/08/29 21:38:41
It's actually only the polyfill which needs this-
Jennifer Messerly
2013/08/29 22:44:27
okay, that makes sense, but surely we need that pa
| |
| 61 'HTMLModElement': 'ins', | |
| 62 'HTMLOListElement': 'ol', | |
| 63 'HTMLObjectElement': 'object', | |
| 64 'HTMLOptGroupElement': 'optgroup', | |
| 65 'HTMLOptionElement': 'option', | |
| 66 'HTMLOutputElement': 'output', | |
| 67 'HTMLParagraphElement': 'p', | |
| 68 'HTMLParamElement': 'param', | |
| 69 'HTMLPreElement': 'pre', | |
| 70 'HTMLProgressElement': 'progress', | |
| 71 'HTMLQuoteElement': 'blockquote', | |
| 72 'HTMLQuoteElement': 'q', | |
| 73 'HTMLScriptElement': 'script', | |
| 74 'HTMLSelectElement': 'select', | |
| 75 'HTMLShadowElement': 'shadow', | |
| 76 'HTMLSourceElement': 'source', | |
| 77 'HTMLSpanElement': 'span', | |
| 78 'HTMLStyleElement': 'style', | |
| 79 'HTMLTableCaptionElement': 'caption', | |
| 80 'HTMLTableCellElement': 'td', | |
| 81 'HTMLTableColElement': 'col', | |
| 82 'HTMLTableElement': 'table', | |
| 83 'HTMLTableRowElement': 'tr', | |
| 84 'HTMLTableSectionElement': 'tbody', | |
| 85 'HTMLTableSectionElement': 'tfoot', | |
| 86 'HTMLTableSectionElement': 'thead', | |
| 87 'HTMLTextAreaElement': 'textarea', | |
| 88 'HTMLTitleElement': 'title', | |
| 89 'HTMLTrackElement': 'track', | |
| 90 'HTMLUListElement': 'ul', | |
| 91 'HTMLVideoElement': 'video', | |
| 92 }; | |
| 93 | |
| 21 void _registerCustomElement(context, document, String tag, Type type) { | 94 void _registerCustomElement(context, document, String tag, Type type) { |
| 22 // Function follows the same pattern as the following JavaScript code for | 95 // Function follows the same pattern as the following JavaScript code for |
| 23 // registering a custom element. | 96 // registering a custom element. |
| 24 // | 97 // |
| 25 // var proto = Object.create(HTMLElement.prototype, { | 98 // var proto = Object.create(HTMLElement.prototype, { |
| 26 // createdCallback: { | 99 // createdCallback: { |
| 27 // value: function() { | 100 // value: function() { |
| 28 // window.console.log('here'); | 101 // window.console.log('here'); |
| 29 // } | 102 // } |
| 30 // } | 103 // } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 53 JS('void', '#.createdCallback = #', properties, | 126 JS('void', '#.createdCallback = #', properties, |
| 54 JS('=Object', '{value: #}', jsCreatedCallback)); | 127 JS('=Object', '{value: #}', jsCreatedCallback)); |
| 55 | 128 |
| 56 var baseProto = JS('=Object', '#.prototype', baseConstructor); | 129 var baseProto = JS('=Object', '#.prototype', baseConstructor); |
| 57 var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties); | 130 var proto = JS('=Object', 'Object.create(#, #)', baseProto, properties); |
| 58 | 131 |
| 59 var interceptor = JS('=Object', '#.prototype', interceptorClass); | 132 var interceptor = JS('=Object', '#.prototype', interceptorClass); |
| 60 | 133 |
| 61 setNativeSubclassDispatchRecord(proto, interceptor); | 134 setNativeSubclassDispatchRecord(proto, interceptor); |
| 62 | 135 |
| 63 JS('void', '#.register(#, #)', | 136 var options = JS('=Object', '{prototype: #}', proto); |
| 64 document, tag, JS('', '{prototype: #}', proto)); | 137 |
| 138 if (baseClassName != 'HTMLElement') { | |
| 139 if (_typeNameToTag.containsKey(baseClassName)) { | |
| 140 JS('=Object', '#.extends = #', options, _typeNameToTag[baseClassName]); | |
| 141 } | |
| 142 } | |
| 143 | |
| 144 JS('void', '#.register(#, #)', document, tag, options); | |
| 65 } | 145 } |
| OLD | NEW |