diff --git a/image/public/imgIContainer.idl b/image/public/imgIContainer.idl index 2b50e4b6b6e..8cdac3facd4 100644 --- a/image/public/imgIContainer.idl +++ b/image/public/imgIContainer.idl @@ -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); }; diff --git a/image/src/ImageWrapper.cpp b/image/src/ImageWrapper.cpp index 58abe90785a..cd929145a1e 100644 --- a/image/src/ImageWrapper.cpp +++ b/image/src/ImageWrapper.cpp @@ -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 diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index 5151ee1cd78..6217f99ae19 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -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) { diff --git a/image/src/VectorImage.cpp b/image/src/VectorImage.cpp index e1850511d54..04305d8b061 100644 --- a/image/src/VectorImage.cpp +++ b/image/src/VectorImage.cpp @@ -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