Fix NPAPI NPN_PushPopupsEnabledState and NPN_PopPopupsEnabledState signature mismatches, statically initialize browser-side NPAPI function table with no casting. b=554170 r=bent

This commit is contained in:
Josh Aas 2010-03-25 19:45:33 -04:00
parent 373fc7b896
commit b5a2f793a8
6 changed files with 78 additions and 92 deletions

View File

@ -123,11 +123,9 @@ parent:
async NPN_InvalidateRect(NPRect rect);
rpc NPN_PushPopupsEnabledState(bool aState)
returns (bool aSuccess);
rpc NPN_PushPopupsEnabledState(bool aState);
rpc NPN_PopPopupsEnabledState()
returns (bool aSuccess);
rpc NPN_PopPopupsEnabledState();
rpc NPN_GetValueForURL(NPNURLVariable variable, nsCString url)
returns (nsCString value, NPError result);

View File

@ -830,17 +830,16 @@ PluginInstanceParent::GetActorForNPObject(NPObject* aObject)
}
bool
PluginInstanceParent::AnswerNPN_PushPopupsEnabledState(const bool& aState,
bool* aSuccess)
PluginInstanceParent::AnswerNPN_PushPopupsEnabledState(const bool& aState)
{
*aSuccess = mNPNIface->pushpopupsenabledstate(mNPP, aState ? 1 : 0);
mNPNIface->pushpopupsenabledstate(mNPP, aState ? 1 : 0);
return true;
}
bool
PluginInstanceParent::AnswerNPN_PopPopupsEnabledState(bool* aSuccess)
PluginInstanceParent::AnswerNPN_PopPopupsEnabledState()
{
*aSuccess = mNPNIface->poppopupsenabledstate(mNPP);
mNPNIface->poppopupsenabledstate(mNPP);
return true;
}

View File

@ -157,11 +157,10 @@ public:
RecvNPN_InvalidateRect(const NPRect& rect);
virtual bool
AnswerNPN_PushPopupsEnabledState(const bool& aState,
bool* aSuccess);
AnswerNPN_PushPopupsEnabledState(const bool& aState);
virtual bool
AnswerNPN_PopPopupsEnabledState(bool* aSuccess);
AnswerNPN_PopPopupsEnabledState();
NS_OVERRIDE virtual bool
AnswerNPN_GetValueForURL(const NPNURLVariable& variable,

View File

@ -673,10 +673,10 @@ _releasevariantvalue(NPVariant *variant);
static void NP_CALLBACK
_setexception(NPObject* npobj, const NPUTF8 *message);
static bool NP_CALLBACK
static void NP_CALLBACK
_pushpopupsenabledstate(NPP aNPP, NPBool enabled);
static bool NP_CALLBACK
static void NP_CALLBACK
_poppopupsenabledstate(NPP aNPP);
static void NP_CALLBACK
@ -1289,34 +1289,23 @@ _setexception(NPObject* aNPObj,
NS_WARNING("Not yet implemented!");
}
bool NP_CALLBACK
void NP_CALLBACK
_pushpopupsenabledstate(NPP aNPP,
NPBool aEnabled)
{
PLUGIN_LOG_DEBUG_FUNCTION;
// XXXbent This is incorrect, followup to make this return void!
ENSURE_PLUGIN_THREAD(false);
ENSURE_PLUGIN_THREAD_VOID();
bool retval;
if (InstCast(aNPP)->CallNPN_PushPopupsEnabledState(aEnabled ? true : false,
&retval)) {
return retval;
}
return false;
InstCast(aNPP)->CallNPN_PushPopupsEnabledState(aEnabled ? true : false);
}
bool NP_CALLBACK
void NP_CALLBACK
_poppopupsenabledstate(NPP aNPP)
{
PLUGIN_LOG_DEBUG_FUNCTION;
// XXXbent This is incorrect, followup to make this return void!
ENSURE_PLUGIN_THREAD(false);
ENSURE_PLUGIN_THREAD_VOID();
bool retval;
if (InstCast(aNPP)->CallNPN_PopPopupsEnabledState(&retval)) {
return retval;
}
return false;
InstCast(aNPP)->CallNPN_PopPopupsEnabledState();
}
void NP_CALLBACK

View File

@ -108,8 +108,8 @@ typedef bool (*NPN_HasPropertyProcPtr)(NPP npp, NPObject *obj, NPIdentif
typedef bool (*NPN_HasMethodProcPtr)(NPP npp, NPObject *obj, NPIdentifier propertyName);
typedef void (*NPN_ReleaseVariantValueProcPtr)(NPVariant *variant);
typedef void (*NPN_SetExceptionProcPtr)(NPObject *obj, const NPUTF8 *message);
typedef bool (*NPN_PushPopupsEnabledStateProcPtr)(NPP npp, NPBool enabled);
typedef bool (*NPN_PopPopupsEnabledStateProcPtr)(NPP npp);
typedef void (*NPN_PushPopupsEnabledStateProcPtr)(NPP npp, NPBool enabled);
typedef void (*NPN_PopPopupsEnabledStateProcPtr)(NPP npp);
typedef bool (*NPN_EnumerateProcPtr)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count);
typedef void (*NPN_PluginThreadAsyncCallProcPtr)(NPP instance, void (*func)(void *), void *userData);
typedef bool (*NPN_ConstructProcPtr)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);

