diff --git a/mozilla/docshell/base/nsDSURIContentListener.h b/mozilla/docshell/base/nsDSURIContentListener.h index 5da2549faaf..d52b5a651f9 100644 --- a/mozilla/docshell/base/nsDSURIContentListener.h +++ b/mozilla/docshell/base/nsDSURIContentListener.h @@ -27,15 +27,18 @@ #include "nsString.h" #include "nsIURIContentListener.h" #include "nsICategoryManager.h" +#include "nsWeakReference.h" class nsDocShell; -class nsDSURIContentListener : public nsIURIContentListener +class nsDSURIContentListener : + public nsIURIContentListener, + public nsSupportsWeakReference + { friend class nsDocShell; public: NS_DECL_ISUPPORTS - NS_DECL_NSIURICONTENTLISTENER nsresult Init(); @@ -50,7 +53,12 @@ protected: protected: nsDocShell* mDocShell; - nsIURIContentListener* mParentContentListener; // Weak Reference + // Store the parent listener in either of these depending on + // if supports weak references or not. Proper weak refs are + // preferred and encouraged! + nsWeakPtr mWeakParentContentListener; + nsIURIContentListener* mParentContentListener; + nsCOMPtr mCatMgr; }; diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 296aeaa700f..1b29fc7e680 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -587,7 +587,6 @@ nsWebShell::OnLinkClickSync(nsIContent *aContent, // throwing the click away. if (!uri && NS_SUCCEEDED(EnsureContentListener())) { - nsCOMPtr listener = do_QueryInterface(mContentListener); NS_ConvertUCS2toUTF8 spec(aURLSpec); PRBool abort = PR_FALSE; uri = do_CreateInstance(kSimpleURICID, &rv); @@ -598,7 +597,7 @@ nsWebShell::OnLinkClickSync(nsIContent *aContent, NS_ASSERTION(NS_SUCCEEDED(rv), "spec is invalid"); if (NS_SUCCEEDED(rv)) { - listener->OnStartURIOpen(uri, &abort); + mContentListener->OnStartURIOpen(uri, &abort); } } // We didn't load the URI, so we failed