Bug 836124 - Replace GetCurrentFrameIsOpaque() with [noscript] FrameIsOpaque(aWhichFrame). r=joe

This commit is contained in:
Seth Fowler 2013-02-04 14:22:30 -08:00
Родитель d3c43f64f9
Коммит 41916bc9e5
4 изменённых файлов: 41 добавлений и 41 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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

Просмотреть файл

@ -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.
}
//******************************************************************************

Просмотреть файл

@ -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;