Fix to 39933.
Make the sample plugin implement nsIScriptablePlugin, and update sample .html file with an (unused!) JavaScript evaluator for poking at the plugin. r=jst a=ekrock git-svn-id: svn://10.0.0.236/trunk@76917 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -32,14 +32,53 @@ function SetText()
|
||||
document.the_form.the_text.value;
|
||||
}
|
||||
|
||||
/*
|
||||
// For JS evaluator below; unused.
|
||||
|
||||
var it = undefined; // persistent last special value.
|
||||
function EvalIt() {
|
||||
var inText = document.eval_form.eval_text.value;
|
||||
|
||||
dump(document.simple1);
|
||||
|
||||
try {
|
||||
var result = eval(inText);
|
||||
result = result ? result : "";
|
||||
document.eval_form.result_text.value = result;
|
||||
if (it)
|
||||
document.eval_form.it_text.value = "it: " + it;
|
||||
document.eval_form.eval_text.value = "";
|
||||
} catch (err) {
|
||||
document.eval_form.result_text.value = "Exn: " + err.toString();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
</script>
|
||||
|
||||
|
||||
<form name ="the_form">
|
||||
<INPUT TYPE="text" NAME="the_text" VALUE="some text" SIZE="25">
|
||||
<input type=button value="Set Text" onclick='SetText()'>
|
||||
<input type=button value="Get Text" onclick='GetText()'>
|
||||
</form>
|
||||
|
||||
<!--
|
||||
<hr>
|
||||
<form name ="eval_form">
|
||||
JavaScript evaluation for poking at the plugin ('document.simple1').<br>
|
||||
input:<br>
|
||||
<INPUT TYPE="text" NAME="eval_text" onchange = "EvalIt()" SIZE="80"><br>
|
||||
result:<br>
|
||||
<INPUT TYPE="text" NAME="result_text" SIZE="80"><br>
|
||||
contents of 'it':<br>
|
||||
<INPUT TYPE="text" NAME="it_text" SIZE="80">
|
||||
<p>
|
||||
<input type=button value="eval" onclick="EvalIt()">
|
||||
</form>
|
||||
-->
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
</center>
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
#include "simpleCID.h"
|
||||
|
||||
#include "nsISimplePluginInstance.h"
|
||||
#include "nsIScriptablePlugin.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Windows Includes
|
||||
@@ -171,7 +172,9 @@ static const PRInt32 kNumMimeTypes = sizeof(kMimeTypes) / sizeof(*kMimeTypes);
|
||||
|
||||
class SimplePluginInstance :
|
||||
public nsIPluginInstance,
|
||||
public nsIScriptablePlugin,
|
||||
public nsISimplePluginInstance {
|
||||
|
||||
public:
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// for implementing a generic module
|
||||
@@ -191,6 +194,7 @@ public:
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTABLEPLUGIN
|
||||
NS_DECL_NSISIMPLEPLUGININSTANCE
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
@@ -367,6 +371,32 @@ static nsModuleComponentInfo gComponentInfo[] = {
|
||||
|
||||
NS_IMPL_NSGETMODULE("SimplePlugin", gComponentInfo);
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIScriptablePlugin methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
NS_METHOD
|
||||
SimplePluginInstance::GetScriptablePeer(void **aScriptablePeer)
|
||||
{
|
||||
// We implement the interface we want to be scriptable by
|
||||
// (nsISimplePluginInstance) so we just return this.
|
||||
*aScriptablePeer = NS_STATIC_CAST(nsISimplePluginInstance *, this);
|
||||
NS_ADDREF(NS_STATIC_CAST(nsISimplePluginInstance *, *aScriptablePeer));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
SimplePluginInstance::GetScriptableInterface(nsIID **aScriptableInterface)
|
||||
{
|
||||
*aScriptableInterface = (nsIID *)nsMemory::Alloc(sizeof(nsIID));
|
||||
NS_ENSURE_TRUE(*aScriptableInterface, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
**aScriptableInterface = NS_GET_IID(nsISimplePluginInstance);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SimplePluginInstance Methods
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -461,7 +491,7 @@ SimplePluginInstance::~SimplePluginInstance(void)
|
||||
// These macros produce simple version of QueryInterface and AddRef.
|
||||
// See the nsISupports.h header file for details.
|
||||
|
||||
NS_IMPL_ISUPPORTS2(SimplePluginInstance, nsIPluginInstance, nsISimplePluginInstance)
|
||||
NS_IMPL_ISUPPORTS3(SimplePluginInstance, nsIPluginInstance, nsISimplePluginInstance, nsIScriptablePlugin)
|
||||
|
||||
/*+++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
* NewInstance:
|
||||
|
||||
Reference in New Issue
Block a user