Bug 1253434 - Avoid trying to capture plugin windows that have a zero width or height and a positive value for the other dim. r?aklotz
MozReview-Commit-ID: 614EhJjmG4a
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -1266,17 +1266,17 @@ PluginInstanceParent::UpdateScrollCaptur
CAPTURE_LOG("no windowdc");
aRequestNewCapture = true;
return false;
}
RECT bounds = {0};
::GetWindowRect(mChildPluginHWND, &bounds);
if ((bounds.left == bounds.right && bounds.top == bounds.bottom) ||
- (!mWindowSize.width && !mWindowSize.height)) {
+ mWindowSize.IsEmpty()) {
CAPTURE_LOG("empty bounds");
// Lots of null window plugins in content, don't capture.
return false;
}
// If we need to init mScrollCapture do so, also reset it if the size of the
// plugin window changes.
if (!mScrollCapture || mScrollCapture->GetSize() != mWindowSize) {
@@ -1292,17 +1292,17 @@ PluginInstanceParent::UpdateScrollCaptur
int rgnType = ::GetWindowRgnBox(mPluginHWND, &clip);
bool clipCorrect = !clip.left && !clip.top &&
clip.right == mWindowSize.width &&
clip.bottom == mWindowSize.height;
bool isVisible = ::IsWindowVisible(mChildPluginHWND);
CAPTURE_LOG("validcap=%d visible=%d region=%d clip=%d:%dx%dx%dx%d",
- mValidFirstCapture, isVisible, rgnType, clipCorrect
+ mValidFirstCapture, isVisible, rgnType, clipCorrect,
clip.left, clip.top, clip.right, clip.bottom);
// We have a good capture and can't update so keep using the existing
// capture image. Otherwise fall through so we paint the fill color to
// the layer.
if (mValidFirstCapture && (!isVisible || !clipCorrect)) {
return true;
}
@@ -1321,16 +1321,21 @@ PluginInstanceParent::UpdateScrollCaptur
CAPTURE_LOG("blt failure??");
return false;
}
::GdiFlush();
mValidFirstCapture = true;
}
IntSize targetSize = mScrollCapture->GetSize();
+
+ if (targetSize.IsEmpty()) {
+ return false;
+ }
+
RefPtr<gfx::DrawTarget> dt =
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(mScrollCapture,
targetSize);
if (nativeScrollCapture) {
// Copy the native capture image over to a remotable gfx surface.
RefPtr<gfx::SourceSurface> sourceSurface =
gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(nullptr,