From 4465f2b8b2091272eb45fad778b7296f3ea7feeb Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Mon, 15 Nov 1999 07:29:23 +0000 Subject: [PATCH] Changed references to nsIContentViewerContainer to nsISupports in the march to get rid of nsIContentViewerContainer. r=pavlov --- docshell/base/nsWebShell.cpp | 6 +- extensions/wallet/src/nsWalletService.cpp | 86 ++++++------------- layout/build/nsLayoutDLF.cpp | 34 ++++---- uriloader/base/nsDocLoader.cpp | 78 ++++++++--------- webshell/public/nsIDocStreamLoaderFactory.h | 3 +- webshell/public/nsIDocumentLoader.h | 10 +-- webshell/src/nsDocLoader.cpp | 78 ++++++++--------- webshell/src/nsWebShell.cpp | 6 +- widget/src/beos/nsMenuItem.cpp | 17 +--- widget/src/gtk/nsMenuItem.cpp | 16 +--- widget/src/mac/nsMenuItem.cpp | 13 +-- widget/src/motif/nsMenuItem.cpp | 1 - widget/src/os2/nsMenuItem.cpp | 13 +-- widget/src/photon/nsMenuItem.cpp | 14 +-- widget/src/qt/nsMenuItem.cpp | 18 +--- widget/src/windows/nsMenuItem.cpp | 13 +-- xpfe/appshell/src/nsWebShellWindow.cpp | 29 ++----- xpfe/appshell/src/nsXULCommand.cpp | 13 +-- xpfe/browser/src/nsBrowserInstance.cpp | 10 +-- .../directory/nsDirectoryViewer.cpp | 9 +- 20 files changed, 157 insertions(+), 310 deletions(-) diff --git a/docshell/base/nsWebShell.cpp b/docshell/base/nsWebShell.cpp index 637fed4e009..f8353db3d01 100644 --- a/docshell/base/nsWebShell.cpp +++ b/docshell/base/nsWebShell.cpp @@ -953,7 +953,7 @@ nsWebShell::Init(nsNativeWidget aNativeParent, } // Set the webshell as the default IContentViewerContainer for the loader... - mDocLoader->SetContainer(this); + mDocLoader->SetContainer(NS_STATIC_CAST(nsIContentViewerContainer*, this)); //Register ourselves as an observer for the new doc loader mDocLoader->AddObserver((nsIDocumentLoaderObserver*)this); @@ -1858,7 +1858,7 @@ nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc, nsIDOMElement *aRootNode) nsCOMPtr doc = do_QueryInterface(aDOMDoc); if (!doc) { return NS_ERROR_NULL_POINTER; } - NS_ENSURE_SUCCESS(docFactory->CreateInstanceForDocument(this, + NS_ENSURE_SUCCESS(docFactory->CreateInstanceForDocument(NS_STATIC_CAST(nsIContentViewerContainer*, this), doc, "view", getter_AddRefs(documentViewer)), @@ -2130,7 +2130,7 @@ nsWebShell::DoLoadURL(nsIURI * aUri, */ rv = mDocLoader->LoadDocument(aUri, // URL string aCommand, // Command - this, // Container + NS_STATIC_CAST(nsIContentViewerContainer*, this),// Container aPostDataStream, // Post Data nsnull, // Extra Info... aType, // reload type diff --git a/extensions/wallet/src/nsWalletService.cpp b/extensions/wallet/src/nsWalletService.cpp index 50a3f14cab4..cf56e464644 100644 --- a/extensions/wallet/src/nsWalletService.cpp +++ b/extensions/wallet/src/nsWalletService.cpp @@ -222,43 +222,29 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* ch nsIDocumentLoaderObserver * aObserver) { nsresult rv = NS_OK; - nsIContentViewerContainer *cont = nsnull; - nsIWebShell *ws = nsnull; if (aLoader == nsnull) { return rv; } - rv = aLoader->GetContainer(&cont); + nsCOMPtr cont; + rv = aLoader->GetContainer(getter_AddRefs(cont)); if (NS_FAILED(rv) || (cont == nsnull)) { return rv; } - rv = cont->QueryInterface(nsIWebShell::GetIID(), (void **)&ws); - if (NS_FAILED(rv) || (ws == nsnull)) { - NS_RELEASE(cont); - return rv; - } - nsIContentViewer* cv = nsnull; - rv = ws->GetContentViewer(&cv); + nsCOMPtr ws(do_QueryInterface(cont)); + NS_ENSURE_TRUE(ws, NS_ERROR_FAILURE); + + nsCOMPtr cv; + rv = ws->GetContentViewer(getter_AddRefs(cv)); if (NS_FAILED(rv) || (cv == nsnull)) { - NS_RELEASE(ws); - NS_RELEASE(cont); - return rv; - } - nsIDocumentViewer* docViewer = nsnull; - rv = cv->QueryInterface(nsIDocumentViewer::GetIID(), (void**) &docViewer); - if (NS_FAILED(rv) || (docViewer == nsnull)) { - NS_RELEASE(cv); - NS_RELEASE(ws); - NS_RELEASE(cont); return rv; } + nsCOMPtr docViewer(do_QueryInterface(cv)); + NS_ENSURE_TRUE(docViewer, NS_ERROR_FAILURE); + nsCOMPtr doc; rv = docViewer->GetDocument(*getter_AddRefs(doc)); if (NS_FAILED(rv) || (doc == nsnull)) { - NS_RELEASE(docViewer); - NS_RELEASE(cv); - NS_RELEASE(ws); - NS_RELEASE(cont); return rv; } @@ -279,25 +265,15 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* ch NS_IF_RELEASE(docURL); nsCRT::free(spec); - nsIDOMHTMLDocument *htmldoc = nsnull; - rv = doc->QueryInterface(kIDOMHTMLDocumentIID, (void**)&htmldoc); - if (NS_FAILED(rv) || (htmldoc == nsnull)) { - NS_RELEASE(docViewer); - NS_RELEASE(cv); - NS_RELEASE(ws); - NS_RELEASE(cont); + nsCOMPtr htmldoc(do_QueryInterface(doc)); + if (htmldoc == nsnull) { PR_Free(URLName); - return rv; + return NS_ERROR_FAILURE; } - nsIDOMHTMLCollection* forms = nsnull; - rv = htmldoc->GetForms(&forms); + nsCOMPtr forms; + rv = htmldoc->GetForms(getter_AddRefs(forms)); if (NS_FAILED(rv) || (forms == nsnull)) { - NS_RELEASE(htmldoc); - NS_RELEASE(docViewer); - NS_RELEASE(cv); - NS_RELEASE(ws); - NS_RELEASE(cont); PR_Free(URLName); return rv; } @@ -305,25 +281,22 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* ch PRUint32 numForms; forms->GetLength(&numForms); for (PRUint32 formX = 0; formX < numForms; formX++) { - nsIDOMNode* formNode = nsnull; - forms->Item(formX, &formNode); + nsCOMPtr formNode; + forms->Item(formX, getter_AddRefs(formNode)); if (nsnull != formNode) { - nsIDOMHTMLFormElement* formElement = nsnull; - rv = formNode->QueryInterface(kIDOMHTMLFormElementIID, (void**)&formElement); - if ((NS_SUCCEEDED(rv)) && (nsnull != formElement)) { - nsIDOMHTMLCollection* elements = nsnull; - rv = formElement->GetElements(&elements); + nsCOMPtr formElement(do_QueryInterface(formNode)); + if ((nsnull != formElement)) { + nsCOMPtr elements; + rv = formElement->GetElements(getter_AddRefs(elements)); if ((NS_SUCCEEDED(rv)) && (nsnull != elements)) { /* got to the form elements at long last */ PRUint32 numElements; elements->GetLength(&numElements); for (PRUint32 elementX = 0; elementX < numElements; elementX++) { - nsIDOMNode* elementNode = nsnull; - elements->Item(elementX, &elementNode); + nsCOMPtr elementNode; + elements->Item(elementX, getter_AddRefs(elementNode)); if (nsnull != elementNode) { - nsIDOMHTMLInputElement *inputElement = nsnull; - rv = elementNode->QueryInterface - (nsIDOMHTMLInputElement::GetIID(), (void**)&inputElement); + nsCOMPtr inputElement(do_QueryInterface(elementNode)); if ((NS_SUCCEEDED(rv)) && (nsnull != inputElement)) { nsAutoString type(""); rv = inputElement->GetType(type); @@ -347,25 +320,14 @@ nsWalletlibService::OnEndDocumentLoad(nsIDocumentLoader* aLoader, nsIChannel* ch } } } - NS_RELEASE(inputElement); } - NS_RELEASE(elementNode); } } - NS_RELEASE(elements); } - NS_RELEASE(formElement); } - NS_RELEASE(formNode); } } - NS_RELEASE(forms); - NS_RELEASE(htmldoc); - NS_RELEASE(docViewer); - NS_RELEASE(cv); - NS_RELEASE(ws); - NS_RELEASE(cont); PR_Free(URLName); return rv; } diff --git a/layout/build/nsLayoutDLF.cpp b/layout/build/nsLayoutDLF.cpp index 1c1fd387ca1..36c9b838906 100644 --- a/layout/build/nsLayoutDLF.cpp +++ b/layout/build/nsLayoutDLF.cpp @@ -36,6 +36,7 @@ #include "nsIXULContentSink.h" #include "nsIStreamLoadableDocument.h" #include "nsIDocStreamLoaderFactory.h" +#include "nsIContentViewerContainer.h" // Factory code for creating variations on html documents @@ -120,12 +121,12 @@ public: nsIChannel* aChannel, nsILoadGroup* aLoadGroup, const char* aContentType, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListener, nsIContentViewer** aDocViewer); - NS_IMETHOD CreateInstanceForDocument(nsIContentViewerContainer* aContainer, + NS_IMETHOD CreateInstanceForDocument(nsISupports* aContainer, nsIDocument* aDocument, const char *aCommand, nsIContentViewer** aDocViewerResult); @@ -134,7 +135,7 @@ public: NS_METHOD CreateInstance(nsIInputStream& aInputStream, const char* aContentType, const char* aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIContentViewer** aDocViewer); @@ -143,7 +144,7 @@ public: nsresult CreateDocument(const char* aCommand, nsIChannel* aChannel, nsILoadGroup* aLoadGroup, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, const nsCID& aDocumentCID, nsIStreamListener** aDocListener, nsIContentViewer** aDocViewer); @@ -152,14 +153,14 @@ public: nsIChannel* aChannel, nsILoadGroup* aLoadGroup, const char* aContentType, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListener, nsIContentViewer** aDocViewer); nsresult CreateXULDocumentFromStream(nsIInputStream& aXULStream, const char* aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIContentViewer** aDocViewer); @@ -225,7 +226,7 @@ nsLayoutDLF::CreateInstance(const char *aCommand, nsIChannel* aChannel, nsILoadGroup* aLoadGroup, const char* aContentType, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListener, nsIContentViewer** aDocViewer) @@ -293,7 +294,7 @@ nsLayoutDLF::CreateInstance(const char *aCommand, NS_IMETHODIMP -nsLayoutDLF::CreateInstanceForDocument(nsIContentViewerContainer* aContainer, +nsLayoutDLF::CreateInstanceForDocument(nsISupports* aContainer, nsIDocument* aDocument, const char *aCommand, nsIContentViewer** aDocViewerResult) @@ -321,7 +322,7 @@ nsresult nsLayoutDLF::CreateDocument(const char* aCommand, nsIChannel* aChannel, nsILoadGroup* aLoadGroup, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, const nsCID& aDocumentCID, nsIStreamListener** aDocListener, nsIContentViewer** aDocViewer) @@ -360,7 +361,8 @@ nsLayoutDLF::CreateDocument(const char* aCommand, // Initialize the document to begin loading the data. An // nsIStreamListener connected to the parser is returned in // aDocListener. - rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener); + nsCOMPtr container(do_QueryInterface(aContainer)); + rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, container, aDocListener); if (NS_FAILED(rv)) break; @@ -377,7 +379,7 @@ NS_IMETHODIMP nsLayoutDLF::CreateInstance(nsIInputStream& aInputStream, const char* aContentType, const char* aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIContentViewer** aDocViewer) @@ -429,7 +431,7 @@ nsLayoutDLF::CreateRDFDocument(const char* aCommand, nsIChannel* aChannel, nsILoadGroup* aLoadGroup, const char* aContentType, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListener, nsIContentViewer** aDocViewer) @@ -451,7 +453,8 @@ nsLayoutDLF::CreateRDFDocument(const char* aCommand, * An nsIStreamListener connected to the parser is returned in * aDocListener. */ - rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener); + nsCOMPtr container(do_QueryInterface(aContainer)); + rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, container, aDocListener); if (NS_SUCCEEDED(rv)) { /* * Bind the document to the Content Viewer... @@ -467,7 +470,7 @@ nsLayoutDLF::CreateRDFDocument(const char* aCommand, nsresult nsLayoutDLF::CreateXULDocumentFromStream(nsIInputStream& aXULStream, const char* aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIContentViewer** aDocViewer) { @@ -490,7 +493,8 @@ nsLayoutDLF::CreateXULDocumentFromStream(nsIInputStream& aXULStream, if ( NS_FAILED(status) ) break; - status = loader->LoadFromStream(aXULStream, aContainer, aCommand); + nsCOMPtr container(do_QueryInterface(aContainer)); + status = loader->LoadFromStream(aXULStream, container, aCommand); } while (0); diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index bf4c6850d61..4cdf75a6080 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -137,7 +137,7 @@ public: nsresult Init(nsDocLoaderImpl* aDocLoader, const char *aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo); NS_DECL_ISUPPORTS @@ -158,9 +158,9 @@ protected: protected: char* m_Command; - nsIContentViewerContainer* m_Container; - nsISupports* m_ExtraInfo; - nsIStreamListener* m_NextStream; + nsCOMPtr m_Container; + nsCOMPtr m_ExtraInfo; + nsCOMPtr m_NextStream; nsDocLoaderImpl* m_DocLoader; }; @@ -190,7 +190,7 @@ public: // nsIDocumentLoader interface NS_IMETHOD LoadDocument(nsIURI * aUri, const char *aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsIInputStream* aPostDataStream = nsnull, nsISupports* aExtraInfo = nsnull, nsLoadFlags aType = nsIChannel::LOAD_NORMAL, @@ -211,8 +211,8 @@ public: NS_IMETHOD AddObserver(nsIDocumentLoaderObserver *aObserver); NS_IMETHOD RemoveObserver(nsIDocumentLoaderObserver *aObserver); - NS_IMETHOD SetContainer(nsIContentViewerContainer* aContainer); - NS_IMETHOD GetContainer(nsIContentViewerContainer** aResult); + NS_IMETHOD SetContainer(nsISupports* aContainer); + NS_IMETHOD GetContainer(nsISupports** aResult); NS_IMETHOD GetContentViewerContainer(PRUint32 aDocumentID, nsIContentViewerContainer** aResult); NS_IMETHOD GetLoadGroup(nsILoadGroup** aResult); @@ -254,7 +254,7 @@ public: nsresult CreateContentViewer(const char *aCommand, nsIChannel* channel, const char* aContentType, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListener, nsIContentViewer** aDocViewer); @@ -274,7 +274,7 @@ protected: nsCOMPtr mDocumentChannel; // [OWNER] ???compare with document nsVoidArray mDocObservers; - nsIContentViewerContainer* mContainer; // [WEAK] it owns me! + nsISupports* mContainer; // [WEAK] it owns me! nsDocLoaderImpl* mParent; // [OWNER] but upside down ownership model // needs to be fixed*** @@ -426,7 +426,7 @@ nsresult nsDocLoaderImpl::CreateContentViewer(const char *aCommand, nsIChannel* channel, const char* aContentType, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListenerResult, nsIContentViewer** aDocViewerResult) @@ -452,11 +452,13 @@ nsDocLoaderImpl::CreateContentViewer(const char *aCommand, return rv; } + nsCOMPtr container(do_QueryInterface(aContainer)); + // Now create an instance of the content viewer rv = factory->CreateInstance(aCommand, channel, mLoadGroup, aContentType, - aContainer, + container, aExtraInfo, aDocListenerResult, aDocViewerResult); NS_RELEASE(factory); @@ -466,7 +468,7 @@ nsDocLoaderImpl::CreateContentViewer(const char *aCommand, NS_IMETHODIMP nsDocLoaderImpl::LoadDocument(nsIURI * aUri, const char* aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsIInputStream* aPostDataStream, nsISupports* aExtraInfo, nsLoadFlags aType, @@ -611,7 +613,7 @@ nsDocLoaderImpl::RemoveObserver(nsIDocumentLoaderObserver* aObserver) } NS_IMETHODIMP -nsDocLoaderImpl::SetContainer(nsIContentViewerContainer* aContainer) +nsDocLoaderImpl::SetContainer(nsISupports* aContainer) { // This is a weak reference... mContainer = aContainer; @@ -620,17 +622,14 @@ nsDocLoaderImpl::SetContainer(nsIContentViewerContainer* aContainer) } NS_IMETHODIMP -nsDocLoaderImpl::GetContainer(nsIContentViewerContainer** aResult) +nsDocLoaderImpl::GetContainer(nsISupports** aResult) { - nsresult rv = NS_OK; + NS_ENSURE_ARG_POINTER(aResult); - if (nsnull == aResult) { - rv = NS_ERROR_NULL_POINTER; - } else { - *aResult = mContainer; - NS_IF_ADDREF(*aResult); - } - return rv; + *aResult = mContainer; + NS_IF_ADDREF(*aResult); + + return NS_OK; } NS_IMETHODIMP @@ -957,29 +956,23 @@ nsDocumentBindInfo::nsDocumentBindInfo() NS_INIT_REFCNT(); m_Command = nsnull; - m_Container = nsnull; - m_ExtraInfo = nsnull; - m_NextStream = nsnull; m_DocLoader = nsnull; } nsresult nsDocumentBindInfo::Init(nsDocLoaderImpl* aDocLoader, const char *aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo) { - m_NextStream = nsnull; m_Command = (nsnull != aCommand) ? PL_strdup(aCommand) : nsnull; m_DocLoader = aDocLoader; NS_ADDREF(m_DocLoader); - m_Container = aContainer; - NS_IF_ADDREF(m_Container); + m_Container = aContainer; // This does an addref - m_ExtraInfo = aExtraInfo; - NS_IF_ADDREF(m_ExtraInfo); + m_ExtraInfo = aExtraInfo; // This does an addref return NS_OK; } @@ -992,9 +985,6 @@ nsDocumentBindInfo::~nsDocumentBindInfo() m_Command = nsnull; NS_RELEASE (m_DocLoader); - NS_IF_RELEASE(m_NextStream); - NS_IF_RELEASE(m_Container); - NS_IF_RELEASE(m_ExtraInfo); } /* @@ -1138,7 +1128,7 @@ nsDocumentBindInfo::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) aContentType, m_Container, m_ExtraInfo, - &m_NextStream, + getter_AddRefs(m_NextStream), &viewer); } else { rv = NS_ERROR_NULL_POINTER; @@ -1146,9 +1136,11 @@ nsDocumentBindInfo::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) if (NS_FAILED(rv)) { printf("DocLoaderFactory: Unable to create ContentViewer for command=%s, content-type=%s\n", m_Command ? m_Command : "(null)", aContentType); - if ( m_Container ) { + nsCOMPtr + cvContainer(do_QueryInterface(m_Container)); + if ( cvContainer ) { // Give content container a chance to do something with this URL. - rv = m_Container->HandleUnknownContentType( (nsIDocumentLoader*) m_DocLoader, channel, aContentType, m_Command ); + rv = cvContainer->HandleUnknownContentType( (nsIDocumentLoader*) m_DocLoader, channel, aContentType, m_Command ); } // Stop the binding. // This crashes on Unix/Mac... Stop(); @@ -1158,10 +1150,12 @@ nsDocumentBindInfo::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) /* * Give the document container the new viewer... */ - if (m_Container) { + nsCOMPtr + cvContainer(do_QueryInterface(m_Container)); + if (cvContainer) { viewer->SetContainer(m_Container); - rv = m_Container->Embed(viewer, m_Command, m_ExtraInfo); + rv = cvContainer->Embed(viewer, m_Command, m_ExtraInfo); if (NS_FAILED(rv)) { goto done; } @@ -1213,11 +1207,9 @@ NS_METHOD nsDocumentBindInfo::OnDataAvailable(nsIChannel* channel, nsISupports * * Currently this can happen if javascript loads a new URL * (via nsIWebShell::LoadURL) during the parse phase... */ - nsIStreamListener* listener = m_NextStream; + nsCOMPtr listener(m_NextStream); - NS_ADDREF(listener); rv = listener->OnDataAvailable(channel, ctxt, aStream, sourceOffset, aLength); - NS_RELEASE(listener); } else { rv = NS_BINDING_FAILED; } @@ -1261,7 +1253,7 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIChannel* channel, nsISupports *ct rv = m_NextStream->OnStopRequest(channel, ctxt, aStatus, aMsg); } - NS_IF_RELEASE(m_NextStream); + m_NextStream = nsnull; // Release our stream we are holding return rv; } diff --git a/webshell/public/nsIDocStreamLoaderFactory.h b/webshell/public/nsIDocStreamLoaderFactory.h index 65a9beb02bf..06700379937 100644 --- a/webshell/public/nsIDocStreamLoaderFactory.h +++ b/webshell/public/nsIDocStreamLoaderFactory.h @@ -30,7 +30,6 @@ class nsIInputStream; class nsIContentViewer; -class nsIContentViewerContainer; /* 9188bc80-f92e-11d2-81ef-0060083a0bcf */ #define NS_IDOCSTREAMLOADERFACTORY_IID \ @@ -44,7 +43,7 @@ public: NS_IMETHOD CreateInstance(nsIInputStream& aInputStream, const char* aContentType, const char* aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIContentViewer** aDocViewer) = 0; }; diff --git a/webshell/public/nsIDocumentLoader.h b/webshell/public/nsIDocumentLoader.h index fbf99e5ed68..f8e415fd3f5 100644 --- a/webshell/public/nsIDocumentLoader.h +++ b/webshell/public/nsIDocumentLoader.h @@ -70,12 +70,12 @@ public: nsIChannel* aChannel, nsILoadGroup* aLoadGroup, const char* aContentType, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListenerResult, nsIContentViewer** aDocViewerResult) = 0; - NS_IMETHOD CreateInstanceForDocument(nsIContentViewerContainer* aContainer, + NS_IMETHOD CreateInstanceForDocument(nsISupports* aContainer, nsIDocument* aDocument, const char *aCommand, nsIContentViewer** aDocViewerResult) = 0; @@ -99,7 +99,7 @@ public: NS_IMETHOD LoadDocument(nsIURI * aUri, const char* aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsIInputStream* aPostDataStream = nsnull, nsISupports* aExtraInfo = nsnull, nsLoadFlags aType = nsIChannel::LOAD_NORMAL, @@ -121,9 +121,9 @@ public: NS_IMETHOD RemoveObserver(nsIDocumentLoaderObserver *aObserver) = 0; - NS_IMETHOD SetContainer(nsIContentViewerContainer* aContainer) = 0; + NS_IMETHOD SetContainer(nsISupports* aContainer) = 0; - NS_IMETHOD GetContainer(nsIContentViewerContainer** aResult) = 0; + NS_IMETHOD GetContainer(nsISupports** aResult) = 0; NS_IMETHOD GetContentViewerContainer(PRUint32 aDocumentID, nsIContentViewerContainer** aResult) = 0; diff --git a/webshell/src/nsDocLoader.cpp b/webshell/src/nsDocLoader.cpp index bf4c6850d61..4cdf75a6080 100644 --- a/webshell/src/nsDocLoader.cpp +++ b/webshell/src/nsDocLoader.cpp @@ -137,7 +137,7 @@ public: nsresult Init(nsDocLoaderImpl* aDocLoader, const char *aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo); NS_DECL_ISUPPORTS @@ -158,9 +158,9 @@ protected: protected: char* m_Command; - nsIContentViewerContainer* m_Container; - nsISupports* m_ExtraInfo; - nsIStreamListener* m_NextStream; + nsCOMPtr m_Container; + nsCOMPtr m_ExtraInfo; + nsCOMPtr m_NextStream; nsDocLoaderImpl* m_DocLoader; }; @@ -190,7 +190,7 @@ public: // nsIDocumentLoader interface NS_IMETHOD LoadDocument(nsIURI * aUri, const char *aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsIInputStream* aPostDataStream = nsnull, nsISupports* aExtraInfo = nsnull, nsLoadFlags aType = nsIChannel::LOAD_NORMAL, @@ -211,8 +211,8 @@ public: NS_IMETHOD AddObserver(nsIDocumentLoaderObserver *aObserver); NS_IMETHOD RemoveObserver(nsIDocumentLoaderObserver *aObserver); - NS_IMETHOD SetContainer(nsIContentViewerContainer* aContainer); - NS_IMETHOD GetContainer(nsIContentViewerContainer** aResult); + NS_IMETHOD SetContainer(nsISupports* aContainer); + NS_IMETHOD GetContainer(nsISupports** aResult); NS_IMETHOD GetContentViewerContainer(PRUint32 aDocumentID, nsIContentViewerContainer** aResult); NS_IMETHOD GetLoadGroup(nsILoadGroup** aResult); @@ -254,7 +254,7 @@ public: nsresult CreateContentViewer(const char *aCommand, nsIChannel* channel, const char* aContentType, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListener, nsIContentViewer** aDocViewer); @@ -274,7 +274,7 @@ protected: nsCOMPtr mDocumentChannel; // [OWNER] ???compare with document nsVoidArray mDocObservers; - nsIContentViewerContainer* mContainer; // [WEAK] it owns me! + nsISupports* mContainer; // [WEAK] it owns me! nsDocLoaderImpl* mParent; // [OWNER] but upside down ownership model // needs to be fixed*** @@ -426,7 +426,7 @@ nsresult nsDocLoaderImpl::CreateContentViewer(const char *aCommand, nsIChannel* channel, const char* aContentType, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListenerResult, nsIContentViewer** aDocViewerResult) @@ -452,11 +452,13 @@ nsDocLoaderImpl::CreateContentViewer(const char *aCommand, return rv; } + nsCOMPtr container(do_QueryInterface(aContainer)); + // Now create an instance of the content viewer rv = factory->CreateInstance(aCommand, channel, mLoadGroup, aContentType, - aContainer, + container, aExtraInfo, aDocListenerResult, aDocViewerResult); NS_RELEASE(factory); @@ -466,7 +468,7 @@ nsDocLoaderImpl::CreateContentViewer(const char *aCommand, NS_IMETHODIMP nsDocLoaderImpl::LoadDocument(nsIURI * aUri, const char* aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsIInputStream* aPostDataStream, nsISupports* aExtraInfo, nsLoadFlags aType, @@ -611,7 +613,7 @@ nsDocLoaderImpl::RemoveObserver(nsIDocumentLoaderObserver* aObserver) } NS_IMETHODIMP -nsDocLoaderImpl::SetContainer(nsIContentViewerContainer* aContainer) +nsDocLoaderImpl::SetContainer(nsISupports* aContainer) { // This is a weak reference... mContainer = aContainer; @@ -620,17 +622,14 @@ nsDocLoaderImpl::SetContainer(nsIContentViewerContainer* aContainer) } NS_IMETHODIMP -nsDocLoaderImpl::GetContainer(nsIContentViewerContainer** aResult) +nsDocLoaderImpl::GetContainer(nsISupports** aResult) { - nsresult rv = NS_OK; + NS_ENSURE_ARG_POINTER(aResult); - if (nsnull == aResult) { - rv = NS_ERROR_NULL_POINTER; - } else { - *aResult = mContainer; - NS_IF_ADDREF(*aResult); - } - return rv; + *aResult = mContainer; + NS_IF_ADDREF(*aResult); + + return NS_OK; } NS_IMETHODIMP @@ -957,29 +956,23 @@ nsDocumentBindInfo::nsDocumentBindInfo() NS_INIT_REFCNT(); m_Command = nsnull; - m_Container = nsnull; - m_ExtraInfo = nsnull; - m_NextStream = nsnull; m_DocLoader = nsnull; } nsresult nsDocumentBindInfo::Init(nsDocLoaderImpl* aDocLoader, const char *aCommand, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo) { - m_NextStream = nsnull; m_Command = (nsnull != aCommand) ? PL_strdup(aCommand) : nsnull; m_DocLoader = aDocLoader; NS_ADDREF(m_DocLoader); - m_Container = aContainer; - NS_IF_ADDREF(m_Container); + m_Container = aContainer; // This does an addref - m_ExtraInfo = aExtraInfo; - NS_IF_ADDREF(m_ExtraInfo); + m_ExtraInfo = aExtraInfo; // This does an addref return NS_OK; } @@ -992,9 +985,6 @@ nsDocumentBindInfo::~nsDocumentBindInfo() m_Command = nsnull; NS_RELEASE (m_DocLoader); - NS_IF_RELEASE(m_NextStream); - NS_IF_RELEASE(m_Container); - NS_IF_RELEASE(m_ExtraInfo); } /* @@ -1138,7 +1128,7 @@ nsDocumentBindInfo::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) aContentType, m_Container, m_ExtraInfo, - &m_NextStream, + getter_AddRefs(m_NextStream), &viewer); } else { rv = NS_ERROR_NULL_POINTER; @@ -1146,9 +1136,11 @@ nsDocumentBindInfo::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) if (NS_FAILED(rv)) { printf("DocLoaderFactory: Unable to create ContentViewer for command=%s, content-type=%s\n", m_Command ? m_Command : "(null)", aContentType); - if ( m_Container ) { + nsCOMPtr + cvContainer(do_QueryInterface(m_Container)); + if ( cvContainer ) { // Give content container a chance to do something with this URL. - rv = m_Container->HandleUnknownContentType( (nsIDocumentLoader*) m_DocLoader, channel, aContentType, m_Command ); + rv = cvContainer->HandleUnknownContentType( (nsIDocumentLoader*) m_DocLoader, channel, aContentType, m_Command ); } // Stop the binding. // This crashes on Unix/Mac... Stop(); @@ -1158,10 +1150,12 @@ nsDocumentBindInfo::OnStartRequest(nsIChannel* channel, nsISupports *ctxt) /* * Give the document container the new viewer... */ - if (m_Container) { + nsCOMPtr + cvContainer(do_QueryInterface(m_Container)); + if (cvContainer) { viewer->SetContainer(m_Container); - rv = m_Container->Embed(viewer, m_Command, m_ExtraInfo); + rv = cvContainer->Embed(viewer, m_Command, m_ExtraInfo); if (NS_FAILED(rv)) { goto done; } @@ -1213,11 +1207,9 @@ NS_METHOD nsDocumentBindInfo::OnDataAvailable(nsIChannel* channel, nsISupports * * Currently this can happen if javascript loads a new URL * (via nsIWebShell::LoadURL) during the parse phase... */ - nsIStreamListener* listener = m_NextStream; + nsCOMPtr listener(m_NextStream); - NS_ADDREF(listener); rv = listener->OnDataAvailable(channel, ctxt, aStream, sourceOffset, aLength); - NS_RELEASE(listener); } else { rv = NS_BINDING_FAILED; } @@ -1261,7 +1253,7 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIChannel* channel, nsISupports *ct rv = m_NextStream->OnStopRequest(channel, ctxt, aStatus, aMsg); } - NS_IF_RELEASE(m_NextStream); + m_NextStream = nsnull; // Release our stream we are holding return rv; } diff --git a/webshell/src/nsWebShell.cpp b/webshell/src/nsWebShell.cpp index 637fed4e009..f8353db3d01 100644 --- a/webshell/src/nsWebShell.cpp +++ b/webshell/src/nsWebShell.cpp @@ -953,7 +953,7 @@ nsWebShell::Init(nsNativeWidget aNativeParent, } // Set the webshell as the default IContentViewerContainer for the loader... - mDocLoader->SetContainer(this); + mDocLoader->SetContainer(NS_STATIC_CAST(nsIContentViewerContainer*, this)); //Register ourselves as an observer for the new doc loader mDocLoader->AddObserver((nsIDocumentLoaderObserver*)this); @@ -1858,7 +1858,7 @@ nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc, nsIDOMElement *aRootNode) nsCOMPtr doc = do_QueryInterface(aDOMDoc); if (!doc) { return NS_ERROR_NULL_POINTER; } - NS_ENSURE_SUCCESS(docFactory->CreateInstanceForDocument(this, + NS_ENSURE_SUCCESS(docFactory->CreateInstanceForDocument(NS_STATIC_CAST(nsIContentViewerContainer*, this), doc, "view", getter_AddRefs(documentViewer)), @@ -2130,7 +2130,7 @@ nsWebShell::DoLoadURL(nsIURI * aUri, */ rv = mDocLoader->LoadDocument(aUri, // URL string aCommand, // Command - this, // Container + NS_STATIC_CAST(nsIContentViewerContainer*, this),// Container aPostDataStream, // Post Data nsnull, // Extra Info... aType, // reload type diff --git a/widget/src/beos/nsMenuItem.cpp b/widget/src/beos/nsMenuItem.cpp index b7bbb01f7d0..fcf1cf78404 100644 --- a/widget/src/beos/nsMenuItem.cpp +++ b/widget/src/beos/nsMenuItem.cpp @@ -29,7 +29,6 @@ #include "nsCOMPtr.h" #include "nsIContent.h" -#include "nsIContentViewerContainer.h" #include "nsIContentViewer.h" #include "nsIDOMElement.h" #include "nsIDocumentViewer.h" @@ -373,20 +372,10 @@ NS_METHOD nsMenuItem::DoCommand() if(!mWebShell || !mDOMElement) return rv; - nsCOMPtr contentViewerContainer; - contentViewerContainer = do_QueryInterface(mWebShell); - if (!contentViewerContainer) { - NS_ERROR("Webshell doesn't support the content viewer container interface"); - //g_print("Webshell doesn't support the content viewer container interface"); - return rv; - } - nsCOMPtr contentViewer; - if (NS_FAILED(rv = contentViewerContainer->GetContentViewer(getter_AddRefs(contentViewer)))) { - NS_ERROR("Unable to retrieve content viewer."); - //g_print("Unable to retrieve content viewer."); - return rv; - } + NS_ENSURE_SUCCESS(mWebShell->GetContentViewer(getter_AddRefs(contentViewer)), + NS_ERROR_FAILURE); + nsCOMPtr docViewer; docViewer = do_QueryInterface(contentViewer); diff --git a/widget/src/gtk/nsMenuItem.cpp b/widget/src/gtk/nsMenuItem.cpp index be0c0826403..412ed64642c 100644 --- a/widget/src/gtk/nsMenuItem.cpp +++ b/widget/src/gtk/nsMenuItem.cpp @@ -33,7 +33,6 @@ #include "nsCOMPtr.h" #include "nsIContent.h" -#include "nsIContentViewerContainer.h" #include "nsIContentViewer.h" #include "nsIDOMElement.h" #include "nsIDocumentViewer.h" @@ -442,20 +441,9 @@ NS_METHOD nsMenuItem::DoCommand() if(!mWebShell || !mDOMElement) return rv; - nsCOMPtr contentViewerContainer; - contentViewerContainer = do_QueryInterface(mWebShell); - if (!contentViewerContainer) { - NS_ERROR("Webshell doesn't support the content viewer container interface"); - //g_print("Webshell doesn't support the content viewer container interface"); - return rv; - } - nsCOMPtr contentViewer; - if (NS_FAILED(rv = contentViewerContainer->GetContentViewer(getter_AddRefs(contentViewer)))) { - NS_ERROR("Unable to retrieve content viewer."); - //g_print("Unable to retrieve content viewer."); - return rv; - } + NS_ENSURE_SUCCESS(mWebShell->GetContentViewer(getter_AddRefs(contentViewer)), + NS_ERROR_FAILURE); nsCOMPtr docViewer; docViewer = do_QueryInterface(contentViewer); diff --git a/widget/src/mac/nsMenuItem.cpp b/widget/src/mac/nsMenuItem.cpp index b6a13ccfa0b..1fe0b4e9043 100644 --- a/widget/src/mac/nsMenuItem.cpp +++ b/widget/src/mac/nsMenuItem.cpp @@ -413,18 +413,9 @@ NS_METHOD nsMenuItem::DoCommand() { nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr contentViewerContainer; - contentViewerContainer = do_QueryInterface(mWebShell); - if (!contentViewerContainer) { - NS_ERROR("Webshell doesn't support the content viewer container interface"); - return rv; - } - nsCOMPtr contentViewer; - if (NS_FAILED(rv = contentViewerContainer->GetContentViewer(getter_AddRefs(contentViewer)))) { - NS_ERROR("Unable to retrieve content viewer."); - return rv; - } + NS_ENSURE_SUCCESS(mWebShell->GetContentViewer(getter_AddRefs(contentViewer)), + NS_ERROR_FAILURE); nsCOMPtr docViewer; docViewer = do_QueryInterface(contentViewer); diff --git a/widget/src/motif/nsMenuItem.cpp b/widget/src/motif/nsMenuItem.cpp index e00df79c7a4..8700997f71d 100644 --- a/widget/src/motif/nsMenuItem.cpp +++ b/widget/src/motif/nsMenuItem.cpp @@ -33,7 +33,6 @@ #include "nsCOMPtr.h" #include "nsIContent.h" -#include "nsIContentViewerContainer.h" #include "nsIContentViewer.h" #include "nsIDOMElement.h" #include "nsIDocumentViewer.h" diff --git a/widget/src/os2/nsMenuItem.cpp b/widget/src/os2/nsMenuItem.cpp index 57c88038fb0..b74268262ce 100644 --- a/widget/src/os2/nsMenuItem.cpp +++ b/widget/src/os2/nsMenuItem.cpp @@ -290,18 +290,9 @@ nsresult nsMenuItem::DoCommand() // code copied from windows nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr contentViewerContainer; - contentViewerContainer = do_QueryInterface(mWebShell); - if (!contentViewerContainer) { - NS_ERROR("Webshell doesn't support the content viewer container interface"); - return rv; - } - nsCOMPtr contentViewer; - if (NS_FAILED(rv = contentViewerContainer->GetContentViewer(getter_AddRefs(contentViewer)))) { - NS_ERROR("Unable to retrieve content viewer."); - return rv; - } + NS_ENSURE_SUCCESS(mWebShell->GetContentViewer(getter_AddRefs(contentViewer)), + NS_ERROR_FAILURE); nsCOMPtr docViewer; docViewer = do_QueryInterface(contentViewer); diff --git a/widget/src/photon/nsMenuItem.cpp b/widget/src/photon/nsMenuItem.cpp index 58f6f22edc0..4b05ab8d303 100644 --- a/widget/src/photon/nsMenuItem.cpp +++ b/widget/src/photon/nsMenuItem.cpp @@ -32,7 +32,6 @@ #include "nsIPopUpMenu.h" #include "nsCOMPtr.h" -#include "nsIContentViewerContainer.h" #include "nsIContentViewer.h" #include "nsIDocumentViewer.h" #include "nsIPresContext.h" @@ -502,18 +501,9 @@ NS_METHOD nsMenuItem::DoCommand() if(!mWebShell || !mDOMElement) return rv; - nsCOMPtr contentViewerContainer; - contentViewerContainer = do_QueryInterface(mWebShell); - if (!contentViewerContainer) { - NS_ERROR("Webshell doesn't support the content viewer container interface"); - return rv; - } - nsCOMPtr contentViewer; - if (NS_FAILED(rv = contentViewerContainer->GetContentViewer(getter_AddRefs(contentViewer)))) { - NS_ERROR("Unable to retrieve content viewer."); - return rv; - } + NS_ENSURE_SUCCESS(mWebShell->GetContentViewer(getter_AddRefs(contentViewer)), + NS_ERROR_FAILURE); nsCOMPtr docViewer; docViewer = do_QueryInterface(contentViewer); diff --git a/widget/src/qt/nsMenuItem.cpp b/widget/src/qt/nsMenuItem.cpp index bc4269054b4..8bf4fce23a9 100644 --- a/widget/src/qt/nsMenuItem.cpp +++ b/widget/src/qt/nsMenuItem.cpp @@ -30,7 +30,6 @@ #include "nsQEventHandler.h" #include "nsCOMPtr.h" #include "nsIContent.h" -#include "nsIContentViewerContainer.h" #include "nsIContentViewer.h" #include "nsIDOMElement.h" #include "nsIDocumentViewer.h" @@ -384,22 +383,9 @@ NS_METHOD nsMenuItem::DoCommand() return rv; } - nsCOMPtr contentViewerContainer; - contentViewerContainer = do_QueryInterface(mWebShell); - if (!contentViewerContainer) - { - NS_ERROR("Webshell doesn't support the content viewer container interface"); - //g_print("Webshell doesn't support the content viewer container interface"); - return rv; - } - nsCOMPtr contentViewer; - if (NS_FAILED(rv = contentViewerContainer->GetContentViewer(getter_AddRefs(contentViewer)))) - { - NS_ERROR("Unable to retrieve content viewer."); - //g_print("Unable to retrieve content viewer."); - return rv; - } + NS_ENSURE_SUCCESS(mWebShell->GetContentViewer(getter_AddRefs(contentViewer)), + NS_ERROR_FAILURE); nsCOMPtr docViewer; docViewer = do_QueryInterface(contentViewer); diff --git a/widget/src/windows/nsMenuItem.cpp b/widget/src/windows/nsMenuItem.cpp index 7c25cd09919..5da315014d2 100644 --- a/widget/src/windows/nsMenuItem.cpp +++ b/widget/src/windows/nsMenuItem.cpp @@ -349,18 +349,9 @@ NS_IMETHODIMP nsMenuItem::DoCommand() { nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr contentViewerContainer; - contentViewerContainer = do_QueryInterface(mWebShell); - if (!contentViewerContainer) { - NS_ERROR("Webshell doesn't support the content viewer container interface"); - return rv; - } - nsCOMPtr contentViewer; - if (NS_FAILED(rv = contentViewerContainer->GetContentViewer(getter_AddRefs(contentViewer)))) { - NS_ERROR("Unable to retrieve content viewer."); - return rv; - } + NS_ENSURE_SUCCESS(mWebShell->GetContentViewer(getter_AddRefs(contentViewer)), + NS_ERROR_FAILURE); nsCOMPtr docViewer; docViewer = do_QueryInterface(contentViewer); diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index a89b661f28f..844d367b804 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -965,18 +965,12 @@ void nsWebShellWindow::DynamicLoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aP rv = NS_ERROR_FAILURE; // do a resize - nsCOMPtr contentViewerContainer; - contentViewerContainer = do_QueryInterface(mWebShell); - if (!contentViewerContainer) { - NS_ERROR("Webshell doesn't support the content viewer container interface"); - return; - } - nsCOMPtr contentViewer; - if (NS_FAILED(rv = contentViewerContainer->GetContentViewer(getter_AddRefs(contentViewer)))) { - NS_ERROR("Unable to retrieve content viewer."); - return; - } + if( NS_FAILED(mWebShell->GetContentViewer(getter_AddRefs(contentViewer)))) + { + NS_WARN_IF_FALSE(PR_FALSE, "Error Getting contentViewer"); + return; + } nsCOMPtr docViewer; docViewer = do_QueryInterface(contentViewer); @@ -1205,18 +1199,9 @@ nsWebShellWindow::GetPresShell(nsIPresShell** aPresShell) { nsresult rv = NS_OK; - nsCOMPtr contentViewerContainer; - contentViewerContainer = do_QueryInterface(mWebShell); - if (!contentViewerContainer) { - NS_ERROR("Webshell doesn't support the content viewer container interface"); - return NS_ERROR_FAILURE; - } - nsCOMPtr contentViewer; - if (NS_FAILED(rv = contentViewerContainer->GetContentViewer(getter_AddRefs(contentViewer)))) { - NS_ERROR("Unable to retrieve content viewer."); - return NS_ERROR_FAILURE; - } + NS_ENSURE_SUCCESS(mWebShell->GetContentViewer(getter_AddRefs(contentViewer)), + NS_ERROR_FAILURE); nsCOMPtr docViewer; docViewer = do_QueryInterface(contentViewer); diff --git a/xpfe/appshell/src/nsXULCommand.cpp b/xpfe/appshell/src/nsXULCommand.cpp index 4534c2ad969..bba19c392b7 100644 --- a/xpfe/appshell/src/nsXULCommand.cpp +++ b/xpfe/appshell/src/nsXULCommand.cpp @@ -133,18 +133,9 @@ NS_IMETHODIMP nsXULCommand::DoCommand() { nsresult rv = NS_ERROR_FAILURE; - nsCOMPtr contentViewerContainer; - contentViewerContainer = do_QueryInterface(mWebShell); - if (!contentViewerContainer) { - NS_ERROR("Webshell doesn't support the content viewer container interface"); - return rv; - } - nsCOMPtr contentViewer; - if (NS_FAILED(rv = contentViewerContainer->GetContentViewer(getter_AddRefs(contentViewer)))) { - NS_ERROR("Unable to retrieve content viewer."); - return rv; - } + NS_ENSURE_SUCCESS(mWebShell->GetContentViewer(getter_AddRefs(contentViewer)), + NS_ERROR_FAILURE); nsCOMPtr docViewer; docViewer = do_QueryInterface(contentViewer); diff --git a/xpfe/browser/src/nsBrowserInstance.cpp b/xpfe/browser/src/nsBrowserInstance.cpp index 8f8f87887e7..c94db7f8cee 100644 --- a/xpfe/browser/src/nsBrowserInstance.cpp +++ b/xpfe/browser/src/nsBrowserInstance.cpp @@ -1401,19 +1401,17 @@ nsBrowserAppCore::OnStartDocumentLoad(nsIDocumentLoader* aLoader, nsIURI* aURL, // Check if this notification is for a frame PRBool isFrame=PR_FALSE; - nsIContentViewerContainer * container=nsnull; - aLoader->GetContainer(&container); + nsCOMPtr container; + aLoader->GetContainer(getter_AddRefs(container)); if (container) { nsCOMPtr ws(do_QueryInterface(container)); if (ws) { - nsIWebShell * parent=nsnull; - ws->GetParent(parent); + nsCOMPtr parent; + ws->GetParent(*getter_AddRefs(parent)); if (parent) isFrame = PR_TRUE; - NS_IF_RELEASE(parent); } } - NS_IF_RELEASE(container); if (!isFrame) { nsAutoString kStartDocumentLoad("StartDocumentLoad"); diff --git a/xpfe/components/directory/nsDirectoryViewer.cpp b/xpfe/components/directory/nsDirectoryViewer.cpp index ef9335210c4..61178022756 100644 --- a/xpfe/components/directory/nsDirectoryViewer.cpp +++ b/xpfe/components/directory/nsDirectoryViewer.cpp @@ -34,7 +34,6 @@ #include "nsEscape.h" #include "nsNeckoUtil.h" #include "nsIContentViewer.h" -#include "nsIContentViewerContainer.h" #include "nsIDocument.h" #include "nsIDocumentLoader.h" #include "nsIDocumentViewer.h" @@ -947,12 +946,12 @@ public: nsIChannel* aChannel, nsILoadGroup* aLoadGroup, const char* aContentType, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListenerResult, nsIContentViewer** aDocViewerResult); - NS_IMETHOD CreateInstanceForDocument(nsIContentViewerContainer* aContainer, + NS_IMETHOD CreateInstanceForDocument(nsISupports* aContainer, nsIDocument* aDocument, const char *aCommand, nsIContentViewer** aDocViewerResult); @@ -1027,7 +1026,7 @@ nsDirectoryViewerFactory::CreateInstance(const char *aCommand, nsIChannel* aChannel, nsILoadGroup* aLoadGroup, const char* aContentType, - nsIContentViewerContainer* aContainer, + nsISupports* aContainer, nsISupports* aExtraInfo, nsIStreamListener** aDocListenerResult, nsIContentViewer** aDocViewerResult) @@ -1086,7 +1085,7 @@ nsDirectoryViewerFactory::CreateInstance(const char *aCommand, NS_IMETHODIMP -nsDirectoryViewerFactory::CreateInstanceForDocument(nsIContentViewerContainer* aContainer, +nsDirectoryViewerFactory::CreateInstanceForDocument(nsISupports* aContainer, nsIDocument* aDocument, const char *aCommand, nsIContentViewer** aDocViewerResult)