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 draft
authorJim Mathies <jmathies@mozilla.com>
Thu, 03 Mar 2016 17:15:25 -0600
changeset 336630 fe43e53f1c438de05321f873939f3f2bc37581a7
parent 336127 bdde3fedb45be528f985a0aff373b37b010fb927
child 515477 fd895d9dcdfacb4b7f04c99391ffb6a2ecd32eac
push id12153
push userjmathies@mozilla.com
push dateThu, 03 Mar 2016 23:18:54 +0000
reviewersaklotz
bugs1253434
milestone47.0a1
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
dom/plugins/ipc/PluginInstanceParent.cpp
--- 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,