added GetJSWindow

git-svn-id: svn://10.0.0.236/trunk@24970 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
beard%netscape.com
1999-03-24 05:40:02 +00:00
parent 694daf35c1
commit 9d6661c4ef
4 changed files with 74 additions and 0 deletions

View File

@@ -27,6 +27,11 @@
#include "nsFileSpec.h"
#include "nsCOMPtr.h"
#include "nsIDocument.h"
#include "nsIScriptContextOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptObjectOwner.h"
#ifdef XP_PC
#include "windows.h"
#include "winbase.h"
@@ -751,6 +756,35 @@ printf("instance peer setwindowsize called\n");
return NS_OK;
}
NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSWindow(JSObject* *outJSWindow)
{
*outJSWindow = NULL;
nsresult rv = NS_ERROR_FAILURE;
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);
}
return rv;
}
nsresult nsPluginInstancePeerImpl :: Initialize(nsIPluginInstanceOwner *aOwner,
const nsMIMEType aMIMEType)
{

View File

@@ -58,6 +58,9 @@ public:
NS_IMETHOD
SetWindowSize(PRUint32 width, PRUint32 height);
NS_IMETHOD
GetJSWindow(JSObject* *outJSWindow);
// nsIWindowlessPluginInstancePeer
// (Corresponds to NPN_InvalidateRect.)

View File

@@ -27,6 +27,11 @@
#include "nsFileSpec.h"
#include "nsCOMPtr.h"
#include "nsIDocument.h"
#include "nsIScriptContextOwner.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptObjectOwner.h"
#ifdef XP_PC
#include "windows.h"
#include "winbase.h"
@@ -751,6 +756,35 @@ printf("instance peer setwindowsize called\n");
return NS_OK;
}
NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSWindow(JSObject* *outJSWindow)
{
*outJSWindow = NULL;
nsresult rv = NS_ERROR_FAILURE;
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);
}
return rv;
}
nsresult nsPluginInstancePeerImpl :: Initialize(nsIPluginInstanceOwner *aOwner,
const nsMIMEType aMIMEType)
{

View File

@@ -58,6 +58,9 @@ public:
NS_IMETHOD
SetWindowSize(PRUint32 width, PRUint32 height);
NS_IMETHOD
GetJSWindow(JSObject* *outJSWindow);
// nsIWindowlessPluginInstancePeer
// (Corresponds to NPN_InvalidateRect.)