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

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

Issue 2705213003: Refined types for most HtmlElement factory constructors (Closed)
Patch Set: Created 3 years, 10 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 | « tools/dom/scripts/htmldartgenerator.py ('k') | tools/dom/scripts/systemnative.py » ('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 4fc7e6ef772e08d4c1f5fd78f8fcd090a2266f70..dc1d79e435d84c693f375725718513460de22b6e 100644
--- a/tools/dom/scripts/systemhtml.py
+++ b/tools/dom/scripts/systemhtml.py
@@ -463,6 +463,19 @@ js_support_checks = dict({
else ElemSupportStr(_html_element_constructors[key])) for key in
_js_support_checks_basic_element_with_constructors +
_js_support_checks_additional_element).items())
+
+
+# JavaScript element class names of elements for which createElement does not
+# always return exactly the right element, either because it might not be
+# supported, or some browser does something weird.
+_js_unreliable_element_factories = set(
+ _js_support_checks_basic_element_with_constructors +
+ _js_support_checks_additional_element +
+ [
+ 'HTMLEmbedElement',
+ 'HTMLObjectElement',
+ ])
+
# ------------------------------------------------------------------------------
class HtmlDartInterfaceGenerator(object):
@@ -804,6 +817,26 @@ class Dart2JSBackend(HtmlDartGenerator):
# Custom factory will be taken from the template.
return self._interface.doc_js_name in _js_custom_constructors
+ def MakeFactoryCall(self, factory, method, arguments, constructor_info):
+ if factory is 'document' and method is 'createElement' \
+ and not ',' in arguments \
+ and not self._HasUnreliableFactoryConstructor():
+ return emitter.Format(
+ "JS('returns:$INTERFACE_NAME;creates:$INTERFACE_NAME;new:true',"
+ " '#.$METHOD(#)', $FACTORY, $ARGUMENTS)",
+ INTERFACE_NAME=self._interface_type_info.interface_name(),
+ FACTORY=factory,
+ METHOD=method,
+ ARGUMENTS=arguments)
+ return emitter.Format(
+ '$FACTORY.$METHOD($ARGUMENTS)',
+ FACTORY=factory,
+ METHOD=method,
+ ARGUMENTS=arguments)
+
+ def _HasUnreliableFactoryConstructor(self):
+ return self._interface.doc_js_name in _js_unreliable_element_factories
+
def IsConstructorArgumentOptional(self, argument):
return argument.optional
« no previous file with comments | « tools/dom/scripts/htmldartgenerator.py ('k') | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698