OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 """This module provides shared functionality for the system to generate | 6 """This module provides shared functionality for the system to generate |
7 Dart:html APIs from the IDL database.""" | 7 Dart:html APIs from the IDL database.""" |
8 | 8 |
9 import emitter | 9 import emitter |
10 import os | 10 import os |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 'Window.document', | 62 'Window.document', |
63 'Window.indexedDB', | 63 'Window.indexedDB', |
64 'Window.location', | 64 'Window.location', |
65 'Window.open', | 65 'Window.open', |
66 'Window.requestAnimationFrame', | 66 'Window.requestAnimationFrame', |
67 'Window.webkitCancelAnimationFrame', | 67 'Window.webkitCancelAnimationFrame', |
68 'Window.webkitRequestAnimationFrame', | 68 'Window.webkitRequestAnimationFrame', |
69 'WorkerContext.indexedDB', | 69 'WorkerContext.indexedDB', |
70 ]) | 70 ]) |
71 | 71 |
72 js_support_checks = { | |
73 'ArrayBuffer': "JS('bool', 'typeof window.ArrayBuffer != \"undefined\"')", | |
74 'Database': "JS('bool', '!!(window.openDatabase)')", | |
75 'DOMApplicationCache': "JS('bool', '!!(window.applicationCache)')", | |
76 'DOMFileSystem': "JS('bool', '!!(window.webkitRequestFileSystem)')", | |
77 'HashChangeEvent': "Event._isTypeSupported('HashChangeEvent')", | |
78 'HTMLContentElement': "Element.isTagSupported('content')", | |
79 'HTMLDataListElement': "Element.isTagSupported('datalist')", | |
80 'HTMLDetailsElement': "Element.isTagSupported('details')", | |
81 'HTMLEmbedElement': "Element.isTagSupported('embed')", | |
82 # IE creates keygen as Block elements | |
83 'HTMLKeygenElement': "Element.isTagSupported('keygen') " | |
84 "&& (new Element.tag('keygen') is KeygenElement)", | |
85 'HTMLMeterElement': "Element.isTagSupported('meter')", | |
86 'HTMLObjectElement': "Element.isTagSupported('object')", | |
87 'HTMLOutputElement': "Element.isTagSupported('output')", | |
88 'HTMLProgressElement': "Element.isTagSupported('progress')", | |
89 'HTMLShadowElement': "Element.isTagSupported('shadow')", | |
90 'HTMLTrackElement': "Element.isTagSupported('track')", | |
91 'MediaStreamEvent': "Event._isTypeSupported('MediaStreamEvent')", | |
92 'MediaStreamTrackEvent': "Event._isTypeSupported('MediaStreamTrackEvent')", | |
93 'NotificationCenter': "JS('bool', '!!(window.webkitNotifications)')", | |
94 'Performance': "JS('bool', '!!(window.performance)')", | |
95 'SpeechRecognition': "JS('bool', '!!(window.SpeechRecognition || " | |
96 "window.webkitSpeechRecognition)')", | |
97 'XMLHttpRequestProgressEvent': | |
98 "Event._isTypeSupported('XMLHttpRequestProgressEvent')", | |
99 'WebGLRenderingContext': "JS('bool', '!!(window.WebGLRenderingContext)')", | |
100 'WebKitCSSMatrix': "JS('bool', '!!(window.WebKitCSSMatrix)')", | |
101 'WebKitPoint': "JS('bool', '!!(window.WebKitPoint)')", | |
102 'WebSocket': "JS('bool', 'typeof window.WebSocket != \"undefined\"')", | |
103 'XSLTProcessor': "JS('bool', '!!(window.XSLTProcessor)')", | |
104 } | |
105 | |
106 # Classes that offer only static methods, and therefore we should suppress | 72 # Classes that offer only static methods, and therefore we should suppress |
107 # constructor creation. | 73 # constructor creation. |
108 _static_classes = set(['Url']) | 74 _static_classes = set(['Url']) |
109 | 75 |
110 # Information for generating element constructors. | 76 # Information for generating element constructors. |
111 # | 77 # |
112 # TODO(sra): maybe remove all the argument complexity and use cascades. | 78 # TODO(sra): maybe remove all the argument complexity and use cascades. |
113 # | 79 # |
114 # var c = new CanvasElement(width: 100, height: 70); | 80 # var c = new CanvasElement(width: 100, height: 70); |
115 # var c = new CanvasElement()..width = 100..height = 70; | 81 # var c = new CanvasElement()..width = 100..height = 70; |
(...skipping 17 matching lines...) Expand all Loading... | |
133 info.js_name = None | 99 info.js_name = None |
134 info.type_name = interface_name | 100 info.type_name = interface_name |
135 info.param_infos = map(lambda tXn: ParamInfo(tXn[1], tXn[0], True), | 101 info.param_infos = map(lambda tXn: ParamInfo(tXn[1], tXn[0], True), |
136 self.opt_params) | 102 self.opt_params) |
137 info.requires_named_arguments = True | 103 info.requires_named_arguments = True |
138 info.factory_parameters = ['"%s"' % self.tag] | 104 info.factory_parameters = ['"%s"' % self.tag] |
139 info.pure_dart_constructor = True | 105 info.pure_dart_constructor = True |
140 return info | 106 return info |
141 | 107 |
142 _html_element_constructors = { | 108 _html_element_constructors = { |
143 'AnchorElement' : | 109 'HTMLAnchorElement' : |
144 ElementConstructorInfo(tag='a', opt_params=[('DOMString', 'href')]), | 110 ElementConstructorInfo(tag='a', opt_params=[('DOMString', 'href')]), |
145 'AreaElement': 'area', | 111 'HTMLAreaElement': 'area', |
146 'ButtonElement': 'button', | 112 'HTMLButtonElement': 'button', |
147 'BRElement': 'br', | 113 'HTMLBRElement': 'br', |
148 'BaseElement': 'base', | 114 'HTMLBaseElement': 'base', |
149 'BodyElement': 'body', | 115 'HTMLBodyElement': 'body', |
150 'ButtonElement': 'button', | 116 'HTMLButtonElement': 'button', |
151 'CanvasElement': | 117 'HTMLCanvasElement': |
152 ElementConstructorInfo(tag='canvas', | 118 ElementConstructorInfo(tag='canvas', |
153 opt_params=[('int', 'width'), ('int', 'height')]), | 119 opt_params=[('int', 'width'), ('int', 'height')]), |
154 'ContentElement': 'content', | 120 'HTMLContentElement': 'content', |
155 'DataListElement': 'datalist', | 121 'HTMLDataListElement': 'datalist', |
156 'DListElement': 'dl', | 122 'HTMLDListElement': 'dl', |
157 'DetailsElement': 'details', | 123 'HTMLDetailsElement': 'details', |
158 'DivElement': 'div', | 124 'HTMLDivElement': 'div', |
159 'EmbedElement': 'embed', | 125 'HTMLEmbedElement': 'embed', |
160 'FieldSetElement': 'fieldset', | 126 'HTMLFieldSetElement': 'fieldset', |
161 'FormElement': 'form', | 127 'HTMLFormElement': 'form', |
162 'HRElement': 'hr', | 128 'HTMLHRElement': 'hr', |
163 'HeadElement': 'head', | 129 'HTMLHeadElement': 'head', |
164 'HeadingElement': [ElementConstructorInfo('h1'), | 130 'HTMLHeadingElement': [ElementConstructorInfo('h1'), |
165 ElementConstructorInfo('h2'), | 131 ElementConstructorInfo('h2'), |
166 ElementConstructorInfo('h3'), | 132 ElementConstructorInfo('h3'), |
167 ElementConstructorInfo('h4'), | 133 ElementConstructorInfo('h4'), |
168 ElementConstructorInfo('h5'), | 134 ElementConstructorInfo('h5'), |
169 ElementConstructorInfo('h6')], | 135 ElementConstructorInfo('h6')], |
170 'HtmlElement': 'html', | 136 'HTMLHtmlElement': 'html', |
171 'IFrameElement': 'iframe', | 137 'HTMLIFrameElement': 'iframe', |
172 'ImageElement': | 138 'HTMLImageElement': |
173 ElementConstructorInfo(tag='img', | 139 ElementConstructorInfo(tag='img', |
174 opt_params=[('DOMString', 'src'), | 140 opt_params=[('DOMString', 'src'), |
175 ('int', 'width'), ('int', 'height')]), | 141 ('int', 'width'), ('int', 'height')]), |
176 'KeygenElement': 'keygen', | 142 'HTMLKeygenElement': 'keygen', |
177 'LIElement': 'li', | 143 'HTMLLIElement': 'li', |
178 'LabelElement': 'label', | 144 'HTMLLabelElement': 'label', |
179 'LegendElement': 'legend', | 145 'HTMLLegendElement': 'legend', |
180 'LinkElement': 'link', | 146 'HTMLLinkElement': 'link', |
181 'MapElement': 'map', | 147 'HTMLMapElement': 'map', |
182 'MenuElement': 'menu', | 148 'HTMLMenuElement': 'menu', |
183 'MeterElement': 'meter', | 149 'HTMLMeterElement': 'meter', |
184 'OListElement': 'ol', | 150 'HTMLOListElement': 'ol', |
185 'ObjectElement': 'object', | 151 'HTMLObjectElement': 'object', |
186 'OptGroupElement': 'optgroup', | 152 'HTMLOptGroupElement': 'optgroup', |
187 'OutputElement': 'output', | 153 'HTMLOutputElement': 'output', |
188 'ParagraphElement': 'p', | 154 'HTMLParagraphElement': 'p', |
189 'ParamElement': 'param', | 155 'HTMLParamElement': 'param', |
190 'PreElement': 'pre', | 156 'HTMLPreElement': 'pre', |
191 'ProgressElement': 'progress', | 157 'HTMLProgressElement': 'progress', |
192 'ScriptElement': 'script', | 158 'HTMLScriptElement': 'script', |
193 'SelectElement': 'select', | 159 'HTMLSelectElement': 'select', |
194 'SourceElement': 'source', | 160 'HTMLSourceElement': 'source', |
195 'SpanElement': 'span', | 161 'HTMLSpanElement': 'span', |
196 'StyleElement': 'style', | 162 'HTMLStyleElement': 'style', |
197 'TableCaptionElement': 'caption', | 163 'HTMLTableCaptionElement': 'caption', |
198 'TableCellElement': 'td', | 164 'HTMLTableCellElement': 'td', |
199 'TableColElement': 'col', | 165 'HTMLTableColElement': 'col', |
200 'TableElement': 'table', | 166 'HTMLTableElement': 'table', |
201 'TableRowElement': 'tr', | 167 'HTMLTableRowElement': 'tr', |
202 #'TableSectionElement' <thead> <tbody> <tfoot> | 168 #'HTMLTableSectionElement' <thead> <tbody> <tfoot> |
203 'TextAreaElement': 'textarea', | 169 'HTMLTextAreaElement': 'textarea', |
204 'TitleElement': 'title', | 170 'HTMLTitleElement': 'title', |
205 'TrackElement': 'track', | 171 'HTMLTrackElement': 'track', |
206 'UListElement': 'ul', | 172 'HTMLUListElement': 'ul', |
207 'VideoElement': 'video' | 173 'HTMLVideoElement': 'video' |
208 } | 174 } |
209 | 175 |
210 _svg_element_constructors = { | 176 _svg_element_constructors = { |
211 'AElement': 'a', | 177 'SVGAElement': 'a', |
212 'AnimateColorElement': 'animateColor', | 178 'SVGAltGlyphElement': 'altGlyph', |
213 'AnimateElement': 'animate', | 179 'SVGAnimateElement': 'animate', |
214 'AnimateMotionElement': 'animateMotion', | 180 'SVGAnimateMotionElement': 'animateMotion', |
215 'AnimateTransformElement': 'animateTransform', | 181 'SVGAnimateTransformElement': 'animateTransform', |
216 'AnimationElement': 'animation', | 182 'SVGAnimationElement': 'animation', |
217 'CircleElement': 'circle', | 183 'SVGCircleElement': 'circle', |
218 'ClipPathElement': 'clipPath', | 184 'SVGClipPathElement': 'clipPath', |
219 'CursorElement': 'cursor', | 185 'SVGCursorElement': 'cursor', |
220 'DefsElement': 'defs', | 186 'SVGDefsElement': 'defs', |
221 'DescElement': 'desc', | 187 'SVGDescElement': 'desc', |
222 'EllipseElement': 'ellipse', | 188 'SVGEllipseElement': 'ellipse', |
223 'FilterElement': 'filter', | 189 'SVGFEBlendElement': 'feBlend', |
224 'FontElement': 'font', | 190 'SVGFEColorMatrixElement': 'feColorMatrix', |
225 'FontFaceElement': 'font-face', | 191 'SVGFEComponentTransferElement': 'feComponentTransfer', |
226 'FontFaceFormatElement': 'font-face-format', | 192 'SVGFEConvolveMatrixElement': 'feConvolveMatrix', |
227 'FontFaceNameElement': 'font-face-name', | 193 'SVGFEDiffuseLightingElement': 'feDiffuseLighting', |
228 'FontFaceSrcElement': 'font-face-src', | 194 'SVGFEDisplacementMapElement': 'feDisplacementMap', |
229 'FontFaceUriElement': 'font-face-uri', | 195 'SVGFEDistantLightElement': 'feDistantLight', |
230 'ForeignObjectElement': 'foreignObject', | 196 'SVGFEFloodElement': 'feFlood', |
231 'GlyphElement': 'glyph', | 197 'SVGFEFuncAElement': 'feFuncA', |
232 'GElement': 'g', | 198 'SVGFEFuncBElement': 'feFuncB', |
233 'HKernElement': 'hkern', | 199 'SVGFEFuncGElement': 'feFuncG', |
234 'ImageElement': 'image', | 200 'SVGFEFuncRElement': 'feFuncR', |
235 'LinearGradientElement': 'linearGradient', | 201 'SVGFEGaussianBlurElement': 'feGaussianBlur', |
236 'LineElement': 'line', | 202 'SVGFEImageElement': 'feImage', |
237 'MarkerElement': 'marker', | 203 'SVGFEMergeElement': 'feMerge', |
238 'MaskElement': 'mask', | 204 'SVGFEMergeNodeElement': 'feMergeNode', |
239 'MPathElement': 'mpath', | 205 'SVGFEMorphology': 'feMorphology', |
240 'PathElement': 'path', | 206 'SVGFEOffsetElement': 'feOffset', |
241 'PatternElement': 'pattern', | 207 'SVGFEPointLightElement': 'fePointLight', |
242 'PolygonElement': 'polygon', | 208 'SVGFESpecularLightingElement': 'feSpecularLighting', |
243 'PolylineElement': 'polyline', | 209 'SVGFESpotLightElement': 'feSpotLight', |
244 'RadialGradientElement': 'radialGradient', | 210 'SVGFETileElement': 'feTile', |
245 'RectElement': 'rect', | 211 'SVGFETurbulenceElement': 'feTurbulence', |
246 'ScriptElement': 'script', | 212 'SVGFilterElement': 'filter', |
247 'SetElement': 'set', | 213 'SVGForeignObjectElement': 'foreignObject', |
248 'StopElement': 'stop', | 214 'SVGGlyphElement': 'glyph', |
249 'StyleElement': 'style', | 215 'SVGGElement': 'g', |
250 'SwitchElement': 'switch', | 216 'SVGHKernElement': 'hkern', |
251 'SymbolElement': 'symbol', | 217 'SVGImageElement': 'image', |
252 'TextElement': 'text', | 218 'SVGLinearGradientElement': 'linearGradient', |
253 'TitleElement': 'title', | 219 'SVGLineElement': 'line', |
254 'TRefElement': 'tref', | 220 'SVGMarkerElement': 'marker', |
255 'TSpanElement': 'tspan', | 221 'SVGMaskElement': 'mask', |
256 'UseElement': 'use', | 222 'SVGMPathElement': 'mpath', |
257 'ViewElement': 'view', | 223 'SVGPathElement': 'path', |
258 'VKernElement': 'vkern', | 224 'SVGPatternElement': 'pattern', |
225 'SVGPolygonElement': 'polygon', | |
226 'SVGPolylineElement': 'polyline', | |
227 'SVGRadialGradientElement': 'radialGradient', | |
228 'SVGRectElement': 'rect', | |
229 'SVGScriptElement': 'script', | |
230 'SVGSetElement': 'set', | |
231 'SVGStopElement': 'stop', | |
232 'SVGStyleElement': 'style', | |
233 'SVGSwitchElement': 'switch', | |
234 'SVGSymbolElement': 'symbol', | |
235 'SVGTextElement': 'text', | |
236 'SVGTitleElement': 'title', | |
237 'SVGTRefElement': 'tref', | |
238 'SVGTSpanElement': 'tspan', | |
239 'SVGUseElement': 'use', | |
240 'SVGViewElement': 'view', | |
241 'SVGVKernElement': 'vkern', | |
259 } | 242 } |
260 | 243 |
261 _element_constructors = { | 244 _element_constructors = { |
262 'html': _html_element_constructors, | 245 'html': _html_element_constructors, |
263 'indexed_db': {}, | 246 'indexed_db': {}, |
264 'svg': _svg_element_constructors, | 247 'svg': _svg_element_constructors, |
265 'web_audio': {}, | 248 'web_audio': {}, |
266 } | 249 } |
267 | 250 |
268 _factory_ctr_strings = { | 251 _factory_ctr_strings = { |
(...skipping 24 matching lines...) Expand all Loading... | |
293 return [] | 276 return [] |
294 infos = element_constructors[typename] | 277 infos = element_constructors[typename] |
295 if isinstance(infos, str): | 278 if isinstance(infos, str): |
296 infos = ElementConstructorInfo(tag=infos, | 279 infos = ElementConstructorInfo(tag=infos, |
297 factory_provider_name=factory_provider_name) | 280 factory_provider_name=factory_provider_name) |
298 if not isinstance(infos, list): | 281 if not isinstance(infos, list): |
299 infos = [infos] | 282 infos = [infos] |
300 return infos | 283 return infos |
301 | 284 |
302 # ------------------------------------------------------------------------------ | 285 # ------------------------------------------------------------------------------ |
286 def SvgSupportStr(tagName): | |
287 return 'Svg%s' % ElemSupportStr(tagName) | |
288 | |
289 def ElemSupportStr(tagName): | |
290 return "Element.isTagSupported('%s')" % tagName | |
291 | |
292 _js_support_checks_basic_element = [ | |
293 'HTMLContentElement', | |
294 'HTMLDataListElement', | |
295 'HTMLDetailsElement', | |
296 'HTMLEmbedElement', | |
297 'HTMLMeterElement', | |
298 'HTMLObjectElement', | |
299 'HTMLOutputElement', | |
300 'HTMLProgressElement', | |
301 'HTMLTrackElement', | |
302 ] | |
303 | |
304 _js_support_checks_additional_element = [ | |
305 # IE creates keygen as Block elements | |
306 'HTMLKeygenElement', | |
307 'SVGAltGlyphElement', | |
308 'SVGAnimateElement', | |
309 'SVGAnimateMotionElement', | |
310 'SVGAnimateTransformElement', | |
311 'SVGCursorElement', | |
312 'SVGFEBlendElement', | |
313 'SVGFEColorMatrixElement', | |
314 'SVGFEComponentTransferElement', | |
315 'SVGFEConvolveMatrixElement', | |
316 'SVGFEDiffuseLightingElement', | |
317 'SVGFEDisplacementMapElement', | |
318 'SVGFEDistantLightElement', | |
319 'SVGFEFloodElement', | |
320 'SVGFEFuncAElement', | |
321 'SVGFEFuncBElement', | |
322 'SVGFEFuncGElement', | |
323 'SVGFEFuncRElement', | |
324 'SVGFEGaussianBlurElement', | |
325 'SVGFEImageElement', | |
326 'SVGFEMergeElement', | |
327 'SVGFEMergeNodeElement', | |
328 'SVGFEMorphology', | |
329 'SVGFEOffsetElement', | |
330 'SVGFEPointLightElement', | |
331 'SVGFESpecularLightingElement', | |
332 'SVGFESpotLightElement', | |
333 'SVGFETileElement', | |
334 'SVGFETurbulenceElement', | |
335 'SVGFilterElement', | |
336 'SVGForeignObjectElement', | |
337 'SVGSetElement', | |
338 ] | |
339 | |
340 js_support_checks = dict({ | |
341 'ArrayBuffer': "JS('bool', 'typeof window.ArrayBuffer != \"undefined\"')", | |
342 'Database': "JS('bool', '!!(window.openDatabase)')", | |
343 'DOMApplicationCache': "JS('bool', '!!(window.applicationCache)')", | |
344 'DOMFileSystem': "JS('bool', '!!(window.webkitRequestFileSystem)')", | |
345 'HashChangeEvent': "Event._isTypeSupported('HashChangeEvent')", | |
346 'HTMLShadowElement': ElemSupportStr('shadow'), | |
blois
2013/02/01 18:24:19
Should this not move into the basic_element checks
Emily Fortuna
2013/02/01 18:58:57
No. This uses the data in the _html_element_constr
| |
347 'MediaStreamEvent': "Event._isTypeSupported('MediaStreamEvent')", | |
348 'MediaStreamTrackEvent': "Event._isTypeSupported('MediaStreamTrackEvent')", | |
349 'NotificationCenter': "JS('bool', '!!(window.webkitNotifications)')", | |
350 'Performance': "JS('bool', '!!(window.performance)')", | |
351 'SpeechRecognition': "JS('bool', '!!(window.SpeechRecognition || " | |
352 "window.webkitSpeechRecognition)')", | |
353 'SVGExternalResourcesRequired': ('supported(SvgElement element)', | |
354 "JS('bool', '#.externalResourcesRequired !== undefined && " | |
355 "#.externalResourcesRequired.animVal !== undefined', " | |
356 "element, element)"), | |
357 'SVGLangSpace': ('supported(SvgElement element)', | |
358 "JS('bool', '#.xmlspace !== undefined && #.xmllang !== undefined', " | |
359 "element, element)"), | |
360 'XMLHttpRequestProgressEvent': | |
361 "Event._isTypeSupported('XMLHttpRequestProgressEvent')", | |
362 'WebGLRenderingContext': "JS('bool', '!!(window.WebGLRenderingContext)')", | |
363 'WebKitCSSMatrix': "JS('bool', '!!(window.WebKitCSSMatrix)')", | |
364 'WebKitPoint': "JS('bool', '!!(window.WebKitPoint)')", | |
365 'WebSocket': "JS('bool', 'typeof window.WebSocket != \"undefined\"')", | |
366 'XSLTProcessor': "JS('bool', '!!(window.XSLTProcessor)')", | |
367 }.items() + | |
368 dict((key, | |
blois
2013/02/01 18:24:19
Odd indenting
Emily Fortuna
2013/02/01 18:58:57
This was the most readable way I saw to write this
blois
2013/02/01 19:00:53
I was just looking at the 6 space indent, but real
| |
369 SvgSupportStr(_svg_element_constructors[key]) if key.startswith('SVG') | |
370 else ElemSupportStr(_html_element_constructors[key])) for key in | |
371 _js_support_checks_basic_element + | |
372 _js_support_checks_additional_element).items()) | |
373 # ------------------------------------------------------------------------------ | |
303 | 374 |
304 class HtmlDartInterfaceGenerator(object): | 375 class HtmlDartInterfaceGenerator(object): |
305 """Generates dart interface and implementation for the DOM IDL interface.""" | 376 """Generates dart interface and implementation for the DOM IDL interface.""" |
306 | 377 |
307 def __init__(self, options, library_emitter, event_generator, interface, | 378 def __init__(self, options, library_emitter, event_generator, interface, |
308 backend): | 379 backend): |
309 self._renamer = options.renamer | 380 self._renamer = options.renamer |
310 self._database = options.database | 381 self._database = options.database |
311 self._template_loader = options.templates | 382 self._template_loader = options.templates |
312 self._type_registry = options.type_registry | 383 self._type_registry = options.type_registry |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 if interface_name in _static_classes: | 423 if interface_name in _static_classes: |
353 constructor_info = None | 424 constructor_info = None |
354 else: | 425 else: |
355 constructor_info = AnalyzeConstructor(self._interface) | 426 constructor_info = AnalyzeConstructor(self._interface) |
356 if constructor_info: | 427 if constructor_info: |
357 constructors.append(constructor_info) | 428 constructors.append(constructor_info) |
358 # TODO(antonm): consider removing it later. | 429 # TODO(antonm): consider removing it later. |
359 factory_provider = interface_name | 430 factory_provider = interface_name |
360 | 431 |
361 # HTML Elements and SVG Elements have convenience constructors. | 432 # HTML Elements and SVG Elements have convenience constructors. |
362 infos = ElementConstructorInfos(interface_name, | 433 infos = ElementConstructorInfos(self._interface.id, |
363 _element_constructors[self._library_name], factory_provider_name= | 434 _element_constructors[self._library_name], factory_provider_name= |
364 _factory_ctr_strings[self._library_name]['provider_name']) | 435 _factory_ctr_strings[self._library_name]['provider_name']) |
365 | 436 |
366 if infos: | 437 if infos: |
367 factory_constructor_name = _factory_ctr_strings[ | 438 factory_constructor_name = _factory_ctr_strings[ |
368 self._library_name]['constructor_name'] | 439 self._library_name]['constructor_name'] |
369 | 440 |
370 for info in infos: | 441 for info in infos: |
371 constructors.append(info.ConstructorInfo(self._interface.id)) | 442 constructors.append(info.ConstructorInfo(self._interface.id)) |
372 if factory_provider: | 443 if factory_provider: |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 def StartInterface(self, members_emitter): | 585 def StartInterface(self, members_emitter): |
515 self._members_emitter = members_emitter | 586 self._members_emitter = members_emitter |
516 | 587 |
517 def FinishInterface(self): | 588 def FinishInterface(self): |
518 pass | 589 pass |
519 | 590 |
520 def HasSupportCheck(self): | 591 def HasSupportCheck(self): |
521 return self._interface.doc_js_name in js_support_checks | 592 return self._interface.doc_js_name in js_support_checks |
522 | 593 |
523 def GetSupportCheck(self): | 594 def GetSupportCheck(self): |
595 """Return a tuple of the support check function signature and the support | |
596 test itself. If no parameters are supplied, we assume the default.""" | |
597 if self._interface.doc_js_name in _js_support_checks_additional_element: | |
598 if self._interface.doc_js_name in _svg_element_constructors: | |
599 lib_prefix = 'Svg' | |
600 constructors = _svg_element_constructors | |
601 else: | |
602 lib_prefix = '' | |
603 constructors = _html_element_constructors | |
604 return (js_support_checks.get(self._interface.doc_js_name) + | |
605 " && (new %sElement.tag('%s') is %s)" % (lib_prefix, | |
606 constructors[self._interface.doc_js_name], | |
607 self._renamer.RenameInterface(self._interface))) | |
524 return js_support_checks.get(self._interface.doc_js_name) | 608 return js_support_checks.get(self._interface.doc_js_name) |
525 | 609 |
526 def GenerateCustomFactory(self, constructor_info): | 610 def GenerateCustomFactory(self, constructor_info): |
527 # Custom factory will be taken from the template. | 611 # Custom factory will be taken from the template. |
528 return self._interface.doc_js_name in [ | 612 return self._interface.doc_js_name in [ |
529 'AudioContext', | 613 'AudioContext', |
530 'Blob', | 614 'Blob', |
531 'MutationObserver', | 615 'MutationObserver', |
532 'SpeechRecognition', | 616 'SpeechRecognition', |
533 ] | 617 ] |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1020 for library_name in libraries: | 1104 for library_name in libraries: |
1021 self._libraries[library_name] = DartLibrary( | 1105 self._libraries[library_name] = DartLibrary( |
1022 library_name, template_loader, library_type, output_dir) | 1106 library_name, template_loader, library_type, output_dir) |
1023 | 1107 |
1024 def AddFile(self, basename, library_name, path): | 1108 def AddFile(self, basename, library_name, path): |
1025 self._libraries[library_name].AddFile(path) | 1109 self._libraries[library_name].AddFile(path) |
1026 | 1110 |
1027 def Emit(self, emitter, auxiliary_dir): | 1111 def Emit(self, emitter, auxiliary_dir): |
1028 for lib in self._libraries.values(): | 1112 for lib in self._libraries.values(): |
1029 lib.Emit(emitter, auxiliary_dir) | 1113 lib.Emit(emitter, auxiliary_dir) |
OLD | NEW |