Bug 972312 part 1. Generate virtual As*Event functions on WebIDL events so that we can easily go from an nsDOMEvent to the relevant event subtype. r=smaug
authorBoris Zbarsky <bzbarsky@mit.edu>
Sun, 23 Feb 2014 00:01:12 -0500
changeset 170408 8374817674559644752f4e72ee7f6413008e0596
parent 170407 cbacdf83f1fb944f36eb50bd7c1c9da488a7739f
child 170409 24aa8fa1f13adfd87ff4de5d4a668014571c9905
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerssmaug
bugs972312
milestone30.0a1
Bug 972312 part 1. Generate virtual As*Event functions on WebIDL events so that we can easily go from an nsDOMEvent to the relevant event subtype. r=smaug
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -11987,19 +11987,27 @@ class CGEventClass(CGBindingImplClass):
             "  ${nativeType}(mozilla::dom::EventTarget* aOwner);\n\n")
 
         baseDeclarations = string.Template(baseDeclarations).substitute(
             {
               "nativeType": self.descriptor.nativeType.split('::')[-1],
               "parentType": self.parentType
             })
 
-        CGClass.__init__(self, descriptor.nativeType.split('::')[-1],
+        className = descriptor.nativeType.split('::')[-1]
+        asConcreteTypeMethod = ClassMethod("As%s" % className,
+                                           "%s*" % className,
+                                           [],
+                                           virtual=True,
+                                           body="return this;",
+                                           breakAfterReturnDecl=" ")
+
+        CGClass.__init__(self, className,
                          bases=[ClassBase(self.parentType)],
-                         methods=self.methodDecls,
+                         methods=[asConcreteTypeMethod]+self.methodDecls,
                          members=members,
                          extradeclarations=baseDeclarations)
 
     def getWrapObjectBody(self):
         return "return %sBinding::Wrap(aCx, aScope, this);" % self.descriptor.name
 
     def implTraverse(self):
         retVal = ""