From 56191027370e84e7fc4a88edde7c2d95e0dc33c4 Mon Sep 17 00:00:00 2001 From: "warren%netscape.com" Date: Tue, 15 Sep 1998 03:45:38 +0000 Subject: [PATCH] Accepting michaelp's API changes for GetValue/SetValue. --- modules/plugin/bad/badapter.cpp | 31 ++-- modules/plugin/base/public/nsIPlugin.h | 13 -- .../plugin/base/public/nsIPluginInstance.h | 10 ++ .../base/public/nsIPluginInstancePeer.h | 22 ++- modules/plugin/base/public/nsIPluginManager.h | 12 -- modules/plugin/base/public/nsplugindefs.h | 23 +-- modules/plugin/public/nsIPlugin.h | 13 -- modules/plugin/public/nsIPluginInstance.h | 10 ++ modules/plugin/public/nsIPluginInstancePeer.h | 22 ++- modules/plugin/public/nsIPluginManager.h | 12 -- modules/plugin/public/nsplugindefs.h | 23 +-- modules/plugin/samples/backward/badapter.cpp | 31 ++-- modules/plugin/samples/simple/makefile.win | 4 +- modules/plugin/samples/simple/npsimple.cpp | 19 +-- modules/plugin/src/npglue.cpp | 142 +++++++++------ modules/plugin/src/npglue.h | 11 +- modules/plugin/src/nsplugin.cpp | 161 ++++++++++-------- modules/plugin/test/makefile.win | 4 +- modules/plugin/test/npsimple.cpp | 19 +-- 19 files changed, 294 insertions(+), 288 deletions(-) diff --git a/modules/plugin/bad/badapter.cpp b/modules/plugin/bad/badapter.cpp index 15f3cb3a263a..375d041aef59 100644 --- a/modules/plugin/bad/badapter.cpp +++ b/modules/plugin/bad/badapter.cpp @@ -213,12 +213,9 @@ public: NS_IMETHOD ShowStatus(const char* message); - // XXX - Where did this go? NS_IMETHOD - Version(int* plugin_major, int* plugin_minor, - int* netscape_major, int* netscape_minor); + SetWindowSize(PRUint32 width, PRUint32 height); - nsIPluginInstance* GetInstance(void) { return mInstance; } NPP GetNPPInstance(void) { return npp; } @@ -1273,22 +1270,6 @@ CPluginInstancePeer::GetAttribute(const char* name, const char* *result) return NS_ERROR_FAILURE; } -//+++++++++++++++++++++++++++++++++++++++++++++++++ -// Version: -// -// XXX - Where did this go in the new API? -// -//+++++++++++++++++++++++++++++++++++++++++++++++++ - -NS_METHOD -CPluginInstancePeer::Version(int* plugin_major, int* plugin_minor, - int* netscape_major, int* netscape_minor) -{ - NPN_Version(plugin_major, plugin_minor, netscape_major, netscape_minor); - return NS_OK; -} - - //+++++++++++++++++++++++++++++++++++++++++++++++++ // NewStream: //+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1329,6 +1310,16 @@ CPluginInstancePeer::ShowStatus(const char* message) return NS_OK; } +NS_METHOD +CPluginInstancePeer::SetWindowSize(PRUint32 width, PRUint32 height) +{ + NPError err; + NPSize size; + size.width = width; + size.height = height; + err = NPN_SetValue(npp, NPPVpluginWindowSize, &size); + return fromNPError[err]; +} //+++++++++++++++++++++++++++++++++++++++++++++++++ // nsISupports functions diff --git a/modules/plugin/base/public/nsIPlugin.h b/modules/plugin/base/public/nsIPlugin.h index 53db089d7b7d..9811adfeb601 100644 --- a/modules/plugin/base/public/nsIPlugin.h +++ b/modules/plugin/base/public/nsIPlugin.h @@ -106,19 +106,6 @@ public: */ NS_IMETHOD GetValue(nsPluginVariable variable, void *value) = 0; - - /** - * Sets the value of a variable associated with the plugin. - * - * (Corresponds to NPP_SetValue.) - * - * @param variable - the plugin variable to get - * @param value - the address of the value to store - * @result - NS_OK if this operation was successful - */ - NS_IMETHOD - SetValue(nsPluginVariable variable, void *value) = 0; - }; #define NS_IPLUGIN_IID \ diff --git a/modules/plugin/base/public/nsIPluginInstance.h b/modules/plugin/base/public/nsIPluginInstance.h index d277af536afb..4f0a6b1256e5 100644 --- a/modules/plugin/base/public/nsIPluginInstance.h +++ b/modules/plugin/base/public/nsIPluginInstance.h @@ -167,6 +167,16 @@ public: URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData) = 0; + /** + * Returns the value of a variable associated with the plugin instance. + * + * @param variable - the plugin instance variable to get + * @param value - the address of where to store the resulting value + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetValue(nsPluginInstanceVariable variable, void *value) = 0; + }; #define NS_IPLUGININSTANCE_IID \ diff --git a/modules/plugin/base/public/nsIPluginInstancePeer.h b/modules/plugin/base/public/nsIPluginInstancePeer.h index 05d29933a8bf..ff29b2fa4a02 100644 --- a/modules/plugin/base/public/nsIPluginInstancePeer.h +++ b/modules/plugin/base/public/nsIPluginInstancePeer.h @@ -66,18 +66,6 @@ public: NS_IMETHOD GetValue(nsPluginInstancePeerVariable variable, void *value) = 0; - /** - * Sets the value of a variable associated with the plugin manager. - * - * (Corresponds to NPN_SetValue.) - * - * @param variable - the plugin manager variable to get - * @param value - the address of the value to store - * @result - NS_OK if this operation was successful - */ - NS_IMETHOD - SetValue(nsPluginInstancePeerVariable variable, void *value) = 0; - /** * Returns the MIME type of the plugin instance. * @@ -129,6 +117,16 @@ public: NS_IMETHOD ShowStatus(const char* message) = 0; + /** + * Set the desired size of the window in which the plugin instance lives. + * + * @param width - new window width + * @param height - new window height + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + SetWindowSize(PRUint32 width, PRUint32 height) = 0; + }; #define NS_IPLUGININSTANCEPEER_IID \ diff --git a/modules/plugin/base/public/nsIPluginManager.h b/modules/plugin/base/public/nsIPluginManager.h index fe5df70e314d..6e08db759e21 100644 --- a/modules/plugin/base/public/nsIPluginManager.h +++ b/modules/plugin/base/public/nsIPluginManager.h @@ -58,18 +58,6 @@ public: NS_IMETHOD GetValue(nsPluginManagerVariable variable, void *value) = 0; - /** - * Sets the value of a variable associated with the plugin manager. - * - * (Corresponds to NPN_SetValue.) - * - * @param variable - the plugin manager variable to get - * @param value - the address of the value to store - * @result - NS_OK if this operation was successful - */ - NS_IMETHOD - SetValue(nsPluginManagerVariable variable, void *value) = 0; - /** * Causes the plugins directory to be searched again for new plugin * libraries. diff --git a/modules/plugin/base/public/nsplugindefs.h b/modules/plugin/base/public/nsplugindefs.h index c06bf04c35f7..6c93474da569 100644 --- a/modules/plugin/base/public/nsplugindefs.h +++ b/modules/plugin/base/public/nsplugindefs.h @@ -168,23 +168,24 @@ struct nsPluginPrintCallbackStruct { // List of variables which should be implmented by the plugin enum nsPluginVariable { - nsPluginVariable_NameString = 1, - nsPluginVariable_DescriptionString = 2 + nsPluginVariable_NameString = 1, + nsPluginVariable_DescriptionString = 2 }; -// List of variables which are implemented by the browser enum nsPluginManagerVariable { - nsPluginManagerVariable_XDisplay = 1, - nsPluginManagerVariable_XtAppContext = 2, - nsPluginManagerVariable_NetscapeWindow = 3 + nsPluginManagerVariable_XDisplay = 1, + nsPluginManagerVariable_XtAppContext = 2 }; enum nsPluginInstancePeerVariable { - nsPluginInstancePeerVariable_WindowBool = 3, - nsPluginInstancePeerVariable_TransparentBool = 4, - nsPluginInstancePeerVariable_JavaClass = 5, - nsPluginInstancePeerVariable_WindowSize = 6, - nsPluginInstancePeerVariable_TimerInterval = 7 + nsPluginInstancePeerVariable_NetscapeWindow = 3 +// nsPluginInstancePeerVariable_JavaClass = 5, +// nsPluginInstancePeerVariable_TimerInterval = 7 +}; + +enum nsPluginInstanceVariable { + nsPluginInstanceVariable_WindowlessBool = 3, + nsPluginInstanceVariable_TransparentBool = 4 }; //////////////////////////////////////////////////////////////////////////////// diff --git a/modules/plugin/public/nsIPlugin.h b/modules/plugin/public/nsIPlugin.h index 53db089d7b7d..9811adfeb601 100644 --- a/modules/plugin/public/nsIPlugin.h +++ b/modules/plugin/public/nsIPlugin.h @@ -106,19 +106,6 @@ public: */ NS_IMETHOD GetValue(nsPluginVariable variable, void *value) = 0; - - /** - * Sets the value of a variable associated with the plugin. - * - * (Corresponds to NPP_SetValue.) - * - * @param variable - the plugin variable to get - * @param value - the address of the value to store - * @result - NS_OK if this operation was successful - */ - NS_IMETHOD - SetValue(nsPluginVariable variable, void *value) = 0; - }; #define NS_IPLUGIN_IID \ diff --git a/modules/plugin/public/nsIPluginInstance.h b/modules/plugin/public/nsIPluginInstance.h index d277af536afb..4f0a6b1256e5 100644 --- a/modules/plugin/public/nsIPluginInstance.h +++ b/modules/plugin/public/nsIPluginInstance.h @@ -167,6 +167,16 @@ public: URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData) = 0; + /** + * Returns the value of a variable associated with the plugin instance. + * + * @param variable - the plugin instance variable to get + * @param value - the address of where to store the resulting value + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + GetValue(nsPluginInstanceVariable variable, void *value) = 0; + }; #define NS_IPLUGININSTANCE_IID \ diff --git a/modules/plugin/public/nsIPluginInstancePeer.h b/modules/plugin/public/nsIPluginInstancePeer.h index 05d29933a8bf..ff29b2fa4a02 100644 --- a/modules/plugin/public/nsIPluginInstancePeer.h +++ b/modules/plugin/public/nsIPluginInstancePeer.h @@ -66,18 +66,6 @@ public: NS_IMETHOD GetValue(nsPluginInstancePeerVariable variable, void *value) = 0; - /** - * Sets the value of a variable associated with the plugin manager. - * - * (Corresponds to NPN_SetValue.) - * - * @param variable - the plugin manager variable to get - * @param value - the address of the value to store - * @result - NS_OK if this operation was successful - */ - NS_IMETHOD - SetValue(nsPluginInstancePeerVariable variable, void *value) = 0; - /** * Returns the MIME type of the plugin instance. * @@ -129,6 +117,16 @@ public: NS_IMETHOD ShowStatus(const char* message) = 0; + /** + * Set the desired size of the window in which the plugin instance lives. + * + * @param width - new window width + * @param height - new window height + * @result - NS_OK if this operation was successful + */ + NS_IMETHOD + SetWindowSize(PRUint32 width, PRUint32 height) = 0; + }; #define NS_IPLUGININSTANCEPEER_IID \ diff --git a/modules/plugin/public/nsIPluginManager.h b/modules/plugin/public/nsIPluginManager.h index fe5df70e314d..6e08db759e21 100644 --- a/modules/plugin/public/nsIPluginManager.h +++ b/modules/plugin/public/nsIPluginManager.h @@ -58,18 +58,6 @@ public: NS_IMETHOD GetValue(nsPluginManagerVariable variable, void *value) = 0; - /** - * Sets the value of a variable associated with the plugin manager. - * - * (Corresponds to NPN_SetValue.) - * - * @param variable - the plugin manager variable to get - * @param value - the address of the value to store - * @result - NS_OK if this operation was successful - */ - NS_IMETHOD - SetValue(nsPluginManagerVariable variable, void *value) = 0; - /** * Causes the plugins directory to be searched again for new plugin * libraries. diff --git a/modules/plugin/public/nsplugindefs.h b/modules/plugin/public/nsplugindefs.h index c06bf04c35f7..6c93474da569 100644 --- a/modules/plugin/public/nsplugindefs.h +++ b/modules/plugin/public/nsplugindefs.h @@ -168,23 +168,24 @@ struct nsPluginPrintCallbackStruct { // List of variables which should be implmented by the plugin enum nsPluginVariable { - nsPluginVariable_NameString = 1, - nsPluginVariable_DescriptionString = 2 + nsPluginVariable_NameString = 1, + nsPluginVariable_DescriptionString = 2 }; -// List of variables which are implemented by the browser enum nsPluginManagerVariable { - nsPluginManagerVariable_XDisplay = 1, - nsPluginManagerVariable_XtAppContext = 2, - nsPluginManagerVariable_NetscapeWindow = 3 + nsPluginManagerVariable_XDisplay = 1, + nsPluginManagerVariable_XtAppContext = 2 }; enum nsPluginInstancePeerVariable { - nsPluginInstancePeerVariable_WindowBool = 3, - nsPluginInstancePeerVariable_TransparentBool = 4, - nsPluginInstancePeerVariable_JavaClass = 5, - nsPluginInstancePeerVariable_WindowSize = 6, - nsPluginInstancePeerVariable_TimerInterval = 7 + nsPluginInstancePeerVariable_NetscapeWindow = 3 +// nsPluginInstancePeerVariable_JavaClass = 5, +// nsPluginInstancePeerVariable_TimerInterval = 7 +}; + +enum nsPluginInstanceVariable { + nsPluginInstanceVariable_WindowlessBool = 3, + nsPluginInstanceVariable_TransparentBool = 4 }; //////////////////////////////////////////////////////////////////////////////// diff --git a/modules/plugin/samples/backward/badapter.cpp b/modules/plugin/samples/backward/badapter.cpp index 15f3cb3a263a..375d041aef59 100644 --- a/modules/plugin/samples/backward/badapter.cpp +++ b/modules/plugin/samples/backward/badapter.cpp @@ -213,12 +213,9 @@ public: NS_IMETHOD ShowStatus(const char* message); - // XXX - Where did this go? NS_IMETHOD - Version(int* plugin_major, int* plugin_minor, - int* netscape_major, int* netscape_minor); + SetWindowSize(PRUint32 width, PRUint32 height); - nsIPluginInstance* GetInstance(void) { return mInstance; } NPP GetNPPInstance(void) { return npp; } @@ -1273,22 +1270,6 @@ CPluginInstancePeer::GetAttribute(const char* name, const char* *result) return NS_ERROR_FAILURE; } -//+++++++++++++++++++++++++++++++++++++++++++++++++ -// Version: -// -// XXX - Where did this go in the new API? -// -//+++++++++++++++++++++++++++++++++++++++++++++++++ - -NS_METHOD -CPluginInstancePeer::Version(int* plugin_major, int* plugin_minor, - int* netscape_major, int* netscape_minor) -{ - NPN_Version(plugin_major, plugin_minor, netscape_major, netscape_minor); - return NS_OK; -} - - //+++++++++++++++++++++++++++++++++++++++++++++++++ // NewStream: //+++++++++++++++++++++++++++++++++++++++++++++++++ @@ -1329,6 +1310,16 @@ CPluginInstancePeer::ShowStatus(const char* message) return NS_OK; } +NS_METHOD +CPluginInstancePeer::SetWindowSize(PRUint32 width, PRUint32 height) +{ + NPError err; + NPSize size; + size.width = width; + size.height = height; + err = NPN_SetValue(npp, NPPVpluginWindowSize, &size); + return fromNPError[err]; +} //+++++++++++++++++++++++++++++++++++++++++++++++++ // nsISupports functions diff --git a/modules/plugin/samples/simple/makefile.win b/modules/plugin/samples/simple/makefile.win index be4b3c0b705d..94ce10546971 100644 --- a/modules/plugin/samples/simple/makefile.win +++ b/modules/plugin/samples/simple/makefile.win @@ -31,7 +31,7 @@ OBJS = .\$(OBJDIR)\npsimple.obj \ JDIRS = . -JRI_GEN = \ +xJRI_GEN = \ Simple \ java.lang.Object \ netscape.plugin.Plugin \ @@ -76,7 +76,7 @@ GARBAGE = $(GARBAGE) _gen #//------------------------------------------------------------------------ include <$(DEPTH)/config/rules.mak> -LINCS=$(LINCS) -I$(PUBLIC)\plugin -I$(PUBLIC)\xpcom -I$(PUBLIC)\java -I$(PUBLIC)\plugimpl -I$(PUBLIC)\raptor +LINCS=$(LINCS) -I$(PUBLIC)\plugin -I$(PUBLIC)\xpcom -I$(PUBLIC)\java -I$(PUBLIC)\plugimpl -I$(PUBLIC)\raptor -I_jri install:: $(DLL) $(MAKE_INSTALL) $(XPDIST)\classes11\Simple.class $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple diff --git a/modules/plugin/samples/simple/npsimple.cpp b/modules/plugin/samples/simple/npsimple.cpp index ba686f478522..89d8d677c4ea 100644 --- a/modules/plugin/samples/simple/npsimple.cpp +++ b/modules/plugin/samples/simple/npsimple.cpp @@ -163,10 +163,6 @@ public: NS_IMETHOD GetValue(nsPluginVariable variable, void *value); - // (Corresponds to NPP_SetValue.) - NS_IMETHOD - SetValue(nsPluginVariable variable, void *value); - // The old NPP_New call has been factored into two plugin instance methods: // // CreateInstance -- called once, after the plugin instance is created. This @@ -266,6 +262,9 @@ public: URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData); + NS_IMETHOD + GetValue(nsPluginInstanceVariable variable, void *value); + //////////////////////////////////////////////////////////////////////////// // SimplePluginInstance specific methods: @@ -504,12 +503,6 @@ SimplePlugin::GetValue(nsPluginVariable variable, void *value) return err; } -NS_METHOD -SimplePlugin::SetValue(nsPluginVariable variable, void *value) -{ - return NS_OK; -} - /*+++++++++++++++++++++++++++++++++++++++++++++++++ * GetJavaClass: * @@ -788,6 +781,12 @@ SimplePluginInstance::URLNotify(const char* url, const char* target, return NS_OK; } +NS_METHOD +SimplePluginInstance::GetValue(nsPluginInstanceVariable variable, void *value) +{ + return NS_OK; +} + //////////////////////////////////////////////////////////////////////////////// // SimplePluginStream Methods //////////////////////////////////////////////////////////////////////////////// diff --git a/modules/plugin/src/npglue.cpp b/modules/plugin/src/npglue.cpp index 6388c8448b8a..7a9fdcc8be86 100644 --- a/modules/plugin/src/npglue.cpp +++ b/modules/plugin/src/npglue.cpp @@ -1602,6 +1602,67 @@ npn_getvalue(NPP npp, NPNVariable variable, void *r_value) return(ret); } +NPError +npn_SetWindowless(np_instance* instance, PRBool windowed) +{ + /* + * XXX On the Mac, a window has already been allocated by the time NPP_New + * has been called - which is fine, since we'll still use the window. + * Unfortunately, we can't use the window's presence to determine whether + * it's too late to set the windowed property. + */ +#ifndef XP_MAC + /* + * If the window has already been allocated, it's too late + * to tell us. + */ + if (!instance->app->wdata->window) + instance->windowed = windowed; + else + return NPERR_INVALID_PARAM; +#else + instance->windowed = windowed; +#endif + return NPERR_NO_ERROR; +} + +NPError +npn_SetTransparent(np_instance* instance, PRBool transparent) +{ + instance->transparent = transparent; +#ifdef LAYERS + if (instance->layer && + (instance->transparent != !(CL_GetLayerFlags(instance->layer) & CL_OPAQUE))) + { + XP_Rect bbox; + + /* Get the bbox and convert it into its own coordinate space */ + CL_GetLayerBbox(instance->layer, &bbox); + + CL_ChangeLayerFlag(instance->layer, CL_OPAQUE, (PRBool)!instance->transparent); + CL_ChangeLayerFlag(instance->layer, + CL_PREFER_DRAW_OFFSCREEN, + (PRBool)instance->transparent); + + /* Force drawing of the entire transparent plug-in. */ + CL_UpdateLayerRect(CL_GetLayerCompositor(instance->layer), + instance->layer, &bbox, PR_FALSE); + } +#endif /* LAYERS */ + return NPERR_NO_ERROR; +} + +NPError +npn_SetWindowSize(np_instance* instance, NPSize* pnpsz) +{ + np_data * ndata = (np_data *)instance->app->np_data; + LO_EmbedStruct * pes = ndata->lo_struct; + + LO_SetEmbedSize(instance->cx, pes, pnpsz->width, pnpsz->height); + LO_RelayoutFromElement(instance->cx, (LO_Element *)pes); + return NPERR_NO_ERROR; +} + NPError NP_EXPORT npn_setvalue(NPP npp, NPPVariable variable, void *r_value) { @@ -1616,65 +1677,24 @@ npn_setvalue(NPP npp, NPPVariable variable, void *r_value) return NPERR_INVALID_INSTANCE_ERROR; switch(variable) { - case NPPVpluginWindowBool: - /* - * XXX On the Mac, a window has already been allocated by the time NPP_New - * has been called - which is fine, since we'll still use the window. - * Unfortunately, we can't use the window's presence to determine whether - * it's too late to set the windowed property. - */ -#ifndef XP_MAC - /* - * If the window has already been allocated, it's too late - * to tell us. - */ - if (!instance->app->wdata->window) - instance->windowed = (0 != r_value); - else - ret = NPERR_INVALID_PARAM; -#else - instance->windowed = (0 != r_value); -#endif - break; - case NPPVpluginTransparentBool: - instance->transparent = (0 != r_value); -#ifdef LAYERS - if (instance->layer && - (instance->transparent != !(CL_GetLayerFlags(instance->layer) & CL_OPAQUE))) - { - XP_Rect bbox; - - /* Get the bbox and convert it into its own coordinate space */ - CL_GetLayerBbox(instance->layer, &bbox); - - CL_ChangeLayerFlag(instance->layer, CL_OPAQUE, (PRBool)!instance->transparent); - CL_ChangeLayerFlag(instance->layer, - CL_PREFER_DRAW_OFFSCREEN, - (PRBool)instance->transparent); + case NPPVpluginWindowBool: + ret = npn_SetWindowless(instance, (PRBool)(0 != r_value)); + break; - /* Force drawing of the entire transparent plug-in. */ - CL_UpdateLayerRect(CL_GetLayerCompositor(instance->layer), - instance->layer, &bbox, PR_FALSE); - } -#endif /* LAYERS */ - break; + case NPPVpluginTransparentBool: + ret = npn_SetTransparent(instance, (PRBool)(0 != r_value)); + break; - case NPPVpluginTimerInterval: - np_SetTimerInterval(npp, *(uint32*)r_value); - break; + case NPPVpluginTimerInterval: + np_SetTimerInterval(npp, *(uint32*)r_value); + break; - case NPPVpluginWindowSize: - { - NPSize * pnpsz = (NPSize *)r_value; - np_data * ndata = (np_data *)instance->app->np_data; - LO_EmbedStruct * pes = ndata->lo_struct; + case NPPVpluginWindowSize: + ret = npn_SetWindowSize(instance, (NPSize *)r_value); + break; - LO_SetEmbedSize(instance->cx, pes, pnpsz->width, pnpsz->height); - LO_RelayoutFromElement(instance->cx, (LO_Element *)pes); - break; - } - default: - break; + default: + break; } return(ret); @@ -2807,6 +2827,18 @@ np_newinstance(np_handle *handle, MWContext *cx, NPEmbeddedApp *app, npp->pdata = peerInst; ndata->sdata = (NPSavedData*)pluginInst; err = NPERR_NO_ERROR; + + // This used to be done by the NPN_SetValue call. The user was required + // to call them during NPP_New: + extern nsresult fromNPError[]; + void* value; + // It's an abomination that we don't pass the address of value here: + err3 = pluginInst->GetValue(nsPluginInstanceVariable_WindowlessBool, value); + if (err3 == NS_OK) + (void)npn_SetWindowless(instance, (PRBool)value); + err3 = pluginInst->GetValue(nsPluginInstanceVariable_TransparentBool, value); + if (err3 == NS_OK) + (void)npn_SetTransparent(instance, (PRBool)value); } else { // this will release the plugin instance. diff --git a/modules/plugin/src/npglue.h b/modules/plugin/src/npglue.h index d90bfdb97143..6c778e465d95 100644 --- a/modules/plugin/src/npglue.h +++ b/modules/plugin/src/npglue.h @@ -272,6 +272,8 @@ npn_getJavaPeer(NPP npp); #pragma pointers_in_A0 #endif +extern NPError +npn_SetWindowSize(np_instance* instance, NPSize* pnpsz); /* End of function prototypes */ @@ -291,9 +293,6 @@ public: NS_IMETHOD GetValue(nsPluginManagerVariable variable, void *value); - NS_IMETHOD - SetValue(nsPluginManagerVariable variable, void *value); - // (Corresponds to NPN_ReloadPlugins.) NS_IMETHOD ReloadPlugins(PRBool reloadPages); @@ -446,9 +445,6 @@ public: NS_IMETHOD GetValue(nsPluginInstancePeerVariable variable, void *value); - NS_IMETHOD - SetValue(nsPluginInstancePeerVariable variable, void *value); - // (Corresponds to NPP_New's MIMEType argument.) NS_IMETHOD GetMIMEType(nsMIMEType *result); @@ -465,6 +461,9 @@ public: NS_IMETHOD ShowStatus(const char* message); + NS_IMETHOD + SetWindowSize(PRUint32 width, PRUint32 height); + //////////////////////////////////////////////////////////////////////////// // from nsIJRILiveConnectPluginInstancePeer: diff --git a/modules/plugin/src/nsplugin.cpp b/modules/plugin/src/nsplugin.cpp index 0ffc29cd0785..787d982cfe54 100644 --- a/modules/plugin/src/nsplugin.cpp +++ b/modules/plugin/src/nsplugin.cpp @@ -150,12 +150,14 @@ nsPluginManager::GetValue(nsPluginManagerVariable variable, void *value) return fromNPError[err]; } +#if 0 NS_METHOD nsPluginManager::SetValue(nsPluginManagerVariable variable, void *value) { NPError err = npn_setvalue(NULL, (NPPVariable)variable, value); return fromNPError[err]; } +#endif NS_METHOD nsPluginManager::ReloadPlugins(PRBool reloadPages) @@ -493,43 +495,49 @@ DestroyGetURLEvent(PLEvent* event) } NS_METHOD -nsPluginManager::GetURL(nsISupports* peer, const char* url, const char* target, +nsPluginManager::GetURL(nsISupports* pinst, const char* url, const char* target, void* notifyData, const char* altHost, const char* referrer, PRBool forceJSEnabled) { NPError rslt = NPERR_INVALID_PARAM; - nsPluginInstancePeer* instPeer = NULL; - if (peer->QueryInterface(kPluginInstancePeerCID, (void**)&instPeer) == NS_OK) { - if (PR_CurrentThread() == mozilla_thread) { - NPP npp = instPeer->GetNPP(); - rslt = np_geturlinternal(npp, - url, - target, - altHost, - referrer, - forceJSEnabled, - notifyData != NULL, - notifyData); - } - else { - GetURLEvent* e = PR_NEW(GetURLEvent); - if (e == NULL) { - rslt = NPERR_OUT_OF_MEMORY_ERROR; + nsIPluginInstance* inst = NULL; + if (pinst->QueryInterface(kIPluginInstanceIID, (void**)&inst) == NS_OK) { + // Warning: Casting to our implementation type of plugin instance peer here: + nsPluginInstancePeer* peer; + nsresult err = inst->GetPeer((nsIPluginInstancePeer**)&peer); + if (err == NS_OK) { + if (PR_CurrentThread() == mozilla_thread) { + NPP npp = peer->GetNPP(); + rslt = np_geturlinternal(npp, + url, + target, + altHost, + referrer, + forceJSEnabled, + notifyData != NULL, + notifyData); } else { - PL_InitEvent(&e->event, NULL, HandleGetURLEvent, DestroyGetURLEvent); - e->peer = instPeer; - e->url = url; - e->target = target; - e->notifyData = notifyData; - e->altHost = altHost; - e->referrer = referrer; - e->forceJSEnabled = forceJSEnabled; - /*rslt = (NPError)*/PL_PostSynchronousEvent(mozilla_event_queue, &e->event); - rslt = NPERR_NO_ERROR; /* XXX irix c++ compiler doesn't like the above cast */ + GetURLEvent* e = PR_NEW(GetURLEvent); + if (e == NULL) { + rslt = NPERR_OUT_OF_MEMORY_ERROR; + } + else { + PL_InitEvent(&e->event, NULL, HandleGetURLEvent, DestroyGetURLEvent); + e->peer = peer; + e->url = url; + e->target = target; + e->notifyData = notifyData; + e->altHost = altHost; + e->referrer = referrer; + e->forceJSEnabled = forceJSEnabled; + /*rslt = (NPError)*/PL_PostSynchronousEvent(mozilla_event_queue, &e->event); + rslt = NPERR_NO_ERROR; /* XXX irix c++ compiler doesn't like the above cast */ + } } + peer->Release(); } - instPeer->Release(); + inst->Release(); } return fromNPError[rslt]; } @@ -578,7 +586,7 @@ DestroyPostURLEvent(PLEvent* event) } NS_METHOD -nsPluginManager::PostURL(nsISupports* peer, const char* url, const char* target, +nsPluginManager::PostURL(nsISupports* pinst, const char* url, const char* target, PRUint32 postDataLen, const char* postData, PRBool isFile, void* notifyData, const char* altHost, const char* referrer, @@ -586,47 +594,53 @@ nsPluginManager::PostURL(nsISupports* peer, const char* url, const char* target, PRUint32 postHeadersLen, const char* postHeaders) { NPError rslt = NPERR_INVALID_PARAM; - nsPluginInstancePeer* instPeer = NULL; - if (peer->QueryInterface(kPluginInstancePeerCID, (void**)&instPeer) == NS_OK) { - if (PR_CurrentThread() == mozilla_thread) { - NPP npp = instPeer->GetNPP(); - PR_ASSERT(postHeaders == NULL); // XXX need to deal with postHeaders - rslt = np_posturlinternal(npp, - url, - target, - altHost, - referrer, - forceJSEnabled, - postDataLen, - postData, - isFile, - notifyData != NULL, - notifyData); - } - else { - PostURLEvent* e = PR_NEW(PostURLEvent); - if (e == NULL) { - rslt = NPERR_OUT_OF_MEMORY_ERROR; + nsIPluginInstance* inst = NULL; + if (pinst->QueryInterface(kIPluginInstanceIID, (void**)&inst) == NS_OK) { + // Warning: Casting to our implementation type of plugin instance peer here: + nsPluginInstancePeer* peer; + nsresult err = inst->GetPeer((nsIPluginInstancePeer**)&peer); + if (err == NS_OK) { + if (PR_CurrentThread() == mozilla_thread) { + NPP npp = peer->GetNPP(); + PR_ASSERT(postHeaders == NULL); // XXX need to deal with postHeaders + rslt = np_posturlinternal(npp, + url, + target, + altHost, + referrer, + forceJSEnabled, + postDataLen, + postData, + isFile, + notifyData != NULL, + notifyData); } else { - PL_InitEvent(&e->event, NULL, HandlePostURLEvent, DestroyPostURLEvent); - e->peer = instPeer; - e->url = url; - e->target = target; - e->notifyData = notifyData; - e->altHost = altHost; - e->referrer = referrer; - e->forceJSEnabled = forceJSEnabled; - e->postDataLen = postDataLen; - e->postData = postData; - e->isFile = isFile; - e->postHeadersLen = postHeadersLen; - e->postHeaders = postHeaders; - /*rslt = (NPError)*/PL_PostSynchronousEvent(mozilla_event_queue, &e->event); - rslt = NPERR_NO_ERROR; /* XXX irix c++ compiler doesn't like the above cast */ + PostURLEvent* e = PR_NEW(PostURLEvent); + if (e == NULL) { + rslt = NPERR_OUT_OF_MEMORY_ERROR; + } + else { + PL_InitEvent(&e->event, NULL, HandlePostURLEvent, DestroyPostURLEvent); + e->peer = peer; + e->url = url; + e->target = target; + e->notifyData = notifyData; + e->altHost = altHost; + e->referrer = referrer; + e->forceJSEnabled = forceJSEnabled; + e->postDataLen = postDataLen; + e->postData = postData; + e->isFile = isFile; + e->postHeadersLen = postHeadersLen; + e->postHeaders = postHeaders; + /*rslt = (NPError)*/PL_PostSynchronousEvent(mozilla_event_queue, &e->event); + rslt = NPERR_NO_ERROR; /* XXX irix c++ compiler doesn't like the above cast */ + } } + peer->Release(); } - instPeer->Release(); + inst->Release(); } return fromNPError[rslt]; } @@ -805,12 +819,14 @@ nsPluginInstancePeer::GetValue(nsPluginInstancePeerVariable variable, void *valu return fromNPError[err]; } +#if 0 NS_METHOD nsPluginInstancePeer::SetValue(nsPluginInstancePeerVariable variable, void *value) { NPError err = npn_setvalue(fNPP, (NPPVariable)variable, value); return fromNPError[err]; } +#endif NS_METHOD nsPluginInstancePeer::GetMIMEType(nsMIMEType *result) @@ -846,6 +862,17 @@ nsPluginInstancePeer::ShowStatus(const char* message) return NS_OK; } +NS_METHOD +nsPluginInstancePeer::SetWindowSize(PRUint32 width, PRUint32 height) +{ + NPError err; + NPSize size; + size.width = width; + size.height = height; + err = npn_SetWindowSize((np_instance*)fNPP->ndata, &size); + return fromNPError[err]; +} + NS_METHOD nsPluginInstancePeer::InvalidateRect(nsPluginRect *invalidRect) { diff --git a/modules/plugin/test/makefile.win b/modules/plugin/test/makefile.win index be4b3c0b705d..94ce10546971 100644 --- a/modules/plugin/test/makefile.win +++ b/modules/plugin/test/makefile.win @@ -31,7 +31,7 @@ OBJS = .\$(OBJDIR)\npsimple.obj \ JDIRS = . -JRI_GEN = \ +xJRI_GEN = \ Simple \ java.lang.Object \ netscape.plugin.Plugin \ @@ -76,7 +76,7 @@ GARBAGE = $(GARBAGE) _gen #//------------------------------------------------------------------------ include <$(DEPTH)/config/rules.mak> -LINCS=$(LINCS) -I$(PUBLIC)\plugin -I$(PUBLIC)\xpcom -I$(PUBLIC)\java -I$(PUBLIC)\plugimpl -I$(PUBLIC)\raptor +LINCS=$(LINCS) -I$(PUBLIC)\plugin -I$(PUBLIC)\xpcom -I$(PUBLIC)\java -I$(PUBLIC)\plugimpl -I$(PUBLIC)\raptor -I_jri install:: $(DLL) $(MAKE_INSTALL) $(XPDIST)\classes11\Simple.class $(DEPTH)\cmd\winfe\mkfiles32\x86dbg\plugins\simple diff --git a/modules/plugin/test/npsimple.cpp b/modules/plugin/test/npsimple.cpp index ba686f478522..89d8d677c4ea 100644 --- a/modules/plugin/test/npsimple.cpp +++ b/modules/plugin/test/npsimple.cpp @@ -163,10 +163,6 @@ public: NS_IMETHOD GetValue(nsPluginVariable variable, void *value); - // (Corresponds to NPP_SetValue.) - NS_IMETHOD - SetValue(nsPluginVariable variable, void *value); - // The old NPP_New call has been factored into two plugin instance methods: // // CreateInstance -- called once, after the plugin instance is created. This @@ -266,6 +262,9 @@ public: URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData); + NS_IMETHOD + GetValue(nsPluginInstanceVariable variable, void *value); + //////////////////////////////////////////////////////////////////////////// // SimplePluginInstance specific methods: @@ -504,12 +503,6 @@ SimplePlugin::GetValue(nsPluginVariable variable, void *value) return err; } -NS_METHOD -SimplePlugin::SetValue(nsPluginVariable variable, void *value) -{ - return NS_OK; -} - /*+++++++++++++++++++++++++++++++++++++++++++++++++ * GetJavaClass: * @@ -788,6 +781,12 @@ SimplePluginInstance::URLNotify(const char* url, const char* target, return NS_OK; } +NS_METHOD +SimplePluginInstance::GetValue(nsPluginInstanceVariable variable, void *value) +{ + return NS_OK; +} + //////////////////////////////////////////////////////////////////////////////// // SimplePluginStream Methods ////////////////////////////////////////////////////////////////////////////////