Changed storage of of the container to hold simply nsISupports as the mContainer instead of nsIContentViewerContainer. Changed calls to QueryCapability to use the nsIInterfaceRequestor::GetInterface(). r=scc

This commit is contained in:
tbogard%aol.net 1999-11-13 07:36:28 +00:00
parent 00b82b3c85
commit 131348416b
7 changed files with 107 additions and 97 deletions

View file

@ -55,6 +55,7 @@
#include "nsIPageSequenceFrame.h"
#include "nsIURL.h"
#include "nsIWebShell.h"
#include "nsIInterfaceRequestor.h"
#include "nsIServiceManager.h"
@ -139,7 +140,7 @@ protected:
// (ie, non owning) references. If you add any members to this
// class, please make the ownership explicit (pinkerton, scc).
nsIContentViewerContainer* mContainer; // [WEAK] it owns me!
nsISupports* mContainer; // [WEAK] it owns me!
nsCOMPtr<nsIDeviceContext> mDeviceContext; // ??? can't hurt, but...
nsIView* mView; // [WEAK] cleaned up by view mgr
@ -309,8 +310,10 @@ DocumentViewerImpl::SetContainer(nsIContentViewerContainer* aContainer)
NS_IMETHODIMP
DocumentViewerImpl::GetContainer(nsIContentViewerContainer*& aResult)
{
aResult = mContainer;
NS_IF_ADDREF(aResult);
if(mContainer)
return CallQueryInterface(mContainer, &aResult);
else
aResult = nsnull;
return NS_OK;
}
@ -341,31 +344,28 @@ DocumentViewerImpl::Init(nsNativeWidget aNativeParent,
makeCX = PR_TRUE;
}
if (nsnull != mContainer) {
nsILinkHandler* linkHandler = nsnull;
mContainer->QueryCapability(kILinkHandlerIID, (void**)&linkHandler);
nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(mContainer));
if (requestor) {
nsCOMPtr<nsILinkHandler> linkHandler;
requestor->GetInterface(NS_GET_IID(nsILinkHandler),
getter_AddRefs(linkHandler));
mPresContext->SetContainer(mContainer);
mPresContext->SetLinkHandler(linkHandler);
NS_IF_RELEASE(linkHandler);
// Set script-context-owner in the document
nsIScriptContextOwner* owner = nsnull;
mContainer->QueryCapability(kIScriptContextOwnerIID, (void**)&owner);
nsCOMPtr<nsIScriptContextOwner> owner;
requestor->GetInterface(NS_GET_IID(nsIScriptContextOwner),
getter_AddRefs(owner));
if (nsnull != owner) {
mDocument->SetScriptContextOwner(owner);
nsIScriptGlobalObject* global;
rv = owner->GetScriptGlobalObject(&global);
nsCOMPtr<nsIScriptGlobalObject> global;
rv = owner->GetScriptGlobalObject(getter_AddRefs(global));
if (NS_SUCCEEDED(rv) && (nsnull != global)) {
nsIDOMDocument *domdoc = nsnull;
mDocument->QueryInterface(kIDOMDocumentIID,
(void**) &domdoc);
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(mDocument));
if (nsnull != domdoc) {
global->SetNewDocument(domdoc);
NS_RELEASE(domdoc);
}
NS_RELEASE(global);
}
NS_RELEASE(owner);
}
}

View file

