From 5d5b72ad5e7f56db97f763bfae6e96c28fb59ffc Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Thu, 29 Jan 2015 13:41:54 -0600 Subject: [PATCH] Bug 1095754 - Move InvalidatePluginAsWorkaround from nsWindow to WinUtils so the compositor can access it. r=aklotz --- widget/windows/WinUtils.cpp | 48 +++++++++++++++++++++++++++++++++++ widget/windows/WinUtils.h | 6 +++++ widget/windows/nsWindow.cpp | 50 +------------------------------------ 3 files changed, 55 insertions(+), 49 deletions(-) diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index f011c30927d..eb2a1833e15 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -1026,6 +1026,54 @@ WinUtils::SHGetKnownFolderPath(REFKNOWNFOLDERID rfid, return sGetKnownFolderPath(rfid, dwFlags, hToken, ppszPath); } +static BOOL +WINAPI EnumFirstChild(HWND hwnd, LPARAM lParam) +{ + *((HWND*)lParam) = hwnd; + return FALSE; +} + +/* static */ +void +WinUtils::InvalidatePluginAsWorkaround(nsIWidget *aWidget, const nsIntRect &aRect) +{ + aWidget->Invalidate(aRect); + + // XXX - Even more evil workaround!! See bug 762948, flash's bottom + // level sandboxed window doesn't seem to get our invalidate. We send + // an invalidate to it manually. This is totally specialized for this + // bug, for other child window structures this will just be a more or + // less bogus invalidate but since that should not have any bad + // side-effects this will have to do for now. + HWND current = (HWND)aWidget->GetNativeData(NS_NATIVE_WINDOW); + + RECT windowRect; + RECT parentRect; + + ::GetWindowRect(current, &parentRect); + + HWND next = current; + do { + current = next; + ::EnumChildWindows(current, &EnumFirstChild, (LPARAM)&next); + ::GetWindowRect(next, &windowRect); + // This is relative to the screen, adjust it to be relative to the + // window we're reconfiguring. + windowRect.left -= parentRect.left; + windowRect.top -= parentRect.top; + } while (next != current && windowRect.top == 0 && windowRect.left == 0); + + if (windowRect.top == 0 && windowRect.left == 0) { + RECT rect; + rect.left = aRect.x; + rect.top = aRect.y; + rect.right = aRect.XMost(); + rect.bottom = aRect.YMost(); + + ::InvalidateRect(next, &rect, FALSE); + } +} + #ifdef MOZ_PLACES /************************************************************************/ /* Constructs as AsyncFaviconDataReady Object diff --git a/widget/windows/WinUtils.h b/widget/windows/WinUtils.h index 7f8d2c14350..21d5f09a6c7 100644 --- a/widget/windows/WinUtils.h +++ b/widget/windows/WinUtils.h @@ -351,6 +351,12 @@ public: */ static nsIntRect ToIntRect(const RECT& aRect); + /** + * Helper used in invalidating flash plugin windows owned + * by low rights flash containers. + */ + static void InvalidatePluginAsWorkaround(nsIWidget *aWidget, const nsIntRect &aRect); + /** * Returns true if the context or IME state is enabled. Otherwise, false. */ diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index b440c32174c..27d5dbd9538 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -6316,54 +6316,6 @@ bool nsWindow::OnGesture(WPARAM wParam, LPARAM lParam) return true; // Handled } -static BOOL WINAPI EnumFirstChild(HWND hwnd, LPARAM lParam) -{ - *((HWND*)lParam) = hwnd; - return FALSE; -} - -static void InvalidatePluginAsWorkaround(nsWindow *aWindow, const nsIntRect &aRect) -{ - aWindow->Invalidate(aRect); - - // XXX - Even more evil workaround!! See bug 762948, flash's bottom - // level sandboxed window doesn't seem to get our invalidate. We send - // an invalidate to it manually. This is totally specialized for this - // bug, for other child window structures this will just be a more or - // less bogus invalidate but since that should not have any bad - // side-effects this will have to do for now. - HWND current = (HWND)aWindow->GetNativeData(NS_NATIVE_WINDOW); - - RECT windowRect; - RECT parentRect; - - ::GetWindowRect(current, &parentRect); - - HWND next = current; - - do { - current = next; - - ::EnumChildWindows(current, &EnumFirstChild, (LPARAM)&next); - - ::GetWindowRect(next, &windowRect); - // This is relative to the screen, adjust it to be relative to the - // window we're reconfiguring. - windowRect.left -= parentRect.left; - windowRect.top -= parentRect.top; - } while (next != current && windowRect.top == 0 && windowRect.left == 0); - - if (windowRect.top == 0 && windowRect.left == 0) { - RECT rect; - rect.left = aRect.x; - rect.top = aRect.y; - rect.right = aRect.XMost(); - rect.bottom = aRect.YMost(); - - ::InvalidateRect(next, &rect, FALSE); - } -} - nsresult nsWindow::ConfigureChildren(const nsTArray& aConfigurations) { @@ -6406,7 +6358,7 @@ nsWindow::ConfigureChildren(const nsTArray& aConfigurations) -bounds.y); nsIntRect toInvalidate = r.GetBounds(); - InvalidatePluginAsWorkaround(w, toInvalidate); + WinUtils::InvalidatePluginAsWorkaround(w, toInvalidate); } } rv = w->SetWindowClipRegion(configuration.mClipRegion, false);