From 6c8fbf340c9d156cc540bcf156ae999575dd17d3 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Fri, 13 Dec 2013 08:34:24 +0000 Subject: [PATCH] Bug 944442 - DeCOMify imgIContainer::GetFrame. r=seth --HG-- extra : rebase_source : 612c1923f3ed8a01fc30f2d306b4682e585e53fe --- .../shell/src/nsWindowsShellService.cpp | 7 ++-- content/svg/content/src/SVGFEImageElement.cpp | 6 +-- image/public/imgIContainer.idl | 6 ++- image/src/ClippedImage.cpp | 22 ++++------ image/src/ClippedImage.h | 14 +++---- image/src/FrozenImage.cpp | 7 ++-- image/src/FrozenImage.h | 5 +-- image/src/ImageWrapper.cpp | 7 ++-- image/src/OrientedImage.cpp | 18 ++++---- image/src/OrientedImage.h | 5 +-- image/src/RasterImage.cpp | 41 ++++++++----------- image/src/VectorImage.cpp | 18 ++++---- image/src/imgTools.cpp | 7 ++-- layout/base/nsLayoutUtils.cpp | 8 ++-- widget/cocoa/nsClipboard.mm | 7 ++-- widget/cocoa/nsCocoaUtils.mm | 6 +-- widget/cocoa/nsMenuItemIconX.mm | 7 ++-- widget/gtk/nsImageToPixbuf.cpp | 12 +++--- widget/os2/nsWindow.cpp | 7 ++-- widget/qt/nsClipboard.cpp | 7 ++-- widget/windows/WinUtils.cpp | 4 +- widget/windows/nsImageClipboard.cpp | 7 ++-- widget/windows/nsWindowGfx.cpp | 7 ++-- 23 files changed, 100 insertions(+), 135 deletions(-) diff --git a/browser/components/shell/src/nsWindowsShellService.cpp b/browser/components/shell/src/nsWindowsShellService.cpp index 35b9bcfc46f..908508639a9 100644 --- a/browser/components/shell/src/nsWindowsShellService.cpp +++ b/browser/components/shell/src/nsWindowsShellService.cpp @@ -752,10 +752,9 @@ WriteBitmap(nsIFile* aFile, imgIContainer* aImage) { nsresult rv; - nsRefPtr surface; - aImage->GetFrame(imgIContainer::FRAME_FIRST, - imgIContainer::FLAG_SYNC_DECODE, - getter_AddRefs(surface)); + nsRefPtr surface = + aImage->GetFrame(imgIContainer::FRAME_FIRST, + imgIContainer::FLAG_SYNC_DECODE); NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE); nsRefPtr image(surface->GetAsReadableARGB32ImageSurface()); diff --git a/content/svg/content/src/SVGFEImageElement.cpp b/content/svg/content/src/SVGFEImageElement.cpp index 5ebf78c9d0f..c91795c3044 100644 --- a/content/svg/content/src/SVGFEImageElement.cpp +++ b/content/svg/content/src/SVGFEImageElement.cpp @@ -211,9 +211,9 @@ SVGFEImageElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstance, nsRefPtr currentFrame; if (imageContainer) { - imageContainer->GetFrame(imgIContainer::FRAME_CURRENT, - imgIContainer::FLAG_SYNC_DECODE, - getter_AddRefs(currentFrame)); + currentFrame = + imageContainer->GetFrame(imgIContainer::FRAME_CURRENT, + imgIContainer::FLAG_SYNC_DECODE); } if (!currentFrame) { diff --git a/image/public/imgIContainer.idl b/image/public/imgIContainer.idl index 3bcfc05689f..884f27e3083 100644 --- a/image/public/imgIContainer.idl +++ b/image/public/imgIContainer.idl @@ -55,6 +55,7 @@ native nsSize(nsSize); native Orientation(mozilla::image::Orientation); [ref] native TimeStamp(mozilla::TimeStamp); [ptr] native SVGImageContext(mozilla::SVGImageContext); +native already_AddRefed_gfxASurface(already_AddRefed); /** @@ -64,7 +65,7 @@ native Orientation(mozilla::image::Orientation); * * Internally, imgIContainer also manages animation of images. */ -[scriptable, builtinclass, uuid(73340b79-e3ae-4f02-97d0-822db78017e5)] +[scriptable, builtinclass, uuid(8b7db7dd-bfe9-40d3-9114-3a79c0658afd)] interface imgIContainer : nsISupports { /** @@ -172,7 +173,8 @@ interface imgIContainer : nsISupports * @param aWhichFrame Frame specifier of the FRAME_* variety. * @param aFlags Flags of the FLAG_* variety */ - [noscript] gfxASurface getFrame(in uint32_t aWhichFrame, + [noscript, notxpcom] already_AddRefed_gfxASurface + getFrame(in uint32_t aWhichFrame, in uint32_t aFlags); /** diff --git a/image/src/ClippedImage.cpp b/image/src/ClippedImage.cpp index d5cf33ca157..c09e8d2aa4c 100644 --- a/image/src/ClippedImage.cpp +++ b/image/src/ClippedImage.cpp @@ -209,23 +209,21 @@ ClippedImage::GetIntrinsicRatio(nsSize* aRatio) return NS_OK; } -NS_IMETHODIMP +NS_IMETHODIMP_(already_AddRefed) ClippedImage::GetFrame(uint32_t aWhichFrame, - uint32_t aFlags, - gfxASurface** _retval) + uint32_t aFlags) { - return GetFrameInternal(mClip.Size(), nullptr, aWhichFrame, aFlags, _retval); + return GetFrameInternal(mClip.Size(), nullptr, aWhichFrame, aFlags); } -nsresult +already_AddRefed ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize, const SVGImageContext* aSVGContext, uint32_t aWhichFrame, - uint32_t aFlags, - gfxASurface** _retval) + uint32_t aFlags) { if (!ShouldClip()) { - return InnerImage()->GetFrame(aWhichFrame, aFlags, _retval); + return InnerImage()->GetFrame(aWhichFrame, aFlags); } float frameToDraw = InnerImage()->GetFrameIndex(aWhichFrame); @@ -273,9 +271,7 @@ ClippedImage::GetFrameInternal(const nsIntSize& aViewportSize, } MOZ_ASSERT(mCachedSurface, "Should have a cached surface now"); - nsRefPtr surf = mCachedSurface->Surface(); - surf.forget(_retval); - return NS_OK; + return mCachedSurface->Surface(); } NS_IMETHODIMP @@ -335,8 +331,8 @@ ClippedImage::Draw(gfxContext* aContext, if (MustCreateSurface(aContext, aUserSpaceToImageSpace, sourceRect, aSubimage, aFlags)) { // Create a temporary surface containing a single tile of this image. // GetFrame will call DrawSingleTile internally. - nsRefPtr surface; - GetFrameInternal(aViewportSize, aSVGContext, aWhichFrame, aFlags, getter_AddRefs(surface)); + nsRefPtr surface = + GetFrameInternal(aViewportSize, aSVGContext, aWhichFrame, aFlags); NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE); // Create a drawable from that surface. diff --git a/image/src/ClippedImage.h b/image/src/ClippedImage.h index 51bffa5f580..69c609fdece 100644 --- a/image/src/ClippedImage.h +++ b/image/src/ClippedImage.h @@ -35,9 +35,8 @@ public: NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE; NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE; NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE; - NS_IMETHOD GetFrame(uint32_t aWhichFrame, - uint32_t aFlags, - gfxASurface** _retval) MOZ_OVERRIDE; + NS_IMETHOD_(already_AddRefed) GetFrame(uint32_t aWhichFrame, + uint32_t aFlags) MOZ_OVERRIDE; NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager, mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE; NS_IMETHOD Draw(gfxContext* aContext, @@ -56,11 +55,10 @@ protected: ClippedImage(Image* aImage, nsIntRect aClip); private: - nsresult GetFrameInternal(const nsIntSize& aViewportSize, - const SVGImageContext* aSVGContext, - uint32_t aWhichFrame, - uint32_t aFlags, - gfxASurface** _retval); + already_AddRefed GetFrameInternal(const nsIntSize& aViewportSize, + const SVGImageContext* aSVGContext, + uint32_t aWhichFrame, + uint32_t aFlags); bool ShouldClip(); bool MustCreateSurface(gfxContext* aContext, const gfxMatrix& aTransform, diff --git a/image/src/FrozenImage.cpp b/image/src/FrozenImage.cpp index a308fbc914b..2b260795344 100644 --- a/image/src/FrozenImage.cpp +++ b/image/src/FrozenImage.cpp @@ -40,12 +40,11 @@ FrozenImage::GetAnimated(bool* aAnimated) return rv; } -NS_IMETHODIMP +NS_IMETHODIMP_(already_AddRefed) FrozenImage::GetFrame(uint32_t aWhichFrame, - uint32_t aFlags, - gfxASurface** _retval) + uint32_t aFlags) { - return InnerImage()->GetFrame(FRAME_FIRST, aFlags, _retval); + return InnerImage()->GetFrame(FRAME_FIRST, aFlags); } NS_IMETHODIMP_(bool) diff --git a/image/src/FrozenImage.h b/image/src/FrozenImage.h index 3cb1e8e33ae..947dc322a55 100644 --- a/image/src/FrozenImage.h +++ b/image/src/FrozenImage.h @@ -34,9 +34,8 @@ public: virtual void DecrementAnimationConsumers() MOZ_OVERRIDE; NS_IMETHOD GetAnimated(bool* aAnimated) MOZ_OVERRIDE; - NS_IMETHOD GetFrame(uint32_t aWhichFrame, - uint32_t aFlags, - gfxASurface** _retval) MOZ_OVERRIDE; + NS_IMETHOD_(already_AddRefed) GetFrame(uint32_t aWhichFrame, + uint32_t aFlags) MOZ_OVERRIDE; NS_IMETHOD_(bool) FrameIsOpaque(uint32_t aWhichFrame) MOZ_OVERRIDE; NS_IMETHOD GetImageContainer(layers::LayerManager* aManager, layers::ImageContainer** _retval) MOZ_OVERRIDE; diff --git a/image/src/ImageWrapper.cpp b/image/src/ImageWrapper.cpp index 6e2c9adddf6..aaba02f77c9 100644 --- a/image/src/ImageWrapper.cpp +++ b/image/src/ImageWrapper.cpp @@ -196,12 +196,11 @@ ImageWrapper::GetAnimated(bool* aAnimated) return mInnerImage->GetAnimated(aAnimated); } -NS_IMETHODIMP +NS_IMETHODIMP_(already_AddRefed) ImageWrapper::GetFrame(uint32_t aWhichFrame, - uint32_t aFlags, - gfxASurface** _retval) + uint32_t aFlags) { - return mInnerImage->GetFrame(aWhichFrame, aFlags, _retval); + return mInnerImage->GetFrame(aWhichFrame, aFlags); } NS_IMETHODIMP_(bool) diff --git a/image/src/OrientedImage.cpp b/image/src/OrientedImage.cpp index fb3ae9c5295..24d4e3b7941 100644 --- a/image/src/OrientedImage.cpp +++ b/image/src/OrientedImage.cpp @@ -75,15 +75,14 @@ OrientedImage::GetIntrinsicRatio(nsSize* aRatio) return rv; } -NS_IMETHODIMP +NS_IMETHODIMP_(already_AddRefed) OrientedImage::GetFrame(uint32_t aWhichFrame, - uint32_t aFlags, - gfxASurface** _retval) + uint32_t aFlags) { nsresult rv; if (mOrientation.IsIdentity()) { - return InnerImage()->GetFrame(aWhichFrame, aFlags, _retval); + return InnerImage()->GetFrame(aWhichFrame, aFlags); } // Get the underlying dimensions. @@ -95,7 +94,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame, rv = InnerImage()->GetWidth(&width); rv = NS_FAILED(rv) ? rv : InnerImage()->GetHeight(&height); } - NS_ENSURE_SUCCESS(rv, rv); + NS_ENSURE_SUCCESS(rv, nullptr); // Determine an appropriate format for the surface. gfx::SurfaceFormat surfaceFormat; @@ -116,9 +115,9 @@ OrientedImage::GetFrame(uint32_t aWhichFrame, GetThebesSurfaceForDrawTarget(target); // Create our drawable. - nsRefPtr innerSurface; - rv = InnerImage()->GetFrame(aWhichFrame, aFlags, getter_AddRefs(innerSurface)); - NS_ENSURE_SUCCESS(rv, rv); + nsRefPtr innerSurface = + InnerImage()->GetFrame(aWhichFrame, aFlags); + NS_ENSURE_TRUE(innerSurface, nullptr); nsRefPtr drawable = new gfxSurfaceDrawable(innerSurface, gfxIntSize(width, height)); @@ -129,8 +128,7 @@ OrientedImage::GetFrame(uint32_t aWhichFrame, imageRect, imageRect, imageRect, imageRect, imageFormat, GraphicsFilter::FILTER_FAST); - surface.forget(_retval); - return NS_OK; + return surface.forget(); } NS_IMETHODIMP diff --git a/image/src/OrientedImage.h b/image/src/OrientedImage.h index 6f4c209efdf..1c1886bd655 100644 --- a/image/src/OrientedImage.h +++ b/image/src/OrientedImage.h @@ -32,9 +32,8 @@ public: NS_IMETHOD GetHeight(int32_t* aHeight) MOZ_OVERRIDE; NS_IMETHOD GetIntrinsicSize(nsSize* aSize) MOZ_OVERRIDE; NS_IMETHOD GetIntrinsicRatio(nsSize* aRatio) MOZ_OVERRIDE; - NS_IMETHOD GetFrame(uint32_t aWhichFrame, - uint32_t aFlags, - gfxASurface** _retval) MOZ_OVERRIDE; + NS_IMETHOD_(already_AddRefed) GetFrame(uint32_t aWhichFrame, + uint32_t aFlags) MOZ_OVERRIDE; NS_IMETHOD GetImageContainer(mozilla::layers::LayerManager* aManager, mozilla::layers::ImageContainer** _retval) MOZ_OVERRIDE; NS_IMETHOD Draw(gfxContext* aContext, diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index 39a8d2b0a3c..f224c362a90 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -879,30 +879,29 @@ RasterImage::CopyFrame(uint32_t aWhichFrame, //****************************************************************************** /* [noscript] gfxASurface getFrame(in uint32_t aWhichFrame, * in uint32_t aFlags); */ -NS_IMETHODIMP +NS_IMETHODIMP_(already_AddRefed) RasterImage::GetFrame(uint32_t aWhichFrame, - uint32_t aFlags, - gfxASurface **_retval) + uint32_t aFlags) { + MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE); + if (aWhichFrame > FRAME_MAX_VALUE) - return NS_ERROR_INVALID_ARG; + return nullptr; if (mError) - return NS_ERROR_FAILURE; + return nullptr; // Disallowed in the API if (mInDecoder && (aFlags & imgIContainer::FLAG_SYNC_DECODE)) - return NS_ERROR_FAILURE; - - nsresult rv = NS_OK; + return nullptr; if (!ApplyDecodeFlags(aFlags)) - return NS_ERROR_NOT_AVAILABLE; + return nullptr; // If the caller requested a synchronous decode, do it if (aFlags & FLAG_SYNC_DECODE) { - rv = SyncDecode(); - CONTAINER_ENSURE_SUCCESS(rv); + nsresult rv = SyncDecode(); + CONTAINER_ENSURE_TRUE(NS_SUCCEEDED(rv), nullptr); } // Get the frame. If it's not there, it's probably the caller's fault for @@ -912,8 +911,7 @@ RasterImage::GetFrame(uint32_t aWhichFrame, 0 : GetCurrentImgFrameIndex(); imgFrame *frame = GetDrawableImgFrame(frameIndex); if (!frame) { - *_retval = nullptr; - return NS_ERROR_FAILURE; + return nullptr; } nsRefPtr framesurf; @@ -924,19 +922,17 @@ RasterImage::GetFrame(uint32_t aWhichFrame, if (framerect.x == 0 && framerect.y == 0 && framerect.width == mSize.width && framerect.height == mSize.height) - rv = frame->GetSurface(getter_AddRefs(framesurf)); + frame->GetSurface(getter_AddRefs(framesurf)); // The image doesn't have a surface because it's been optimized away. Create // one. if (!framesurf) { nsRefPtr imgsurf; - rv = CopyFrame(aWhichFrame, aFlags, getter_AddRefs(imgsurf)); + CopyFrame(aWhichFrame, aFlags, getter_AddRefs(imgsurf)); framesurf = imgsurf; } - *_retval = framesurf.forget().get(); - - return rv; + return framesurf.forget(); } already_AddRefed @@ -949,13 +945,8 @@ RasterImage::GetCurrentImage() return nullptr; } - nsRefPtr imageSurface; - nsresult rv = GetFrame(FRAME_CURRENT, FLAG_NONE, getter_AddRefs(imageSurface)); - NS_ENSURE_SUCCESS(rv, nullptr); - - if (!imageSurface) { - return nullptr; - } + nsRefPtr imageSurface = GetFrame(FRAME_CURRENT, FLAG_NONE); + NS_ENSURE_TRUE(imageSurface, nullptr); if (!mImageContainer) { mImageContainer = LayerManager::CreateImageContainer(); diff --git a/image/src/VectorImage.cpp b/image/src/VectorImage.cpp index e99c7a1f4fc..aaadb9cc9b1 100644 --- a/image/src/VectorImage.cpp +++ b/image/src/VectorImage.cpp @@ -647,18 +647,17 @@ VectorImage::FrameIsOpaque(uint32_t aWhichFrame) //****************************************************************************** /* [noscript] gfxASurface getFrame(in uint32_t aWhichFrame, * in uint32_t aFlags; */ -NS_IMETHODIMP +NS_IMETHODIMP_(already_AddRefed) VectorImage::GetFrame(uint32_t aWhichFrame, - uint32_t aFlags, - gfxASurface** _retval) + uint32_t aFlags) { - NS_ENSURE_ARG_POINTER(_retval); + MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE); if (aWhichFrame > FRAME_MAX_VALUE) - return NS_ERROR_INVALID_ARG; + return nullptr; if (mError) - return NS_ERROR_FAILURE; + return nullptr; // Look up height & width // ---------------------- @@ -668,7 +667,7 @@ VectorImage::GetFrame(uint32_t aWhichFrame, !mSVGDocumentWrapper->GetWidthOrHeight(SVGDocumentWrapper::eHeight, imageIntSize.height)) { // We'll get here if our SVG doc has a percent-valued width or height. - return NS_ERROR_FAILURE; + return nullptr; } // Create a surface that we'll ultimately return @@ -689,9 +688,8 @@ VectorImage::GetFrame(uint32_t aWhichFrame, nsIntRect(nsIntPoint(0,0), imageIntSize), imageIntSize, nullptr, aWhichFrame, aFlags); - NS_ENSURE_SUCCESS(rv, rv); - *_retval = surface.forget().get(); - return rv; + NS_ENSURE_SUCCESS(rv, nullptr); + return surface.forget(); } //****************************************************************************** diff --git a/image/src/imgTools.cpp b/image/src/imgTools.cpp index 0dd5640ed8e..30a6b5c59ea 100644 --- a/image/src/imgTools.cpp +++ b/image/src/imgTools.cpp @@ -276,10 +276,9 @@ NS_IMETHODIMP imgTools::EncodeImageData(gfxImageSurface *aSurface, NS_IMETHODIMP imgTools::GetFirstImageFrame(imgIContainer *aContainer, gfxImageSurface **aSurface) { - nsRefPtr surface; - aContainer->GetFrame(imgIContainer::FRAME_FIRST, - imgIContainer::FLAG_SYNC_DECODE, - getter_AddRefs(surface)); + nsRefPtr surface = + aContainer->GetFrame(imgIContainer::FRAME_FIRST, + imgIContainer::FLAG_SYNC_DECODE); NS_ENSURE_TRUE(surface, NS_ERROR_NOT_AVAILABLE); nsRefPtr frame(surface->CopyToARGB32ImageSurface()); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index aef7bb43b61..898e2f75df3 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4816,11 +4816,9 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement, frameFlags |= imgIContainer::FLAG_DECODE_NO_COLORSPACE_CONVERSION; if (aSurfaceFlags & SFE_NO_PREMULTIPLY_ALPHA) frameFlags |= imgIContainer::FLAG_DECODE_NO_PREMULTIPLY_ALPHA; - nsRefPtr framesurf; - rv = imgContainer->GetFrame(whichFrame, - frameFlags, - getter_AddRefs(framesurf)); - if (NS_FAILED(rv)) + nsRefPtr framesurf = + imgContainer->GetFrame(whichFrame, frameFlags); + if (!framesurf) return result; int32_t imgWidth, imgHeight; diff --git a/widget/cocoa/nsClipboard.mm b/widget/cocoa/nsClipboard.mm index 6e8973dcd05..33f430424e4 100644 --- a/widget/cocoa/nsClipboard.mm +++ b/widget/cocoa/nsClipboard.mm @@ -431,10 +431,9 @@ nsClipboard::PasteboardDictFromTransferable(nsITransferable* aTransferable) continue; } - nsRefPtr surface; - image->GetFrame(imgIContainer::FRAME_CURRENT, - imgIContainer::FLAG_SYNC_DECODE, - getter_AddRefs(surface)); + nsRefPtr surface = + image->GetFrame(imgIContainer::FRAME_CURRENT, + imgIContainer::FLAG_SYNC_DECODE); if (!surface) { continue; } diff --git a/widget/cocoa/nsCocoaUtils.mm b/widget/cocoa/nsCocoaUtils.mm index daa877d430a..def55acb5f1 100644 --- a/widget/cocoa/nsCocoaUtils.mm +++ b/widget/cocoa/nsCocoaUtils.mm @@ -372,10 +372,8 @@ nsresult nsCocoaUtils::CreateNSImageFromImageContainer(imgIContainer *aImage, ui } else { - nsRefPtr surface; - aImage->GetFrame(aWhichFrame, - imgIContainer::FLAG_SYNC_DECODE, - getter_AddRefs(surface)); + nsRefPtr surface = + aImage->GetFrame(aWhichFrame, imgIContainer::FLAG_SYNC_DECODE); NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE); frame = surface->GetAsReadableARGB32ImageSurface(); diff --git a/widget/cocoa/nsMenuItemIconX.mm b/widget/cocoa/nsMenuItemIconX.mm index 2975155c0d1..a31b0247e70 100644 --- a/widget/cocoa/nsMenuItemIconX.mm +++ b/widget/cocoa/nsMenuItemIconX.mm @@ -384,10 +384,9 @@ nsMenuItemIconX::OnStopFrame(imgIRequest* aRequest) mImageRegionRect.SetRect(0, 0, origWidth, origHeight); } - nsRefPtr surface; - imageContainer->GetFrame(imgIContainer::FRAME_CURRENT, - imgIContainer::FLAG_NONE, - getter_AddRefs(surface)); + nsRefPtr surface = + imageContainer->GetFrame(imgIContainer::FRAME_CURRENT, + imgIContainer::FLAG_NONE); if (!surface) { [mNativeMenuItem setImage:nil]; return NS_ERROR_FAILURE; diff --git a/widget/gtk/nsImageToPixbuf.cpp b/widget/gtk/nsImageToPixbuf.cpp index 35319b503c1..0acb7f787dc 100644 --- a/widget/gtk/nsImageToPixbuf.cpp +++ b/widget/gtk/nsImageToPixbuf.cpp @@ -36,19 +36,17 @@ nsImageToPixbuf::ConvertImageToPixbuf(imgIContainer* aImage) GdkPixbuf* nsImageToPixbuf::ImageToPixbuf(imgIContainer* aImage) { - nsRefPtr surface; - aImage->GetFrame(imgIContainer::FRAME_CURRENT, - imgIContainer::FLAG_SYNC_DECODE, - getter_AddRefs(surface)); + nsRefPtr surface = + aImage->GetFrame(imgIContainer::FRAME_CURRENT, + imgIContainer::FLAG_SYNC_DECODE); // If the last call failed, it was probably because our call stack originates // in an imgINotificationObserver event, meaning that we're not allowed request // a sync decode. Presumably the originating event is something sensible like // OnStopFrame(), so we can just retry the call without a sync decode. if (!surface) - aImage->GetFrame(imgIContainer::FRAME_CURRENT, - imgIContainer::FLAG_NONE, - getter_AddRefs(surface)); + surface = aImage->GetFrame(imgIContainer::FRAME_CURRENT, + imgIContainer::FLAG_NONE); NS_ENSURE_TRUE(surface, nullptr); diff --git a/widget/os2/nsWindow.cpp b/widget/os2/nsWindow.cpp index a8245bd80de..5c39f900f12 100644 --- a/widget/os2/nsWindow.cpp +++ b/widget/os2/nsWindow.cpp @@ -1334,10 +1334,9 @@ NS_IMETHODIMP nsWindow::SetCursor(imgIContainer* aCursor, return NS_OK; } - nsRefPtr surface; - aCursor->GetFrame(imgIContainer::FRAME_CURRENT, - imgIContainer::FLAG_SYNC_DECODE, - getter_AddRefs(surface)); + nsRefPtr surface = + aCursor->GetFrame(imgIContainer::FRAME_CURRENT, + imgIContainer::FLAG_SYNC_DECODE); NS_ENSURE_TRUE(surface, NS_ERROR_NOT_AVAILABLE); nsRefPtr frame(surface->GetAsReadableARGB32ImageSurface()); diff --git a/widget/qt/nsClipboard.cpp b/widget/qt/nsClipboard.cpp index 6fe5fd1d895..dfabcfaf17b 100644 --- a/widget/qt/nsClipboard.cpp +++ b/widget/qt/nsClipboard.cpp @@ -176,10 +176,9 @@ nsClipboard::SetNativeClipboardData( nsITransferable *aTransferable, if (!image) // Not getting an image for an image mime type!? continue; - nsRefPtr surface; - image->GetFrame(imgIContainer::FRAME_CURRENT, - imgIContainer::FLAG_SYNC_DECODE, - getter_AddRefs(surface)); + nsRefPtr surface = + image->GetFrame(imgIContainer::FRAME_CURRENT, + imgIContainer::FLAG_SYNC_DECODE); if (!surface) continue; diff --git a/widget/windows/WinUtils.cpp b/widget/windows/WinUtils.cpp index 7a2aafaba08..0c41149f937 100644 --- a/widget/windows/WinUtils.cpp +++ b/widget/windows/WinUtils.cpp @@ -694,8 +694,8 @@ AsyncFaviconDataReady::OnComplete(nsIURI *aFaviconURI, getter_AddRefs(container)); NS_ENSURE_SUCCESS(rv, rv); - nsRefPtr imgFrame; - rv = container->GetFrame(imgIContainer::FRAME_FIRST, 0, getter_AddRefs(imgFrame)); + nsRefPtr imgFrame = + container->GetFrame(imgIContainer::FRAME_FIRST, 0); NS_ENSURE_SUCCESS(rv, rv); nsRefPtr imageSurface; diff --git a/widget/windows/nsImageClipboard.cpp b/widget/windows/nsImageClipboard.cpp index 230692f5242..58f5e300b8a 100644 --- a/widget/windows/nsImageClipboard.cpp +++ b/widget/windows/nsImageClipboard.cpp @@ -116,10 +116,9 @@ nsImageToClipboard::CreateFromImage ( imgIContainer* inImage, HANDLE* outBitmap nsresult rv; *outBitmap = nullptr; - nsRefPtr surface; - inImage->GetFrame(imgIContainer::FRAME_CURRENT, - imgIContainer::FLAG_SYNC_DECODE, - getter_AddRefs(surface)); + nsRefPtr surface = + inImage->GetFrame(imgIContainer::FRAME_CURRENT, + imgIContainer::FLAG_SYNC_DECODE); NS_ENSURE_TRUE(surface, NS_ERROR_FAILURE); nsRefPtr frame(surface->GetAsReadableARGB32ImageSurface()); diff --git a/widget/windows/nsWindowGfx.cpp b/widget/windows/nsWindowGfx.cpp index c34e8759713..e086bb613ad 100644 --- a/widget/windows/nsWindowGfx.cpp +++ b/widget/windows/nsWindowGfx.cpp @@ -647,10 +647,9 @@ nsresult nsWindowGfx::CreateIcon(imgIContainer *aContainer, HICON *aIcon) { // Get the image data - nsRefPtr surface; - aContainer->GetFrame(imgIContainer::FRAME_CURRENT, - imgIContainer::FLAG_SYNC_DECODE, - getter_AddRefs(surface)); + nsRefPtr surface = + aContainer->GetFrame(imgIContainer::FRAME_CURRENT, + imgIContainer::FLAG_SYNC_DECODE); NS_ENSURE_TRUE(surface, NS_ERROR_NOT_AVAILABLE); nsRefPtr frame(surface->GetAsReadableARGB32ImageSurface());