diff --git a/mozilla/content/xtf/src/nsXTFElementWrapper.cpp b/mozilla/content/xtf/src/nsXTFElementWrapper.cpp index 0ea1bb32289..7f7ca6f0d51 100644 --- a/mozilla/content/xtf/src/nsXTFElementWrapper.cpp +++ b/mozilla/content/xtf/src/nsXTFElementWrapper.cpp @@ -95,12 +95,16 @@ nsXTFElementWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr) else if (NS_SUCCEEDED(rv = nsXTFElementWrapperBase::QueryInterface(aIID, aInstancePtr))) { return rv; } - else if (AggregatesInterface(aIID)) { -#ifdef DEBUG -// printf("nsXTFElementWrapper::QueryInterface(): creating aggregation tearoff\n"); -#endif - return NS_NewXTFInterfaceAggregator(aIID, GetXTFElement(), (nsIContent*)this, - (nsISupports**)aInstancePtr); + else { + // try to get get the interface from our wrapped element: + void *innerPtr = nsnull; + QueryInterfaceInner(aIID, &innerPtr); + + if (innerPtr) + return NS_NewXTFInterfaceAggregator(aIID, + NS_STATIC_CAST(nsISupports*, innerPtr), + NS_STATIC_CAST(nsIContent*, this), + aInstancePtr); } return NS_ERROR_NO_INTERFACE; @@ -542,15 +546,14 @@ nsXTFElementWrapper::SetNotificationMask(PRUint32 aNotificationMask) //---------------------------------------------------------------------- // implementation helpers: PRBool -nsXTFElementWrapper::AggregatesInterface(REFNSIID aIID) +nsXTFElementWrapper::QueryInterfaceInner(REFNSIID aIID, void** result) { // We must ensure that the inner element has a distinct xpconnect // identity, so we mustn't aggregate nsIXPConnectWrappedJS: if (aIID.Equals(NS_GET_IID(nsIXPConnectWrappedJS))) return PR_FALSE; - nsCOMPtr inst; - GetXTFElement()->QueryInterface(aIID, getter_AddRefs(inst)); - return (inst!=nsnull); + GetXTFElement()->QueryInterface(aIID, result); + return (*result!=nsnull); } PRBool diff --git a/mozilla/content/xtf/src/nsXTFElementWrapper.h b/mozilla/content/xtf/src/nsXTFElementWrapper.h index 5eb843181f3..2b638644352 100644 --- a/mozilla/content/xtf/src/nsXTFElementWrapper.h +++ b/mozilla/content/xtf/src/nsXTFElementWrapper.h @@ -120,7 +120,7 @@ protected: virtual nsIXTFElement *GetXTFElement() const = 0; // implementation helpers: - PRBool AggregatesInterface(REFNSIID aIID); + PRBool QueryInterfaceInner(REFNSIID aIID, void** result); PRBool HandledByInner(nsIAtom* attr) const; diff --git a/mozilla/content/xtf/src/nsXTFInterfaceAggregator.cpp b/mozilla/content/xtf/src/nsXTFInterfaceAggregator.cpp index 8d1cd9b0a9d..07f168e155e 100644 --- a/mozilla/content/xtf/src/nsXTFInterfaceAggregator.cpp +++ b/mozilla/content/xtf/src/nsXTFInterfaceAggregator.cpp @@ -54,7 +54,7 @@ protected: NS_NewXTFInterfaceAggregator(const nsIID& iid, nsISupports* inner, nsISupports* outer, - nsISupports** result); + void** result); nsXTFInterfaceAggregator(const nsIID& iid, nsISupports* inner, @@ -84,12 +84,12 @@ private: nsXTFInterfaceAggregator::nsXTFInterfaceAggregator(const nsIID& iid, nsISupports* inner, nsISupports* outer) - : mOuter(outer), mIID(iid) + : mInner(inner), mOuter(outer), mIID(iid) { #ifdef DEBUG // printf("nsXTFInterfaceAggregator CTOR\n"); #endif - inner->QueryInterface(iid, (void**)&mInner); + mInner->AddRef(); mOuter->AddRef(); } @@ -106,13 +106,13 @@ nsresult NS_NewXTFInterfaceAggregator(const nsIID& iid, nsISupports* inner, nsISupports* outer, - nsISupports** aResult){ + void** aResult){ NS_PRECONDITION(aResult != nsnull, "null ptr"); if (!aResult) return NS_ERROR_NULL_POINTER; nsXTFInterfaceAggregator* result = new nsXTFInterfaceAggregator(iid,inner,outer); - if (! result) + if (!result) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(result); diff --git a/mozilla/content/xtf/src/nsXTFInterfaceAggregator.h b/mozilla/content/xtf/src/nsXTFInterfaceAggregator.h index 624b5bfaafa..06f0a125382 100644 --- a/mozilla/content/xtf/src/nsXTFInterfaceAggregator.h +++ b/mozilla/content/xtf/src/nsXTFInterfaceAggregator.h @@ -43,7 +43,7 @@ nsresult NS_NewXTFInterfaceAggregator(const nsIID& iid, nsISupports* inner, nsISupports* outer, - nsISupports** result); + void** result); #endif // __NS_XTFINTERFACEAGGREGATOR_H__