diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index 8b202438fc8..37876a3e4a3 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -953,6 +953,7 @@ RasterImage::GetImageContainer(LayerManager* aManager, (!mImageContainer->Manager() && (mImageContainer->GetBackendType() == aManager->GetBackendType())))) { *_retval = mImageContainer; + NS_ADDREF(*_retval); return NS_OK; } @@ -978,6 +979,7 @@ RasterImage::GetImageContainer(LayerManager* aManager, mImageContainer->SetCurrentImage(image); *_retval = mImageContainer; + NS_ADDREF(*_retval); return NS_OK; } diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 5e279c767f9..5b60d01b18d 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -219,7 +219,7 @@ protected: * supports being optimized to an ImageLayer (TYPE_RASTER only) returns * an ImageContainer for the image. */ - nsRefPtr CanOptimizeImageLayer(LayerManager* aManager); + already_AddRefed CanOptimizeImageLayer(LayerManager* aManager); /** * The region of visible content in the layer, relative to the @@ -968,7 +968,7 @@ ContainerState::FindOpaqueBackgroundColorFor(PRInt32 aThebesLayerIndex) return NS_RGBA(0,0,0,0); } -nsRefPtr +already_AddRefed ContainerState::ThebesLayerData::CanOptimizeImageLayer(LayerManager* aManager) { if (!mImage || !mImageClip.mRoundedClipRects.IsEmpty()) { diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index fcdb0ad5d33..6f64fbe0256 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1210,19 +1210,13 @@ nsDisplayImage::Paint(nsDisplayListBuilder* aBuilder, : (PRUint32) imgIContainer::FLAG_NONE); } -nsCOMPtr -nsDisplayImage::GetImage() -{ - return mImage; -} - -nsRefPtr +already_AddRefed nsDisplayImage::GetContainer(LayerManager* aManager) { - ImageContainer* container; - nsresult rv = mImage->GetImageContainer(aManager, &container); - NS_ENSURE_SUCCESS(rv, NULL); - return container; + nsRefPtr container; + nsresult rv = mImage->GetImageContainer(aManager, getter_AddRefs(container)); + NS_ENSURE_SUCCESS(rv, nsnull); + return container.forget(); } void diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index caba3ba0501..369468a796a 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -386,13 +386,12 @@ public: } virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx); - nsCOMPtr GetImage(); /** * Returns an ImageContainer for this image if the image type * supports it (TYPE_RASTER only). */ - nsRefPtr GetContainer(LayerManager* aManager); + already_AddRefed GetContainer(LayerManager* aManager); /** * Configure an ImageLayer for this display item.