Index: client/dom/scripts/systemhtml.py |
diff --git a/client/dom/scripts/systemhtml.py b/client/dom/scripts/systemhtml.py |
index 4c4945780abf44ed016d8882e35531a62661add9..da6de23275d40a85edcea95a266fbea98e78a4e9 100644 |
--- a/client/dom/scripts/systemhtml.py |
+++ b/client/dom/scripts/systemhtml.py |
@@ -383,6 +383,11 @@ _html_event_names = { |
'webkitTransitionEnd': 'transitionEnd' |
} |
+# These classes require an explicit declaration for the "on" method even though |
+# they don't declare any unique events, because the concrete class hierarchy |
+# doesn't match the interface hierarchy. |
+_html_explicit_event_classes = set(['DocumentFragment']) |
+ |
def _OnAttributeToEventName(on_method): |
event_name = on_method.id[2:] |
if event_name in _on_attribute_to_event_name_mapping: |
@@ -496,6 +501,14 @@ class HtmlSystemShared(object): |
def _ImplClassName(self, type_name): |
return '_' + type_name + 'Impl' |
+ def GetEventAttributes(self, interface): |
+ events = set([attr for attr in interface.attributes |
+ if self._generator._IsEventAttribute(interface, attr)]) |
+ |
+ # Hack to generate no-op Element events for DocumentFragment. |
Jacob
2012/03/07 23:24:05
this comment can now be removed.
nweiz
2012/03/08 01:03:51
Done.
|
+ if events or interface.id in _html_explicit_event_classes: |
+ return events |
+ |
class HtmlSystem(System): |
def __init__(self, templates, database, emitters, output_dir, generator): |
@@ -628,6 +641,9 @@ class HtmlDartInterfaceGenerator(DartInterfaceGenerator): |
CTOR=self._interface.id, |
TYPE=DartType(element_type)) |
+ events = self._shared.GetEventAttributes(self._interface) |
+ if events != None: self.AddEventAttributes(events) |
Jacob
2012/03/07 23:24:05
I believe we're using the style of placing the if
nweiz
2012/03/08 01:03:51
Done.
|
+ |
def AddAttribute(self, getter, setter): |
html_getter_name = self._shared.RenameInHtmlLibrary( |
self._interface, getter.id, 'get:') |
@@ -758,6 +774,9 @@ class HtmlFrogClassGenerator(FrogInterfaceGenerator): |
if constructor_info: |
self._EmitFactoryProvider(interface_name, constructor_info) |
+ events = self._shared.GetEventAttributes(interface) |
+ if events != None: self.AddEventAttributes(events) |
Jacob
2012/03/07 23:24:05
why not just
if events:
self.AddEventAttributes(
nweiz
2012/03/08 01:03:51
Because we want to run AddEventAttributes even if
Jacob
2012/03/08 18:38:09
same comment as above for all cases where == set()
|
+ |
def _EmitFactoryProvider(self, interface_name, constructor_info): |
template_file = 'factoryprovider_%s.darttemplate' % interface_name |
template = self._system._templates.TryLoad(template_file) |
@@ -1237,6 +1256,9 @@ class HtmlDartiumInterfaceGenerator(object): |
if constructor_info: |
self._EmitFactoryProvider(interface_name, constructor_info) |
+ events = self._shared.GetEventAttributes(self._interface) |
+ if events != None: self.AddEventAttributes(events) |
+ |
def _EmitFactoryProvider(self, interface_name, constructor_info): |
template_file = 'factoryprovider_%s.darttemplate' % interface_name |
template = self._system._templates.TryLoad(template_file) |