Bug 1145167 - make imgIContainer::type getter infallible; r=seth

Rather than writing out a separate GetType() for every concrete
imgIContainer, we can tag the attribute as [infallible] in the IDL file.
The IDL code generator takes care of generating the correct GetType,
leading to less code duplication.
This commit is contained in:
Nathan Froyd 2015-03-19 10:12:52 -04:00
parent 8635de289b
commit 6891ac942c
5 changed files with 4 additions and 37 deletions

View File

@ -116,7 +116,7 @@ native nsIntSizeByVal(nsIntSize);
*
* Internally, imgIContainer also manages animation of images.
*/
[scriptable, builtinclass, uuid(44fbd7d5-e417-4d31-ae4a-8ad61d07eb3c)]
[scriptable, builtinclass, uuid(e3261ae7-4749-4cf6-bf06-59946233366f)]
interface imgIContainer : nsISupports
{
/**
@ -173,12 +173,7 @@ interface imgIContainer : nsISupports
/**
* The type of this image (one of the TYPE_* values above).
*/
readonly attribute unsigned short type;
/**
* Direct C++ accessor for 'type' attribute, for convenience.
*/
[noscript, notxpcom] uint16_t GetType();
[infallible] readonly attribute unsigned short type;
/**
* Whether this image is animated. You can only be guaranteed that querying

View File

@ -162,12 +162,6 @@ DynamicImage::GetType(uint16_t* aType)
return NS_OK;
}
NS_IMETHODIMP_(uint16_t)
DynamicImage::GetType()
{
return imgIContainer::TYPE_RASTER;
}
NS_IMETHODIMP
DynamicImage::GetAnimated(bool* aAnimated)
{

View File

@ -167,12 +167,6 @@ ImageWrapper::GetType(uint16_t* aType)
return mInnerImage->GetType(aType);
}
NS_IMETHODIMP_(uint16_t)
ImageWrapper::GetType()
{
return mInnerImage->GetType();
}
NS_IMETHODIMP
ImageWrapper::GetAnimated(bool* aAnimated)
{

View File

@ -449,18 +449,10 @@ RasterImage::GetType(uint16_t *aType)
{
NS_ENSURE_ARG_POINTER(aType);
*aType = GetType();
*aType = imgIContainer::TYPE_RASTER;
return NS_OK;
}
//******************************************************************************
/* [noscript, notxpcom] uint16_t GetType(); */
NS_IMETHODIMP_(uint16_t)
RasterImage::GetType()
{
return imgIContainer::TYPE_RASTER;
}
DrawableFrameRef
RasterImage::LookupFrameInternal(uint32_t aFrameNum,
const IntSize& aSize,

View File

@ -599,18 +599,10 @@ VectorImage::GetType(uint16_t* aType)
{
NS_ENSURE_ARG_POINTER(aType);
*aType = GetType();
*aType = imgIContainer::TYPE_VECTOR;
return NS_OK;
}
//******************************************************************************
/* [noscript, notxpcom] uint16_t GetType(); */
NS_IMETHODIMP_(uint16_t)
VectorImage::GetType()
{
return imgIContainer::TYPE_VECTOR;
}
//******************************************************************************
/* readonly attribute boolean animated; */
NS_IMETHODIMP