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

Unified Diff: tools/dom/scripts/systemhtml.py

Issue 18089011: Added named constructors to Element to construct common elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/scripts/systemhtml.py
diff --git a/tools/dom/scripts/systemhtml.py b/tools/dom/scripts/systemhtml.py
index 90d2610856e7cd158934610b771c677fd00cee79..f4ca952604084d69420660c013ef40216685c938 100644
--- a/tools/dom/scripts/systemhtml.py
+++ b/tools/dom/scripts/systemhtml.py
@@ -325,6 +325,43 @@ def ElementConstructorInfos(typename, element_constructors,
return infos
# ------------------------------------------------------------------------------
+
+_html_element_tags = [
+ # TODO(amouravski): add a custom factory constructor for h1..h6.
+ # TODO(amouravski): add a custom factory constructor for input
+ 'a',
+ 'article',
+ 'aside',
+ 'audio',
+ 'br',
+ 'canvas',
+ 'div',
+ 'footer',
+ 'header',
+ 'hr',
+ 'iframe',
+ 'img',
+ 'li',
+ 'nav',
+ 'ol',
+ 'option',
+ 'p',
+ 'pre',
+ 'section',
+ 'select',
+ 'span',
+ 'svg',
+ 'table',
+ 'td',
+ 'textarea',
+ 'th',
+ 'tr',
+ 'ul',
+ 'video',
+]
+
+
+# ------------------------------------------------------------------------------
def SvgSupportStr(tagName):
return 'Svg%s' % ElemSupportStr(tagName)
@@ -543,6 +580,22 @@ class HtmlDartInterfaceGenerator(object):
if self._renamer.ShouldSuppressInterface(self._interface):
class_modifiers = 'abstract '
+# additional_methods = 'asdasdas'
blois 2013/06/28 00:28:11 delete.
Andrei Mouravski 2013/06/28 19:19:21 Done.
+# if self._interface.id == 'HTMLElement':
+# additional_methods = ''.join(_ElementTagConstructors())
+
+ additional_methods = []
+ if self._interface.id in 'HTMLElement':
+ for tag in _html_element_tags:
+ method = (
+ "\n"
+ " /// Creates a new `<{0}>` element.\n"
blois 2013/06/28 00:28:11 Just put this into the template file.
Andrei Mouravski 2013/06/28 19:19:21 I don't understand. Do you mean inline all of the
+ " ///\n"
+ " /// This is identical to calling `new Element.tag({0})`.\n"
+ " factory Element.{0}() => new Element.tag({0});\n").format(tag)
+ additional_methods.append(method)
+ additional_str = ''.join(additional_methods)
+
self._implementation_members_emitter = implementation_emitter.Emit(
self._backend.ImplementationTemplate(),
LIBRARYNAME='dart.dom.%s' % self._library_name,
@@ -553,7 +606,8 @@ class HtmlDartInterfaceGenerator(object):
IMPLEMENTS=implements_str,
MIXINS=mixins_str,
DOMNAME=self._interface.doc_js_name,
- NATIVESPEC=self._backend.NativeSpec())
+ NATIVESPEC=self._backend.NativeSpec(),
+ ADDITIONAL_METHODS=additional_str)
self._backend.StartInterface(self._implementation_members_emitter)
self._backend.EmitHelpers(base_class)
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698