@ -55,6 +55,7 @@
#include "nsIPageSequenceFrame.h"
#include "nsIURL.h"
#include "nsIWebShell.h"
#include "nsIInterfaceRequestor.h"
#include "nsIServiceManager.h"
@ -139,7 +140,7 @@ protected:
// (ie, non owning) references. If you add any members to this
// class, please make the ownership explicit (pinkerton, scc).
nsIContentViewerContainer* mContainer; // [WEAK] it owns me!
nsISupports* mContainer; // [WEAK] it owns me!
nsCOMPtr<nsIDeviceContext> mDeviceContext; // ??? can't hurt, but...
nsIView* mView; // [WEAK] cleaned up by view mgr
@ -309,8 +310,10 @@ DocumentViewerImpl::SetContainer(nsIContentViewerContainer* aContainer)
NS_IMETHODIMP
DocumentViewerImpl::GetContainer(nsIContentViewerContainer*& aResult)
{
aResult = mContainer;
NS_IF_ADDREF(aResult);
if(mContainer)
return CallQueryInterface(mContainer, &aResult);
else
aResult = nsnull;
return NS_OK;
}
@ -341,31 +344,28 @@ DocumentViewerImpl::Init(nsNativeWidget aNativeParent,
makeCX = PR_TRUE;
}
if (nsnull != mContainer) {
nsILinkHandler* linkHandler = nsnull;
mContainer->QueryCapability(kILinkHandlerIID, (void**)&linkHandler);
nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(mContainer));
if (requestor) {
nsCOMPtr<nsILinkHandler> linkHandler;
requestor->GetInterface(NS_GET_IID(nsILinkHandler),
getter_AddRefs(linkHandler));
mPresContext->SetContainer(mContainer);
mPresContext->SetLinkHandler(linkHandler);
NS_IF_RELEASE(linkHandler);
// Set script-context-owner in the document
nsIScriptContextOwner* owner = nsnull;
mContainer->QueryCapability(kIScriptContextOwnerIID, (void**)&owner);
nsCOMPtr<nsIScriptContextOwner> owner;
requestor->GetInterface(NS_GET_IID(nsIScriptContextOwner),
getter_AddRefs(owner));
if (nsnull != owner) {
mDocument->SetScriptContextOwner(owner);
nsIScriptGlobalObject* global;
rv = owner->GetScriptGlobalObject(&global);
nsCOMPtr<nsIScriptGlobalObject> global;
rv = owner->GetScriptGlobalObject(getter_AddRefs(global));
if (NS_SUCCEEDED(rv) && (nsnull != global)) {
nsIDOMDocument *domdoc = nsnull;
mDocument->QueryInterface(kIDOMDocumentIID,
(void**) &domdoc);
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(mDocument));
if (nsnull != domdoc) {
global->SetNewDocument(domdoc);
NS_RELEASE(domdoc);
}
NS_RELEASE(global);
}
NS_RELEASE(owner);
}
}

View file

@ -55,6 +55,7 @@
#include "nsIPageSequenceFrame.h"
#include "nsIURL.h"
#include "nsIWebShell.h"
#include "nsIInterfaceRequestor.h"
#include "nsIServiceManager.h"
@ -139,7 +140,7 @@ protected:
// (ie, non owning) references. If you add any members to this
// class, please make the ownership explicit (pinkerton, scc).
nsIContentViewerContainer* mContainer; // [WEAK] it owns me!
nsISupports* mContainer; // [WEAK] it owns me!
nsCOMPtr<nsIDeviceContext> mDeviceContext; // ??? can't hurt, but...
nsIView* mView; // [WEAK] cleaned up by view mgr
@ -309,8 +310,10 @@ DocumentViewerImpl::SetContainer(nsIContentViewerContainer* aContainer)
NS_IMETHODIMP
DocumentViewerImpl::GetContainer(nsIContentViewerContainer*& aResult)
{
aResult = mContainer;
NS_IF_ADDREF(aResult);
if(mContainer)
return CallQueryInterface(mContainer, &aResult);
else
aResult = nsnull;
return NS_OK;
}
@ -341,31 +344,28 @@ DocumentViewerImpl::Init(nsNativeWidget aNativeParent,
makeCX = PR_TRUE;
}
if (nsnull != mContainer) {
nsILinkHandler* linkHandler = nsnull;
mContainer->QueryCapability(kILinkHandlerIID, (void**)&linkHandler);
nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(mContainer));
if (requestor) {
nsCOMPtr<nsILinkHandler> linkHandler;
requestor->GetInterface(NS_GET_IID(nsILinkHandler),
getter_AddRefs(linkHandler));
mPresContext->SetContainer(mContainer);
mPresContext->SetLinkHandler(linkHandler);
NS_IF_RELEASE(linkHandler);
// Set script-context-owner in the document
nsIScriptContextOwner* owner = nsnull;
mContainer->QueryCapability(kIScriptContextOwnerIID, (void**)&owner);
nsCOMPtr<nsIScriptContextOwner> owner;
requestor->GetInterface(NS_GET_IID(nsIScriptContextOwner),
getter_AddRefs(owner));
if (nsnull != owner) {
mDocument->SetScriptContextOwner(owner);
nsIScriptGlobalObject* global;
rv = owner->GetScriptGlobalObject(&global);
nsCOMPtr<nsIScriptGlobalObject> global;
rv = owner->GetScriptGlobalObject(getter_AddRefs(global));
if (NS_SUCCEEDED(rv) && (nsnull != global)) {
nsIDOMDocument *domdoc = nsnull;
mDocument->QueryInterface(kIDOMDocumentIID,
(void**) &domdoc);
nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(mDocument));
if (nsnull != domdoc) {
global->SetNewDocument(domdoc);
NS_RELEASE(domdoc);
}
NS_RELEASE(global);
}
NS_RELEASE(owner);
}
}

