diff --git a/image/src/Image.h b/image/src/Image.h index d76660701ed3..8abdcb8bc824 100644 --- a/image/src/Image.h +++ b/image/src/Image.h @@ -65,10 +65,9 @@ public: virtual imgStatusTracker& GetStatusTracker() = 0; /** - * The rectangle defining the location and size of the currently displayed - * frame. + * The rectangle defining the location and size of the given frame. */ - virtual void GetCurrentFrameRect(nsIntRect& aRect) = 0; + virtual nsIntRect FrameRect(uint32_t aWhichFrame) = 0; /** * The size, in bytes, occupied by the significant data portions of the image. diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index 3fe392c01036..924ab3e956a1 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -905,24 +905,29 @@ RasterImage::FrameIsOpaque(uint32_t aWhichFrame) framerect.IsEqualInterior(nsIntRect(0, 0, mSize.width, mSize.height)); } -void -RasterImage::GetCurrentFrameRect(nsIntRect& aRect) +nsIntRect +RasterImage::FrameRect(uint32_t aWhichFrame) { - // Get the current frame - imgFrame* curframe = GetCurrentImgFrame(); - - // If we have the frame, use that rectangle - if (curframe) { - aRect = curframe->GetRect(); - } else { - // If the frame doesn't exist, we pass the empty rectangle. It's not clear - // whether this is appropriate in general, but at the moment the only - // consumer of this method is imgStatusTracker (when it wants to figure out - // dirty rectangles to send out batched observer updates). This should - // probably be revisited when we fix bug 503973. - aRect.MoveTo(0, 0); - aRect.SizeTo(0, 0); + if (aWhichFrame > FRAME_MAX_VALUE) { + NS_WARNING("aWhichFrame outside valid range!"); + return nsIntRect(); } + + // Get the requested frame. + imgFrame* frame = aWhichFrame == FRAME_FIRST ? GetImgFrame(0) + : GetCurrentImgFrame(); + + // If we have the frame, use that rectangle. + if (frame) { + return frame->GetRect(); + } + + // If the frame doesn't exist, we return the empty rectangle. It's not clear + // whether this is appropriate in general, but at the moment the only + // consumer of this method is imgStatusTracker (when it wants to figure out + // dirty rectangles to send out batched observer updates). This should + // probably be revisited when we fix bug 503973. + return nsIntRect(); } uint32_t diff --git a/image/src/RasterImage.h b/image/src/RasterImage.h index cabcddbde6ae..bd95fb734ff1 100644 --- a/image/src/RasterImage.h +++ b/image/src/RasterImage.h @@ -160,7 +160,7 @@ public: nsresult Init(imgDecoderObserver* aObserver, const char* aMimeType, uint32_t aFlags); - virtual void GetCurrentFrameRect(nsIntRect& aRect) MOZ_OVERRIDE; + virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; // Raster-specific methods static NS_METHOD WriteToRasterImage(nsIInputStream* aIn, void* aClosure, diff --git a/image/src/VectorImage.cpp b/image/src/VectorImage.cpp index f983a6183d7a..f9ac1886db0b 100644 --- a/image/src/VectorImage.cpp +++ b/image/src/VectorImage.cpp @@ -213,10 +213,10 @@ VectorImage::Init(imgDecoderObserver* aObserver, return NS_OK; } -void -VectorImage::GetCurrentFrameRect(nsIntRect& aRect) +nsIntRect +VectorImage::FrameRect(uint32_t aWhichFrame) { - aRect = nsIntRect::GetMaxSizedIntRect(); + return nsIntRect::GetMaxSizedIntRect(); } size_t diff --git a/image/src/VectorImage.h b/image/src/VectorImage.h index 8479a1d8956b..0b4a7b420fa5 100644 --- a/image/src/VectorImage.h +++ b/image/src/VectorImage.h @@ -40,7 +40,7 @@ public: nsresult Init(imgDecoderObserver* aObserver, const char* aMimeType, uint32_t aFlags); - virtual void GetCurrentFrameRect(nsIntRect& aRect) MOZ_OVERRIDE; + virtual nsIntRect FrameRect(uint32_t aWhichFrame) MOZ_OVERRIDE; virtual size_t HeapSizeOfSourceWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const; virtual size_t HeapSizeOfDecodedWithComputedFallback(nsMallocSizeOfFun aMallocSizeOf) const; diff --git a/image/src/imgStatusTracker.cpp b/image/src/imgStatusTracker.cpp index 42eae6a8629f..5eb084f177b6 100644 --- a/image/src/imgStatusTracker.cpp +++ b/image/src/imgStatusTracker.cpp @@ -371,8 +371,7 @@ imgStatusTracker::SyncNotify(imgRequestProxy* proxy) // OnDataAvailable // XXX - Should only send partial rects here, but that needs to // wait until we fix up the observer interface - nsIntRect r; - mImage->GetCurrentFrameRect(r); + nsIntRect r(mImage->FrameRect(imgIContainer::FRAME_CURRENT)); // If there's any content in this frame at all (always true for // vector images, true for raster images that have decoded at