2009-06-30 18:51:05 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: sw=4 ts=4 et :
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-06-30 18:51:05 +00:00
|
|
|
|
2009-09-09 06:31:35 +00:00
|
|
|
#ifndef dom_plugins_PluginInstanceChild_h
|
|
|
|
#define dom_plugins_PluginInstanceChild_h 1
|
2009-06-30 18:51:05 +00:00
|
|
|
|
2009-09-09 22:59:06 +00:00
|
|
|
#include "mozilla/plugins/PPluginInstanceChild.h"
|
2009-09-09 06:31:35 +00:00
|
|
|
#include "mozilla/plugins/PluginScriptableObjectChild.h"
|
2009-12-03 08:16:14 +00:00
|
|
|
#include "mozilla/plugins/StreamNotifyChild.h"
|
2011-01-27 22:37:00 +00:00
|
|
|
#include "mozilla/plugins/PPluginSurfaceChild.h"
|
2012-02-16 03:30:22 +00:00
|
|
|
#include "mozilla/ipc/CrossProcessMutex.h"
|
|
|
|
#include "nsClassHashtable.h"
|
2009-12-01 21:05:26 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
#include "mozilla/gfx/SharedDIBWin.h"
|
2011-06-25 15:25:03 +00:00
|
|
|
#elif defined(MOZ_WIDGET_COCOA)
|
2011-07-12 14:31:18 +00:00
|
|
|
#include "PluginUtilsOSX.h"
|
2012-07-31 15:11:57 +00:00
|
|
|
#include "mozilla/gfx/QuartzSupport.h"
|
2010-04-20 14:52:19 +00:00
|
|
|
#include "base/timer.h"
|
2011-07-12 14:31:18 +00:00
|
|
|
|
2009-12-01 21:05:26 +00:00
|
|
|
#endif
|
2009-06-30 18:51:05 +00:00
|
|
|
|
|
|
|
#include "npfunctions.h"
|
2009-09-17 22:15:12 +00:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsTArray.h"
|
2010-01-20 03:13:24 +00:00
|
|
|
#include "ChildAsyncCall.h"
|
|
|
|
#include "ChildTimer.h"
|
2010-02-18 20:20:25 +00:00
|
|
|
#include "nsRect.h"
|
2010-02-24 21:14:13 +00:00
|
|
|
#include "nsTHashtable.h"
|
2010-06-23 14:18:00 +00:00
|
|
|
#include "mozilla/PaintTracker.h"
|
2009-06-30 18:51:05 +00:00
|
|
|
|
2012-02-16 03:30:22 +00:00
|
|
|
#include <map>
|
|
|
|
|
2014-05-28 08:23:00 +00:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2012-08-01 20:34:08 +00:00
|
|
|
#include "gtk2xtbin.h"
|
|
|
|
#endif
|
|
|
|
|
2013-09-24 20:45:14 +00:00
|
|
|
class gfxASurface;
|
|
|
|
|
2009-06-30 18:51:05 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
|
|
|
|
2009-09-09 22:59:06 +00:00
|
|
|
class PBrowserStreamChild;
|
|
|
|
class BrowserStreamChild;
|
2010-03-06 21:03:05 +00:00
|
|
|
class StreamNotifyChild;
|
2009-09-09 22:00:14 +00:00
|
|
|
|
2009-09-09 22:59:06 +00:00
|
|
|
class PluginInstanceChild : public PPluginInstanceChild
|
2009-06-30 18:51:05 +00:00
|
|
|
{
|
2009-09-21 14:51:35 +00:00
|
|
|
friend class BrowserStreamChild;
|
|
|
|
friend class PluginStreamChild;
|
2014-10-29 15:04:51 +00:00
|
|
|
friend class StreamNotifyChild;
|
|
|
|
friend class PluginScriptableObjectChild;
|
2009-09-21 14:51:35 +00:00
|
|
|
|
2009-07-01 21:19:32 +00:00
|
|
|
#ifdef OS_WIN
|
|
|
|
friend LRESULT CALLBACK PluginWindowProc(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
2011-02-12 01:56:11 +00:00
|
|
|
static LRESULT CALLBACK PluginWindowProcInternal(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
2009-07-01 21:19:32 +00:00
|
|
|
#endif
|
|
|
|
|
2009-07-02 16:54:22 +00:00
|
|
|
protected:
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool AnswerNPP_SetWindow(const NPRemoteWindow& window) override;
|
2009-07-02 16:54:22 +00:00
|
|
|
|
2011-06-08 20:20:53 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
AnswerNPP_GetValue_NPPVpluginWantsAllNetworkStreams(bool* wantsAllStreams, NPError* rv) override;
|
2009-09-25 02:03:59 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
AnswerNPP_GetValue_NPPVpluginNeedsXEmbed(bool* needs, NPError* rv) override;
|
2009-09-17 23:09:20 +00:00
|
|
|
virtual bool
|
2009-09-17 22:15:12 +00:00
|
|
|
AnswerNPP_GetValue_NPPVpluginScriptableNPObject(PPluginScriptableObjectChild** value,
|
2015-03-21 16:28:04 +00:00
|
|
|
NPError* result) override;
|
2011-04-27 13:42:18 +00:00
|
|
|
virtual bool
|
|
|
|
AnswerNPP_GetValue_NPPVpluginNativeAccessibleAtkPlugId(nsCString* aPlugId,
|
2015-03-21 16:28:04 +00:00
|
|
|
NPError* aResult) override;
|
2010-01-20 03:23:35 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
AnswerNPP_SetValue_NPNVprivateModeBool(const bool& value, NPError* result) override;
|
2010-01-20 03:23:35 +00:00
|
|
|
|
2009-09-19 01:19:11 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
AnswerNPP_HandleEvent(const NPRemoteEvent& event, int16_t* handled) override;
|
2010-03-26 20:07:37 +00:00
|
|
|
virtual bool
|
2014-01-20 05:03:45 +00:00
|
|
|
AnswerNPP_HandleEvent_Shmem(const NPRemoteEvent& event,
|
2015-01-16 19:58:52 +00:00
|
|
|
Shmem&& mem,
|
2014-01-20 05:03:45 +00:00
|
|
|
int16_t* handled,
|
2015-03-21 16:28:04 +00:00
|
|
|
Shmem* rtnmem) override;
|
2010-04-20 14:52:19 +00:00
|
|
|
virtual bool
|
2014-01-20 05:03:45 +00:00
|
|
|
AnswerNPP_HandleEvent_IOSurface(const NPRemoteEvent& event,
|
|
|
|
const uint32_t& surface,
|
2015-03-21 16:28:04 +00:00
|
|
|
int16_t* handled) override;
|
2009-09-19 01:19:11 +00:00
|
|
|
|
2010-09-15 16:02:44 +00:00
|
|
|
// Async rendering
|
|
|
|
virtual bool
|
|
|
|
RecvAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
|
2015-03-21 16:28:04 +00:00
|
|
|
const NPRemoteWindow& aWindow) override;
|
2010-09-15 16:02:44 +00:00
|
|
|
|
2010-12-05 21:57:33 +00:00
|
|
|
virtual void
|
|
|
|
DoAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
|
|
|
|
const NPRemoteWindow& aWindow,
|
|
|
|
bool aIsAsync);
|
|
|
|
|
2014-01-20 05:03:45 +00:00
|
|
|
virtual PPluginSurfaceChild*
|
|
|
|
AllocPPluginSurfaceChild(const WindowsSharedMemoryHandle&,
|
2015-03-21 16:28:04 +00:00
|
|
|
const gfxIntSize&, const bool&) override {
|
2011-01-27 22:37:00 +00:00
|
|
|
return new PPluginSurfaceChild();
|
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual bool DeallocPPluginSurfaceChild(PPluginSurfaceChild* s) override {
|
2011-01-27 22:37:00 +00:00
|
|
|
delete s;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-03-11 07:35:31 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
AnswerPaint(const NPRemoteEvent& event, int16_t* handled) override
|
2010-03-11 07:35:31 +00:00
|
|
|
{
|
2010-06-23 14:18:00 +00:00
|
|
|
PaintTracker pt;
|
2010-03-11 07:35:31 +00:00
|
|
|
return AnswerNPP_HandleEvent(event, handled);
|
|
|
|
}
|
|
|
|
|
2010-03-22 22:35:15 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
RecvWindowPosChanged(const NPRemoteEvent& event) override;
|
2010-03-22 22:35:15 +00:00
|
|
|
|
2012-10-16 19:41:21 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
RecvContentsScaleFactorChanged(const double& aContentsScaleFactor) override;
|
2012-10-16 19:41:21 +00:00
|
|
|
|
2010-01-15 20:35:57 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
AnswerNPP_Destroy(NPError* result) override;
|
2010-01-15 20:35:57 +00:00
|
|
|
|
2009-09-09 22:59:06 +00:00
|
|
|
virtual PPluginScriptableObjectChild*
|
2015-03-21 16:28:04 +00:00
|
|
|
AllocPPluginScriptableObjectChild() override;
|
2009-08-10 23:28:22 +00:00
|
|
|
|
2009-09-17 23:09:20 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
DeallocPPluginScriptableObjectChild(PPluginScriptableObjectChild* aObject) override;
|
2009-08-10 23:28:22 +00:00
|
|
|
|
2012-07-06 18:15:45 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
RecvPPluginScriptableObjectConstructor(PPluginScriptableObjectChild* aActor) override;
|
2009-10-07 23:50:48 +00:00
|
|
|
|
2014-12-29 23:13:09 +00:00
|
|
|
virtual bool
|
2015-01-07 04:51:46 +00:00
|
|
|
RecvPBrowserStreamConstructor(PBrowserStreamChild* aActor, const nsCString& aURL,
|
|
|
|
const uint32_t& aLength, const uint32_t& aLastmodified,
|
2015-03-21 16:28:04 +00:00
|
|
|
PStreamNotifyChild* aNotifyData, const nsCString& aHeaders) override;
|
2009-08-18 20:20:03 +00:00
|
|
|
|
2010-01-12 23:06:18 +00:00
|
|
|
virtual bool
|
2014-12-29 23:13:09 +00:00
|
|
|
AnswerNPP_NewStream(
|
|
|
|
PBrowserStreamChild* actor,
|
2010-01-12 23:06:18 +00:00
|
|
|
const nsCString& mimeType,
|
|
|
|
const bool& seekable,
|
|
|
|
NPError* rv,
|
2015-03-21 16:28:04 +00:00
|
|
|
uint16_t* stype) override;
|
2014-01-20 05:03:45 +00:00
|
|
|
|
2014-12-29 23:13:09 +00:00
|
|
|
virtual bool
|
|
|
|
RecvAsyncNPP_NewStream(
|
|
|
|
PBrowserStreamChild* actor,
|
|
|
|
const nsCString& mimeType,
|
2015-03-21 16:28:04 +00:00
|
|
|
const bool& seekable) override;
|
2014-12-29 23:13:09 +00:00
|
|
|
|
|
|
|
virtual PBrowserStreamChild*
|
|
|
|
AllocPBrowserStreamChild(const nsCString& url,
|
|
|
|
const uint32_t& length,
|
|
|
|
const uint32_t& lastmodified,
|
|
|
|
PStreamNotifyChild* notifyData,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsCString& headers) override;
|
2014-12-29 23:13:09 +00:00
|
|
|
|
2009-09-21 14:51:35 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
DeallocPBrowserStreamChild(PBrowserStreamChild* stream) override;
|
2009-08-18 20:20:03 +00:00
|
|
|
|
2009-09-21 14:51:35 +00:00
|
|
|
virtual PPluginStreamChild*
|
2013-07-08 15:48:39 +00:00
|
|
|
AllocPPluginStreamChild(const nsCString& mimeType,
|
|
|
|
const nsCString& target,
|
2015-03-21 16:28:04 +00:00
|
|
|
NPError* result) override;
|
2009-09-21 14:51:35 +00:00
|
|
|
|
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
DeallocPPluginStreamChild(PPluginStreamChild* stream) override;
|
2009-09-21 14:51:35 +00:00
|
|
|
|
2009-09-08 21:22:50 +00:00
|
|
|
virtual PStreamNotifyChild*
|
2013-07-08 15:48:39 +00:00
|
|
|
AllocPStreamNotifyChild(const nsCString& url, const nsCString& target,
|
|
|
|
const bool& post, const nsCString& buffer,
|
|
|
|
const bool& file,
|
2015-03-21 16:28:04 +00:00
|
|
|
NPError* result) override;
|
2009-09-08 21:22:50 +00:00
|
|
|
|
2012-07-06 18:15:45 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
DeallocPStreamNotifyChild(PStreamNotifyChild* notifyData) override;
|
2009-09-08 21:22:50 +00:00
|
|
|
|
2010-01-26 21:40:15 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
AnswerSetPluginFocus() override;
|
2010-01-26 21:40:15 +00:00
|
|
|
|
2010-01-27 00:08:39 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
AnswerUpdateWindow() override;
|
2010-01-27 00:08:39 +00:00
|
|
|
|
2012-02-16 03:30:25 +00:00
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
RecvNPP_DidComposite() override;
|
2012-02-16 03:30:25 +00:00
|
|
|
|
2012-08-01 20:34:08 +00:00
|
|
|
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
|
|
|
bool CreateWindow(const NPRemoteWindow& aWindow);
|
|
|
|
void DeleteWindow();
|
|
|
|
#endif
|
|
|
|
|
2009-06-30 18:51:05 +00:00
|
|
|
public:
|
2014-12-29 23:13:09 +00:00
|
|
|
PluginInstanceChild(const NPPluginFuncs* aPluginIface,
|
|
|
|
const nsCString& aMimeType,
|
|
|
|
const uint16_t& aMode,
|
|
|
|
const InfallibleTArray<nsCString>& aNames,
|
|
|
|
const InfallibleTArray<nsCString>& aValues);
|
2009-06-30 18:51:05 +00:00
|
|
|
|
2009-09-09 06:31:35 +00:00
|
|
|
virtual ~PluginInstanceChild();
|
2009-06-30 18:51:05 +00:00
|
|
|
|
2014-12-29 23:13:09 +00:00
|
|
|
NPError DoNPP_New();
|
|
|
|
|
|
|
|
// Common sync+async implementation of NPP_NewStream
|
|
|
|
NPError DoNPP_NewStream(BrowserStreamChild* actor,
|
|
|
|
const nsCString& mimeType,
|
|
|
|
const bool& seekable,
|
|
|
|
uint16_t* stype);
|
|
|
|
|
2009-07-01 21:19:32 +00:00
|
|
|
bool Initialize();
|
2009-06-30 18:51:05 +00:00
|
|
|
|
|
|
|
NPP GetNPP()
|
|
|
|
{
|
|
|
|
return &mData;
|
|
|
|
}
|
|
|
|
|
2009-09-09 06:31:35 +00:00
|
|
|
NPError
|
2009-09-25 02:03:59 +00:00
|
|
|
NPN_GetValue(NPNVariable aVariable, void* aValue);
|
|
|
|
|
|
|
|
NPError
|
|
|
|
NPN_SetValue(NPPVariable aVariable, void* aValue);
|
2009-06-30 18:51:05 +00:00
|
|
|
|
2009-09-17 22:15:12 +00:00
|
|
|
PluginScriptableObjectChild*
|
2009-09-23 07:12:52 +00:00
|
|
|
GetActorForNPObject(NPObject* aObject);
|
2009-09-17 22:15:12 +00:00
|
|
|
|
2009-09-21 14:51:35 +00:00
|
|
|
NPError
|
|
|
|
NPN_NewStream(NPMIMEType aMIMEType, const char* aWindow,
|
|
|
|
NPStream** aStream);
|
|
|
|
|
2010-01-04 21:46:34 +00:00
|
|
|
void InvalidateRect(NPRect* aInvalidRect);
|
2009-11-13 20:20:03 +00:00
|
|
|
|
2011-10-14 18:00:44 +00:00
|
|
|
#ifdef MOZ_WIDGET_COCOA
|
|
|
|
void Invalidate();
|
|
|
|
#endif // definied(MOZ_WIDGET_COCOA)
|
|
|
|
|
2010-01-20 03:13:24 +00:00
|
|
|
uint32_t ScheduleTimer(uint32_t interval, bool repeat, TimerFunc func);
|
|
|
|
void UnscheduleTimer(uint32_t id);
|
|
|
|
|
2010-03-25 18:25:38 +00:00
|
|
|
void AsyncCall(PluginThreadCallback aFunc, void* aUserData);
|
2015-04-27 22:07:28 +00:00
|
|
|
// This function is a more general version of AsyncCall
|
|
|
|
void PostChildAsyncCall(ChildAsyncCall* aTask);
|
2010-03-25 18:25:38 +00:00
|
|
|
|
2010-12-07 00:50:47 +00:00
|
|
|
int GetQuirks();
|
2010-02-25 00:13:48 +00:00
|
|
|
|
2011-01-05 19:44:21 +00:00
|
|
|
void NPN_URLRedirectResponse(void* notifyData, NPBool allow);
|
|
|
|
|
2012-02-16 03:30:22 +00:00
|
|
|
void DoAsyncRedraw();
|
2010-10-21 21:52:48 +00:00
|
|
|
private:
|
|
|
|
friend class PluginModuleChild;
|
|
|
|
|
2010-02-20 21:59:40 +00:00
|
|
|
NPError
|
|
|
|
InternalGetNPObjectForValue(NPNVariable aValue,
|
|
|
|
NPObject** aObject);
|
|
|
|
|
2012-02-16 03:30:22 +00:00
|
|
|
bool IsAsyncDrawing();
|
|
|
|
|
2011-02-16 22:43:31 +00:00
|
|
|
virtual bool RecvUpdateBackground(const SurfaceDescriptor& aBackground,
|
2015-03-21 16:28:04 +00:00
|
|
|
const nsIntRect& aRect) override;
|
2011-02-16 22:43:31 +00:00
|
|
|
|
|
|
|
virtual PPluginBackgroundDestroyerChild*
|
2015-03-21 16:28:04 +00:00
|
|
|
AllocPPluginBackgroundDestroyerChild() override;
|
2011-02-16 22:43:31 +00:00
|
|
|
|
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
RecvPPluginBackgroundDestroyerConstructor(PPluginBackgroundDestroyerChild* aActor) override;
|
2011-02-16 22:43:31 +00:00
|
|
|
|
|
|
|
virtual bool
|
2015-03-21 16:28:04 +00:00
|
|
|
DeallocPPluginBackgroundDestroyerChild(PPluginBackgroundDestroyerChild* aActor) override;
|
2011-02-16 22:43:31 +00:00
|
|
|
|
2009-07-01 21:19:32 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
static bool RegisterWindowClass();
|
|
|
|
bool CreatePluginWindow();
|
|
|
|
void DestroyPluginWindow();
|
|
|
|
void ReparentPluginWindow(HWND hWndParent);
|
|
|
|
void SizePluginWindow(int width, int height);
|
2010-02-09 22:34:38 +00:00
|
|
|
int16_t WinlessHandleEvent(NPEvent& event);
|
2010-03-23 03:06:35 +00:00
|
|
|
void CreateWinlessPopupSurrogate();
|
|
|
|
void DestroyWinlessPopupSurrogate();
|
|
|
|
void InitPopupMenuHook();
|
2010-04-26 16:29:11 +00:00
|
|
|
void SetupFlashMsgThrottle();
|
2010-05-06 16:40:26 +00:00
|
|
|
void UnhookWinlessFlashThrottle();
|
2010-10-21 21:52:48 +00:00
|
|
|
void HookSetWindowLongPtr();
|
2011-09-29 06:19:26 +00:00
|
|
|
static inline bool SetWindowLongHookCheck(HWND hWnd,
|
2010-10-21 21:52:48 +00:00
|
|
|
int nIndex,
|
|
|
|
LONG_PTR newLong);
|
2010-04-26 16:29:11 +00:00
|
|
|
void FlashThrottleMessage(HWND, UINT, WPARAM, LPARAM, bool);
|
2009-07-01 21:19:32 +00:00
|
|
|
static LRESULT CALLBACK DummyWindowProc(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
|
|
|
static LRESULT CALLBACK PluginWindowProc(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
2010-03-23 03:06:35 +00:00
|
|
|
static BOOL WINAPI TrackPopupHookProc(HMENU hMenu,
|
|
|
|
UINT uFlags,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int nReserved,
|
|
|
|
HWND hWnd,
|
|
|
|
CONST RECT *prcRect);
|
2010-04-26 16:29:11 +00:00
|
|
|
static BOOL CALLBACK EnumThreadWindowsCallback(HWND hWnd,
|
|
|
|
LPARAM aParam);
|
|
|
|
static LRESULT CALLBACK WinlessHiddenFlashWndProc(HWND hWnd,
|
|
|
|
UINT message,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam);
|
2010-10-21 21:52:48 +00:00
|
|
|
#ifdef _WIN64
|
|
|
|
static LONG_PTR WINAPI SetWindowLongPtrAHook(HWND hWnd,
|
|
|
|
int nIndex,
|
|
|
|
LONG_PTR newLong);
|
|
|
|
static LONG_PTR WINAPI SetWindowLongPtrWHook(HWND hWnd,
|
|
|
|
int nIndex,
|
|
|
|
LONG_PTR newLong);
|
|
|
|
|
|
|
|
#else
|
|
|
|
static LONG WINAPI SetWindowLongAHook(HWND hWnd,
|
|
|
|
int nIndex,
|
|
|
|
LONG newLong);
|
|
|
|
static LONG WINAPI SetWindowLongWHook(HWND hWnd,
|
|
|
|
int nIndex,
|
|
|
|
LONG newLong);
|
|
|
|
#endif
|
2010-04-26 16:29:11 +00:00
|
|
|
|
|
|
|
class FlashThrottleAsyncMsg : public ChildAsyncCall
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FlashThrottleAsyncMsg();
|
|
|
|
FlashThrottleAsyncMsg(PluginInstanceChild* aInst,
|
|
|
|
HWND aWnd, UINT aMsg,
|
|
|
|
WPARAM aWParam, LPARAM aLParam,
|
|
|
|
bool isWindowed)
|
2012-07-30 14:20:58 +00:00
|
|
|
: ChildAsyncCall(aInst, nullptr, nullptr),
|
2010-04-26 16:29:11 +00:00
|
|
|
mWnd(aWnd),
|
|
|
|
mMsg(aMsg),
|
|
|
|
mWParam(aWParam),
|
|
|
|
mLParam(aLParam),
|
|
|
|
mWindowed(isWindowed)
|
|
|
|
{}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
void Run() override;
|
2010-04-26 16:29:11 +00:00
|
|
|
|
|
|
|
WNDPROC GetProc();
|
|
|
|
HWND GetWnd() { return mWnd; }
|
|
|
|
UINT GetMsg() { return mMsg; }
|
|
|
|
WPARAM GetWParam() { return mWParam; }
|
|
|
|
LPARAM GetLParam() { return mLParam; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
HWND mWnd;
|
|
|
|
UINT mMsg;
|
|
|
|
WPARAM mWParam;
|
|
|
|
LPARAM mLParam;
|
|
|
|
bool mWindowed;
|
|
|
|
};
|
|
|
|
|
2009-07-01 21:19:32 +00:00
|
|
|
#endif
|
2009-06-30 18:51:05 +00:00
|
|
|
const NPPluginFuncs* mPluginIface;
|
2014-12-29 23:13:09 +00:00
|
|
|
nsCString mMimeType;
|
|
|
|
uint16_t mMode;
|
|
|
|
InfallibleTArray<nsCString> mNames;
|
|
|
|
InfallibleTArray<nsCString> mValues;
|
2009-06-30 18:51:05 +00:00
|
|
|
NPP_t mData;
|
|
|
|
NPWindow mWindow;
|
2012-10-02 19:48:05 +00:00
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
double mContentsScaleFactor;
|
|
|
|
#endif
|
2012-02-16 03:24:38 +00:00
|
|
|
int16_t mDrawingModel;
|
2012-02-16 03:30:22 +00:00
|
|
|
|
|
|
|
mozilla::Mutex mAsyncInvalidateMutex;
|
|
|
|
CancelableTask *mAsyncInvalidateTask;
|
2010-01-15 20:35:57 +00:00
|
|
|
|
2010-02-20 21:59:40 +00:00
|
|
|
// Cached scriptable actors to avoid IPC churn
|
|
|
|
PluginScriptableObjectChild* mCachedWindowActor;
|
|
|
|
PluginScriptableObjectChild* mCachedElementActor;
|
|
|
|
|
2009-10-11 23:54:49 +00:00
|
|
|
#if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
|
2009-06-30 18:51:05 +00:00
|
|
|
NPSetWindowCallbackStruct mWsInfo;
|
2014-05-28 08:23:00 +00:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2012-08-01 20:34:08 +00:00
|
|
|
bool mXEmbed;
|
|
|
|
XtClient mXtClient;
|
|
|
|
#endif
|
2009-07-01 21:19:32 +00:00
|
|
|
#elif defined(OS_WIN)
|
|
|
|
HWND mPluginWindowHWND;
|
|
|
|
WNDPROC mPluginWndProc;
|
|
|
|
HWND mPluginParentHWND;
|
2010-02-09 22:34:38 +00:00
|
|
|
int mNestedEventLevelDepth;
|
|
|
|
HWND mCachedWinlessPluginHWND;
|
2010-03-23 03:06:35 +00:00
|
|
|
HWND mWinlessPopupSurrogateHWND;
|
2010-02-18 20:20:25 +00:00
|
|
|
nsIntPoint mPluginSize;
|
2010-04-26 16:29:11 +00:00
|
|
|
WNDPROC mWinlessThrottleOldWndProc;
|
2010-05-06 16:40:26 +00:00
|
|
|
HWND mWinlessHiddenMsgHWND;
|
2009-07-02 16:54:22 +00:00
|
|
|
#endif
|
2009-09-17 22:15:12 +00:00
|
|
|
|
2010-01-20 03:13:24 +00:00
|
|
|
friend class ChildAsyncCall;
|
2010-03-25 18:25:38 +00:00
|
|
|
|
|
|
|
Mutex mAsyncCallMutex;
|
2010-01-20 03:13:24 +00:00
|
|
|
nsTArray<ChildAsyncCall*> mPendingAsyncCalls;
|
2010-02-03 22:17:09 +00:00
|
|
|
nsTArray<nsAutoPtr<ChildTimer> > mTimers;
|
2010-01-20 03:13:24 +00:00
|
|
|
|
2010-02-24 21:14:13 +00:00
|
|
|
/**
|
|
|
|
* During destruction we enumerate all remaining scriptable objects and
|
|
|
|
* invalidate/delete them. Enumeration can re-enter, so maintain a
|
|
|
|
* hash separate from PluginModuleChild.mObjectMap.
|
|
|
|
*/
|
|
|
|
nsAutoPtr< nsTHashtable<DeletingObjectEntry> > mDeletingHash;
|
|
|
|
|
2009-12-01 21:05:26 +00:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
private:
|
|
|
|
// Shared dib rendering management for windowless plugins.
|
2010-03-10 15:54:22 +00:00
|
|
|
bool SharedSurfaceSetWindow(const NPRemoteWindow& aWindow);
|
2009-12-15 00:27:25 +00:00
|
|
|
int16_t SharedSurfacePaint(NPEvent& evcopy);
|
2009-12-01 21:05:26 +00:00
|
|
|
void SharedSurfaceRelease();
|
2009-12-15 00:27:25 +00:00
|
|
|
bool AlphaExtractCacheSetup();
|
|
|
|
void AlphaExtractCacheRelease();
|
|
|
|
void UpdatePaintClipRect(RECT* aRect);
|
2009-12-01 21:05:26 +00:00
|
|
|
|
|
|
|
private:
|
2009-12-15 00:27:25 +00:00
|
|
|
enum {
|
|
|
|
RENDER_NATIVE,
|
|
|
|
RENDER_BACK_ONE,
|
|
|
|
RENDER_BACK_TWO
|
|
|
|
};
|
2009-12-01 21:05:26 +00:00
|
|
|
gfx::SharedDIBWin mSharedSurfaceDib;
|
2009-12-15 00:27:25 +00:00
|
|
|
struct {
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t doublePass;
|
2009-12-15 00:27:25 +00:00
|
|
|
HDC hdc;
|
|
|
|
HBITMAP bmp;
|
|
|
|
} mAlphaExtract;
|
2009-12-01 21:05:26 +00:00
|
|
|
#endif // defined(OS_WIN)
|
2011-06-25 15:25:03 +00:00
|
|
|
#if defined(MOZ_WIDGET_COCOA)
|
2010-04-01 21:53:56 +00:00
|
|
|
private:
|
2011-02-15 18:30:09 +00:00
|
|
|
#if defined(__i386__)
|
2012-07-31 15:11:57 +00:00
|
|
|
NPEventModel mEventModel;
|
2011-02-15 18:30:09 +00:00
|
|
|
#endif
|
2012-07-31 15:11:57 +00:00
|
|
|
CGColorSpaceRef mShColorSpace;
|
|
|
|
CGContextRef mShContext;
|
|
|
|
mozilla::RefPtr<nsCARenderer> mCARenderer;
|
|
|
|
void *mCGLayer;
|
2010-07-29 22:38:32 +00:00
|
|
|
|
2011-10-14 18:00:44 +00:00
|
|
|
// Core Animation drawing model requires a refresh timer.
|
2012-07-31 15:11:57 +00:00
|
|
|
uint32_t mCARefreshTimer;
|
2011-10-14 18:00:44 +00:00
|
|
|
|
2010-07-29 22:38:32 +00:00
|
|
|
public:
|
|
|
|
const NPCocoaEvent* getCurrentEvent() {
|
|
|
|
return mCurrentEvent;
|
|
|
|
}
|
2011-05-19 21:08:14 +00:00
|
|
|
|
|
|
|
bool CGDraw(CGContextRef ref, nsIntRect aUpdateRect);
|
2010-07-29 22:38:32 +00:00
|
|
|
|
2011-02-15 18:30:09 +00:00
|
|
|
#if defined(__i386__)
|
|
|
|
NPEventModel EventModel() { return mEventModel; }
|
|
|
|
#endif
|
2010-09-23 05:27:59 +00:00
|
|
|
|
2010-07-29 22:38:32 +00:00
|
|
|
private:
|
|
|
|
const NPCocoaEvent *mCurrentEvent;
|
2010-04-01 21:53:56 +00:00
|
|
|
#endif
|
2010-09-15 16:02:49 +00:00
|
|
|
|
2011-02-16 22:43:31 +00:00
|
|
|
bool CanPaintOnBackground();
|
|
|
|
|
2010-11-05 14:40:55 +00:00
|
|
|
bool IsVisible() {
|
2011-06-30 16:46:25 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
return mWindow.clipRect.top != mWindow.clipRect.bottom &&
|
|
|
|
mWindow.clipRect.left != mWindow.clipRect.right;
|
|
|
|
#else
|
2010-11-05 14:40:55 +00:00
|
|
|
return mWindow.clipRect.top != 0 ||
|
|
|
|
mWindow.clipRect.left != 0 ||
|
|
|
|
mWindow.clipRect.bottom != 0 ||
|
|
|
|
mWindow.clipRect.right != 0;
|
2011-06-30 16:46:25 +00:00
|
|
|
#endif
|
2010-11-05 14:40:55 +00:00
|
|
|
}
|
|
|
|
|
2010-09-15 16:02:49 +00:00
|
|
|
// ShowPluginFrame - in general does four things:
|
|
|
|
// 1) Create mCurrentSurface optimized for rendering to parent process
|
|
|
|
// 2) Updated mCurrentSurface to be a complete copy of mBackSurface
|
|
|
|
// 3) Draw the invalidated plugin area into mCurrentSurface
|
|
|
|
// 4) Send it to parent process.
|
2010-09-21 16:03:16 +00:00
|
|
|
bool ShowPluginFrame(void);
|
2010-09-15 16:02:49 +00:00
|
|
|
|
2010-10-27 13:09:15 +00:00
|
|
|
// If we can read back safely from mBackSurface, copy
|
|
|
|
// mSurfaceDifferenceRect from mBackSurface to mFrontSurface.
|
|
|
|
// @return Whether the back surface could be read.
|
|
|
|
bool ReadbackDifferenceRect(const nsIntRect& rect);
|
|
|
|
|
2010-09-15 16:02:49 +00:00
|
|
|
// Post ShowPluginFrame task
|
|
|
|
void AsyncShowPluginFrame(void);
|
|
|
|
|
2010-09-21 16:03:16 +00:00
|
|
|
// In the PaintRect functions, aSurface is the size of the full plugin
|
|
|
|
// window. Each PaintRect function renders into the subrectangle aRect of
|
|
|
|
// aSurface (possibly more if we're working around a Flash bug).
|
2010-09-15 16:02:49 +00:00
|
|
|
|
|
|
|
// Paint plugin content rectangle to surface with bg color filling
|
|
|
|
void PaintRectToSurface(const nsIntRect& aRect,
|
|
|
|
gfxASurface* aSurface,
|
|
|
|
const gfxRGBA& aColor);
|
|
|
|
|
|
|
|
// Render plugin content to surface using
|
|
|
|
// white/black image alpha extraction algorithm
|
|
|
|
void PaintRectWithAlphaExtraction(const nsIntRect& aRect,
|
|
|
|
gfxASurface* aSurface);
|
|
|
|
|
|
|
|
// Call plugin NPAPI function to render plugin content to surface
|
|
|
|
// @param - aSurface - should be compatible with current platform plugin rendering
|
|
|
|
// @return - FALSE if plugin not painted to surface
|
|
|
|
void PaintRectToPlatformSurface(const nsIntRect& aRect,
|
|
|
|
gfxASurface* aSurface);
|
|
|
|
|
|
|
|
// Update NPWindow platform attributes and call plugin "setwindow"
|
|
|
|
// @param - aForceSetWindow - call setwindow even if platform attributes are the same
|
2010-09-21 16:03:16 +00:00
|
|
|
void UpdateWindowAttributes(bool aForceSetWindow = false);
|
2010-09-15 16:02:49 +00:00
|
|
|
|
|
|
|
// Create optimized mCurrentSurface for parent process rendering
|
|
|
|
// @return FALSE if optimized surface not created
|
2010-09-21 16:03:16 +00:00
|
|
|
bool CreateOptSurface(void);
|
2010-09-15 16:02:49 +00:00
|
|
|
|
|
|
|
// Create mHelperSurface if mCurrentSurface non compatible with plugins
|
|
|
|
// @return TRUE if helper surface created successfully, or not needed
|
2010-09-21 16:03:16 +00:00
|
|
|
bool MaybeCreatePlatformHelperSurface(void);
|
2010-09-15 16:02:49 +00:00
|
|
|
|
|
|
|
// Make sure that we have surface for rendering
|
2010-09-21 16:03:16 +00:00
|
|
|
bool EnsureCurrentBuffer(void);
|
2010-09-15 16:02:49 +00:00
|
|
|
|
|
|
|
// Helper function for delayed InvalidateRect call
|
|
|
|
// non null mCurrentInvalidateTask will call this function
|
|
|
|
void InvalidateRectDelayed(void);
|
|
|
|
|
2011-01-27 22:37:00 +00:00
|
|
|
// Clear mCurrentSurface/mCurrentSurfaceActor/mHelperSurface
|
|
|
|
void ClearCurrentSurface();
|
|
|
|
|
|
|
|
// Swap mCurrentSurface/mBackSurface and their associated actors
|
|
|
|
void SwapSurfaces();
|
|
|
|
|
|
|
|
// Clear all surfaces in response to NPP_Destroy
|
|
|
|
void ClearAllSurfaces();
|
|
|
|
|
2014-10-29 15:05:36 +00:00
|
|
|
void Destroy();
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
void ActorDestroy(ActorDestroyReason aWhy) override;
|
2014-10-29 15:05:36 +00:00
|
|
|
|
2010-09-15 16:02:49 +00:00
|
|
|
// Set as true when SetupLayer called
|
|
|
|
// and go with different path in InvalidateRect function
|
2010-09-21 16:03:16 +00:00
|
|
|
bool mLayersRendering;
|
|
|
|
|
2010-09-15 16:02:49 +00:00
|
|
|
// Current surface available for rendering
|
|
|
|
nsRefPtr<gfxASurface> mCurrentSurface;
|
2010-09-21 16:03:16 +00:00
|
|
|
|
2010-09-15 16:02:49 +00:00
|
|
|
// Back surface, just keeping reference to
|
|
|
|
// surface which is on ParentProcess side
|
|
|
|
nsRefPtr<gfxASurface> mBackSurface;
|
2010-09-21 16:03:16 +00:00
|
|
|
|
2011-05-19 21:08:14 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// Current IOSurface available for rendering
|
|
|
|
// We can't use thebes gfxASurface like other platforms.
|
2012-11-10 15:45:52 +00:00
|
|
|
PluginUtilsOSX::nsDoubleBufferCARenderer mDoubleBufferCARenderer;
|
2011-05-19 21:08:14 +00:00
|
|
|
#endif
|
|
|
|
|
2011-02-16 22:43:31 +00:00
|
|
|
// (Not to be confused with mBackSurface). This is a recent copy
|
|
|
|
// of the opaque pixels under our object frame, if
|
|
|
|
// |mIsTransparent|. We ask the plugin render directly onto a
|
|
|
|
// copy of the background pixels if available, and fall back on
|
|
|
|
// alpha recovery otherwise.
|
|
|
|
nsRefPtr<gfxASurface> mBackground;
|
|
|
|
|
2011-01-27 22:37:00 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
// These actors mirror mCurrentSurface/mBackSurface
|
|
|
|
PPluginSurfaceChild* mCurrentSurfaceActor;
|
|
|
|
PPluginSurfaceChild* mBackSurfaceActor;
|
|
|
|
#endif
|
|
|
|
|
2010-10-27 13:09:37 +00:00
|
|
|
// Accumulated invalidate rect, while back buffer is not accessible,
|
|
|
|
// in plugin coordinates.
|
2010-09-21 16:03:16 +00:00
|
|
|
nsIntRect mAccumulatedInvalidRect;
|
|
|
|
|
2010-09-15 16:02:49 +00:00
|
|
|
// Plugin only call SetTransparent
|
|
|
|
// and does not remember their transparent state
|
|
|
|
// and p->getvalue return always false
|
2010-09-21 16:03:16 +00:00
|
|
|
bool mIsTransparent;
|
|
|
|
|
2010-09-15 16:02:49 +00:00
|
|
|
// Surface type optimized of parent process
|
2010-09-21 16:03:16 +00:00
|
|
|
gfxSurfaceType mSurfaceType;
|
2010-09-15 16:02:49 +00:00
|
|
|
|
|
|
|
// Keep InvalidateRect task pointer to be able Cancel it on Destroy
|
2010-09-21 16:03:16 +00:00
|
|
|
CancelableTask *mCurrentInvalidateTask;
|
2010-09-15 16:02:49 +00:00
|
|
|
|
2010-12-05 21:57:33 +00:00
|
|
|
// Keep AsyncSetWindow task pointer to be able to Cancel it on Destroy
|
|
|
|
CancelableTask *mCurrentAsyncSetWindowTask;
|
|
|
|
|
2010-09-15 16:02:49 +00:00
|
|
|
// True while plugin-child in plugin call
|
|
|
|
// Use to prevent plugin paint re-enter
|
2010-09-21 16:03:16 +00:00
|
|
|
bool mPendingPluginCall;
|
2010-09-15 16:02:49 +00:00
|
|
|
|
|
|
|
// On some platforms, plugins may not support rendering to a surface with
|
|
|
|
// alpha, or not support rendering to an image surface.
|
|
|
|
// In those cases we need to draw to a temporary platform surface; we cache
|
|
|
|
// that surface here.
|
|
|
|
nsRefPtr<gfxASurface> mHelperSurface;
|
|
|
|
|
2013-08-25 23:56:53 +00:00
|
|
|
// true when plugin does not support painting to ARGB32
|
|
|
|
// surface this is false if plugin supports
|
|
|
|
// NPPVpluginTransparentAlphaBool (which is not part of
|
|
|
|
// NPAPI yet)
|
2010-09-21 16:03:16 +00:00
|
|
|
bool mDoAlphaExtraction;
|
2010-09-15 16:02:49 +00:00
|
|
|
|
2011-01-04 03:56:05 +00:00
|
|
|
// true when the plugin has painted at least once. We use this to ensure
|
|
|
|
// that we ask a plugin to paint at least once even if it's invisible;
|
|
|
|
// some plugin (instances) rely on this in order to work properly.
|
|
|
|
bool mHasPainted;
|
|
|
|
|
2010-09-15 16:02:49 +00:00
|
|
|
// Cached rectangle rendered to previous surface(mBackSurface)
|
2010-10-27 13:09:37 +00:00
|
|
|
// Used for reading back to current surface and syncing data,
|
|
|
|
// in plugin coordinates.
|
2010-09-21 16:03:16 +00:00
|
|
|
nsIntRect mSurfaceDifferenceRect;
|
2014-10-29 15:05:36 +00:00
|
|
|
|
|
|
|
// Has this instance been destroyed, either by ActorDestroy or NPP_Destroy?
|
|
|
|
bool mDestroyed;
|
2009-06-30 18:51:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace plugins
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2009-09-09 06:31:35 +00:00
|
|
|
#endif // ifndef dom_plugins_PluginInstanceChild_h
|