diff --git a/image/public/imgIContainer.idl b/image/public/imgIContainer.idl index bf8bba76ca25..0b7401526806 100644 --- a/image/public/imgIContainer.idl +++ b/image/public/imgIContainer.idl @@ -55,7 +55,7 @@ native gfxGraphicsFilter(gfxPattern::GraphicsFilter); * * Internally, imgIContainer also manages animation of images. */ -[scriptable, builtinclass, uuid(01e12ac9-7d9f-40d9-9ec1-70b64c53ce7a)] +[scriptable, builtinclass, uuid(c7e8eed7-2be9-40b0-be7c-b682097f5b28)] interface imgIContainer : nsISupports { /** @@ -94,12 +94,6 @@ interface imgIContainer : nsISupports */ readonly attribute boolean animated; - /** - * Whether the current frame is opaque; that is, needs the background painted - * behind it. - */ - readonly attribute boolean currentFrameIsOpaque; - /** * Flags for imgIContainer operations. * @@ -152,6 +146,14 @@ interface imgIContainer : nsISupports [noscript] gfxASurface getFrame(in uint32_t aWhichFrame, in uint32_t aFlags); + /** + * Whether the given frame is opaque; that is, needs the background painted + * behind it. + * + * @param aWhichFrame Frame specifier of the FRAME_* variety. + */ + [notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame); + /** * Attempts to create an ImageContainer (and Image) containing the current * frame. Only valid for RASTER type images. diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index 5f5dc77bbb15..3fe392c01036 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -877,33 +877,32 @@ RasterImage::GetCurrentDrawableImgFrame() } //****************************************************************************** -/* readonly attribute boolean currentFrameIsOpaque; */ -NS_IMETHODIMP -RasterImage::GetCurrentFrameIsOpaque(bool *aIsOpaque) +/* [notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame); */ +NS_IMETHODIMP_(bool) +RasterImage::FrameIsOpaque(uint32_t aWhichFrame) { - NS_ENSURE_ARG_POINTER(aIsOpaque); - - if (mError) - return NS_ERROR_FAILURE; - - // See if we can get an image frame - imgFrame *curframe = GetCurrentImgFrame(); - - // If we don't get a frame, the safe answer is "not opaque" - if (!curframe) - *aIsOpaque = false; - - // Otherwise, we can make a more intelligent decision - else { - *aIsOpaque = !curframe->GetNeedsBackground(); - - // We are also transparent if the current frame's size doesn't cover our - // entire area. - nsIntRect framerect = curframe->GetRect(); - *aIsOpaque = *aIsOpaque && framerect.IsEqualInterior(nsIntRect(0, 0, mSize.width, mSize.height)); + if (aWhichFrame > FRAME_MAX_VALUE) { + NS_WARNING("aWhichFrame outside valid range!"); + return false; } - return NS_OK; + if (mError) + return false; + + // See if we can get an image frame. + imgFrame* frame = aWhichFrame == FRAME_FIRST ? GetImgFrame(0) + : GetCurrentImgFrame(); + + // If we don't get a frame, the safe answer is "not opaque". + if (!frame) + return false; + + // Other, the frame is transparent if either: + // 1. It needs a background. + // 2. Its size doesn't cover our entire area. + nsIntRect framerect = frame->GetRect(); + return !frame->GetNeedsBackground() && + framerect.IsEqualInterior(nsIntRect(0, 0, mSize.width, mSize.height)); } void diff --git a/image/src/VectorImage.cpp b/image/src/VectorImage.cpp index be67256cfb63..f983a6183d7a 100644 --- a/image/src/VectorImage.cpp +++ b/image/src/VectorImage.cpp @@ -383,13 +383,14 @@ VectorImage::GetAnimated(bool* aAnimated) } //****************************************************************************** -/* readonly attribute boolean currentFrameIsOpaque; */ -NS_IMETHODIMP -VectorImage::GetCurrentFrameIsOpaque(bool* aIsOpaque) +/* [notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame); */ +NS_IMETHODIMP_(bool) +VectorImage::FrameIsOpaque(uint32_t aWhichFrame) { - NS_ENSURE_ARG_POINTER(aIsOpaque); - *aIsOpaque = false; // In general, SVG content is not opaque. - return NS_OK; + if (aWhichFrame > FRAME_MAX_VALUE) + NS_WARNING("aWhichFrame outside valid range!"); + + return false; // In general, SVG content is not opaque. } //****************************************************************************** diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 66eca3a58369..5d57be367a84 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1643,10 +1643,8 @@ nsStyleImage::IsOpaque() const mImage->GetImage(getter_AddRefs(imageContainer)); NS_ABORT_IF_FALSE(imageContainer, "IsComplete() said image container is ready"); - // Check if the crop region of the current image frame is opaque - bool isOpaque; - if (NS_SUCCEEDED(imageContainer->GetCurrentFrameIsOpaque(&isOpaque)) && - isOpaque) { + // Check if the crop region of the current image frame is opaque. + if (imageContainer->FrameIsOpaque(imgIContainer::FRAME_CURRENT)) { if (!mCropRect) return true;