Bug 867758 - Add imgIContainer::SetAnimationStartTime, which lets us explicitly set the time animation starts (rather than using TimeStamp::Now()). r=seth

--HG--
extra : rebase_source : 4660937d5eb06bf83b749826d2f13da29583e9e7
This commit is contained in:
Joe Drew 2013-05-17 16:57:20 -04:00
parent 06e2a4c09b
commit 5495bbbd03
4 changed files with 40 additions and 2 deletions

View File

@ -57,7 +57,7 @@ native nsSize(nsSize);
*
* Internally, imgIContainer also manages animation of images.
*/
[scriptable, builtinclass, uuid(4c04b27c-7a4b-4676-b04f-402ace3c3dca)]
[scriptable, builtinclass, uuid(b56906e9-830c-45f4-b572-8c71e7619dad)]
interface imgIContainer : nsISupports
{
/**
@ -303,4 +303,17 @@ interface imgIContainer : nsISupports
* animated), returns -1.
*/
[notxpcom] int32_t getFirstFrameDelay();
/*
* If this is an animated image that hasn't started animating already, this
* sets the animation's start time to the indicated time.
*
* This has no effect if the image isn't animated or it has started animating
* already; it also has no effect if the image format doesn't care about
* animation start time.
*
* In all cases, animation does not actually begin until startAnimation(),
* resetAnimation(), or requestRefresh() is called for the first time.
*/
[notxpcom] void setAnimationStartTime([const] in TimeStamp aTime);
};

View File

@ -285,5 +285,11 @@ ImageWrapper::GetFirstFrameDelay()
return mInnerImage->GetFirstFrameDelay();
}
NS_IMETHODIMP_(void)
ImageWrapper::SetAnimationStartTime(const mozilla::TimeStamp& aTime)
{
mInnerImage->SetAnimationStartTime(aTime);
}
} // namespace image
} // namespace mozilla

View File

@ -1560,7 +1560,9 @@ RasterImage::StartAnimation()
// We need to set the time that this initial frame was first displayed, as
// this is used in AdvanceFrame().
mAnim->currentAnimationFrameTime = TimeStamp::Now();
if (mAnim->currentAnimationFrameTime.IsNull()) {
mAnim->currentAnimationFrameTime = TimeStamp::Now();
}
}
return NS_OK;
@ -1619,6 +1621,17 @@ RasterImage::ResetAnimation()
return NS_OK;
}
//******************************************************************************
// [notxpcom] void requestRefresh ([const] in TimeStamp aTime);
NS_IMETHODIMP_(void)
RasterImage::SetAnimationStartTime(const mozilla::TimeStamp& aTime)
{
if (mError || mAnimating || !mAnim)
return;
mAnim->currentAnimationFrameTime = aTime;
}
NS_IMETHODIMP_(float)
RasterImage::GetFrameIndex(uint32_t aWhichFrame)
{

View File

@ -438,6 +438,12 @@ VectorImage::ShouldAnimate()
return ImageResource::ShouldAnimate() && mIsFullyLoaded && mHaveAnimations;
}
NS_IMETHODIMP_(void)
VectorImage::SetAnimationStartTime(const mozilla::TimeStamp& aTime)
{
// We don't care about animation start time.
}
//------------------------------------------------------------------------------
// imgIContainer methods