Merge mozilla-central into mozilla-inbound.
authorMounir Lamouri <mounir.lamouri@gmail.com>
Mon, 27 Jun 2011 14:54:53 +0200
changeset 72390 76cbaa594619a2385af50768042683fa285aaa52
parent 72389 c828b73a419ac447f304317682255307499b3512 (current diff)
parent 72339 7dba94aaa160e8c6dbfff7ed5d603dbc9428172f (diff)
child 72391 58655e365c9135c622e832b8ce5670d7277c1d1f
push id159
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 17:53:11 +0000
treeherdermozilla-beta@8786e3e49240 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone7.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
Merge mozilla-central into mozilla-inbound.
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -83,33 +83,33 @@ nsNPAPIPluginInstance::nsNPAPIPluginInst
     mTransparent(PR_FALSE),
     mCached(PR_FALSE),
     mUsesDOMForCursor(PR_FALSE),
     mInPluginInitCall(PR_FALSE),
     mPlugin(plugin),
     mMIMEType(nsnull),
     mOwner(nsnull),
     mCurrentPluginEvent(nsnull),
-#if defined(MOZ_X11) || defined(XP_WIN) || defined(XP_MACOSX)
+#if defined(MOZ_X11) || defined(XP_WIN)
     mUsePluginLayersPref(PR_TRUE)
 #else
     mUsePluginLayersPref(PR_FALSE)
 #endif
 {
   NS_ASSERTION(mPlugin != NULL, "Plugin is required when creating an instance.");
 
   // Initialize the NPP structure.
 
   mNPP.pdata = NULL;
   mNPP.ndata = this;
 
   nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
   if (prefs) {
     PRBool useLayersPref;
-    nsresult rv = prefs->GetBoolPref("plugins.use_layers", &useLayersPref);
+    nsresult rv = prefs->GetBoolPref("mozilla.plugins.use_layers", &useLayersPref);
     if (NS_SUCCEEDED(rv))
       mUsePluginLayersPref = useLayersPref;
   }
 
   PLUGIN_LOG(PLUGIN_LOG_BASIC, ("nsNPAPIPluginInstance ctor: this=%p\n",this));
 }
 
 nsNPAPIPluginInstance::~nsNPAPIPluginInstance()
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -258,18 +258,18 @@ nsPluginInstanceOwner::UseAsyncRendering
   nsRefPtr<ImageContainer> container = mObjectFrame->GetImageContainer();
 #endif
 
   PRBool useAsyncRendering;
   return (mInstance &&
           NS_SUCCEEDED(mInstance->UseAsyncPainting(&useAsyncRendering)) &&
           useAsyncRendering &&
 #ifdef XP_MACOSX
-          container &&
-          container->GetBackendType() == 
+          mObjectFrame && mObjectFrame->GetImageContainer().get() &&
+          mObjectFrame->GetImageContainer().get()->GetBackendType() == 
                   LayerManager::LAYERS_OPENGL
 #else
           (!mPluginWindow ||
            mPluginWindow->type == NPWindowTypeDrawable)
 #endif
           );
 }
 
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -2331,22 +2331,27 @@ PluginInstanceChild::DoAsyncSetWindow(co
     if (aIsAsync) {
         if (!mCurrentAsyncSetWindowTask) {
             return;
         }
         mCurrentAsyncSetWindowTask = nsnull;
     }
 
     mWindow.window = NULL;
+#ifdef XP_MACOSX
+    if (mWindow.width != aWindow.width || mWindow.height != aWindow.height) 
+        mAccumulatedInvalidRect = nsIntRect(0, 0, aWindow.width, aWindow.height);
+#else
     if (mWindow.width != aWindow.width || mWindow.height != aWindow.height ||
         mWindow.clipRect.top != aWindow.clipRect.top ||
         mWindow.clipRect.left != aWindow.clipRect.left ||
         mWindow.clipRect.bottom != aWindow.clipRect.bottom ||
         mWindow.clipRect.right != aWindow.clipRect.right)
         mAccumulatedInvalidRect = nsIntRect(0, 0, aWindow.width, aWindow.height);
+#endif
 
     mWindow.x = aWindow.x;
     mWindow.y = aWindow.y;
     mWindow.width = aWindow.width;
     mWindow.height = aWindow.height;
     mWindow.clipRect = aWindow.clipRect;
     mWindow.type = aWindow.type;
 
@@ -2686,18 +2691,16 @@ PluginInstanceChild::UpdateWindowAttribu
         needWindowUpdate = true;
     }
 #endif // XP_WIN
 
     if (!needWindowUpdate) {
         return;
     }
 
