From d7303ee7d749ad04e6cd07ff7d2a664b00e488c0 Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Wed, 13 Jan 2010 19:47:38 -0600 Subject: [PATCH] Bug 536369 - OOPP: Add NPNVnetscapeWindow support for windows. r=bsmedberg. --- dom/plugins/PPluginInstance.ipdl | 2 ++ dom/plugins/PluginInstanceChild.cpp | 21 ++++++++++++- dom/plugins/PluginInstanceParent.cpp | 57 ++++++++---------------------------- dom/plugins/PluginInstanceParent.h | 4 +-- 4 files changed, 37 insertions(+), 47 deletions(-) diff --git a/dom/plugins/PPluginInstance.ipdl b/dom/plugins/PPluginInstance.ipdl index 22d5a6b00e..4201763e56 100644 --- a/dom/plugins/PPluginInstance.ipdl +++ b/dom/plugins/PPluginInstance.ipdl @@ -93,6 +93,8 @@ parent: returns (nullable PPluginScriptableObject value, NPError result); rpc NPN_GetValue_NPNVprivateModeBool() returns (bool value, NPError result); + rpc NPN_GetValue_NPNVnetscapeWindow() + returns (intptr_t value, NPError result); rpc NPN_SetValue_NPPVpluginWindow(bool windowed) returns (NPError result); diff --git a/dom/plugins/PluginInstanceChild.cpp b/dom/plugins/PluginInstanceChild.cpp index 5a65af4440..292e780d5e 100644 --- a/dom/plugins/PluginInstanceChild.cpp +++ b/dom/plugins/PluginInstanceChild.cpp @@ -99,7 +99,6 @@ PluginInstanceChild::Answer__delete__(NPError* rv) PluginInstanceDestroyed(this, rv); } - NPError PluginInstanceChild::NPN_GetValue(NPNVariable aVar, void* aValue) @@ -206,6 +205,26 @@ PluginInstanceChild::NPN_GetValue(NPNVariable aVar, return NPERR_NO_ERROR; } + case NPNVnetscapeWindow: { +#ifdef XP_WIN + if (mWindow.type == NPWindowTypeDrawable) { + HWND hwnd = NULL; + NPError result; + if (!CallNPN_GetValue_NPNVnetscapeWindow((intptr_t*)&hwnd, &result)) { + return NPERR_GENERIC_ERROR; + } + *static_cast(aValue) = hwnd; + return result; + } + else { + *static_cast(aValue) = mPluginWindowHWND; + return NPERR_NO_ERROR; + } +#else + return NPERR_GENERIC_ERROR; +#endif + } + default: PR_LOG(gPluginLog, PR_LOG_WARNING, ("In PluginInstanceChild::NPN_GetValue: Unhandled NPNVariable %i (%s)", diff --git a/dom/plugins/PluginInstanceParent.cpp b/dom/plugins/PluginInstanceParent.cpp index 8262b634ce..2c7740eefd 100644 --- a/dom/plugins/PluginInstanceParent.cpp +++ b/dom/plugins/PluginInstanceParent.cpp @@ -151,6 +151,19 @@ PluginInstanceParent::AnswerNPN_GetValue_NPNVisOfflineBool(bool* value, } bool +PluginInstanceParent::AnswerNPN_GetValue_NPNVnetscapeWindow(intptr_t* value, + NPError* result) +{ +#ifdef XP_WIN + HWND hwnd; + *result = mNPNIface->getvalue(mNPP, NPNVnetscapeWindow, &hwnd); + *value = (intptr_t)hwnd; + return true; +#endif + return false; +} + +bool PluginInstanceParent::InternalGetValueForNPObject( NPNVariable aVariable, PPluginScriptableObjectParent** aValue, @@ -466,7 +479,6 @@ PluginInstanceParent::NPP_HandleEvent(void* event) int16_t handled; #if defined(OS_WIN) - RECT rect; if (mWindowType == NPWindowTypeDrawable) { switch(npevent->event) { case WM_PAINT: @@ -479,34 +491,6 @@ PluginInstanceParent::NPP_HandleEvent(void* event) SharedSurfaceAfterPaint(npevent); } break; - case WM_WINDOWPOSCHANGED: - SharedSurfaceSetOrigin(npremoteevent); - if (!CallNPP_HandleEvent(npremoteevent, &handled)) - return 0; - break; - case WM_MOUSELEAVE: - case WM_MOUSEMOVE: - case WM_RBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_MBUTTONUP: - case WM_RBUTTONUP: - case WM_LBUTTONDBLCLK: - case WM_MBUTTONDBLCLK: - case WM_RBUTTONDBLCLK: - { - // Received mouse events have an origin at the position of the plugin rect - // in the page. However, when rendering to the shared dib, the rect origin - // changes to 0,0 via the WM_WINDOWPOSCHANGED event. In this case we need to - // translate these coords to the proper location. - nsPoint pt(GET_X_LPARAM(npremoteevent.event.lParam), GET_Y_LPARAM(npremoteevent.event.lParam)); - pt.MoveBy(-mPluginPosOrigin.x, -mPluginPosOrigin.y); - npremoteevent.event.lParam = MAKELPARAM(pt.x, pt.y); - if (!CallNPP_HandleEvent(npremoteevent, &handled)) - return 0; - } - break; default: if (!CallNPP_HandleEvent(npremoteevent, &handled)) return 0; @@ -733,24 +717,9 @@ PluginInstanceParent::AnswerNPN_PopPopupsEnabledState(bool* aSuccess) * PluginInstanceParent: * * painting: mPluginPort (nsIntRect, saved in SetWindow) - * event translation: mPluginPosOrigin (nsIntPoint, saved in SetOrigin) */ void -PluginInstanceParent::SharedSurfaceSetOrigin(NPRemoteEvent& npremoteevent) -{ - WINDOWPOS* winpos = (WINDOWPOS*)npremoteevent.event.lParam; - - // save the origin, we'll use this to translate input coordinates - mPluginPosOrigin.x = winpos->x; - mPluginPosOrigin.y = winpos->y; - - // Reset to the offscreen dib origin - winpos->x = 0; - winpos->y = 0; -} - -void PluginInstanceParent::SharedSurfaceRelease() { mSharedSurfaceDib.Close(); diff --git a/dom/plugins/PluginInstanceParent.h b/dom/plugins/PluginInstanceParent.h index 9dde722f38..e7f05eac71 100644 --- a/dom/plugins/PluginInstanceParent.h +++ b/dom/plugins/PluginInstanceParent.h @@ -104,6 +104,8 @@ public: virtual bool AnswerNPN_GetValue_NPNVisOfflineBool(bool* value, NPError* result); virtual bool + AnswerNPN_GetValue_NPNVnetscapeWindow(intptr_t* value, NPError* result); + virtual bool AnswerNPN_GetValue_NPNVWindowNPObject( PPluginScriptableObjectParent** value, NPError* result); @@ -216,14 +218,12 @@ private: bool SharedSurfaceSetWindow(const NPWindow* aWindow, NPRemoteWindow& aRemoteWindow); void SharedSurfaceBeforePaint(RECT &rect, NPRemoteEvent& npremoteevent); void SharedSurfaceAfterPaint(NPEvent* npevent); - void SharedSurfaceSetOrigin(NPRemoteEvent& npremoteevent); void SharedSurfaceRelease(); private: gfx::SharedDIBWin mSharedSurfaceDib; nsIntRect mPluginPort; nsIntRect mSharedSize; - nsIntPoint mPluginPosOrigin; #endif // defined(XP_WIN) }; -- 2.11.4.GIT