Bug 1095754 - Move InvalidatePluginAsWorkaround from nsWindow to WinUtils so the compositor can access it. r=aklotz

This commit is contained in:
Jim Mathies 2015-01-29 13:41:54 -06:00
parent 88d8d1f2b0
commit 5d5b72ad5e
3 changed files with 55 additions and 49 deletions

View File

@ -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

View File

@ -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.
*/

View File

@ -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<Configuration>& aConfigurations)
{
@ -6406,7 +6358,7 @@ nsWindow::ConfigureChildren(const nsTArray<Configuration>& aConfigurations)
-bounds.y);
nsIntRect toInvalidate = r.GetBounds();
InvalidatePluginAsWorkaround(w, toInvalidate);
WinUtils::InvalidatePluginAsWorkaround(w, toInvalidate);
}
}
rv = w->SetWindowClipRegion(configuration.mClipRegion, false);