View file

@ -19,6 +19,7 @@
*
* Contributor(s):
*/
#include "nsCOMPtr.h"
#include "nscore.h"
#include "nsCRT.h"
#include "nsIContentViewer.h"
@ -36,6 +37,7 @@
#include "nsIBrowserWindow.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIInterfaceRequestor.h"
// Class IDs
static NS_DEFINE_IID(kChildWindowCID, NS_CHILD_CID);
@ -159,7 +161,7 @@ public:
nsIWidget* mWindow;
nsIDocument* mDocument;
nsIContentViewerContainer* mContainer;
nsCOMPtr<nsISupports> mContainer;
nsIChannel* mChannel;
pluginInstanceOwner *mOwner;
PRBool mEnableRendering;
@ -236,7 +238,6 @@ PluginViewerImpl::~PluginViewerImpl()
NS_RELEASE(mWindow);
}
NS_IF_RELEASE(mDocument);
NS_IF_RELEASE(mContainer);
NS_IF_RELEASE(mChannel);
}
@ -258,17 +259,17 @@ PluginViewerImpl::BindToDocument(nsISupports *aDoc, const char *aCommand)
NS_IMETHODIMP
PluginViewerImpl::SetContainer(nsIContentViewerContainer* aContainer)
{
NS_IF_RELEASE(mContainer);
mContainer = aContainer;
NS_IF_ADDREF(mContainer);
return NS_OK;
}
NS_IMETHODIMP
PluginViewerImpl::GetContainer(nsIContentViewerContainer*& aResult)
{
aResult = mContainer;
NS_IF_ADDREF(mContainer);
if(mContainer)
return CallQueryInterface(mContainer, &aResult);
else
aResult = nsnull;
return NS_OK;
}
@ -308,13 +309,16 @@ PluginViewerImpl::StartLoad(nsIChannel* channel, nsIStreamListener*& aResult)
aResult = nsnull;
// Only instantiate the plugin if our container can host it
nsIPluginHost* host;
nsresult rv = mContainer->QueryCapability(kIPluginHostIID, (void **)&host);
nsCOMPtr<nsIPluginHost> host;
nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(mContainer));
NS_ENSURE_TRUE(requestor, NS_ERROR_FAILURE);
nsresult rv = requestor->GetInterface(NS_GET_IID(nsIPluginHost),
getter_AddRefs(host));
if (NS_OK == rv) {
nsRect r;
mWindow->GetClientBounds(r);
rv = CreatePlugin(host, nsRect(0, 0, r.width, r.height), aResult);
NS_RELEASE(host);
}
return rv;

View file

@ -19,6 +19,7 @@
*
* Contributor(s):
*/
#include "nsCOMPtr.h"
#include "nscore.h"
#include "nsCRT.h"
#include "nsIContentViewer.h"
@ -36,6 +37,7 @@
#include "nsIBrowserWindow.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIInterfaceRequestor.h"
// Class IDs
static NS_DEFINE_IID(kChildWindowCID, NS_CHILD_CID);
@ -159,7 +161,7 @@ public:
nsIWidget* mWindow;
nsIDocument* mDocument;
nsIContentViewerContainer* mContainer;
nsCOMPtr<nsISupports> mContainer;
nsIChannel* mChannel;
pluginInstanceOwner *mOwner;
PRBool mEnableRendering;
@ -236,7 +238,6 @@ PluginViewerImpl::~PluginViewerImpl()
NS_RELEASE(mWindow);
}
NS_IF_RELEASE(mDocument);
NS_IF_RELEASE(mContainer);
NS_IF_RELEASE(mChannel);
}
@ -258,17 +259,17 @@ PluginViewerImpl::BindToDocument(nsISupports *aDoc, const char *aCommand)
NS_IMETHODIMP
PluginViewerImpl::SetContainer(nsIContentViewerContainer* aContainer)
{
NS_IF_RELEASE(mContainer);
mContainer = aContainer;
NS_IF_ADDREF(mContainer);
return NS_OK;
}
NS_IMETHODIMP
PluginViewerImpl::GetContainer(nsIContentViewerContainer*& aResult)
{
aResult = mContainer;
NS_IF_ADDREF(mContainer);
if(mContainer)
return CallQueryInterface(mContainer, &aResult);
else
aResult = nsnull;
return NS_OK;
}
@ -308,13 +309,16 @@ PluginViewerImpl::StartLoad(nsIChannel* channel, nsIStreamListener*& aResult)
aResult = nsnull;
// Only instantiate the plugin if our container can host it
nsIPluginHost* host;
nsresult rv = mContainer->QueryCapability(kIPluginHostIID, (void **)&host);
nsCOMPtr<nsIPluginHost> host;
nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(mContainer));
NS_ENSURE_TRUE(requestor, NS_ERROR_FAILURE);
nsresult rv = requestor->GetInterface(NS_GET_IID(nsIPluginHost),
getter_AddRefs(host));
if (NS_OK == rv) {
nsRect r;
mWindow->GetClientBounds(r);
rv = CreatePlugin(host, nsRect(0, 0, r.width, r.height), aResult);
NS_RELEASE(host);
}
return rv;

