From a5fc876b99008c4e3db4e60e1b772a6675ea9f8a Mon Sep 17 00:00:00 2001 From: "peterlubczynski%netscape.com" Date: Thu, 12 Apr 2001 01:08:51 +0000 Subject: [PATCH] Fix for full-page plugin keeps playing after leaving page bug 75293 sr=attinasi a=av git-svn-id: svn://10.0.0.236/trunk@92043 18797224-902f-48f8-a5cc-f745e15eee43 --- .../plugin/base/src/nsPluginViewer.cpp | 35 ++++++++++++++++++- .../modules/plugin/nglsrc/nsPluginViewer.cpp | 35 ++++++++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp index 36ac8b6ec33..9b1d1b3b431 100644 --- a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp @@ -430,7 +430,40 @@ PluginViewerImpl::LoadComplete(nsresult aStatus) NS_IMETHODIMP PluginViewerImpl::Destroy(void) { - return NS_ERROR_FAILURE; + // XXX ripped off from nsObjectFrame::Destroy() + + // we need to finish with the plugin before native window is destroyed + // doing this in the destructor is too late. + if(mOwner != nsnull) + { + nsIPluginInstance *inst; + if(NS_OK == mOwner->GetInstance(inst)) + { + PRBool doCache = PR_TRUE; + PRBool doCallSetWindowAfterDestroy = PR_FALSE; + + // first, determine if the plugin wants to be cached + inst->GetValue(nsPluginInstanceVariable_DoCacheBool, + (void *) &doCache); + if (!doCache) { + // then determine if the plugin wants Destroy to be called after + // Set Window. This is for bug 50547. + inst->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool, + (void *) &doCallSetWindowAfterDestroy); + !doCallSetWindowAfterDestroy ? inst->SetWindow(nsnull) : 0; + inst->Stop(); + inst->Destroy(); + doCallSetWindowAfterDestroy ? inst->SetWindow(nsnull) : 0; } + else { + inst->SetWindow(nsnull); + inst->Stop(); + } + NS_RELEASE(inst); + } + } + + + return NS_OK; } NS_IMETHODIMP diff --git a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp index 36ac8b6ec33..9b1d1b3b431 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginViewer.cpp @@ -430,7 +430,40 @@ PluginViewerImpl::LoadComplete(nsresult aStatus) NS_IMETHODIMP PluginViewerImpl::Destroy(void) { - return NS_ERROR_FAILURE; + // XXX ripped off from nsObjectFrame::Destroy() + + // we need to finish with the plugin before native window is destroyed + // doing this in the destructor is too late. + if(mOwner != nsnull) + { + nsIPluginInstance *inst; + if(NS_OK == mOwner->GetInstance(inst)) + { + PRBool doCache = PR_TRUE; + PRBool doCallSetWindowAfterDestroy = PR_FALSE; + + // first, determine if the plugin wants to be cached + inst->GetValue(nsPluginInstanceVariable_DoCacheBool, + (void *) &doCache); + if (!doCache) { + // then determine if the plugin wants Destroy to be called after + // Set Window. This is for bug 50547. + inst->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool, + (void *) &doCallSetWindowAfterDestroy); + !doCallSetWindowAfterDestroy ? inst->SetWindow(nsnull) : 0; + inst->Stop(); + inst->Destroy(); + doCallSetWindowAfterDestroy ? inst->SetWindow(nsnull) : 0; } + else { + inst->SetWindow(nsnull); + inst->Stop(); + } + NS_RELEASE(inst); + } + } + + + return NS_OK; } NS_IMETHODIMP