зеркало из https://github.com/mozilla/gecko-dev.git
Bug 836124 - Replace GetCurrentFrameIsOpaque() with [noscript] FrameIsOpaque(aWhichFrame). r=joe
This commit is contained in:
Родитель
d3c43f64f9
Коммит
41916bc9e5
|
@ -55,7 +55,7 @@ native gfxGraphicsFilter(gfxPattern::GraphicsFilter);
|
||||||
*
|
*
|
||||||
* Internally, imgIContainer also manages animation of images.
|
* 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
|
interface imgIContainer : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -94,12 +94,6 @@ interface imgIContainer : nsISupports
|
||||||
*/
|
*/
|
||||||
readonly attribute boolean animated;
|
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.
|
* Flags for imgIContainer operations.
|
||||||
*
|
*
|
||||||
|
@ -152,6 +146,14 @@ interface imgIContainer : nsISupports
|
||||||
[noscript] gfxASurface getFrame(in uint32_t aWhichFrame,
|
[noscript] gfxASurface getFrame(in uint32_t aWhichFrame,
|
||||||
in uint32_t aFlags);
|
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
|
* Attempts to create an ImageContainer (and Image) containing the current
|
||||||
* frame. Only valid for RASTER type images.
|
* frame. Only valid for RASTER type images.
|
||||||
|
|
|
@ -877,33 +877,32 @@ RasterImage::GetCurrentDrawableImgFrame()
|
||||||
}
|
}
|
||||||
|
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
/* readonly attribute boolean currentFrameIsOpaque; */
|
/* [notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP_(bool)
|
||||||
RasterImage::GetCurrentFrameIsOpaque(bool *aIsOpaque)
|
RasterImage::FrameIsOpaque(uint32_t aWhichFrame)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aIsOpaque);
|
if (aWhichFrame > FRAME_MAX_VALUE) {
|
||||||
|
NS_WARNING("aWhichFrame outside valid range!");
|
||||||
if (mError)
|
return false;
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
void
|
||||||
|
|
|
@ -383,13 +383,14 @@ VectorImage::GetAnimated(bool* aAnimated)
|
||||||
}
|
}
|
||||||
|
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
/* readonly attribute boolean currentFrameIsOpaque; */
|
/* [notxpcom] boolean frameIsOpaque(in uint32_t aWhichFrame); */
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP_(bool)
|
||||||
VectorImage::GetCurrentFrameIsOpaque(bool* aIsOpaque)
|
VectorImage::FrameIsOpaque(uint32_t aWhichFrame)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aIsOpaque);
|
if (aWhichFrame > FRAME_MAX_VALUE)
|
||||||
*aIsOpaque = false; // In general, SVG content is not opaque.
|
NS_WARNING("aWhichFrame outside valid range!");
|
||||||
return NS_OK;
|
|
||||||
|
return false; // In general, SVG content is not opaque.
|
||||||
}
|
}
|
||||||
|
|
||||||
//******************************************************************************
|
//******************************************************************************
|
||||||
|
|
|
@ -1643,10 +1643,8 @@ nsStyleImage::IsOpaque() const
|
||||||
mImage->GetImage(getter_AddRefs(imageContainer));
|
mImage->GetImage(getter_AddRefs(imageContainer));
|
||||||
NS_ABORT_IF_FALSE(imageContainer, "IsComplete() said image container is ready");
|
NS_ABORT_IF_FALSE(imageContainer, "IsComplete() said image container is ready");
|
||||||
|
|
||||||
// Check if the crop region of the current image frame is opaque
|
// Check if the crop region of the current image frame is opaque.
|
||||||
bool isOpaque;
|
if (imageContainer->FrameIsOpaque(imgIContainer::FRAME_CURRENT)) {
|
||||||
if (NS_SUCCEEDED(imageContainer->GetCurrentFrameIsOpaque(&isOpaque)) &&
|
|
||||||
isOpaque) {
|
|
||||||
if (!mCropRect)
|
if (!mCropRect)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче