Bug 859377 (Part 1) - Add imgIContainer::GetFrameIndex. r=joe sr=bz

--HG--
extra : rebase_source : e81992f8bead31b273f4afb4fb589849ec1c5218
This commit is contained in:
Seth Fowler 2013-04-25 15:58:20 -07:00
Родитель 971d6ebe6e
Коммит 604be56846
6 изменённых файлов: 47 добавлений и 1 удалений

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

@ -57,7 +57,7 @@ native nsSize(nsSize);
*
* Internally, imgIContainer also manages animation of images.
*/
[scriptable, builtinclass, uuid(55531bcd-7d4a-4da0-ab87-7c64c5ae5e12)]
[scriptable, builtinclass, uuid(e385f907-9a59-419b-8e15-e2a96d8ce044)]
interface imgIContainer : nsISupports
{
/**
@ -279,4 +279,18 @@ interface imgIContainer : nsISupports
/* Methods to control animation */
void resetAnimation();
/*
* Returns an index for the requested animation frame (either FRAME_FIRST or
* FRAME_CURRENT).
*
* The units of the index aren't specified, and may vary between different
* types of images. What you can rely on is that on all occasions when
* getFrameIndex(FRAME_CURRENT) returns a certain value,
* draw(..FRAME_CURRENT..) will draw the same frame. The same holds for
* FRAME_FIRST as well.
*
* @param aWhichFrame Frame specifier of the FRAME_* variety.
*/
[notxpcom] float getFrameIndex(in uint32_t aWhichFrame);
};

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

@ -111,5 +111,12 @@ FrozenImage::ResetAnimation()
return NS_OK;
}
NS_IMETHODIMP_(float)
FrozenImage::GetFrameIndex(uint32_t aWhichFrame)
{
MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE, "Invalid argument");
return 0;
}
} // namespace image
} // namespace mozilla

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

@ -53,6 +53,7 @@ public:
NS_IMETHOD GetAnimationMode(uint16_t* aAnimationMode) MOZ_OVERRIDE;
NS_IMETHOD SetAnimationMode(uint16_t aAnimationMode) MOZ_OVERRIDE;
NS_IMETHOD ResetAnimation() MOZ_OVERRIDE;
NS_IMETHOD_(float) GetFrameIndex(uint32_t aWhichFrame) MOZ_OVERRIDE;
protected:
FrozenImage(Image* aImage) : ImageWrapper(aImage) { }

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

@ -273,5 +273,11 @@ ImageWrapper::ResetAnimation()
return mInnerImage->ResetAnimation();
}
NS_IMETHODIMP_(float)
ImageWrapper::GetFrameIndex(uint32_t aWhichFrame)
{
return mInnerImage->GetFrameIndex(aWhichFrame);
}
} // namespace image
} // namespace mozilla

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

@ -1594,6 +1594,15 @@ RasterImage::ResetAnimation()
return NS_OK;
}
NS_IMETHODIMP_(float)
RasterImage::GetFrameIndex(uint32_t aWhichFrame)
{
MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE, "Invalid argument");
return (aWhichFrame == FRAME_FIRST || !mAnim)
? 0.0f
: mAnim->currentAnimationFrameIndex;
}
void
RasterImage::SetLoopCount(int32_t aLoopCount)
{

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

@ -755,6 +755,15 @@ VectorImage::ResetAnimation()
return NS_OK;
}
NS_IMETHODIMP_(float)
VectorImage::GetFrameIndex(uint32_t aWhichFrame)
{
MOZ_ASSERT(aWhichFrame <= FRAME_MAX_VALUE, "Invalid argument");
return aWhichFrame == FRAME_FIRST
? 0.0f
: mSVGDocumentWrapper->GetCurrentTime();
}
//------------------------------------------------------------------------------
// nsIRequestObserver methods