Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Unified Diff: Source/build/scripts/make_element_factory.py

Issue 35423004: Move SVGNames to Python (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/build/scripts/make_element_factory.py
diff --git a/Source/build/scripts/make_element_factory.py b/Source/build/scripts/make_element_factory.py
index b9600cbf7177340a64a77c999c72294b098718c5..6bf636219e760f143482c28f352a4aa7364e29a3 100755
--- a/Source/build/scripts/make_element_factory.py
+++ b/Source/build/scripts/make_element_factory.py
@@ -35,7 +35,6 @@ import name_utilities
from make_qualified_names import MakeQualifiedNamesWriter
-
def _interface(tag):
if tag['interfaceName']:
return tag['interfaceName']
@@ -43,22 +42,26 @@ def _interface(tag):
# FIXME: We shouldn't hard-code HTML here.
if name == 'HTML':
name = 'Html'
- return 'HTML%sElement' % name
+ dash = name.find('-')
+ while dash != -1:
+ name = name[:dash] + name[dash + 1].upper() + name[dash + 2:]
+ dash = name.find('-')
+ return '%sElement' % name
def _js_interface(tag):
- if tag['JSInterfaceName']:
- return tag['JSInterfaceName']
+ if tag['useDefaultJSInterface']:
+ return 'Element'
return _interface(tag)
def _has_js_interface(tag):
- return not tag['mapToTagName'] and not tag['noConstructor'] and _js_interface(tag) != 'HTMLElement'
+ return not tag['mapToTagName'] and not tag['noConstructor'] and _js_interface(tag) != 'Element'
class MakeElementFactoryWriter(MakeQualifiedNamesWriter):
defaults = dict(MakeQualifiedNamesWriter.default_parameters, **{
- 'JSInterfaceName': None,
+ 'useDefaultJSInterface': None,
'constructorNeedsCreatedByParser': None,
'constructorNeedsFormElement': None,
'contextConditional': None,
@@ -68,7 +71,8 @@ class MakeElementFactoryWriter(MakeQualifiedNamesWriter):
'wrapperOnlyIfMediaIsAvailable': None,
})
default_parameters = dict(MakeQualifiedNamesWriter.default_parameters, **{
- 'fallbackInterfaceName': None,
+ 'fallbackInterfaceName': '',
+ 'fallbackJSInterfaceName': '',
})
filters = dict(MakeQualifiedNamesWriter.filters, **{
'interface': _interface,
@@ -89,11 +93,15 @@ class MakeElementFactoryWriter(MakeQualifiedNamesWriter):
('V8' + self.namespace + 'ElementWrapperFactory.cpp'): self.generate_wrapper_factory_implementation,
})
+ fallback_interface = self.tags_in_file.parameters['fallbackInterfaceName'].strip('"')
+ fallback_js_interface = self.tags_in_file.parameters['fallbackJSInterfaceName'].strip('"') or fallback_interface
+
for tag in self._template_context['tags']:
tag['js_interface'] = _js_interface(tag) if _has_js_interface(tag) else None
self._template_context.update({
- 'fallback_interface': self.tags_in_file.parameters['fallbackInterfaceName'].strip('"'),
+ 'fallback_interface': fallback_interface,
+ 'fallback_js_interface': fallback_js_interface,
})
@template_expander.use_jinja('ElementFactory.h.tmpl', filters=filters)
« no previous file with comments | « no previous file | Source/build/scripts/make_qualified_names.py » ('j') | Source/build/scripts/templates/ElementFactory.cpp.tmpl » ('J')

Powered by Google App Engine
This is Rietveld 408576698