Chromium Code Reviews| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 'Window.document', | 59 'Window.document', |
| 60 'Window.indexedDB', | 60 'Window.indexedDB', |
| 61 'Window.location', | 61 'Window.location', |
| 62 'Window.open', | 62 'Window.open', |
| 63 'Window.requestAnimationFrame', | 63 'Window.requestAnimationFrame', |
| 64 'Window.webkitCancelAnimationFrame', | 64 'Window.webkitCancelAnimationFrame', |
| 65 'Window.webkitRequestAnimationFrame', | 65 'Window.webkitRequestAnimationFrame', |
| 66 'WorkerContext.indexedDB', | 66 'WorkerContext.indexedDB', |
| 67 ]) | 67 ]) |
| 68 | 68 |
| 69 js_support_checks = { | |
| 70 'HTMLContentElement': "Element.isTagSupported('content')", | |
| 71 'HTMLDataListElement': "Element.isTagSupported('datalist')", | |
| 72 'HTMLDetailsElement': "Element.isTagSupported('details')", | |
| 73 'HTMLEmbedElement': "Element.isTagSupported('embed')", | |
| 74 # IE creates keygen as Block elements | |
| 75 'HTMLKeygenElement': "Element.isTagSupported('keygen') " | |
| 76 "&& (new Element.tag('keygen') is KeygenElement)", | |
|
Emily Fortuna
2012/12/27 23:06:49
can we programmatically determine for which classe
blois
2012/12/28 00:43:27
isTagSupported checks if the browser treats it as
| |
| 77 'HTMLMarqueeElement': "Element.isTagSupported('marquee')" | |
| 78 "&& (new Element.tag('marquee') is MarqueeElement)", | |
| 79 'HTMLMeterElement': "Element.isTagSupported('meter')", | |
| 80 'HTMLObjectElement': "Element.isTagSupported('object')", | |
| 81 'HTMLOutputElement': "Element.isTagSupported('output')", | |
| 82 'HTMLProgressElement': "Element.isTagSupported('progress')", | |
| 83 'HTMLTrackElement': "Element.isTagSupported('track')", | |
| 84 } | |
| 69 | 85 |
| 70 # Classes that offer only static methods, and therefore we should suppress | 86 # Classes that offer only static methods, and therefore we should suppress |
| 71 # constructor creation. | 87 # constructor creation. |
| 72 _static_classes = set(['Url']) | 88 _static_classes = set(['Url']) |
| 73 | 89 |
| 74 # Information for generating element constructors. | 90 # Information for generating element constructors. |
| 75 # | 91 # |
| 76 # TODO(sra): maybe remove all the argument complexity and use cascades. | 92 # TODO(sra): maybe remove all the argument complexity and use cascades. |
| 77 # | 93 # |
| 78 # var c = new CanvasElement(width: 100, height: 70); | 94 # var c = new CanvasElement(width: 100, height: 70); |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 CLASSNAME=self._interface_type_info.implementation_name(), | 399 CLASSNAME=self._interface_type_info.implementation_name(), |
| 384 EXTENDS=' extends %s' % base_class if base_class else '', | 400 EXTENDS=' extends %s' % base_class if base_class else '', |
| 385 IMPLEMENTS=implements_str, | 401 IMPLEMENTS=implements_str, |
| 386 DOMNAME=self._interface.doc_js_name, | 402 DOMNAME=self._interface.doc_js_name, |
| 387 NATIVESPEC=self._backend.NativeSpec()) | 403 NATIVESPEC=self._backend.NativeSpec()) |
| 388 self._backend.StartInterface(self._implementation_members_emitter) | 404 self._backend.StartInterface(self._implementation_members_emitter) |
| 389 self._backend.EmitHelpers(base_class) | 405 self._backend.EmitHelpers(base_class) |
| 390 self._backend.AddConstructors( | 406 self._backend.AddConstructors( |
| 391 constructors, factory_provider, factory_constructor_name) | 407 constructors, factory_provider, factory_constructor_name) |
| 392 | 408 |
| 409 self._backend.EmitSupportCheck() | |
| 410 | |
| 393 events_class_name = self._event_generator.ProcessInterface( | 411 events_class_name = self._event_generator.ProcessInterface( |
| 394 self._interface, interface_name, | 412 self._interface, interface_name, |
| 395 self._backend.CustomJSMembers(), | 413 self._backend.CustomJSMembers(), |
| 396 implementation_emitter) | 414 implementation_emitter) |
| 397 if events_class_name: | 415 if events_class_name: |
| 398 self._backend.EmitEventGetter(events_class_name) | 416 self._backend.EmitEventGetter(events_class_name) |
| 399 | 417 |
| 400 merged_interface = self._interface_type_info.merged_interface() | 418 merged_interface = self._interface_type_info.merged_interface() |
| 401 if merged_interface: | 419 if merged_interface: |
| 402 self._backend.AddMembers(self._database.GetInterface(merged_interface), | 420 self._backend.AddMembers(self._database.GetInterface(merged_interface), |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 self._interface.doc_js_name) | 480 self._interface.doc_js_name) |
| 463 return (self._template_loader.TryLoad(template_file) or | 481 return (self._template_loader.TryLoad(template_file) or |
| 464 self._template_loader.Load('dart2js_impl.darttemplate')) | 482 self._template_loader.Load('dart2js_impl.darttemplate')) |
| 465 | 483 |
| 466 def StartInterface(self, members_emitter): | 484 def StartInterface(self, members_emitter): |
| 467 self._members_emitter = members_emitter | 485 self._members_emitter = members_emitter |
| 468 | 486 |
| 469 def FinishInterface(self): | 487 def FinishInterface(self): |
| 470 pass | 488 pass |
| 471 | 489 |
| 490 def HasSupportCheck(self): | |
| 491 return self._interface.doc_js_name in js_support_checks | |
| 492 | |
| 493 def GetSupportCheck(self): | |
| 494 return js_support_checks.get(self._interface.doc_js_name) | |
| 495 | |
| 496 | |
|
Emily Fortuna
2012/12/27 23:06:49
remove extra newline
blois
2012/12/28 00:43:27
Done.
| |
| 472 def EmitStaticFactory(self, constructor_info): | 497 def EmitStaticFactory(self, constructor_info): |
| 473 arguments = constructor_info.ParametersAsArgumentList() | 498 arguments = constructor_info.ParametersAsArgumentList() |
| 474 if arguments: | 499 if arguments: |
| 475 arguments = ', ' + arguments | 500 arguments = ', ' + arguments |
| 476 self._members_emitter.Emit( | 501 self._members_emitter.Emit( |
| 477 " static $INTERFACE_NAME _create($PARAMETERS_DECLARATION) => JS(" | 502 " static $INTERFACE_NAME _create($PARAMETERS_DECLARATION) => JS(" |
| 478 "'$INTERFACE_NAME', " | 503 "'$INTERFACE_NAME', " |
| 479 "'new $CONSTRUCTOR_NAME($ARGUMENTS_PATTERN)'$ARGUMENTS);\n", | 504 "'new $CONSTRUCTOR_NAME($ARGUMENTS_PATTERN)'$ARGUMENTS);\n", |
| 480 INTERFACE_NAME=self._interface_type_info.interface_name(), | 505 INTERFACE_NAME=self._interface_type_info.interface_name(), |
| 481 PARAMETERS_DECLARATION=constructor_info.ParametersDeclaration( | 506 PARAMETERS_DECLARATION=constructor_info.ParametersDeclaration( |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1002 for library_name in libraries: | 1027 for library_name in libraries: |
| 1003 self._libraries[library_name] = DartLibrary( | 1028 self._libraries[library_name] = DartLibrary( |
| 1004 library_name, template_loader, library_type, output_dir) | 1029 library_name, template_loader, library_type, output_dir) |
| 1005 | 1030 |
| 1006 def AddFile(self, basename, library_name, path): | 1031 def AddFile(self, basename, library_name, path): |
| 1007 self._libraries[library_name].AddFile(path) | 1032 self._libraries[library_name].AddFile(path) |
| 1008 | 1033 |
| 1009 def Emit(self, emitter, auxiliary_dir): | 1034 def Emit(self, emitter, auxiliary_dir): |
| 1010 for lib in self._libraries.values(): | 1035 for lib in self._libraries.values(): |
| 1011 lib.Emit(emitter, auxiliary_dir) | 1036 lib.Emit(emitter, auxiliary_dir) |
| OLD | NEW |