Bug 604303 - Move plugin quirks from PluginInstanceChild to PluginModuleChild. r=bsmedgerg, a=betaN.

This commit is contained in:
Jim Mathies 2010-12-06 18:50:47 -06:00
Родитель bcf48151a4
Коммит 7a1e8e8157
4 изменённых файлов: 74 добавлений и 58 удалений

Просмотреть файл

@ -112,10 +112,8 @@ struct RunnableMethodTraits<PluginInstanceChild>
static void ReleaseCallee(PluginInstanceChild* obj) { }
};
PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface,
const nsCString& aMimeType)
PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface)
: mPluginIface(aPluginIface)
, mQuirks(0)
, mCachedWindowActor(nsnull)
, mCachedElementActor(nsnull)
#if defined(OS_WIN)
@ -164,7 +162,6 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface,
#if defined(OS_WIN)
memset(&mAlphaExtract, 0, sizeof(mAlphaExtract));
#endif // OS_WIN
InitQuirksModes(aMimeType);
#if defined(OS_WIN)
InitPopupMenuHook();
#endif // OS_WIN
@ -194,28 +191,10 @@ PluginInstanceChild::~PluginInstanceChild()
#endif
}
void
PluginInstanceChild::InitQuirksModes(const nsCString& aMimeType)
int
PluginInstanceChild::GetQuirks()
{
// application/x-silverlight
// application/x-silverlight-2
NS_NAMED_LITERAL_CSTRING(silverlight, "application/x-silverlight");
if (FindInReadable(silverlight, aMimeType)) {
mQuirks |= QUIRK_SILVERLIGHT_DEFAULT_TRANSPARENT;
#ifdef OS_WIN
mQuirks |= QUIRK_WINLESS_TRACKPOPUP_HOOK;
#endif
}
#ifdef OS_WIN
// application/x-shockwave-flash
NS_NAMED_LITERAL_CSTRING(flash, "application/x-shockwave-flash");
if (FindInReadable(flash, aMimeType)) {
mQuirks |= QUIRK_WINLESS_TRACKPOPUP_HOOK;
mQuirks |= QUIRK_FLASH_THROTTLE_WMUSER_EVENTS;
mQuirks |= QUIRK_FLASH_HOOK_SETLONGPTR;
}
#endif
return PluginModuleChild::current()->GetQuirks();
}
NPError
@ -960,9 +939,9 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
case NPWindowTypeDrawable:
mWindow.type = aWindow.type;
if (mQuirks & QUIRK_WINLESS_TRACKPOPUP_HOOK)
if (GetQuirks() & PluginModuleChild::QUIRK_WINLESS_TRACKPOPUP_HOOK)
CreateWinlessPopupSurrogate();
if (mQuirks & QUIRK_FLASH_THROTTLE_WMUSER_EVENTS)
if (GetQuirks() & PluginModuleChild::QUIRK_FLASH_THROTTLE_WMUSER_EVENTS)
SetupFlashMsgThrottle();
return SharedSurfaceSetWindow(aWindow);
break;
@ -1193,7 +1172,7 @@ PluginInstanceChild::PluginWindowProc(HWND hWnd,
self->CallPluginFocusChange(false);
if (message == WM_USER+1 &&
(self->mQuirks & PluginInstanceChild::QUIRK_FLASH_THROTTLE_WMUSER_EVENTS)) {
(self->GetQuirks() & PluginModuleChild::QUIRK_FLASH_THROTTLE_WMUSER_EVENTS)) {
self->FlashThrottleMessage(hWnd, message, wParam, lParam, true);
return 0;
}
@ -1361,7 +1340,7 @@ PluginInstanceChild::HookSetWindowLongPtr()
return;
#endif
if (!(GetQuirks() & QUIRK_FLASH_HOOK_SETLONGPTR))
if (!(GetQuirks() & PluginModuleChild::QUIRK_FLASH_HOOK_SETLONGPTR))
return;
sUser32Intercept.Init("user32.dll");
@ -1444,7 +1423,7 @@ PluginInstanceChild::TrackPopupHookProc(HMENU hMenu,
void
PluginInstanceChild::InitPopupMenuHook()
{
if (!(mQuirks & QUIRK_WINLESS_TRACKPOPUP_HOOK) ||
if (!(GetQuirks() & PluginModuleChild::QUIRK_WINLESS_TRACKPOPUP_HOOK) ||
sUser32TrackPopupMenuStub)
return;
@ -1544,7 +1523,7 @@ PluginInstanceChild::WinlessHandleEvent(NPEvent& event)
// TrackPopupMenu will fail if the parent window is not associated with
// our ui thread. So we hook TrackPopupMenu so we can hand in a surrogate
// parent created in the child process.
if ((mQuirks & QUIRK_WINLESS_TRACKPOPUP_HOOK) && // XXX turn on by default?
if ((GetQuirks() & PluginModuleChild::QUIRK_WINLESS_TRACKPOPUP_HOOK) && // XXX turn on by default?
(event.event == WM_RBUTTONDOWN || // flash
event.event == WM_RBUTTONUP)) { // silverlight
sWinlessPopupSurrogateHWND = mWinlessPopupSurrogateHWND;
@ -2228,7 +2207,7 @@ PluginInstanceChild::DoAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
mWindow.clipRect = aWindow.clipRect;
mWindow.type = aWindow.type;
if (mQuirks & QUIRK_SILVERLIGHT_DEFAULT_TRANSPARENT)
if (GetQuirks() & PluginModuleChild::QUIRK_SILVERLIGHT_DEFAULT_TRANSPARENT)
mIsTransparent = true;
mLayersRendering = true;
@ -2236,9 +2215,9 @@ PluginInstanceChild::DoAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
UpdateWindowAttributes(true);
#ifdef XP_WIN
if (mQuirks & QUIRK_WINLESS_TRACKPOPUP_HOOK)
if (GetQuirks() & PluginModuleChild::QUIRK_WINLESS_TRACKPOPUP_HOOK)
CreateWinlessPopupSurrogate();
if (mQuirks & QUIRK_FLASH_THROTTLE_WMUSER_EVENTS)
if (GetQuirks() & PluginModuleChild::QUIRK_FLASH_THROTTLE_WMUSER_EVENTS)
SetupFlashMsgThrottle();
#endif

Просмотреть файл

@ -183,7 +183,7 @@ protected:
AnswerUpdateWindow();
public:
PluginInstanceChild(const NPPluginFuncs* aPluginIface, const nsCString& aMimeType);
PluginInstanceChild(const NPPluginFuncs* aPluginIface);
virtual ~PluginInstanceChild();
@ -214,30 +214,11 @@ public:
void AsyncCall(PluginThreadCallback aFunc, void* aUserData);
int GetQuirks() { return mQuirks; }
// Quirks mode support for various plugin mime types
enum PluginQuirks {
// Silverlight assumes it is transparent in windowless mode. This quirk
// matches the logic in nsNPAPIPluginInstance::SetWindowless.
QUIRK_SILVERLIGHT_DEFAULT_TRANSPARENT = 1 << 0,
// Win32: Hook TrackPopupMenu api so that we can swap out parent
// hwnds. The api will fail with parents not associated with our
// child ui thread. See WinlessHandleEvent for details.
QUIRK_WINLESS_TRACKPOPUP_HOOK = 1 << 1,
// Win32: Throttle flash WM_USER+1 heart beat messages to prevent
// flooding chromium's dispatch loop, which can cause ipc traffic
// processing lag.
QUIRK_FLASH_THROTTLE_WMUSER_EVENTS = 1 << 2,
// Win32: Catch resets on our subclass by hooking SetWindowLong.
QUIRK_FLASH_HOOK_SETLONGPTR = 1 << 3,
};
int GetQuirks();
private:
friend class PluginModuleChild;
void InitQuirksModes(const nsCString& aMimeType);
NPError
InternalGetNPObjectForValue(NPNVariable aValue,
NPObject** aObject);
@ -334,7 +315,6 @@ private:
const NPPluginFuncs* mPluginIface;
NPP_t mData;
NPWindow mWindow;
int mQuirks;
// Cached scriptable actors to avoid IPC churn
PluginScriptableObjectChild* mCachedWindowActor;

Просмотреть файл

@ -101,7 +101,8 @@ static bool gDelayFlashFocusReplyUntilEval = false;
PluginModuleChild::PluginModuleChild() :
mLibrary(0),
mShutdownFunc(0),
mInitializeFunc(0)
mInitializeFunc(0),
mQuirks(QUIRKS_NOT_INITIALIZED)
#if defined(OS_WIN) || defined(OS_MACOSX)
, mGetEntryPointsFunc(0)
#elif defined(MOZ_WIDGET_GTK2)
@ -1719,8 +1720,10 @@ PluginModuleChild::AllocPPluginInstance(const nsCString& aMimeType,
PLUGIN_LOG_DEBUG_METHOD;
AssertPluginThread();
InitQuirksModes(aMimeType);
nsAutoPtr<PluginInstanceChild> childInstance(
new PluginInstanceChild(&mFunctions, aMimeType));
new PluginInstanceChild(&mFunctions));
if (!childInstance->Initialize()) {
*rv = NPERR_GENERIC_ERROR;
return 0;
@ -1728,6 +1731,33 @@ PluginModuleChild::AllocPPluginInstance(const nsCString& aMimeType,
return childInstance.forget();
}
void
PluginModuleChild::InitQuirksModes(const nsCString& aMimeType)
{
if (mQuirks != QUIRKS_NOT_INITIALIZED)
return;
mQuirks = 0;
// application/x-silverlight
// application/x-silverlight-2
NS_NAMED_LITERAL_CSTRING(silverlight, "application/x-silverlight");
if (FindInReadable(silverlight, aMimeType)) {
mQuirks |= QUIRK_SILVERLIGHT_DEFAULT_TRANSPARENT;
#ifdef OS_WIN
mQuirks |= QUIRK_WINLESS_TRACKPOPUP_HOOK;
#endif
}
#ifdef OS_WIN
// application/x-shockwave-flash
NS_NAMED_LITERAL_CSTRING(flash, "application/x-shockwave-flash");
if (FindInReadable(flash, aMimeType)) {
mQuirks |= QUIRK_WINLESS_TRACKPOPUP_HOOK;
mQuirks |= QUIRK_FLASH_THROTTLE_WMUSER_EVENTS;
mQuirks |= QUIRK_FLASH_HOOK_SETLONGPTR;
}
#endif
}
bool
PluginModuleChild::AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
const nsCString& aMimeType,

Просмотреть файл

@ -205,7 +205,33 @@ public:
}
#endif
// Quirks mode support for various plugin mime types
enum PluginQuirks {
QUIRKS_NOT_INITIALIZED = 0,
// Silverlight assumes it is transparent in windowless mode. This quirk
// matches the logic in nsNPAPIPluginInstance::SetWindowless.
QUIRK_SILVERLIGHT_DEFAULT_TRANSPARENT = 1 << 0,
// Win32: Hook TrackPopupMenu api so that we can swap out parent
// hwnds. The api will fail with parents not associated with our
// child ui thread. See WinlessHandleEvent for details.
QUIRK_WINLESS_TRACKPOPUP_HOOK = 1 << 1,
// Win32: Throttle flash WM_USER+1 heart beat messages to prevent
// flooding chromium's dispatch loop, which can cause ipc traffic
// processing lag.
QUIRK_FLASH_THROTTLE_WMUSER_EVENTS = 1 << 2,
// Win32: Catch resets on our subclass by hooking SetWindowLong.
QUIRK_FLASH_HOOK_SETLONGPTR = 1 << 3,
};
int GetQuirks() { return mQuirks; }
void AddQuirk(PluginQuirks quirk) {
if (mQuirks == QUIRKS_NOT_INITIALIZED)
mQuirks = 0;
mQuirks |= quirk;
}
private:
void InitQuirksModes(const nsCString& aMimeType);
bool InitGraphics();
#if defined(MOZ_WIDGET_GTK2)
static gboolean DetectNestedEventLoop(gpointer data);
@ -226,6 +252,7 @@ private:
std::string mPluginFilename;
PRLibrary* mLibrary;
nsCString mUserAgent;
int mQuirks;
// we get this from the plugin
NP_PLUGINSHUTDOWN mShutdownFunc;