Make full-screen plugins deactivate better

This commit is contained in:
kipp%netscape.com 1998-09-11 04:43:27 +00:00
parent dcf6b5fd92
commit 29976662a8

View File

@ -21,31 +21,12 @@
#include "nsIContentViewer.h"
#include "nsIContentViewerContainer.h"
#include "nsIPluginHost.h"
#include "nsIPluginInstance.h"
#include "nsIStreamListener.h"
#include "nsIURL.h"
#include "nsRepository.h"
#include "nsWidgetsCID.h"
//#include "nsString.h"
//#include "nsISupports.h"
//
//#include "nsIDocument.h"
//#include "nsIPresContext.h"
//#include "nsIPresShell.h"
//#include "nsIStyleSet.h"
//#include "nsIStyleSheet.h"
//
//#include "nsIScriptContextOwner.h"
//#include "nsIScriptGlobalObject.h"
//#include "nsILinkHandler.h"
//#include "nsIDOMDocument.h"
//
//#include "nsViewsCID.h"
//#include "nsIDeviceContext.h"
//#include "nsIViewManager.h"
//#include "nsIView.h"
//
// Class IDs
static NS_DEFINE_IID(kChildWindowCID, NS_CHILD_CID);
static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
@ -114,6 +95,8 @@ public:
nsresult CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds);
void DestroyPlugin();
nsresult MakeWindow(nsNativeWidget aParent,
nsIDeviceContext* aDeviceContext,
const nsRect& aBounds);
@ -183,6 +166,15 @@ PluginViewerImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
PluginViewerImpl::~PluginViewerImpl()
{
NS_IF_RELEASE(mContainer);
if (nsnull != mInstance) {
DestroyPlugin();
NS_RELEASE(mInstance);
}
if (nsnull != mWindow) {
mWindow->Destroy();
NS_RELEASE(mWindow);
}
NS_IF_RELEASE(mURL);
}
/*
@ -242,13 +234,13 @@ PluginViewerImpl::StartLoad(nsIURL* aURL, const char* aContentType,
aResult = nsnull;
// Only instantiate the plugin if our container can host it
nsIPluginHost* pm;
nsresult rv = mContainer->QueryCapability(kIPluginHostIID, (void **)&pm);
nsIPluginHost* host;
nsresult rv = mContainer->QueryCapability(kIPluginHostIID, (void **)&host);
if (NS_OK == rv) {
nsRect r;
mWindow->GetBounds(r);
rv = CreatePlugin(pm, nsRect(0, 0, r.width, r.height));
NS_RELEASE(pm);
rv = CreatePlugin(host, nsRect(0, 0, r.width, r.height));
NS_RELEASE(host);
}
return rv;
@ -284,6 +276,14 @@ PluginViewerImpl::CreatePlugin(nsIPluginHost* aHost, const nsRect& aBounds)
return rv;
}
void
PluginViewerImpl::DestroyPlugin()
{
if (nsnull != mInstance) {
mInstance->Destroy();
}
}
static nsEventStatus PR_CALLBACK
HandlePluginEvent(nsGUIEvent *aEvent)
{