Bug 536369 - OOPP: Add NPNVnetscapeWindow support for windows. r=bsmedberg.

This commit is contained in:
Jim Mathies 2010-01-13 19:47:38 -06:00
parent 3960d009a6
commit 938c329d54
4 changed files with 37 additions and 47 deletions

View File

@ -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);

View File

@ -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<HWND*>(aValue) = hwnd;
return result;
}
else {
*static_cast<HWND*>(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)",

View File

@ -150,6 +150,19 @@ PluginInstanceParent::AnswerNPN_GetValue_NPNVisOfflineBool(bool* value,
return true;
}
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,
@ -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,23 +717,8 @@ 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()
{

View File

@ -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)
};