| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 'Window.document', | 63 'Window.document', |
| 64 'Window.indexedDB', | 64 'Window.indexedDB', |
| 65 'Window.location', | 65 'Window.location', |
| 66 'Window.open', | 66 'Window.open', |
| 67 'Window.requestAnimationFrame', | 67 'Window.requestAnimationFrame', |
| 68 'Window.webkitCancelAnimationFrame', | 68 'Window.webkitCancelAnimationFrame', |
| 69 'Window.webkitRequestAnimationFrame', | 69 'Window.webkitRequestAnimationFrame', |
| 70 'WorkerContext.indexedDB', | 70 'WorkerContext.indexedDB', |
| 71 ]) | 71 ]) |
| 72 | 72 |
| 73 js_support_checks = { | |
| 74 'ArrayBuffer': "JS('bool', 'typeof window.ArrayBuffer != \"undefined\"')", | |
| 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 'WebSocket': "JS('bool', 'typeof window.WebSocket != \"undefined\"')", | |
| 98 } | |
| 99 | |
| 100 # Classes that offer only static methods, and therefore we should suppress | 73 # Classes that offer only static methods, and therefore we should suppress |
| 101 # constructor creation. | 74 # constructor creation. |
| 102 _static_classes = set(['Url']) | 75 _static_classes = set(['Url']) |
| 103 | 76 |
| 104 # Information for generating element constructors. | 77 # Information for generating element constructors. |
| 105 # | 78 # |
| 106 # TODO(sra): maybe remove all the argument complexity and use cascades. | 79 # TODO(sra): maybe remove all the argument complexity and use cascades. |
| 107 # | 80 # |
| 108 # var c = new CanvasElement(width: 100, height: 70); | 81 # var c = new CanvasElement(width: 100, height: 70); |
| 109 # var c = new CanvasElement()..width = 100..height = 70; | 82 # var c = new CanvasElement()..width = 100..height = 70; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 127 info.js_name = None | 100 info.js_name = None |
| 128 info.type_name = interface_name | 101 info.type_name = interface_name |
| 129 info.param_infos = map(lambda tXn: ParamInfo(tXn[1], tXn[0], True), | 102 info.param_infos = map(lambda tXn: ParamInfo(tXn[1], tXn[0], True), |
| 130 self.opt_params) | 103 self.opt_params) |
| 131 info.requires_named_arguments = True | 104 info.requires_named_arguments = True |
| 132 info.factory_parameters = ['"%s"' % self.tag] | 105 info.factory_parameters = ['"%s"' % self.tag] |
| 133 info.pure_dart_constructor = True | 106 info.pure_dart_constructor = True |
| 134 return info | 107 return info |
| 135 | 108 |
| 136 _html_element_constructors = { | 109 _html_element_constructors = { |
| 137 'AnchorElement' : | 110 'HTMLAnchorElement' : |
| 138 ElementConstructorInfo(tag='a', opt_params=[('DOMString', 'href')]), | 111 ElementConstructorInfo(tag='a', opt_params=[('DOMString', 'href')]), |
| 139 'AreaElement': 'area', | 112 'HTMLAreaElement': 'area', |
| 140 'ButtonElement': 'button', | 113 'HTMLButtonElement': 'button', |
| 141 'BRElement': 'br', | 114 'HTMLBRElement': 'br', |
| 142 'BaseElement': 'base', | 115 'HTMLBaseElement': 'base', |
| 143 'BodyElement': 'body', | 116 'HTMLBodyElement': 'body', |
| 144 'ButtonElement': 'button', | 117 'HTMLButtonElement': 'button', |
| 145 'CanvasElement': | 118 'HTMLCanvasElement': |
| 146 ElementConstructorInfo(tag='canvas', | 119 ElementConstructorInfo(tag='canvas', |
| 147 opt_params=[('int', 'width'), ('int', 'height')]), | 120 opt_params=[('int', 'width'), ('int', 'height')]), |
| 148 'ContentElement': 'content', | 121 'HTMLContentElement': 'content', |
| 149 'DataListElement': 'datalist', | 122 'HTMLDataListElement': 'datalist', |
| 150 'DListElement': 'dl', | 123 'HTMLDListElement': 'dl', |
| 151 'DetailsElement': 'details', | 124 'HTMLDetailsElement': 'details', |
| 152 'DivElement': 'div', | 125 'HTMLDivElement': 'div', |
| 153 'EmbedElement': 'embed', | 126 'HTMLEmbedElement': 'embed', |
| 154 'FieldSetElement': 'fieldset', | 127 'HTMLFieldSetElement': 'fieldset', |
| 155 'FormElement': 'form', | 128 'HTMLFormElement': 'form', |
| 156 'HRElement': 'hr', | 129 'HTMLHRElement': 'hr', |
| 157 'HeadElement': 'head', | 130 'HTMLHeadElement': 'head', |
| 158 'HeadingElement': [ElementConstructorInfo('h1'), | 131 'HTMLHeadingElement': [ElementConstructorInfo('h1'), |
| 159 ElementConstructorInfo('h2'), | 132 ElementConstructorInfo('h2'), |
| 160 ElementConstructorInfo('h3'), | 133 ElementConstructorInfo('h3'), |
| 161 ElementConstructorInfo('h4'), | 134 ElementConstructorInfo('h4'), |
| 162 ElementConstructorInfo('h5'), | 135 ElementConstructorInfo('h5'), |
| 163 ElementConstructorInfo('h6')], | 136 ElementConstructorInfo('h6')], |
| 164 'HtmlElement': 'html', | 137 'HTMLHtmlElement': 'html', |
| 165 'IFrameElement': 'iframe', | 138 'HTMLIFrameElement': 'iframe', |
| 166 'ImageElement': | 139 'HTMLImageElement': |
| 167 ElementConstructorInfo(tag='img', | 140 ElementConstructorInfo(tag='img', |
| 168 opt_params=[('DOMString', 'src'), | 141 opt_params=[('DOMString', 'src'), |
| 169 ('int', 'width'), ('int', 'height')]), | 142 ('int', 'width'), ('int', 'height')]), |
| 170 'KeygenElement': 'keygen', | 143 'HTMLKeygenElement': 'keygen', |
| 171 'LIElement': 'li', | 144 'HTMLLIElement': 'li', |
| 172 'LabelElement': 'label', | 145 'HTMLLabelElement': 'label', |
| 173 'LegendElement': 'legend', | 146 'HTMLLegendElement': 'legend', |
| 174 'LinkElement': 'link', | 147 'HTMLLinkElement': 'link', |
| 175 'MapElement': 'map', | 148 'HTMLMapElement': 'map', |
| 176 'MenuElement': 'menu', | 149 'HTMLMenuElement': 'menu', |
| 177 'MeterElement': 'meter', | 150 'HTMLMeterElement': 'meter', |
| 178 'OListElement': 'ol', | 151 'HTMLOListElement': 'ol', |
| 179 'ObjectElement': 'object', | 152 'HTMLObjectElement': 'object', |
| 180 'OptGroupElement': 'optgroup', | 153 'HTMLOptGroupElement': 'optgroup', |
| 181 'OutputElement': 'output', | 154 'HTMLOutputElement': 'output', |
| 182 'ParagraphElement': 'p', | 155 'HTMLParagraphElement': 'p', |
| 183 'ParamElement': 'param', | 156 'HTMLParamElement': 'param', |
| 184 'PreElement': 'pre', | 157 'HTMLPreElement': 'pre', |
| 185 'ProgressElement': 'progress', | 158 'HTMLProgressElement': 'progress', |
| 186 'ScriptElement': 'script', | 159 'HTMLScriptElement': 'script', |
| 187 'SelectElement': 'select', | 160 'HTMLSelectElement': 'select', |
| 188 'SourceElement': 'source', | 161 'HTMLSourceElement': 'source', |
| 189 'SpanElement': 'span', | 162 'HTMLSpanElement': 'span', |
| 190 'StyleElement': 'style', | 163 'HTMLStyleElement': 'style', |
| 191 'TableCaptionElement': 'caption', | 164 'HTMLTableCaptionElement': 'caption', |
| 192 'TableCellElement': 'td', | 165 'HTMLTableCellElement': 'td', |
| 193 'TableColElement': 'col', | 166 'HTMLTableColElement': 'col', |
| 194 'TableElement': 'table', | 167 'HTMLTableElement': 'table', |
| 195 'TableRowElement': 'tr', | 168 'HTMLTableRowElement': 'tr', |
| 196 #'TableSectionElement' <thead> <tbody> <tfoot> | 169 #'HTMLTableSectionElement' <thead> <tbody> <tfoot> |
| 197 'TextAreaElement': 'textarea', | 170 'HTMLTextAreaElement': 'textarea', |
| 198 'TitleElement': 'title', | 171 'HTMLTitleElement': 'title', |
| 199 'TrackElement': 'track', | 172 'HTMLTrackElement': 'track', |
| 200 'UListElement': 'ul', | 173 'HTMLUListElement': 'ul', |
| 201 'VideoElement': 'video' | 174 'HTMLVideoElement': 'video' |
| 202 } | 175 } |
| 203 | 176 |
| 204 _svg_element_constructors = { | 177 _svg_element_constructors = { |
| 205 'AElement': 'a', | 178 'SVGAElement': 'a', |
| 206 'AnimateColorElement': 'animateColor', | 179 'SVGAltGlyphElement': 'altGlyph', |
| 207 'AnimateElement': 'animate', | 180 'SVGAnimateElement': 'animate', |
| 208 'AnimateMotionElement': 'animateMotion', | 181 'SVGAnimateMotionElement': 'animateMotion', |
| 209 'AnimateTransformElement': 'animateTransform', | 182 'SVGAnimateTransformElement': 'animateTransform', |
| 210 'AnimationElement': 'animation', | 183 'SVGAnimationElement': 'animation', |
| 211 'CircleElement': 'circle', | 184 'SVGCircleElement': 'circle', |
| 212 'ClipPathElement': 'clipPath', | 185 'SVGClipPathElement': 'clipPath', |
| 213 'CursorElement': 'cursor', | 186 'SVGCursorElement': 'cursor', |
| 214 'DefsElement': 'defs', | 187 'SVGDefsElement': 'defs', |
| 215 'DescElement': 'desc', | 188 'SVGDescElement': 'desc', |
| 216 'EllipseElement': 'ellipse', | 189 'SVGEllipseElement': 'ellipse', |
| 217 'FilterElement': 'filter', | 190 'SVGFEBlendElement': 'feBlend', |
| 218 'FontElement': 'font', | 191 'SVGFEColorMatrixElement': 'feColorMatrix', |
| 219 'FontFaceElement': 'font-face', | 192 'SVGFEComponentTransferElement': 'feComponentTransfer', |
| 220 'FontFaceFormatElement': 'font-face-format', | 193 'SVGFEConvolveMatrixElement': 'feConvolveMatrix', |
| 221 'FontFaceNameElement': 'font-face-name', | 194 'SVGFEDiffuseLightingElement': 'feDiffuseLighting', |
| 222 'FontFaceSrcElement': 'font-face-src', | 195 'SVGFEDisplacementMapElement': 'feDisplacementMap', |
| 223 'FontFaceUriElement': 'font-face-uri', | 196 'SVGFEDistantLightElement': 'feDistantLight', |
| 224 'ForeignObjectElement': 'foreignObject', | 197 'SVGFEFloodElement': 'feFlood', |
| 225 'GlyphElement': 'glyph', | 198 'SVGFEFuncAElement': 'feFuncA', |
| 226 'GElement': 'g', | 199 'SVGFEFuncBElement': 'feFuncB', |
| 227 'HKernElement': 'hkern', | 200 'SVGFEFuncGElement': 'feFuncG', |
| 228 'ImageElement': 'image', | 201 'SVGFEFuncRElement': 'feFuncR', |
| 229 'LinearGradientElement': 'linearGradient', | 202 'SVGFEGaussianBlurElement': 'feGaussianBlur', |
| 230 'LineElement': 'line', | 203 'SVGFEImageElement': 'feImage', |
| 231 'MarkerElement': 'marker', | 204 'SVGFEMergeElement': 'feMerge', |
| 232 'MaskElement': 'mask', | 205 'SVGFEMergeNodeElement': 'feMergeNode', |
| 233 'MPathElement': 'mpath', | 206 'SVGFEMorphology': 'feMorphology', |
| 234 'PathElement': 'path', | 207 'SVGFEOffsetElement': 'feOffset', |
| 235 'PatternElement': 'pattern', | 208 'SVGFEPointLightElement': 'fePointLight', |
| 236 'PolygonElement': 'polygon', | 209 'SVGFESpecularLightingElement': 'feSpecularLighting', |
| 237 'PolylineElement': 'polyline', | 210 'SVGFESpotLightElement': 'feSpotLight', |
| 238 'RadialGradientElement': 'radialGradient', | 211 'SVGFETileElement': 'feTile', |
| 239 'RectElement': 'rect', | 212 'SVGFETurbulenceElement': 'feTurbulence', |
| 240 'ScriptElement': 'script', | 213 'SVGFilterElement': 'filter', |
| 241 'SetElement': 'set', | 214 'SVGForeignObjectElement': 'foreignObject', |
| 242 'StopElement': 'stop', | 215 'SVGGlyphElement': 'glyph', |
| 243 'StyleElement': 'style', | 216 'SVGGElement': 'g', |
| 244 'SwitchElement': 'switch', | 217 'SVGHKernElement': 'hkern', |
| 245 'SymbolElement': 'symbol', | 218 'SVGImageElement': 'image', |
| 246 'TextElement': 'text', | 219 'SVGLinearGradientElement': 'linearGradient', |
| 247 'TitleElement': 'title', | 220 'SVGLineElement': 'line', |
| 248 'TRefElement': 'tref', | 221 'SVGMarkerElement': 'marker', |
| 249 'TSpanElement': 'tspan', | 222 'SVGMaskElement': 'mask', |
| 250 'UseElement': 'use', | 223 'SVGMPathElement': 'mpath', |
| 251 'ViewElement': 'view', | 224 'SVGPathElement': 'path', |
| 252 'VKernElement': 'vkern', | 225 'SVGPatternElement': 'pattern', |
| 226 'SVGPolygonElement': 'polygon', |
| 227 'SVGPolylineElement': 'polyline', |
| 228 'SVGRadialGradientElement': 'radialGradient', |
| 229 'SVGRectElement': 'rect', |
| 230 'SVGScriptElement': 'script', |
| 231 'SVGSetElement': 'set', |
| 232 'SVGStopElement': 'stop', |
| 233 'SVGStyleElement': 'style', |
| 234 'SVGSwitchElement': 'switch', |
| 235 'SVGSymbolElement': 'symbol', |
| 236 'SVGTextElement': 'text', |
| 237 'SVGTitleElement': 'title', |
| 238 'SVGTRefElement': 'tref', |
| 239 'SVGTSpanElement': 'tspan', |
| 240 'SVGUseElement': 'use', |
| 241 'SVGViewElement': 'view', |
| 242 'SVGVKernElement': 'vkern', |
| 253 } | 243 } |
| 254 | 244 |
| 255 _element_constructors = { | 245 _element_constructors = { |
| 256 'html': _html_element_constructors, | 246 'html': _html_element_constructors, |
| 257 'indexed_db': {}, | 247 'indexed_db': {}, |
| 258 'svg': _svg_element_constructors, | 248 'svg': _svg_element_constructors, |
| 259 'web_audio': {}, | 249 'web_audio': {}, |
| 260 } | 250 } |
| 261 | 251 |
| 262 _factory_ctr_strings = { | 252 _factory_ctr_strings = { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 287 return [] | 277 return [] |
| 288 infos = element_constructors[typename] | 278 infos = element_constructors[typename] |
| 289 if isinstance(infos, str): | 279 if isinstance(infos, str): |
| 290 infos = ElementConstructorInfo(tag=infos, | 280 infos = ElementConstructorInfo(tag=infos, |
| 291 factory_provider_name=factory_provider_name) | 281 factory_provider_name=factory_provider_name) |
| 292 if not isinstance(infos, list): | 282 if not isinstance(infos, list): |
| 293 infos = [infos] | 283 infos = [infos] |
| 294 return infos | 284 return infos |
| 295 | 285 |
| 296 # ------------------------------------------------------------------------------ | 286 # ------------------------------------------------------------------------------ |
| 287 def SvgSupportStr(tagName): |
| 288 return 'Svg%s' % ElemSupportStr(tagName) |
| 289 |
| 290 def ElemSupportStr(tagName): |
| 291 return "Element.isTagSupported('%s')" % tagName |
| 292 |
| 293 _js_support_checks_basic_element = [ |
| 294 'HTMLContentElement', |
| 295 'HTMLDataListElement', |
| 296 'HTMLDetailsElement', |
| 297 'HTMLEmbedElement', |
| 298 'HTMLMeterElement', |
| 299 'HTMLObjectElement', |
| 300 'HTMLOutputElement', |
| 301 'HTMLProgressElement', |
| 302 'HTMLTrackElement', |
| 303 ] |
| 304 |
| 305 _js_support_checks_additional_element = [ |
| 306 # IE creates keygen as Block elements |
| 307 'HTMLKeygenElement', |
| 308 'SVGAltGlyphElement', |
| 309 'SVGAnimateElement', |
| 310 'SVGAnimateMotionElement', |
| 311 'SVGAnimateTransformElement', |
| 312 'SVGCursorElement', |
| 313 'SVGFEBlendElement', |
| 314 'SVGFEColorMatrixElement', |
| 315 'SVGFEComponentTransferElement', |
| 316 'SVGFEConvolveMatrixElement', |
| 317 'SVGFEDiffuseLightingElement', |
| 318 'SVGFEDisplacementMapElement', |
| 319 'SVGFEDistantLightElement', |
| 320 'SVGFEFloodElement', |
| 321 'SVGFEFuncAElement', |
| 322 'SVGFEFuncBElement', |
| 323 'SVGFEFuncGElement', |
| 324 'SVGFEFuncRElement', |
| 325 'SVGFEGaussianBlurElement', |
| 326 'SVGFEImageElement', |
| 327 'SVGFEMergeElement', |
| 328 'SVGFEMergeNodeElement', |
| 329 'SVGFEMorphology', |
| 330 'SVGFEOffsetElement', |
| 331 'SVGFEPointLightElement', |
| 332 'SVGFESpecularLightingElement', |
| 333 'SVGFESpotLightElement', |
| 334 'SVGFETileElement', |
| 335 'SVGFETurbulenceElement', |
| 336 'SVGFilterElement', |
| 337 'SVGForeignObjectElement', |
| 338 'SVGSetElement', |
| 339 ] |
| 340 |
| 341 js_support_checks = dict({ |
| 342 'ArrayBuffer': "JS('bool', 'typeof window.ArrayBuffer != \"undefined\"')", |
| 343 'DOMApplicationCache': "JS('bool', '!!(window.applicationCache)')", |
| 344 'DOMFileSystem': "JS('bool', '!!(window.webkitRequestFileSystem)')", |
| 345 'HashChangeEvent': "Event._isTypeSupported('HashChangeEvent')", |
| 346 'HTMLShadowElement': ElemSupportStr('shadow'), |
| 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 'SVGStylable': ('supported(SVGElement element)', |
| 361 "JS('bool', '#.getPresentationAttribute !== undefined', element)"), |
| 362 'WebSocket': "JS('bool', 'typeof window.WebSocket != \"undefined\"')", |
| 363 }.items() + |
| 364 dict((key, |
| 365 SvgSupportStr(_svg_element_constructors[key]) if key.startswith('SVG') |
| 366 else ElemSupportStr(_html_element_constructors[key])) for key in |
| 367 _js_support_checks_basic_element + |
| 368 _js_support_checks_additional_element).items()) |
| 369 # ------------------------------------------------------------------------------ |
| 297 | 370 |
| 298 class HtmlDartInterfaceGenerator(object): | 371 class HtmlDartInterfaceGenerator(object): |
| 299 """Generates dart interface and implementation for the DOM IDL interface.""" | 372 """Generates dart interface and implementation for the DOM IDL interface.""" |
| 300 | 373 |
| 301 def __init__(self, options, library_emitter, event_generator, interface, | 374 def __init__(self, options, library_emitter, event_generator, interface, |
| 302 backend): | 375 backend): |
| 303 self._renamer = options.renamer | 376 self._renamer = options.renamer |
| 304 self._database = options.database | 377 self._database = options.database |
| 305 self._template_loader = options.templates | 378 self._template_loader = options.templates |
| 306 self._type_registry = options.type_registry | 379 self._type_registry = options.type_registry |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 if interface_name in _static_classes: | 418 if interface_name in _static_classes: |
| 346 constructor_info = None | 419 constructor_info = None |
| 347 else: | 420 else: |
| 348 constructor_info = AnalyzeConstructor(self._interface) | 421 constructor_info = AnalyzeConstructor(self._interface) |
| 349 if constructor_info: | 422 if constructor_info: |
| 350 constructors.append(constructor_info) | 423 constructors.append(constructor_info) |
| 351 # TODO(antonm): consider removing it later. | 424 # TODO(antonm): consider removing it later. |
| 352 factory_provider = interface_name | 425 factory_provider = interface_name |
| 353 | 426 |
| 354 # HTML Elements and SVG Elements have convenience constructors. | 427 # HTML Elements and SVG Elements have convenience constructors. |
| 355 infos = ElementConstructorInfos(interface_name, | 428 infos = ElementConstructorInfos(self._interface.id, |
| 356 _element_constructors[self._library_name], factory_provider_name= | 429 _element_constructors[self._library_name], factory_provider_name= |
| 357 _factory_ctr_strings[self._library_name]['provider_name']) | 430 _factory_ctr_strings[self._library_name]['provider_name']) |
| 358 | 431 |
| 359 if infos: | 432 if infos: |
| 360 factory_constructor_name = _factory_ctr_strings[ | 433 factory_constructor_name = _factory_ctr_strings[ |
| 361 self._library_name]['constructor_name'] | 434 self._library_name]['constructor_name'] |
| 362 | 435 |
| 363 for info in infos: | 436 for info in infos: |
| 364 constructors.append(info.ConstructorInfo(self._interface.id)) | 437 constructors.append(info.ConstructorInfo(self._interface.id)) |
| 365 if factory_provider: | 438 if factory_provider: |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 def StartInterface(self, members_emitter): | 576 def StartInterface(self, members_emitter): |
| 504 self._members_emitter = members_emitter | 577 self._members_emitter = members_emitter |
| 505 | 578 |
| 506 def FinishInterface(self): | 579 def FinishInterface(self): |
| 507 pass | 580 pass |
| 508 | 581 |
| 509 def HasSupportCheck(self): | 582 def HasSupportCheck(self): |
| 510 return self._interface.doc_js_name in js_support_checks | 583 return self._interface.doc_js_name in js_support_checks |
| 511 | 584 |
| 512 def GetSupportCheck(self): | 585 def GetSupportCheck(self): |
| 586 """Return a tuple of the support check function signature and the support |
| 587 test itself. If no parameters are supplied, we assume the default.""" |
| 588 if self._interface.doc_js_name in _js_support_checks_additional_element: |
| 589 if self._interface.doc_js_name in _svg_element_constructors: |
| 590 lib_prefix = 'Svg' |
| 591 constructors = _svg_element_constructors |
| 592 else: |
| 593 lib_prefix = '' |
| 594 constructors = _html_element_constructors |
| 595 return (js_support_checks.get(self._interface.doc_js_name) + |
| 596 " && (new %sElement.tag('%s') is %s)" % (lib_prefix, |
| 597 constructors[self._interface.doc_js_name], |
| 598 self._renamer.RenameInterface(self._interface))) |
| 513 return js_support_checks.get(self._interface.doc_js_name) | 599 return js_support_checks.get(self._interface.doc_js_name) |
| 514 | 600 |
| 515 def EmitStaticFactory(self, constructor_info): | 601 def EmitStaticFactory(self, constructor_info): |
| 516 WITH_CUSTOM_STATIC_FACTORY = [ | 602 WITH_CUSTOM_STATIC_FACTORY = [ |
| 517 'AudioContext', | 603 'AudioContext', |
| 518 'Blob', | 604 'Blob', |
| 519 'MutationObserver', | 605 'MutationObserver', |
| 520 'SpeechRecognition', | 606 'SpeechRecognition', |
| 521 ] | 607 ] |
| 522 | 608 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 for library_name in libraries: | 1118 for library_name in libraries: |
| 1033 self._libraries[library_name] = DartLibrary( | 1119 self._libraries[library_name] = DartLibrary( |
| 1034 library_name, template_loader, library_type, output_dir) | 1120 library_name, template_loader, library_type, output_dir) |
| 1035 | 1121 |
| 1036 def AddFile(self, basename, library_name, path): | 1122 def AddFile(self, basename, library_name, path): |
| 1037 self._libraries[library_name].AddFile(path) | 1123 self._libraries[library_name].AddFile(path) |
| 1038 | 1124 |
| 1039 def Emit(self, emitter, auxiliary_dir): | 1125 def Emit(self, emitter, auxiliary_dir): |
| 1040 for lib in self._libraries.values(): | 1126 for lib in self._libraries.values(): |
| 1041 lib.Emit(emitter, auxiliary_dir) | 1127 lib.Emit(emitter, auxiliary_dir) |
| OLD | NEW |