View file

@ -19,6 +19,7 @@
*
* Contributor(s):
*/
#include "nsCOMPtr.h"
#include "nscore.h"
#include "nsCRT.h"
#include "nsIContentViewer.h"
@ -36,6 +37,7 @@
#include "nsIBrowserWindow.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIInterfaceRequestor.h"
// Class IDs
static NS_DEFINE_IID(kChildWindowCID, NS_CHILD_CID);
@ -159,7 +161,7 @@ public:
nsIWidget* mWindow;
nsIDocument* mDocument;
nsIContentViewerContainer* mContainer;
nsCOMPtr<nsISupports> mContainer;
nsIChannel* mChannel;
pluginInstanceOwner *mOwner;
PRBool mEnableRendering;
@ -236,7 +238,6 @@ PluginViewerImpl::~PluginViewerImpl()
NS_RELEASE(mWindow);
}
NS_IF_RELEASE(mDocument);
NS_IF_RELEASE(mContainer);
NS_IF_RELEASE(mChannel);
}
@ -258,17 +259,17 @@ PluginViewerImpl::BindToDocument(nsISupports *aDoc, const char *aCommand)
NS_IMETHODIMP
PluginViewerImpl::SetContainer(nsIContentViewerContainer* aContainer)
{
NS_IF_RELEASE(mContainer);
mContainer = aContainer;
NS_IF_ADDREF(mContainer);
return NS_OK;
}
NS_IMETHODIMP
PluginViewerImpl::GetContainer(nsIContentViewerContainer*& aResult)
{
aResult = mContainer;
NS_IF_ADDREF(mContainer);
if(mContainer)
return CallQueryInterface(mContainer, &aResult);
else
aResult = nsnull;
return NS_OK;
}
@ -308,13 +309,16 @@ PluginViewerImpl::StartLoad(nsIChannel* channel, nsIStreamListener*& aResult)
aResult = nsnull;
// Only instantiate the plugin if our container can host it
nsIPluginHost* host;
nsresult rv = mContainer->QueryCapability(kIPluginHostIID, (void **)&host);
nsCOMPtr<nsIPluginHost> host;
nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(mContainer));
NS_ENSURE_TRUE(requestor, NS_ERROR_FAILURE);
nsresult rv = requestor->GetInterface(NS_GET_IID(nsIPluginHost),
getter_AddRefs(host));
if (NS_OK == rv) {
nsRect r;
mWindow->GetClientBounds(r);
rv = CreatePlugin(host, nsRect(0, 0, r.width, r.height), aResult);
NS_RELEASE(host);
}
return rv;

View file

