Bug 702627 - Invalidate plugin rect after requesting Java surface during paint r=blassey
authorBrad Lassey <blassey@mozilla.com>
Tue, 15 Nov 2011 18:05:23 -0500
changeset 81911 8d659ca1ae0e227d8da7e016a1f5b438bc05d3fe
parent 81910 e84fa7cf77ad8c4c8f2c9eeeaa80886b31bc7fb0
child 81912 bcada4117c30569952236a8d2b34652f1a1ea83d
push id3859
push userbmo@edmorley.co.uk
push dateTue, 06 Dec 2011 23:26:00 +0000
treeherdermozilla-inbound@0b76ccd7eff0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs702627
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 702627 - Invalidate plugin rect after requesting Java surface during paint r=blassey
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/base/nsPluginInstanceOwner.h
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -1673,29 +1673,29 @@ void nsPluginInstanceOwner::ScrollPositi
       }
       pluginWidget->EndDrawPlugin();
     }
   }
 #endif
 }
 
 #ifdef MOZ_WIDGET_ANDROID
-void nsPluginInstanceOwner::AddPluginView(const gfxRect& aRect)
+bool nsPluginInstanceOwner::AddPluginView(const gfxRect& aRect)
 {
   AndroidBridge::AutoLocalJNIFrame frame(1);
 
   void* javaSurface = mInstance->GetJavaSurface();
   if (!javaSurface) {
     mInstance->RequestJavaSurface();
-    return;
+    return false;
   }
 
   if (aRect.IsEqualEdges(mLastPluginRect)) {
     // Already added and in position, no work to do
-    return;
+    return true;
   }
 
   JNIEnv* env = GetJNIForThread();
   jclass cls = env->FindClass("org/mozilla/gecko/GeckoAppShell");
   jmethodID method = env->GetStaticMethodID(cls,
                                             "addPluginView",
                                             "(Landroid/view/View;DDDD)V");
 
@@ -1711,16 +1711,18 @@ void nsPluginInstanceOwner::AddPluginVie
     ANPEvent event;
     event.inSize = sizeof(ANPEvent);
     event.eventType = kLifecycle_ANPEventType;
     event.data.lifecycle.action = kOnScreen_ANPLifecycleAction;
     mInstance->HandleEvent(&event, nsnull);
 
     mPluginViewAdded = true;
   }
+
+  return true;
 }
 
 void nsPluginInstanceOwner::RemovePluginView()
 {
   AndroidBridge::AutoLocalJNIFrame frame(1);
 
   if (mInstance && mObjectFrame && mPluginViewAdded) {
     mPluginViewAdded = false;
@@ -2877,17 +2879,23 @@ void nsPluginInstanceOwner::Paint(gfxCon
 {
   if (!mInstance || !mObjectFrame)
     return;
 
   PRInt32 model;
   mInstance->GetDrawingModel(&model);
 
   if (model == kSurface_ANPDrawingModel) {
-    AddPluginView(aFrameRect);
+    if (!AddPluginView(aFrameRect)) {
+      NPRect rect;
+      rect.left = rect.top = 0;
+      rect.right = aFrameRect.width;
+      rect.bottom = aFrameRect.height;
+      InvalidateRect(&rect);
+    }
     return;
   }
 
   if (model != kBitmap_ANPDrawingModel)
     return;
 
 #ifdef ANP_BITMAP_DRAWING_MODEL
   static nsRefPtr<gfxImageSurface> pluginSurface;
--- a/dom/plugins/base/nsPluginInstanceOwner.h
+++ b/dom/plugins/base/nsPluginInstanceOwner.h
@@ -305,17 +305,17 @@ private:
   {
     nsIntSize size;
     return NS_SUCCEEDED(mInstance->GetImageSize(&size)) &&
     size == nsIntSize(mPluginWindow->width, mPluginWindow->height);
   }
   
   void FixUpURLS(const nsString &name, nsAString &value);
 #ifdef ANDROID
-  void AddPluginView(const gfxRect& aRect);
+  bool AddPluginView(const gfxRect& aRect);
   void RemovePluginView();
   bool mPluginViewAdded;
   gfxRect mLastPluginRect;
 #endif 
  
   nsPluginNativeWindow       *mPluginWindow;
   nsRefPtr<nsNPAPIPluginInstance> mInstance;
   nsObjectFrame              *mObjectFrame; // owns nsPluginInstanceOwner