From 52713ced889aed459330762e59d1ddaa6bf8f98a Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Fri, 3 Dec 1999 09:36:54 +0000 Subject: [PATCH] 1.) WebShell no longer implements nsIScriptContextOwner. 2.) WebShell now implements the new nsIScriptGlobalObjectOwner. 3.) WebShell supports GetInterface to nsIScriptGlobalObject. 4.) Documents no longer carry around a reference to nsIScriptContextOwner. Instead they hold on to a nsIScriptGlobalObject. nsIDocument::GetScriptContextOwner has now become nsIDocument::GetScriptGlobalObject(). Same change to the set methods. git-svn-id: svn://10.0.0.236/trunk@55177 18797224-902f-48f8-a5cc-f745e15eee43 --- .../plugin/base/src/nsPluginInstancePeer.cpp | 65 ++++++++----------- .../plugin/nglsrc/nsPluginInstancePeer.cpp | 65 ++++++++----------- 2 files changed, 54 insertions(+), 76 deletions(-) diff --git a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp index cb392cb514d..a2412934461 100644 --- a/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginInstancePeer.cpp @@ -35,7 +35,6 @@ #include "nsIServiceManager.h" #include "nsIDocument.h" -#include "nsIScriptContextOwner.h" #include "nsIScriptGlobalObject.h" #include "nsIScriptObjectOwner.h" @@ -781,31 +780,23 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSWindow(JSObject* *outJSWindow) *outJSWindow = NULL; nsresult rv = NS_ERROR_FAILURE; NS_WITH_SERVICE ( nsIJVMManager, jvm, nsIJVMManager::GetCID(), &rv); - if ( NS_SUCCEEDED ( rv ) && jvm != nsnull ) - { - nsIDocument* document = nsnull; - if (mOwner->GetDocument(&document) == NS_OK) { - nsIScriptContextOwner* contextOwner = document->GetScriptContextOwner(); - if (nsnull != contextOwner) { - nsIScriptGlobalObject *global = nsnull; - contextOwner->GetScriptGlobalObject(&global); - nsIScriptContext* context = nsnull; - contextOwner->GetScriptContext(&context); - if (nsnull != global && nsnull != context) { - static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); - nsIScriptObjectOwner* window = nsnull; - if (global->QueryInterface(kIScriptObjectOwnerIID, (void **)&window) == NS_OK) { - rv = window->GetScriptObject(context, (void**)outJSWindow); - NS_RELEASE(window); - } - } - NS_IF_RELEASE(global); - NS_IF_RELEASE(context); - NS_RELEASE(contextOwner); - } - NS_RELEASE(document); - } - } + if ( NS_SUCCEEDED ( rv ) && jvm != nsnull ) { + nsCOMPtr document; + if (mOwner->GetDocument(getter_AddRefs(document)) == NS_OK) { + nsCOMPtr global; + document->GetScriptGlobalObject(getter_AddRefs(global)); + if(global) { + nsCOMPtr context; + global->GetContext(getter_AddRefs(context)); + if (nsnull != context) { + nsCOMPtr window(do_QueryInterface(global)); + if (window) { + rv = window->GetScriptObject(context, (void**)outJSWindow); + } + } + } + } + } return rv; } @@ -821,21 +812,19 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSContext(JSContext* *outContext) nsresult rv = NS_ERROR_FAILURE; NS_WITH_SERVICE(nsIJVMManager, jvm, nsIJVMManager::GetCID(), &rv); if (NS_SUCCEEDED(rv) && jvm != nsnull ) { - nsIDocument* document = nsnull; - if (mOwner->GetDocument(&document) == NS_OK) { - nsIScriptContextOwner* contextOwner = document->GetScriptContextOwner(); - if (nsnull != contextOwner) { - nsIScriptContext* context = nsnull; - if (contextOwner->GetScriptContext(&context) == NS_OK) { + nsCOMPtr document; + if (mOwner->GetDocument(getter_AddRefs(document)) == NS_OK) { + nsCOMPtr global; + document->GetScriptGlobalObject(getter_AddRefs(global)); + if (global) { + nsCOMPtr context; + if (global->GetContext(getter_AddRefs(context)) == NS_OK) { *outContext = (JSContext*) context->GetNativeContext(); - NS_RELEASE(context); rv = NS_OK; } - NS_RELEASE(contextOwner); - } - NS_RELEASE(document); - } - } + } + } + } return rv; } diff --git a/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp b/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp index cb392cb514d..a2412934461 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginInstancePeer.cpp @@ -35,7 +35,6 @@ #include "nsIServiceManager.h" #include "nsIDocument.h" -#include "nsIScriptContextOwner.h" #include "nsIScriptGlobalObject.h" #include "nsIScriptObjectOwner.h" @@ -781,31 +780,23 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSWindow(JSObject* *outJSWindow) *outJSWindow = NULL; nsresult rv = NS_ERROR_FAILURE; NS_WITH_SERVICE ( nsIJVMManager, jvm, nsIJVMManager::GetCID(), &rv); - if ( NS_SUCCEEDED ( rv ) && jvm != nsnull ) - { - nsIDocument* document = nsnull; - if (mOwner->GetDocument(&document) == NS_OK) { - nsIScriptContextOwner* contextOwner = document->GetScriptContextOwner(); - if (nsnull != contextOwner) { - nsIScriptGlobalObject *global = nsnull; - contextOwner->GetScriptGlobalObject(&global); - nsIScriptContext* context = nsnull; - contextOwner->GetScriptContext(&context); - if (nsnull != global && nsnull != context) { - static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); - nsIScriptObjectOwner* window = nsnull; - if (global->QueryInterface(kIScriptObjectOwnerIID, (void **)&window) == NS_OK) { - rv = window->GetScriptObject(context, (void**)outJSWindow); - NS_RELEASE(window); - } - } - NS_IF_RELEASE(global); - NS_IF_RELEASE(context); - NS_RELEASE(contextOwner); - } - NS_RELEASE(document); - } - } + if ( NS_SUCCEEDED ( rv ) && jvm != nsnull ) { + nsCOMPtr document; + if (mOwner->GetDocument(getter_AddRefs(document)) == NS_OK) { + nsCOMPtr global; + document->GetScriptGlobalObject(getter_AddRefs(global)); + if(global) { + nsCOMPtr context; + global->GetContext(getter_AddRefs(context)); + if (nsnull != context) { + nsCOMPtr window(do_QueryInterface(global)); + if (window) { + rv = window->GetScriptObject(context, (void**)outJSWindow); + } + } + } + } + } return rv; } @@ -821,21 +812,19 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSContext(JSContext* *outContext) nsresult rv = NS_ERROR_FAILURE; NS_WITH_SERVICE(nsIJVMManager, jvm, nsIJVMManager::GetCID(), &rv); if (NS_SUCCEEDED(rv) && jvm != nsnull ) { - nsIDocument* document = nsnull; - if (mOwner->GetDocument(&document) == NS_OK) { - nsIScriptContextOwner* contextOwner = document->GetScriptContextOwner(); - if (nsnull != contextOwner) { - nsIScriptContext* context = nsnull; - if (contextOwner->GetScriptContext(&context) == NS_OK) { + nsCOMPtr document; + if (mOwner->GetDocument(getter_AddRefs(document)) == NS_OK) { + nsCOMPtr global; + document->GetScriptGlobalObject(getter_AddRefs(global)); + if (global) { + nsCOMPtr context; + if (global->GetContext(getter_AddRefs(context)) == NS_OK) { *outContext = (JSContext*) context->GetNativeContext(); - NS_RELEASE(context); rv = NS_OK; } - NS_RELEASE(contextOwner); - } - NS_RELEASE(document); - } - } + } + } + } return rv; }