mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1095754 - In the content process provide a way to track and access PluginInstanceParent objects from PluginWidgetChild. r=aklotz
This commit is contained in:
parent
e5e145ed22
commit
968b1551b0
@ -43,7 +43,8 @@
|
||||
#include <windowsx.h>
|
||||
#include "gfxWindowsPlatform.h"
|
||||
#include "mozilla/plugins/PluginSurfaceParent.h"
|
||||
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
// Plugin focus event for widget.
|
||||
extern const wchar_t* kOOPPPluginFocusEventId;
|
||||
UINT gOOPPPluginFocusEvent =
|
||||
@ -73,6 +74,29 @@ StreamNotifyParent::RecvRedirectNotifyResponse(const bool& allow)
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(XP_WIN)
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
/**
|
||||
* e10s specific, used in cross referencing hwnds with plugin instances so we
|
||||
* can access methods here from PluginWidgetChild.
|
||||
*/
|
||||
static nsClassHashtable<nsVoidPtrHashKey, PluginInstanceParent>* sPluginInstanceList;
|
||||
|
||||
// static
|
||||
PluginInstanceParent*
|
||||
PluginInstanceParent::LookupPluginInstanceByID(uintptr_t aId)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (sPluginInstanceList) {
|
||||
return sPluginInstanceList->Get((void*)aId);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
|
||||
NPP npp,
|
||||
const nsCString& aMimeType,
|
||||
@ -95,6 +119,11 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
|
||||
, mShColorSpace(nullptr)
|
||||
#endif
|
||||
{
|
||||
#if defined(OS_WIN)
|
||||
if (!sPluginInstanceList) {
|
||||
sPluginInstanceList = new nsClassHashtable<nsVoidPtrHashKey, PluginInstanceParent>();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
PluginInstanceParent::~PluginInstanceParent()
|
||||
@ -1756,15 +1785,28 @@ PluginInstanceParent::PluginWindowHookProc(HWND hWnd,
|
||||
void
|
||||
PluginInstanceParent::SubclassPluginWindow(HWND aWnd)
|
||||
{
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
mPluginHWND = aWnd; // now a remote window, we can't subclass this
|
||||
mPluginWndProc = nullptr;
|
||||
if ((aWnd && mPluginHWND == aWnd) || (!aWnd && mPluginHWND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(XP_WIN)
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
if (!aWnd) {
|
||||
NS_WARNING("PluginInstanceParent::SubclassPluginWindow unexpected null window");
|
||||
return;
|
||||
}
|
||||
mPluginHWND = aWnd; // now a remote window, we can't subclass this
|
||||
mPluginWndProc = nullptr;
|
||||
// Note sPluginInstanceList wil delete 'this' if we do not remove
|
||||
// it on shutdown.
|
||||
sPluginInstanceList->Put((void*)mPluginHWND, this);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_ASSERTION(!(mPluginHWND && aWnd != mPluginHWND),
|
||||
"PluginInstanceParent::SubclassPluginWindow hwnd is not our window!");
|
||||
|
||||
if (!mPluginHWND) {
|
||||
mPluginHWND = aWnd;
|
||||
mPluginWndProc =
|
||||
(WNDPROC)::SetWindowLongPtrA(mPluginHWND, GWLP_WNDPROC,
|
||||
@ -1775,11 +1817,28 @@ PluginInstanceParent::SubclassPluginWindow(HWND aWnd)
|
||||
NS_ASSERTION(bRes,
|
||||
"PluginInstanceParent::SubclassPluginWindow failed to set prop!");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PluginInstanceParent::UnsubclassPluginWindow()
|
||||
{
|
||||
#if defined(XP_WIN)
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
if (mPluginHWND) {
|
||||
// Remove 'this' from the plugin list safely
|
||||
nsAutoPtr<PluginInstanceParent> tmp;
|
||||
MOZ_ASSERT(sPluginInstanceList);
|
||||
sPluginInstanceList->RemoveAndForget((void*)mPluginHWND, tmp);
|
||||
tmp.forget();
|
||||
if (!sPluginInstanceList->Count()) {
|
||||
delete sPluginInstanceList;
|
||||
sPluginInstanceList = nullptr;
|
||||
}
|
||||
}
|
||||
mPluginHWND = nullptr;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mPluginHWND && mPluginWndProc) {
|
||||
::SetWindowLongPtrA(mPluginHWND, GWLP_WNDPROC,
|
||||
reinterpret_cast<LONG_PTR>(mPluginWndProc));
|
||||
|
@ -51,6 +51,15 @@ class PluginInstanceParent : public PPluginInstanceParent
|
||||
friend class PluginStreamParent;
|
||||
friend class StreamNotifyParent;
|
||||
|
||||
#if defined(XP_WIN)
|
||||
public:
|
||||
/**
|
||||
* Helper method for looking up instances based on a supplied id.
|
||||
*/
|
||||
static PluginInstanceParent*
|
||||
LookupPluginInstanceByID(uintptr_t aId);
|
||||
#endif // defined(XP_WIN)
|
||||
|
||||
public:
|
||||
PluginInstanceParent(PluginModuleParent* parent,
|
||||
NPP npp,
|
||||
|
@ -4,6 +4,13 @@
|
||||
|
||||
#include "mozilla/plugins/PluginWidgetChild.h"
|
||||
#include "PluginWidgetProxy.h"
|
||||
#include "mozilla/DebugOnly.h"
|
||||
#include "nsDebug.h"
|
||||
|
||||
#if defined(XP_WIN)
|
||||
#include "mozilla/plugins/PluginInstanceParent.h"
|
||||
using mozilla::plugins::PluginInstanceParent;
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
@ -28,6 +35,26 @@ PluginWidgetChild::ActorDestroy(ActorDestroyReason aWhy)
|
||||
mWidget = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginWidgetChild::RecvUpdateWindow(const uintptr_t& aChildId)
|
||||
{
|
||||
#if defined(XP_WIN)
|
||||
NS_ASSERTION(aChildId, "Expected child hwnd value for remote plugin instance.");
|
||||
PluginInstanceParent* parentInstance =
|
||||
PluginInstanceParent::LookupPluginInstanceByID(aChildId);
|
||||
NS_ASSERTION(parentInstance, "Expected matching plugin instance");
|
||||
if (parentInstance) {
|
||||
// sync! update call to the plugin instance that forces the
|
||||
// plugin to paint its child window.
|
||||
parentInstance->CallUpdateWindow();
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
NS_NOTREACHED("PluginWidgetChild::RecvUpdateWindow calls unexpected on this platform.");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -19,6 +19,7 @@ public:
|
||||
PluginWidgetChild();
|
||||
virtual ~PluginWidgetChild();
|
||||
|
||||
virtual bool RecvUpdateWindow(const uintptr_t& aChildId) MOZ_OVERRIDE;
|
||||
virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
||||
|
||||
mozilla::widget::PluginWidgetProxy* mWidget;
|
||||
|
Loading…
Reference in New Issue
Block a user