@ -56,6 +56,7 @@
#include "nsVoidArray.h"
#include "nsXPIDLString.h"
#include "rdf.h"
#include "nsIInterfaceRequestor.h"
////////////////////////////////////////////////////////////////////////
@ -83,19 +84,19 @@ protected:
// in the script context _after_ the XUL doc has been embedded into
// content viewer. We'll know that this has happened once we receive
// an OnStartRequest() notification
nsIContentViewerContainer* mContainer; // [WEAK]
nsISupports* mContainer; // [WEAK]
nsCString mBaseURL;
nsCOMPtr<nsIRDFDataSource> mDataSource;
nsHTTPIndex(nsIContentViewerContainer* aContainer);
nsHTTPIndex(nsISupports* aContainer);
nsresult Init(nsIURI* aBaseURL);
virtual ~nsHTTPIndex();
public:
static nsresult Create(nsIURI* aBaseURI, nsIContentViewerContainer* aContainer, nsIHTTPIndex** aResult);
static nsresult Create(nsIURI* aBaseURI, nsISupports* aContainer, nsIHTTPIndex** aResult);
// nsISupports interface
NS_DECL_ISUPPORTS
@ -150,7 +151,7 @@ protected:
nsVoidArray mFormat;
nsHTTPIndexParser(nsHTTPIndex* aHTTPIndex, nsIContentViewerContainer* aContainer);
nsHTTPIndexParser(nsHTTPIndex* aHTTPIndex, nsISupports* aContainer);
nsresult Init();
virtual ~nsHTTPIndexParser();
@ -159,11 +160,11 @@ protected:
// the global object when we get an OnStartRequest() notification
// (at this point, we'll know that the XUL document has been
// embedded and the global object won't get clobbered.
nsIContentViewerContainer* mContainer;
nsISupports* mContainer;
public:
static nsresult Create(nsHTTPIndex* aHTTPIndex,
nsIContentViewerContainer* aContainer,
nsISupports* aContainer,
nsIStreamListener** aResult);
NS_DECL_ISUPPORTS
@ -190,9 +191,7 @@ nsHTTPIndexParser::gFieldTable[] = {
{ nsnull, nsHTTPIndexParser::ParseLiteral, nsnull },
};
nsHTTPIndexParser::nsHTTPIndexParser(nsHTTPIndex* aHTTPIndex, nsIContentViewerContainer* aContainer)
nsHTTPIndexParser::nsHTTPIndexParser(nsHTTPIndex* aHTTPIndex, nsISupports* aContainer)
: mHTTPIndex(aHTTPIndex),
mContainer(aContainer)
{
@ -267,7 +266,7 @@ nsHTTPIndexParser::~nsHTTPIndexParser()
nsresult
nsHTTPIndexParser::Create(nsHTTPIndex* aHTTPIndex,
nsIContentViewerContainer* aContainer,
nsISupports* aContainer,
nsIStreamListener** aResult)
{
NS_PRECONDITION(aHTTPIndex != nsnull, "null ptr");
@ -323,7 +322,8 @@ nsHTTPIndexParser::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext)
{
nsresult rv;
if (mContainer) {
nsCOMPtr<nsIInterfaceRequestor> requestor(do_QueryInterface(mContainer));
if (requestor) {
// We need to undo the AddRef() on the nsHTTPIndex object that
// happened in nsDirectoryViewerFactory::CreateInstance(). We'll
// stuff it into an nsCOMPtr (because we _know_ it'll get release
@ -335,7 +335,7 @@ nsHTTPIndexParser::OnStartRequest(nsIChannel* aChannel, nsISupports* aContext)
// Now get the content viewer container's script object.
nsCOMPtr<nsIScriptContextOwner> contextowner;
rv = mContainer->QueryCapability(nsCOMTypeInfo<nsIScriptContextOwner>::GetIID(),
rv = requestor->GetInterface(NS_GET_IID(nsIScriptContextOwner),
getter_AddRefs(contextowner));
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get script context owner from document");
@ -802,9 +802,7 @@ nsHTTPIndexParser::ParseInt(nsIRDFResource *arc, nsString& aValue, nsIRDFNode**
////////////////////////////////////////////////////////////////////////
// nsHTTPIndex implementation
nsHTTPIndex::nsHTTPIndex(nsIContentViewerContainer* aContainer)
nsHTTPIndex::nsHTTPIndex(nsISupports* aContainer)
: mContainer(aContainer)
{
NS_INIT_REFCNT();
@ -839,7 +837,7 @@ nsHTTPIndex::Init(nsIURI* aBaseURL)
nsresult
nsHTTPIndex::Create(nsIURI* aBaseURL, nsIContentViewerContainer* aContainer, nsIHTTPIndex** aResult)
nsHTTPIndex::Create(nsIURI* aBaseURL, nsISupports* aContainer, nsIHTTPIndex** aResult)
{
nsHTTPIndex* result = new nsHTTPIndex(aContainer);
if (! result)