From 015ae9513d681d1a11eeca60954a12e9dfd5394a Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Mon, 6 Dec 2010 18:50:56 -0600 Subject: [PATCH] Bug 604303 - Trap GetWindowInfo calls in flash and return browser window metrics similar to what we returned prior to the landing of bug 130078. r=bent, a=betaN. --- dom/plugins/PluginModuleChild.cpp | 46 +++++++++++++++++++++++++++++++++++++++ dom/plugins/PluginModuleChild.h | 4 ++++ 2 files changed, 50 insertions(+) diff --git a/dom/plugins/PluginModuleChild.cpp b/dom/plugins/PluginModuleChild.cpp index e6c0b7912a..2532d03a3a 100644 --- a/dom/plugins/PluginModuleChild.cpp +++ b/dom/plugins/PluginModuleChild.cpp @@ -70,6 +70,7 @@ #ifdef XP_WIN #include "COMMessageFilter.h" +#include "nsWindowsDllInterceptor.h" #endif #ifdef OS_MACOSX @@ -81,6 +82,7 @@ using namespace mozilla::plugins; #if defined(XP_WIN) const PRUnichar * kFlashFullscreenClass = L"ShockwaveFlashFullScreen"; +const PRUnichar * kMozillaWindowClass = L"MozillaWindowClass"; #endif namespace { @@ -96,6 +98,11 @@ static PRLibrary *sGtkLib = nsnull; #ifdef XP_WIN // Used with fix for flash fullscreen window loosing focus. static bool gDelayFlashFocusReplyUntilEval = false; +// Used to fix GetWindowInfo problems with internal flash settings dialogs +static WindowsDllInterceptor sUser32Intercept; +typedef BOOL (WINAPI *GetWindowInfoPtr)(HWND hwnd, PWINDOWINFO pwi); +static GetWindowInfoPtr sGetWindowInfoPtrStub = NULL; +static HWND sBrowserHwnd = NULL; #endif PluginModuleChild::PluginModuleChild() : @@ -1710,6 +1717,36 @@ PluginModuleChild::DeallocPPluginIdentifier(PPluginIdentifierChild* aActor) return true; } +#if defined(XP_WIN) +BOOL WINAPI +PMCGetWindowInfoHook(HWND hWnd, PWINDOWINFO pwi) +{ + if (!pwi) + return FALSE; + + if (!sGetWindowInfoPtrStub) { + NS_ASSERTION(FALSE, "Something is horribly wrong in PMCGetWindowInfoHook!"); + return FALSE; + } + + if (!sBrowserHwnd) { + PRUnichar szClass[20]; + if (GetClassNameW(hWnd, szClass, NS_ARRAY_LENGTH(szClass)) && + !wcscmp(szClass, kMozillaWindowClass)) { + sBrowserHwnd = hWnd; + } + } + // Oddity: flash does strange rect comparisons for mouse input destined for + // it's internal settings window. Post removing sub widgets for tabs, touch + // this up so they get the rect they expect. + // XXX potentially tie this to a specific major version? + BOOL result = sGetWindowInfoPtrStub(hWnd, pwi); + if (sBrowserHwnd && sBrowserHwnd == hWnd) + pwi->rcWindow = pwi->rcClient; + return result; +} +#endif + PPluginInstanceChild* PluginModuleChild::AllocPPluginInstance(const nsCString& aMimeType, const uint16_t& aMode, @@ -1722,6 +1759,14 @@ PluginModuleChild::AllocPPluginInstance(const nsCString& aMimeType, InitQuirksModes(aMimeType); +#ifdef XP_WIN + if (mQuirks & QUIRK_FLASH_HOOK_GETWINDOINFO) { + sUser32Intercept.Init("user32.dll"); + sUser32Intercept.AddHook("GetWindowInfo", PMCGetWindowInfoHook, + (void**) &sGetWindowInfoPtrStub); + } +#endif + nsAutoPtr childInstance( new PluginInstanceChild(&mFunctions)); if (!childInstance->Initialize()) { @@ -1754,6 +1799,7 @@ PluginModuleChild::InitQuirksModes(const nsCString& aMimeType) mQuirks |= QUIRK_WINLESS_TRACKPOPUP_HOOK; mQuirks |= QUIRK_FLASH_THROTTLE_WMUSER_EVENTS; mQuirks |= QUIRK_FLASH_HOOK_SETLONGPTR; + mQuirks |= QUIRK_FLASH_HOOK_GETWINDOINFO; } #endif } diff --git a/dom/plugins/PluginModuleChild.h b/dom/plugins/PluginModuleChild.h index f9685c1e2c..7cb2a587c0 100644 --- a/dom/plugins/PluginModuleChild.h +++ b/dom/plugins/PluginModuleChild.h @@ -225,6 +225,10 @@ public: // expose event top left coordinates within the plugin-rect and // not at the drawable origin are misinterpreted. QUIRK_FLASH_EXPOSE_COORD_TRANSLATION = 1 << 4, + // Win32: Catch get window info calls on the browser and tweak the + // results so mouse input works when flash is displaying it's settings + // window. + QUIRK_FLASH_HOOK_GETWINDOINFO = 1 << 5, }; int GetQuirks() { return mQuirks; } -- 2.11.4.GIT