Bug 540843 - Do not cache dom element in nsObjectFrame shm code. r=olli. Maemo only
authorDoug Turner <dougt@dougt.org>
Wed, 20 Jan 2010 14:08:50 -0800
changeset 37357 4539d8e6411ed4a9993e92fb31be2ffea5f1ddfa
parent 37356 76a717c52203af80067a95685da46ebd9d49e8f6
child 37358 2c308fba94ce01e478ae9c4438592faaa372d264
push id11252
push userdougt@mozilla.com
push dateWed, 20 Jan 2010 22:09:00 +0000
treeherdermozilla-central@4539d8e6411e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersolli
bugs540843
milestone1.9.3a1pre
Bug 540843 - Do not cache dom element in nsObjectFrame shm code. r=olli. Maemo only
layout/generic/nsObjectFrame.cpp
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -515,20 +515,16 @@ private:
 #if defined(MOZ_PLATFORM_HILDON) && defined(MOZ_WIDGET_GTK2)
 
   // On hildon, we attempt to use NPImageExpose which allows us faster
   // painting.
 
   // used to keep track of how big our buffer is.
   nsIntSize mPluginSize;
 
-  // the element that was passed into SetAbsoluteScreenPosition().
-  // This will be the element we use to determine which Window we draw into.
-  nsCOMPtr<nsIDOMElement> mBlitParentElement;
-
   // The absolute position on the screen to draw to.
   gfxRect mAbsolutePosition;
 
   // The clip region that we should draw into.
   gfxRect mAbsolutePositionClip;
 
   GC mXlibSurfGC;
   Window mBlitWindow;
@@ -2435,16 +2431,17 @@ nsPluginInstanceOwner::nsPluginInstanceO
 
 #ifdef MOZ_COMPOSITED_PLUGINS
   mLastPoint = nsIntPoint(0,0);
 #endif
 
 #if defined(MOZ_PLATFORM_HILDON) && defined(MOZ_WIDGET_GTK2)
   mPluginSize = nsIntSize(0,0);
   mXlibSurfGC = None;
+  mBlitWindow = nsnull;
   mSharedXImage = nsnull;
   mSharedSegmentInfo.shmaddr = nsnull;
 #endif
 
 #ifdef XP_MACOSX
 #ifndef NP_NO_QUICKDRAW
   mEventModel = NPEventModelCarbon;
 #else
@@ -4950,17 +4947,16 @@ nsPluginInstanceOwner::ReleaseXShm()
     XDestroyImage(mSharedXImage);
     mSharedXImage = nsnull;
   }
 }
 
 PRBool
 nsPluginInstanceOwner::SetupXShm()
 {
-  mBlitWindow = GDK_WINDOW_XWINDOW(GetClosestWindow(mBlitParentElement));
   if (!mBlitWindow)
     return PR_FALSE;
 
   ReleaseXShm();
 
   mXlibSurfGC = XCreateGC(gdk_x11_get_default_xdisplay(),
                           mBlitWindow,
                           0,
@@ -5045,17 +5041,17 @@ nsPluginInstanceOwner::SetupXShm()
 // N900, this approach is considerably faster.
 //
 // Hopefully this API can die off in favor of a more robust plugin API.
 
 void
 nsPluginInstanceOwner::NativeImageDraw(NPRect* invalidRect)
 {
   // if we haven't been positioned yet, ignore
-  if (!mBlitParentElement)
+  if (!mBlitWindow)
     return;
 
   // if the clip rect is zero, we have nothing to do.
   if (NSToIntCeil(mAbsolutePositionClip.Width()) == 0 ||
       NSToIntCeil(mAbsolutePositionClip.Height()) == 0)
     return;
   
   // The flash plugin on Maemo n900 requires the width/height to be
@@ -5763,37 +5759,40 @@ void nsPluginInstanceOwner::FixUpURLS(co
 }
 
 #if defined(MOZ_PLATFORM_HILDON) && defined(MOZ_WIDGET_GTK2)
 nsresult
 nsPluginInstanceOwner::SetAbsoluteScreenPosition(nsIDOMElement* element,
                                                  nsIDOMClientRect* position,
                                                  nsIDOMClientRect* clip)
 {
-  if ((mBlitParentElement && (mBlitParentElement != element)) ||
-      !position || !clip)
+  if (!element || !position || !clip)
     return NS_ERROR_FAILURE;
   
+  if (!mBlitWindow) {
+    mBlitWindow = GDK_WINDOW_XWINDOW(GetClosestWindow(element));
+    if (!mBlitWindow)
+      return NS_ERROR_FAILURE;
+  }
+
   float left, top, width, height;
   position->GetLeft(&left);
   position->GetTop(&top);
   position->GetWidth(&width);
   position->GetHeight(&height);
 
   mAbsolutePosition = gfxRect(left, top, width, height);
   
   clip->GetLeft(&left);
   clip->GetTop(&top);
   clip->GetWidth(&width);
   clip->GetHeight(&height);
 
   mAbsolutePositionClip = gfxRect(left, top, width, height);
 
-  mBlitParentElement = element;
-    
   UpdateVisibility(!(width == 0 && height == 0));
 
   if (!mInstance)
     return NS_OK;
 
   PRBool simpleImageRender = PR_FALSE;
   mInstance->GetValueFromPlugin(NPPVpluginWindowlessLocalBool,
                                 &simpleImageRender);