diff --git a/content/xslt/src/xpath/nsXPathEvaluator.h b/content/xslt/src/xpath/nsXPathEvaluator.h index 54d40a101e1c..58d8be7c38d7 100644 --- a/content/xslt/src/xpath/nsXPathEvaluator.h +++ b/content/xslt/src/xpath/nsXPathEvaluator.h @@ -77,6 +77,12 @@ private: nsRefPtr mRecycler; }; +inline nsISupports* +ToSupports(nsXPathEvaluator* e) +{ + return static_cast(e); +} + /* d0a75e02-b5e7-11d5-a7f2-df109fb8a1fc */ #define TRANSFORMIIX_XPATH_EVALUATOR_CID \ { 0xd0a75e02, 0xb5e7, 0x11d5, { 0xa7, 0xf2, 0xdf, 0x10, 0x9f, 0xb8, 0xa1, 0xfc } } diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 4d513300d155..a3d4f1958fce 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -1910,6 +1910,10 @@ def AssertInheritanceChain(descriptor): " reinterpret_cast<%s*>(aObject));\n" % (desc.nativeType, desc.nativeType)) iface = iface.parent + if descriptor.nativeOwnership == 'nsisupports': + asserts += ( + " MOZ_ASSERT(ToSupports(aObject) == \n" + " reinterpret_cast(aObject));\n") return asserts class CGWrapWithCacheMethod(CGAbstractMethod): @@ -1930,8 +1934,14 @@ class CGWrapWithCacheMethod(CGAbstractMethod): if self.descriptor.workers: return """ return aObject->GetJSObject();""" + if self.descriptor.nativeOwnership == 'nsisupports': + assertISupportsInheritance = ( + ' MOZ_ASSERT(reinterpret_cast(aObject) != aCache,\n' + ' "nsISupports must be on our primary inheritance chain");\n') + else: + assertISupportsInheritance = "" return """%s - +%s JSObject* parent = WrapNativeParent(aCx, aScope, aObject->GetParentObject()); if (!parent) { return NULL; @@ -1959,6 +1969,7 @@ class CGWrapWithCacheMethod(CGAbstractMethod): aCache->SetWrapper(obj); return obj;""" % (AssertInheritanceChain(self.descriptor), + assertISupportsInheritance, CreateBindingJSObject(self.descriptor, "parent"), InitUnforgeableProperties(self.descriptor, self.properties))