Fixing bug 169513, Add the means to obtain the DOM from a plugin r=adamlock sr=beard
git-svn-id: svn://10.0.0.236/trunk@131221 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
|
||||
|
||||
/*
|
||||
* npapi.h $Revision: 3.23 $
|
||||
* npapi.h $Revision: 3.24 $
|
||||
* Netscape client plug-in API spec
|
||||
*/
|
||||
|
||||
@@ -353,7 +353,10 @@ typedef enum {
|
||||
NPNVisOfflineBool,
|
||||
|
||||
/* 10 and over are available on Mozilla builds starting with 0.9.4 */
|
||||
NPNVserviceManager = 10
|
||||
NPNVserviceManager = 10,
|
||||
NPNVDOMElement = 11, /* available in Mozilla 1.2 */
|
||||
NPNVDOMDocument = 12,
|
||||
NPNVDOMWindow = 13
|
||||
} NPNVariable;
|
||||
|
||||
/*
|
||||
|
||||
@@ -53,6 +53,13 @@
|
||||
#include "nsIPluginInstancePeer2.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
|
||||
#include "nsPIPluginInstancePeer.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <Resources.h>
|
||||
#endif
|
||||
@@ -1211,6 +1218,73 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
case NPNVDOMElement: {
|
||||
ns4xPluginInstance *inst = (ns4xPluginInstance *) npp->ndata;
|
||||
NS_ENSURE_TRUE(inst, NPERR_GENERIC_ERROR);
|
||||
|
||||
nsCOMPtr<nsIPluginInstancePeer> pip;
|
||||
inst->GetPeer(getter_AddRefs(pip));
|
||||
nsCOMPtr<nsIPluginTagInfo2> pti2 (do_QueryInterface(pip));
|
||||
if (pti2) {
|
||||
nsCOMPtr<nsIDOMElement> e;
|
||||
pti2->GetDOMElement(getter_AddRefs(e));
|
||||
if (e) {
|
||||
NS_ADDREF(*(nsIDOMElement**)result = e.get());
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
case NPNVDOMDocument: {
|
||||
ns4xPluginInstance *inst = (ns4xPluginInstance *) npp->ndata;
|
||||
NS_ENSURE_TRUE(inst, NPERR_GENERIC_ERROR);
|
||||
|
||||
nsCOMPtr<nsIPluginInstancePeer> pip;
|
||||
inst->GetPeer(getter_AddRefs(pip));
|
||||
nsCOMPtr<nsPIPluginInstancePeer> pp (do_QueryInterface(pip));
|
||||
if (pp) {
|
||||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||
pp->GetOwner(getter_AddRefs(owner));
|
||||
if (owner) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
owner->GetDocument(getter_AddRefs(doc));
|
||||
nsCOMPtr<nsIDOMDocument> domDoc (do_QueryInterface(doc));
|
||||
if (domDoc) {
|
||||
NS_ADDREF(*(nsIDOMDocument**)result = domDoc.get());
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
case NPNVDOMWindow: {
|
||||
ns4xPluginInstance *inst = (ns4xPluginInstance *) npp->ndata;
|
||||
NS_ENSURE_TRUE(inst, NPERR_GENERIC_ERROR);
|
||||
|
||||
nsCOMPtr<nsIPluginInstancePeer> pip;
|
||||
inst->GetPeer(getter_AddRefs(pip));
|
||||
nsCOMPtr<nsPIPluginInstancePeer> pp (do_QueryInterface(pip));
|
||||
if (pp) {
|
||||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||
pp->GetOwner(getter_AddRefs(owner));
|
||||
if (owner) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
owner->GetDocument(getter_AddRefs(doc));
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalScript;
|
||||
doc->GetScriptGlobalObject(getter_AddRefs(globalScript));
|
||||
nsCOMPtr<nsIDOMWindow> domWindow (do_QueryInterface(globalScript));
|
||||
if (domWindow) {
|
||||
NS_ADDREF(*(nsIDOMWindow**)result = domWindow.get());
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
default : return NPERR_GENERIC_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user