From f1efa94fe42e923c5fbd3b3bd3674ce299771ec1 Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Sun, 23 Jan 2000 06:00:11 +0000 Subject: [PATCH] Added the ability to GetInterface to nsIDOMWindow from an nsIDocShell. Changed a couple of AddRef and Release calls to use the macros. git-svn-id: svn://10.0.0.236/trunk@58431 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsDocShell.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 772c672eba2..820ebc3dcb1 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -38,6 +38,7 @@ #include "nsIMarkupDocumentViewer.h" #include "nsXPIDLString.h" #include "nsIChromeEventHandler.h" +#include "nsIDOMWindow.h" #ifdef XXX_NS_DEBUG // XXX: we'll need a logging facility for debugging #define WEB_TRACE(_bit,_args) \ @@ -82,8 +83,7 @@ nsDocShell::~nsDocShell() if(mContentListener) { mContentListener->DocShell(nsnull); - mContentListener->Release(); - mContentListener = nsnull; + NS_RELEASE(mContentListener); } } @@ -1408,9 +1408,16 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID& aIID, void** aSink) if(aIID.Equals(NS_GET_IID(nsIURIContentListener)) && NS_SUCCEEDED(EnsureContentListener())) *aSink = mContentListener; - if(aIID.Equals(NS_GET_IID(nsIScriptGlobalObject)) && + else if(aIID.Equals(NS_GET_IID(nsIScriptGlobalObject)) && NS_SUCCEEDED(EnsureScriptEnvironment())) *aSink = mScriptGlobal; + else if(aIID.Equals(NS_GET_IID(nsIDOMWindow)) && + NS_SUCCEEDED(EnsureScriptEnvironment())) + { + NS_ENSURE_SUCCESS(mScriptGlobal->QueryInterface(NS_GET_IID(nsIDOMWindow), + aSink), NS_ERROR_FAILURE); + return NS_OK; + } else return QueryInterface(aIID, aSink); @@ -1628,7 +1635,7 @@ nsresult nsDocShell::EnsureContentListener() mContentListener = new nsDSURIContentListener(); NS_ENSURE_TRUE(mContentListener, NS_ERROR_OUT_OF_MEMORY); - mContentListener->AddRef(); + NS_ADDREF(mContentListener); mContentListener->DocShell(this); return NS_OK;