-#ifndef XP_MACOSX
-    // Adjusting the window isn't needed for OSX
 #ifndef XP_WIN
     // On Windows, we translate the device context, in order for the window
     // origin to be correct.
     mWindow.x = mWindow.y = 0;
 #endif
 
     if (IsVisible()) {
         // The clip rect is relative to drawable top-left.
@@ -2708,17 +2711,16 @@ PluginInstanceChild::UpdateWindowAttribu
         // This also ensures that the unsigned clip rectangle offsets won't be -ve.
         clipRect.SetRect(0, 0, mWindow.width, mWindow.height);
 
         mWindow.clipRect.left = 0;
         mWindow.clipRect.top = 0;
         mWindow.clipRect.right = clipRect.XMost();
         mWindow.clipRect.bottom = clipRect.YMost();
     }
-#endif // XP_MACOSX
 
 #ifdef XP_WIN
     // Windowless plugins on Windows need a WM_WINDOWPOSCHANGED event to update
     // their location... or at least Flash does: Silverlight uses the
     // window.x/y passed to NPP_SetWindow
 
     if (mPluginIface->event) {
         WINDOWPOS winpos = {
@@ -3009,41 +3011,25 @@ PluginInstanceChild::ShowPluginFrame()
     // paint.
     if (!mLayersRendering || mPendingPluginCall) {
         return false;
     }
 
     AutoRestore<bool> pending(mPendingPluginCall);
     mPendingPluginCall = true;
 
-    bool temporarilyMakeVisible = !IsVisible() && !mHasPainted;
-    if (temporarilyMakeVisible && mWindow.width && mWindow.height) {
-        mWindow.clipRect.right = mWindow.width;
-        mWindow.clipRect.bottom = mWindow.height;
-    } else if (!IsVisible()) {
-        // If we're not visible, don't bother painting a <0,0,0,0>
-        // rect.  If we're eventually made visible, the visibility
-        // change will invalidate our window.
-        ClearCurrentSurface();
-        return true;
-    }
-
-    if (!EnsureCurrentBuffer()) {
-        return false;
-    }
-
 #ifdef XP_MACOSX
     // We can't use the thebes code with CoreAnimation so we will
     // take a different code path.
     if (mDrawingModel == NPDrawingModelCoreAnimation ||
         mDrawingModel == NPDrawingModelInvalidatingCoreAnimation ||
         mDrawingModel == NPDrawingModelCoreGraphics) {
 
-        if (!IsVisible()) {
-            return true;
+        if (!EnsureCurrentBuffer()) {
+          return false;
         }
 
         // Clear accRect here to be able to pass
         // test_invalidate_during_plugin_paint  test
         nsIntRect rect = mAccumulatedInvalidRect;
         mAccumulatedInvalidRect.SetEmpty();
 
         // Fix up old invalidations that might have been made when our
@@ -3062,32 +3048,46 @@ PluginInstanceChild::ShowPluginFrame()
 
         mCARenderer.Render(mWindow.width, mWindow.height, nsnull);
 
         NPRect r = { (uint16_t)rect.y, (uint16_t)rect.x,
                      (uint16_t)rect.YMost(), (uint16_t)rect.XMost() };
         SurfaceDescriptor currSurf;
         currSurf = IOSurfaceDescriptor(mCurrentIOSurface->GetIOSurfaceID());
 
-        mHasPainted = true;
-
         // Unused
         SurfaceDescriptor returnSurf;
 
         if (!SendShow(r, currSurf, &returnSurf)) {
             return false;
         }
 
         return true;
     } else {
         NS_ERROR("Unsupported drawing model for async layer rendering");
         return false;
     }
 #endif
 
+    bool temporarilyMakeVisible = !IsVisible() && !mHasPainted;
+    if (temporarilyMakeVisible && mWindow.width && mWindow.height) {
+        mWindow.clipRect.right = mWindow.width;
+        mWindow.clipRect.bottom = mWindow.height;
+    } else if (!IsVisible()) {
+        // If we're not visible, don't bother painting a <0,0,0,0>
+        // rect.  If we're eventually made visible, the visibility
+        // change will invalidate our window.
+        ClearCurrentSurface();
+        return true;
+    }
+
+    if (!EnsureCurrentBuffer()) {
+        return false;
+    }
+
     NS_ASSERTION(mWindow.width == (mWindow.clipRect.right - mWindow.clipRect.left) &&
                  mWindow.height == (mWindow.clipRect.bottom - mWindow.clipRect.top),
                  "Clip rect should be same size as window when using layers");
 
     // Clear accRect here to be able to pass
     // test_invalidate_during_plugin_paint  test
     nsIntRect rect = mAccumulatedInvalidRect;
     mAccumulatedInvalidRect.SetEmpty();
@@ -3561,21 +3561,17 @@ PluginInstanceChild::ClearAllSurfaces()
 #endif
 
 #ifdef XP_MACOSX
     if (mCurrentIOSurface) {
         // Get last surface back, and drop it
         SurfaceDescriptor temp = null_t();
         NPRect r = { 0, 0, 1, 1 };
         SendShow(r, temp, &temp);
-    }
-
-    if (mCGLayer) {
-        mozilla::plugins::PluginUtilsOSX::ReleaseCGLayer(mCGLayer);
-        mCGLayer = nsnull;
+
     }
 
     mCurrentIOSurface = nsnull;
 #endif
 }
 
 bool
 PluginInstanceChild::AnswerNPP_Destroy(NPError* aResult)
--- a/dom/plugins/ipc/PluginInstanceChild.h
+++ b/dom/plugins/ipc/PluginInstanceChild.h
@@ -431,25 +431,20 @@ public:
 
 private:
     const NPCocoaEvent   *mCurrentEvent;
 #endif
 
     bool CanPaintOnBackground();
 
     bool IsVisible() {
-#ifdef XP_MACOSX
-        return mWindow.clipRect.top != mWindow.clipRect.bottom &&
-               mWindow.clipRect.left != mWindow.clipRect.right;
-#else
         return mWindow.clipRect.top != 0 ||
             mWindow.clipRect.left != 0 ||
             mWindow.clipRect.bottom != 0 ||
             mWindow.clipRect.right != 0;
-#endif
     }
 
     // ShowPluginFrame - in general does four things:
     // 1) Create mCurrentSurface optimized for rendering to parent process
     // 2) Updated mCurrentSurface to be a complete copy of mBackSurface
     // 3) Draw the invalidated plugin area into mCurrentSurface
     // 4) Send it to parent process.
     bool ShowPluginFrame(void);
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -521,17 +521,17 @@ PluginInstanceParent::RecvShow(const NPR
     
         nsIOSurface *newIOSurface = nsIOSurface::LookupSurface(iodesc.surfaceId());
 
         if (!newIOSurface) {
             NS_WARNING("Got bad IOSurfaceDescriptor in RecvShow");
             return false;
         }
       
-        mFrontIOSurface = newIOSurface;
+        mIOSurface = newIOSurface;
 
         RecvNPN_InvalidateRect(updatedRect);
 
         *prevSurface = null_t();
 
         PLUGIN_LOG_DEBUG(("   (RecvShow invalidated for surface %p)",
                           mFrontSurface.get()));
 
@@ -611,44 +611,44 @@ PluginInstanceParent::AsyncSetWindow(NPW
 
     return NS_OK;
 }
 
 nsresult
 PluginInstanceParent::GetImage(ImageContainer* aContainer, Image** aImage)
 {
 #ifdef XP_MACOSX
-    if (!mFrontSurface && !mFrontIOSurface)
+    if (!mFrontSurface && !mIOSurface)
 #else
     if (!mFrontSurface)
 #endif
         return NS_ERROR_NOT_AVAILABLE;
 
     Image::Format format = Image::CAIRO_SURFACE;
 #ifdef XP_MACOSX
-    if (mFrontIOSurface) {
+    if (mIOSurface) {
         format = Image::MAC_IO_SURFACE;
         if (!aContainer->Manager()) {
             return NS_ERROR_FAILURE;
         }
     }
 #endif
 
     nsRefPtr<Image> image;
     image = aContainer->CreateImage(&format, 1);
     if (!image) {
         return NS_ERROR_FAILURE;
     }
 
 #ifdef XP_MACOSX
-    if (mFrontIOSurface) {
+    if (mIOSurface) {
         NS_ASSERTION(image->GetFormat() == Image::MAC_IO_SURFACE, "Wrong format?");
         MacIOSurfaceImage* ioImage = static_cast<MacIOSurfaceImage*>(image.get());
         MacIOSurfaceImage::Data ioData;
-        ioData.mIOSurface = mFrontIOSurface;
+        ioData.mIOSurface = mIOSurface;
         ioImage->SetData(ioData);
         *aImage = image.forget().get();
         return NS_OK;
     }
 #endif
 
     NS_ASSERTION(image->GetFormat() == Image::CAIRO_SURFACE, "Wrong format?");
     CairoImage* pluginImage = static_cast<CairoImage*>(image.get());
@@ -666,18 +666,18 @@ PluginInstanceParent::GetImageSize(nsInt
 {
     if (mFrontSurface) {
         gfxIntSize size = mFrontSurface->GetSize();
         *aSize = nsIntSize(size.width, size.height);
         return NS_OK;
     }
 
 #ifdef XP_MACOSX
-    if (mFrontIOSurface) {
-        *aSize = nsIntSize(mFrontIOSurface->GetWidth(), mFrontIOSurface->GetHeight());
+    if (mIOSurface) {
+        *aSize = nsIntSize(mIOSurface->GetWidth(), mIOSurface->GetHeight());
         return NS_OK;
     }
 #endif
 
     return NS_ERROR_NOT_AVAILABLE;
 }
 
 nsresult
@@ -1162,35 +1162,17 @@ PluginInstanceParent::NPP_HandleEvent(vo
             if (cgContext) {
                 nsCARenderer::DrawSurfaceToCGContext(cgContext, mIOSurface, 
                                                      mShColorSpace,
                                                      npevent->data.draw.x,
                                                      npevent->data.draw.y,
                                                      npevent->data.draw.width,
                                                      npevent->data.draw.height);
             }
-            return true;
-        } else if (mFrontIOSurface) {
-            CGContextRef cgContext = npevent->data.draw.context;
-            if (!mShColorSpace) {
-                mShColorSpace = CreateSystemColorSpace();
-            }
-            if (!mShColorSpace) {
-                PLUGIN_LOG_DEBUG(("Could not allocate ColorSpace."));
-                return false;
-            }
-            if (cgContext) {
-                nsCARenderer::DrawSurfaceToCGContext(cgContext, mFrontIOSurface, 
-                                                     mShColorSpace,
-                                                     npevent->data.draw.x,
-                                                     npevent->data.draw.y,
-                                                     npevent->data.draw.width,
-                                                     npevent->data.draw.height);
-            }
-            return true;
+            return false;
         } else {
             if (mShWidth == 0 && mShHeight == 0) {
                 PLUGIN_LOG_DEBUG(("NPCocoaEventDrawRect on window of size 0."));
                 return false;
             }
             if (!mShSurface.IsReadable()) {
                 PLUGIN_LOG_DEBUG(("Shmem is not readable."));
                 return false;
--- a/dom/plugins/ipc/PluginInstanceParent.h
+++ b/dom/plugins/ipc/PluginInstanceParent.h
@@ -350,17 +350,16 @@ private:
 #if defined(MOZ_WIDGET_COCOA)
 private:
     Shmem                  mShSurface; 
     size_t                 mShWidth;
     size_t                 mShHeight;
     CGColorSpaceRef        mShColorSpace;
     int16_t                mDrawingModel;
     nsAutoPtr<nsIOSurface> mIOSurface;
-    nsAutoPtr<nsIOSurface> mFrontIOSurface;
 #endif // definied(MOZ_WIDGET_COCOA)
 
     // ObjectFrame layer wrapper
     nsRefPtr<gfxASurface>    mFrontSurface;
     // For windowless+transparent instances, this surface contains a
     // "pretty recent" copy of the pixels under its <object> frame.
     // On the plugin side, we use this surface to avoid doing alpha
     // recovery when possible.  This surface is created and owned by
--- a/dom/plugins/ipc/PluginUtilsOSX.mm
+++ b/dom/plugins/ipc/PluginUtilsOSX.mm
@@ -92,21 +92,18 @@ void* mozilla::plugins::PluginUtilsOSX::
 
 void mozilla::plugins::PluginUtilsOSX::ReleaseCGLayer(void *cgLayer) {
   CGBridgeLayer *bridgeLayer = (CGBridgeLayer*)cgLayer;
   [bridgeLayer release];
 }
 
 void mozilla::plugins::PluginUtilsOSX::Repaint(void *caLayer, nsIntRect aRect) {
   CGBridgeLayer *bridgeLayer = (CGBridgeLayer*)caLayer;
-  [CATransaction begin];
   [bridgeLayer updateRect:aRect];
   [bridgeLayer setNeedsDisplay];
-  [bridgeLayer displayIfNeeded];
-  [CATransaction commit];
 }
 
 @interface EventProcessor : NSObject {
   RemoteProcessEvents   aRemoteEvents;
   void                 *aPluginModule;
 }
 - (void)setRemoteEvents:(RemoteProcessEvents) remoteEvents pluginModule:(void*) pluginModule;
 - (void)onTick;
--- a/dom/plugins/test/mochitest/utils.js
+++ b/dom/plugins/test/mochitest/utils.js
@@ -1,12 +1,13 @@
 function paintCountIs(plugin, expected, msg) {
   var count = plugin.getPaintCount();
   var realExpected = expected;
-  var isAsync = SimpleTest.testPluginIsOOP();
+  var isAsync = SimpleTest.testPluginIsOOP() &&
+    navigator.platform.indexOf("Mac") < 0;
   if (isAsync) {
     ++realExpected; // extra paint at startup for all async-rendering plugins
   } else {
     netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
     try {
       if (Components.classes["@mozilla.org/gfx/info;1"].getService(Components.interfaces.nsIGfxInfo).D2DEnabled) {
         realExpected *= 2;
       }
--- a/dom/plugins/test/reftest/plugin-background.css
+++ b/dom/plugins/test/reftest/plugin-background.css
@@ -3,19 +3,17 @@ div {
 }
 #bad {
   left:220px; top:0px;
   z-index: 0;
 }
 #good {
   left:0px; top:0px;
   width:220px; height:220px;
-  /* Core Animation alpha blending rounding differs
-     from the Core Graphics blending, adjust with care */
-  background-color: rgba(0,255,0, 0.51);
+  background-color: rgba(0,255,0, 0.6);
   z-index: 0;
 }
 
 #topbar {
   left:0px; top:0px;
   width:220px; height:20px;
   background-color: rgb(0,0,0);
   z-index: 2;
@@ -52,10 +50,9 @@ div#plugin {
   background-color: rgba(0,0,255, 0.2);
   z-index: 1;
 }
 
 embed#plugin {
   position: absolute;
   left:1px; top:1px;
   z-index: 1;
-}
-
+}
\ No newline at end of file
--- a/dom/plugins/test/reftest/reftest.list
+++ b/dom/plugins/test/reftest/reftest.list
@@ -3,17 +3,17 @@ random-if(!haveTestPlugin) != plugin-san
 fails-if(!haveTestPlugin) == plugin-sanity.html div-sanity.html
 fails-if(!haveTestPlugin) == plugin-alpha-zindex.html div-alpha-zindex.html
 fails-if(!haveTestPlugin) == plugin-alpha-opacity.html div-alpha-opacity.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == windowless-clipping-1.html windowless-clipping-1-ref.html # bug 631832
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == border-padding-1.html border-padding-1-ref.html # bug 629430
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == border-padding-2.html border-padding-2-ref.html # bug 629430
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) skip-if(Android) == border-padding-3.html border-padding-3-ref.html # bug 629430
 random-if(cocoaWidget||d2d) fails-if(!haveTestPlugin&&!Android) skip-if(!testPluginIsOOP()) == pluginproblemui-direction-1.html pluginproblemui-direction-1-ref.html
-random-if(cocoaWidget) fails-if(!haveTestPlugin&&!Android) skip-if(!testPluginIsOOP()) == pluginproblemui-direction-2.html pluginproblemui-direction-2-ref.html
+fails-if(!haveTestPlugin&&!Android) skip-if(!testPluginIsOOP()) == pluginproblemui-direction-2.html pluginproblemui-direction-2-ref.html
 fails-if(!haveTestPlugin) == plugin-canvas-alpha-zindex.html div-alpha-zindex.html
 fails-if(!haveTestPlugin) == plugin-transform-alpha-zindex.html div-alpha-zindex.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-busy-alpha-zindex.html div-alpha-zindex.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-background.html plugin-background-ref.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-background-1-step.html plugin-background-ref.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-background-2-step.html plugin-background-ref.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-background-5-step.html plugin-background-ref.html
 random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-background-10-step.html plugin-background-ref.html
--- a/gfx/thebes/nsCoreAnimationSupport.h
+++ b/gfx/thebes/nsCoreAnimationSupport.h
@@ -70,20 +70,16 @@ public:
    * used.
    */ 
   void AttachIOSurface(nsIOSurface *aSurface);
   static nsresult DrawSurfaceToCGContext(CGContextRef aContext, 
                                          nsIOSurface *surf, 
                                          CGColorSpaceRef aColorSpace, 
                                          int aX, int aY,
                                          size_t aWidth, size_t aHeight);
-
-#ifdef DEBUG
-  static void SaveToDisk(nsIOSurface *surf);
-#endif
 private:
   void Destroy();
 
   void *mCARenderer;
   _CGLPBufferObject *mPixelBuffer;
   _CGLContextObject *mOpenGLContext;
   CGImageRef         mCGImage;
   void              *mCGData;
--- a/gfx/thebes/nsCoreAnimationSupport.mm
+++ b/gfx/thebes/nsCoreAnimationSupport.mm
@@ -311,16 +311,20 @@ nsIOSurface* nsIOSurface::CreateIOSurfac
 
 nsIOSurface* nsIOSurface::LookupSurface(IOSurfaceID aIOSurfaceID) { 
   if (!nsIOSurfaceLib::isInit())
     return nsnull;
 
   IOSurfacePtr surfaceRef = nsIOSurfaceLib::IOSurfaceLookup(aIOSurfaceID);
   if (!surfaceRef)
     return nsnull;
+  // IOSurfaceLookup does not retain the object for us,
+  // we want IOSurfacePtr to remain for the lifetime of
+  // nsIOSurface.
+  CFRetain(surfaceRef);
 
   nsIOSurface* ioSurface = new nsIOSurface(surfaceRef);
   if (!ioSurface) {
     ::CFRelease(surfaceRef);
     return nsnull;
   }
   return ioSurface;
 }
@@ -493,37 +497,20 @@ nsresult nsCARenderer::SetupRenderer(voi
                             options:nil] retain];
   mCARenderer = caRenderer;
   if (caRenderer == nil) {
     mUnsupportedWidth = aWidth;
     mUnsupportedHeight = aHeight;
     Destroy();
     return NS_ERROR_FAILURE;
   }
-
-  // Create a transaction and disable animations
-  // to make the position update instant.
-  [CATransaction begin];
-  NSMutableDictionary *newActions = [[NSMutableDictionary alloc] initWithObjectsAndKeys:[NSNull null], @"onOrderIn",
-                                   [NSNull null], @"onOrderOut",
-                                   [NSNull null], @"sublayers",
-                                   [NSNull null], @"contents",
-                                   [NSNull null], @"position",
-                                   [NSNull null], @"bounds",
-                                   nil];
-  layer.actions = newActions;
-  [newActions release];
-
-  [CATransaction setValue: [NSNumber numberWithFloat:0.0f] forKey: kCATransactionAnimationDuration];
-  [CATransaction setValue: (id) kCFBooleanTrue forKey: kCATransactionDisableActions];
   [layer setBounds:CGRectMake(0, 0, aWidth, aHeight)];
   [layer setPosition:CGPointMake(aWidth/2.0, aHeight/2.0)];
   caRenderer.layer = layer;
   caRenderer.bounds = CGRectMake(0, 0, aWidth, aHeight);
-  [CATransaction commit];
 
   // We either target rendering to a CGImage or IOSurface.
   if (!mIOSurface) {
     mCGData = malloc(aWidth*aHeight*4);
     if (!mCGData) {
       mUnsupportedWidth = aWidth;
       mUnsupportedHeight = aHeight;
       Destroy();
@@ -688,17 +675,16 @@ nsresult nsCARenderer::Render(int aWidth
     if (oldContext)
       ::CGLSetCurrentContext(oldContext);
     return NS_ERROR_FAILURE;
   }
 
   ::glClearColor(0.0, 0.0, 0.0, 0.0);
   ::glClear(GL_COLOR_BUFFER_BIT);
 
-  [CATransaction commit];
   double caTime = ::CACurrentMediaTime();
   [caRenderer beginFrameAtTime:caTime timeStamp:NULL];
   [caRenderer addUpdateRect:CGRectMake(0,0, aWidth, aHeight)];
   [caRenderer render];
   [caRenderer endFrame];
 
   // Read the data back either to the IOSurface or mCGImage.
   if (mIOSurface) {
@@ -776,60 +762,8 @@ nsresult nsCARenderer::DrawSurfaceToCGCo
                        subImage);
 
   ::CGImageRelease(subImage);
   ::CGImageRelease(cgImage);
   surf->Unlock();
   return NS_OK;
 }
 
-#ifdef DEBUG
-
-int sSaveToDiskSequence = 0;
-void nsCARenderer::SaveToDisk(nsIOSurface *surf) {
-  surf->Lock();
-  size_t bytesPerRow = surf->GetBytesPerRow();
-  size_t ioWidth = surf->GetWidth();
-  size_t ioHeight = surf->GetHeight();
-  void* ioData = surf->GetBaseAddress();
-  CGDataProviderRef dataProvider = ::CGDataProviderCreateWithData(ioData,
-                                      ioData, ioHeight*(bytesPerRow)*4, 
-                                      NULL); //No release callback 
-  if (!dataProvider) {
-    surf->Unlock();
-    return;
-  }
-
-  CGImageRef cgImage = ::CGImageCreate(ioWidth, ioHeight, 8, 32, bytesPerRow,
-              CreateSystemColorSpace(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host,
-              dataProvider, NULL, true, kCGRenderingIntentDefault);
-  ::CGDataProviderRelease(dataProvider);
-  if (!cgImage) {
-    surf->Unlock();
-    return;
-  }
-
-  char cstr[1000];
-
-  sprintf(cstr, "file:///Users/benoitgirard/debug/iosurface_%i.png", ++sSaveToDiskSequence);
-
-  CFStringRef cfStr = ::CFStringCreateWithCString(kCFAllocatorDefault, cstr, kCFStringEncodingMacRoman);
-
-  printf("Exporting: %s\n", cstr);
-  CFURLRef url = ::CFURLCreateWithString( NULL, cfStr, NULL);
-
-  CFStringRef type = kUTTypePNG;
-  size_t count = 1; 
-  CFDictionaryRef options = NULL;
-  CGImageDestinationRef dest = ::CGImageDestinationCreateWithURL(url, type, count, options);
-
-  ::CGImageDestinationAddImage(dest, cgImage, NULL);
-
-  ::CGImageDestinationFinalize(dest);
-  ::CFRelease(dest);
-
-  surf->Unlock();
-
-  return;
-
-}
-
-#endif
--- a/js/jsd/jsd_xpc.cpp
+++ b/js/jsd/jsd_xpc.cpp
@@ -2668,18 +2668,20 @@ jsdService::ActivateDebugger (JSRuntime 
     else
         JSD_ClearFunctionHook (mCx);
     mOn = PR_TRUE;
 
 #ifdef DEBUG
     printf ("+++ JavaScript debugging hooks installed.\n");
 #endif
 
-    if (mActivationCallback)
-        return mActivationCallback->OnDebuggerActivated();
+    nsCOMPtr<jsdIActivationCallback> activationCallback;
+    mActivationCallback.swap(activationCallback);
+    if (activationCallback)
+        return activationCallback->OnDebuggerActivated();
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
 jsdService::Off (void)
 {
     if (!mOn)
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -1554,19 +1554,23 @@ nsObjectFrame::UpdateImageLayer(ImageCon
 LayerState
 nsObjectFrame::GetLayerState(nsDisplayListBuilder* aBuilder,
                              LayerManager* aManager)
 {
   if (!mInstanceOwner)
     return LAYER_NONE;
 
 #ifdef XP_MACOSX
-  if (aManager && aManager->GetBackendType() !=
-      LayerManager::LAYERS_OPENGL) {
-    return LAYER_NONE;
+  if (aManager &&
+      aManager->GetBackendType() == LayerManager::LAYERS_OPENGL &&
+      mInstanceOwner->UseAsyncRendering() &&
+      mInstanceOwner->GetEventModel() == NPEventModelCocoa &&
+      mInstanceOwner->GetDrawingModel() == NPDrawingModelCoreGraphics)
+  {
+    return LAYER_ACTIVE;
   }
 #endif
 
   if (!mInstanceOwner->UseAsyncRendering())
     return LAYER_NONE;
 
   return LAYER_ACTIVE;
 }
--- a/xpcom/glue/nsCycleCollectionParticipant.h
+++ b/xpcom/glue/nsCycleCollectionParticipant.h
@@ -410,17 +410,17 @@ public:
     }
 
 #define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_MEMBER(_field,              \
                                                           _element_class)      \
     NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY(tmp->_field, _element_class,    \
                                                #_field)
 
 #define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS                       \
-    TraverseScriptObjects(tmp, cb);
+    TraverseScriptObjects(p, cb);
 
 #define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END                                  \
     return NS_OK;                                                              \
   }
 
 ///////////////////////////////////////////////////////////////////////////////
 // Helpers for implementing nsScriptObjectTracer::Trace
 ///////////////////////////////////////////////////////////////////////////////