View File

@ -110,7 +110,66 @@ using mozilla::PluginPRLibrary;
using mozilla::plugins::PluginModuleParent;
#endif
static NPNetscapeFuncs sBrowserFuncs;
using namespace mozilla::plugins::parent;
// We should make this const...
static NPNetscapeFuncs sBrowserFuncs = {
sizeof(sBrowserFuncs),
(NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR,
_geturl,
_posturl,
_requestread,
_newstream,
_write,
_destroystream,
_status,
_useragent,
_memalloc,
_memfree,
_memflush,
_reloadplugins,
_getJavaEnv,
_getJavaPeer,
_geturlnotify,
_posturlnotify,
_getvalue,
_setvalue,
_invalidaterect,
_invalidateregion,
_forceredraw,
_getstringidentifier,
_getstringidentifiers,
_getintidentifier,
_identifierisstring,
_utf8fromidentifier,
_intfromidentifier,
_createobject,
_retainobject,
_releaseobject,
_invoke,
_invokeDefault,
_evaluate,
_getproperty,
_setproperty,
_removeproperty,
_hasproperty,
_hasmethod,
_releasevariantvalue,
_setexception,
_pushpopupsenabledstate,
_poppopupsenabledstate,
_enumerate,
_pluginthreadasynccall,
_construct,
_getvalueforurl,
_setvalueforurl,
_getauthenticationinfo,
_scheduletimer,
_unscheduletimer,
_popupcontextmenu,
_convertpoint
};
static PRLock *sPluginThreadAsyncCallLock = nsnull;
static PRCList sPendingAsyncCalls = PR_INIT_STATIC_CLIST(&sPendingAsyncCalls);
@ -122,8 +181,6 @@ enum eNPPStreamTypeInternal {
static NS_DEFINE_IID(kMemoryCID, NS_MEMORY_CID);
using namespace mozilla::plugins::parent;
// This function sends a notification using the observer service to any object
// registered to listen to the "experimental-notify-plugin-call" subject.
// Each "experimental-notify-plugin-call" notification carries with it the run
@ -152,62 +209,6 @@ nsNPAPIPlugin::CheckClassInitialized()
if (initialized)
return;
// XXX It'd be nice to make this const and initialize it statically...
sBrowserFuncs.size = sizeof(sBrowserFuncs);
sBrowserFuncs.version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
sBrowserFuncs.geturl = ((NPN_GetURLProcPtr)_geturl);
sBrowserFuncs.posturl = ((NPN_PostURLProcPtr)_posturl);
sBrowserFuncs.requestread = ((NPN_RequestReadProcPtr)_requestread);
sBrowserFuncs.newstream = ((NPN_NewStreamProcPtr)_newstream);
sBrowserFuncs.write = ((NPN_WriteProcPtr)_write);
sBrowserFuncs.destroystream = ((NPN_DestroyStreamProcPtr)_destroystream);
sBrowserFuncs.status = ((NPN_StatusProcPtr)_status);
sBrowserFuncs.uagent = ((NPN_UserAgentProcPtr)_useragent);
sBrowserFuncs.memalloc = ((NPN_MemAllocProcPtr)_memalloc);
sBrowserFuncs.memfree = ((NPN_MemFreeProcPtr)_memfree);
sBrowserFuncs.memflush = ((NPN_MemFlushProcPtr)_memflush);
sBrowserFuncs.reloadplugins = ((NPN_ReloadPluginsProcPtr)_reloadplugins);
sBrowserFuncs.getJavaEnv = ((NPN_GetJavaEnvProcPtr)_getJavaEnv);
sBrowserFuncs.getJavaPeer = ((NPN_GetJavaPeerProcPtr)_getJavaPeer);
sBrowserFuncs.geturlnotify = ((NPN_GetURLNotifyProcPtr)_geturlnotify);
sBrowserFuncs.posturlnotify = ((NPN_PostURLNotifyProcPtr)_posturlnotify);
sBrowserFuncs.getvalue = ((NPN_GetValueProcPtr)_getvalue);
sBrowserFuncs.setvalue = ((NPN_SetValueProcPtr)_setvalue);
sBrowserFuncs.invalidaterect = ((NPN_InvalidateRectProcPtr)_invalidaterect);
sBrowserFuncs.invalidateregion = ((NPN_InvalidateRegionProcPtr)_invalidateregion);
sBrowserFuncs.forceredraw = ((NPN_ForceRedrawProcPtr)_forceredraw);
sBrowserFuncs.getstringidentifier = ((NPN_GetStringIdentifierProcPtr)_getstringidentifier);
sBrowserFuncs.getstringidentifiers = ((NPN_GetStringIdentifiersProcPtr)_getstringidentifiers);
sBrowserFuncs.getintidentifier = ((NPN_GetIntIdentifierProcPtr)_getintidentifier);
sBrowserFuncs.identifierisstring = ((NPN_IdentifierIsStringProcPtr)_identifierisstring);
sBrowserFuncs.utf8fromidentifier = ((NPN_UTF8FromIdentifierProcPtr)_utf8fromidentifier);
sBrowserFuncs.intfromidentifier = ((NPN_IntFromIdentifierProcPtr)_intfromidentifier);
sBrowserFuncs.createobject = ((NPN_CreateObjectProcPtr)_createobject);
sBrowserFuncs.retainobject = ((NPN_RetainObjectProcPtr)_retainobject);
sBrowserFuncs.releaseobject = ((NPN_ReleaseObjectProcPtr)_releaseobject);
sBrowserFuncs.invoke = ((NPN_InvokeProcPtr)_invoke);
sBrowserFuncs.invokeDefault = ((NPN_InvokeDefaultProcPtr)_invokeDefault);
sBrowserFuncs.evaluate = ((NPN_EvaluateProcPtr)_evaluate);
sBrowserFuncs.getproperty = ((NPN_GetPropertyProcPtr)_getproperty);
sBrowserFuncs.setproperty = ((NPN_SetPropertyProcPtr)_setproperty);
sBrowserFuncs.removeproperty = ((NPN_RemovePropertyProcPtr)_removeproperty);
sBrowserFuncs.hasproperty = ((NPN_HasPropertyProcPtr)_hasproperty);
sBrowserFuncs.hasmethod = ((NPN_HasMethodProcPtr)_hasmethod);
sBrowserFuncs.enumerate = ((NPN_EnumerateProcPtr)_enumerate);
sBrowserFuncs.construct = ((NPN_ConstructProcPtr)_construct);
sBrowserFuncs.releasevariantvalue = ((NPN_ReleaseVariantValueProcPtr)_releasevariantvalue);
sBrowserFuncs.setexception = ((NPN_SetExceptionProcPtr)_setexception);
sBrowserFuncs.pushpopupsenabledstate = ((NPN_PushPopupsEnabledStateProcPtr)_pushpopupsenabledstate);
sBrowserFuncs.poppopupsenabledstate = ((NPN_PopPopupsEnabledStateProcPtr)_poppopupsenabledstate);
sBrowserFuncs.pluginthreadasynccall = ((NPN_PluginThreadAsyncCallProcPtr)_pluginthreadasynccall);
sBrowserFuncs.getvalueforurl = ((NPN_GetValueForURLPtr)_getvalueforurl);
sBrowserFuncs.setvalueforurl = ((NPN_SetValueForURLPtr)_setvalueforurl);
sBrowserFuncs.getauthenticationinfo = ((NPN_GetAuthenticationInfoPtr)_getauthenticationinfo);
sBrowserFuncs.scheduletimer = ((NPN_ScheduleTimerPtr)_scheduletimer);
sBrowserFuncs.unscheduletimer = ((NPN_UnscheduleTimerPtr)_unscheduletimer);
sBrowserFuncs.popupcontextmenu = ((NPN_PopUpContextMenuPtr)_popupcontextmenu);
sBrowserFuncs.convertpoint = ((NPN_ConvertPointPtr)_convertpoint);
if (!sPluginThreadAsyncCallLock)
sPluginThreadAsyncCallLock = nsAutoLock::NewLock("sPluginThreadAsyncCallLock");