diff --git a/content/base/src/nsPrintEngine.cpp b/content/base/src/nsPrintEngine.cpp index 156f51a8a221..eaf1e7b95c47 100644 --- a/content/base/src/nsPrintEngine.cpp +++ b/content/base/src/nsPrintEngine.cpp @@ -2735,7 +2735,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink) // turn off animated GIFs if (aPO->mPresContext) { - aPO->mPresContext->GetImageAnimationMode(&aPO->mImgAnimationMode); + aPO->mImgAnimationMode = aPO->mPresContext->ImageAnimationMode(); aPO->mPresContext->SetImageAnimationMode(imgIContainer::kDontAnimMode); } diff --git a/editor/composer/src/nsComposerDocumentCommands.cpp b/editor/composer/src/nsComposerDocumentCommands.cpp index 5420985ab264..578c61cad2dc 100644 --- a/editor/composer/src/nsComposerDocumentCommands.cpp +++ b/editor/composer/src/nsComposerDocumentCommands.cpp @@ -128,8 +128,7 @@ nsSetDocumentOptionsCommand::DoCommandParams(const char *aCommandName, { // for possible values of animation mode, see: // http://lxr.mozilla.org/seamonkey/source/modules/libpr0n/public/imgIContainer.idl - rv = presContext->SetImageAnimationMode(animationMode); - if (NS_FAILED(rv)) return rv; + presContext->SetImageAnimationMode(animationMode); } PRBool allowPlugins; @@ -182,11 +181,8 @@ nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName, { // for possible values of animation mode, see // http://lxr.mozilla.org/seamonkey/source/modules/libpr0n/public/imgIContainer.idl - PRUint16 tmp; - rv = presContext->GetImageAnimationMode(&tmp); - if (NS_FAILED(rv)) return rv; - - rv = aParams->SetLongValue("imageAnimation", animationMode); + rv = aParams->SetLongValue("imageAnimation", + presContext->ImageAnimationMode()); if (NS_FAILED(rv)) return rv; } diff --git a/editor/composer/src/nsEditingSession.cpp b/editor/composer/src/nsEditingSession.cpp index aabf81acafaa..14aa91ada92a 100644 --- a/editor/composer/src/nsEditingSession.cpp +++ b/editor/composer/src/nsEditingSession.cpp @@ -407,8 +407,7 @@ nsEditingSession::SetupEditorOnWindow(nsIDOMWindow *aWindow) if (NS_FAILED(rv)) return rv; if (!presContext) return NS_ERROR_FAILURE; - rv = presContext->SetImageAnimationMode(imgIContainer::kDontAnimMode); - if (NS_FAILED(rv)) return rv; + presContext->SetImageAnimationMode(imgIContainer::kDontAnimMode); // create and set editor nsCOMPtr editorDocShell = do_QueryInterface(docShell, &rv); diff --git a/layout/base/nsImageLoader.cpp b/layout/base/nsImageLoader.cpp index 60ce24d52dd8..743b8bf52bfd 100644 --- a/layout/base/nsImageLoader.cpp +++ b/layout/base/nsImageLoader.cpp @@ -140,10 +140,7 @@ NS_IMETHODIMP nsImageLoader::OnStartContainer(imgIRequest *aRequest, * one frame = 1 * one loop = 2 */ - PRUint16 animateMode = imgIContainer::kNormalAnimMode; //default value - nsresult rv = mPresContext->GetImageAnimationMode(&animateMode); - if (NS_SUCCEEDED(rv)) - aImage->SetAnimationMode(animateMode); + aImage->SetAnimationMode(mPresContext->ImageAnimationMode()); } return NS_OK; } diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index c45902681a16..588b8b8b68e6 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -685,7 +685,7 @@ nsPresContext::SetShell(nsIPresShell* aShell) if (doc) { mBaseURL = doc->GetBaseURL(); - if (mBaseURL) { + if (!mNeverAnimate && mBaseURL) { PRBool isChrome = PR_FALSE; PRBool isRes = PR_FALSE; mBaseURL->SchemeIs("chrome", &isChrome); @@ -774,14 +774,6 @@ nsPresContext::SetCompatibilityMode(nsCompatibility aMode) } } -NS_IMETHODIMP -nsPresContext::GetImageAnimationMode(PRUint16* aModeResult) -{ - NS_PRECONDITION(aModeResult, "null out param"); - *aModeResult = mImageAnimationMode; - return NS_OK; -} - // Helper function for setting Anim Mode on image static void SetImgAnimModeOnImgReq(imgIRequest* aImgReq, PRUint16 aMode) { @@ -826,7 +818,7 @@ void nsPresContext::SetImgAnimations(nsIContent *aParent, PRUint16 aMode) } } -NS_IMETHODIMP +void nsPresContext::SetImageAnimationMode(PRUint16 aMode) { NS_ASSERTION(aMode == imgIContainer::kNormalAnimMode || @@ -851,7 +843,6 @@ nsPresContext::SetImageAnimationMode(PRUint16 aMode) } mImageAnimationMode = aMode; - return NS_OK; } /* diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 58ddcfacb8b0..42cbf325a067 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -158,8 +158,8 @@ public: /** * Access the image animation mode for this context */ - NS_IMETHOD GetImageAnimationMode(PRUint16* aModeResult) = 0; - NS_IMETHOD SetImageAnimationMode(PRUint16 aMode) = 0; + PRUint16 ImageAnimationMode() const { return mImageAnimationMode; } + virtual void SetImageAnimationMode(PRUint16 aMode) = 0; /** * Get an special load flags for images for this context @@ -580,6 +580,7 @@ protected: nsIEventStateManager* mEventManager; // [STRONG] nsCompatibility mCompatibilityMode; + PRUint16 mImageAnimationMode; }; // Bit values for StartLoadImage's aImageStatus diff --git a/layout/base/public/nsIPresContext.h b/layout/base/public/nsIPresContext.h index 58ddcfacb8b0..42cbf325a067 100644 --- a/layout/base/public/nsIPresContext.h +++ b/layout/base/public/nsIPresContext.h @@ -158,8 +158,8 @@ public: /** * Access the image animation mode for this context */ - NS_IMETHOD GetImageAnimationMode(PRUint16* aModeResult) = 0; - NS_IMETHOD SetImageAnimationMode(PRUint16 aMode) = 0; + PRUint16 ImageAnimationMode() const { return mImageAnimationMode; } + virtual void SetImageAnimationMode(PRUint16 aMode) = 0; /** * Get an special load flags for images for this context @@ -580,6 +580,7 @@ protected: nsIEventStateManager* mEventManager; // [STRONG] nsCompatibility mCompatibilityMode; + PRUint16 mImageAnimationMode; }; // Bit values for StartLoadImage's aImageStatus diff --git a/layout/base/public/nsPresContext.h b/layout/base/public/nsPresContext.h index 58ddcfacb8b0..42cbf325a067 100644 --- a/layout/base/public/nsPresContext.h +++ b/layout/base/public/nsPresContext.h @@ -158,8 +158,8 @@ public: /** * Access the image animation mode for this context */ - NS_IMETHOD GetImageAnimationMode(PRUint16* aModeResult) = 0; - NS_IMETHOD SetImageAnimationMode(PRUint16 aMode) = 0; + PRUint16 ImageAnimationMode() const { return mImageAnimationMode; } + virtual void SetImageAnimationMode(PRUint16 aMode) = 0; /** * Get an special load flags for images for this context @@ -580,6 +580,7 @@ protected: nsIEventStateManager* mEventManager; // [STRONG] nsCompatibility mCompatibilityMode; + PRUint16 mImageAnimationMode; }; // Bit values for StartLoadImage's aImageStatus diff --git a/layout/base/src/nsImageLoader.cpp b/layout/base/src/nsImageLoader.cpp index 60ce24d52dd8..743b8bf52bfd 100644 --- a/layout/base/src/nsImageLoader.cpp +++ b/layout/base/src/nsImageLoader.cpp @@ -140,10 +140,7 @@ NS_IMETHODIMP nsImageLoader::OnStartContainer(imgIRequest *aRequest, * one frame = 1 * one loop = 2 */ - PRUint16 animateMode = imgIContainer::kNormalAnimMode; //default value - nsresult rv = mPresContext->GetImageAnimationMode(&animateMode); - if (NS_SUCCEEDED(rv)) - aImage->SetAnimationMode(animateMode); + aImage->SetAnimationMode(mPresContext->ImageAnimationMode()); } return NS_OK; } diff --git a/layout/base/src/nsPresContext.cpp b/layout/base/src/nsPresContext.cpp index c45902681a16..588b8b8b68e6 100644 --- a/layout/base/src/nsPresContext.cpp +++ b/layout/base/src/nsPresContext.cpp @@ -685,7 +685,7 @@ nsPresContext::SetShell(nsIPresShell* aShell) if (doc) { mBaseURL = doc->GetBaseURL(); - if (mBaseURL) { + if (!mNeverAnimate && mBaseURL) { PRBool isChrome = PR_FALSE; PRBool isRes = PR_FALSE; mBaseURL->SchemeIs("chrome", &isChrome); @@ -774,14 +774,6 @@ nsPresContext::SetCompatibilityMode(nsCompatibility aMode) } } -NS_IMETHODIMP -nsPresContext::GetImageAnimationMode(PRUint16* aModeResult) -{ - NS_PRECONDITION(aModeResult, "null out param"); - *aModeResult = mImageAnimationMode; - return NS_OK; -} - // Helper function for setting Anim Mode on image static void SetImgAnimModeOnImgReq(imgIRequest* aImgReq, PRUint16 aMode) { @@ -826,7 +818,7 @@ void nsPresContext::SetImgAnimations(nsIContent *aParent, PRUint16 aMode) } } -NS_IMETHODIMP +void nsPresContext::SetImageAnimationMode(PRUint16 aMode) { NS_ASSERTION(aMode == imgIContainer::kNormalAnimMode || @@ -851,7 +843,6 @@ nsPresContext::SetImageAnimationMode(PRUint16 aMode) } mImageAnimationMode = aMode; - return NS_OK; } /* diff --git a/layout/base/src/nsPresContext.h b/layout/base/src/nsPresContext.h index a804e33ee222..0ff88bcce2f8 100644 --- a/layout/base/src/nsPresContext.h +++ b/layout/base/src/nsPresContext.h @@ -72,8 +72,7 @@ public: NS_IMETHOD Init(nsIDeviceContext* aDeviceContext); NS_IMETHOD SetShell(nsIPresShell* aShell); virtual void SetCompatibilityMode(nsCompatibility aMode); - NS_IMETHOD GetImageAnimationMode(PRUint16* aModeResult); - NS_IMETHOD SetImageAnimationMode(PRUint16 aMode); + virtual void SetImageAnimationMode(PRUint16 aMode); NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags); NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel); NS_IMETHOD GetIOService(nsIIOService** aIOService); @@ -256,8 +255,7 @@ protected: nsCOMPtr mBaseURL; PRPackedBool mImageAnimationStopped; // image animation stopped - - PRUint16 mImageAnimationMode; + PRPackedBool mNeverAnimate; // never animate images PRPackedBool mStopped; // loading stopped PRPackedBool mStopChrome; // should we stop chrome? diff --git a/layout/base/src/nsPrintContext.cpp b/layout/base/src/nsPrintContext.cpp index 9f8bd1b43272..a609f75b6774 100644 --- a/layout/base/src/nsPrintContext.cpp +++ b/layout/base/src/nsPrintContext.cpp @@ -66,8 +66,7 @@ public: NS_IMETHOD GetPaginatedScrolling(PRBool* aResult); NS_IMETHOD GetPageDim(nsRect* aActualRect, nsRect* aAdjRect); NS_IMETHOD SetPageDim(nsRect* aRect); - NS_IMETHOD SetImageAnimationMode(PRUint16 aMode); - NS_IMETHOD GetImageAnimationMode(PRUint16* aModeResult); + virtual void SetImageAnimationMode(PRUint16 aMode); NS_IMETHOD SetPrintSettings(nsIPrintSettings* aPS); NS_IMETHOD GetPrintSettings(nsIPrintSettings** aPS); @@ -81,6 +80,9 @@ PrintContext::PrintContext() : { SetBackgroundImageDraw(PR_FALSE); SetBackgroundColorDraw(PR_FALSE); + // Printed images are never animated + mImageAnimationMode = imgIContainer::kDontAnimMode; + mNeverAnimate = PR_TRUE; } PrintContext::~PrintContext() @@ -163,21 +165,9 @@ PrintContext::SetPageDim(nsRect* aPageDim) /** * Ignore any attempt to set an animation mode for printed images */ -NS_IMETHODIMP +void PrintContext::SetImageAnimationMode(PRUint16 aMode) { - return NS_OK; -} - -/** - * Printed images are never animated: always return kDontAnimMode - */ -NS_IMETHODIMP -PrintContext::GetImageAnimationMode(PRUint16* aModeResult) -{ - NS_PRECONDITION(aModeResult, "null out param"); - *aModeResult = imgIContainer::kDontAnimMode; - return NS_OK; } NS_IMETHODIMP diff --git a/layout/base/src/nsPrintPreviewContext.cpp b/layout/base/src/nsPrintPreviewContext.cpp index 57622b41e980..18d719f14d51 100644 --- a/layout/base/src/nsPrintPreviewContext.cpp +++ b/layout/base/src/nsPrintPreviewContext.cpp @@ -63,8 +63,7 @@ public: NS_IMETHOD GetPaginatedScrolling(PRBool* aResult); NS_IMETHOD GetPageDim(nsRect* aActualRect, nsRect* aAdjRect); NS_IMETHOD SetPageDim(nsRect* aRect); - NS_IMETHOD SetImageAnimationMode(PRUint16 aMode); - NS_IMETHOD GetImageAnimationMode(PRUint16* aModeResult); + virtual void SetImageAnimationMode(PRUint16 aMode); NS_IMETHOD SetPrintSettings(nsIPrintSettings* aPS); NS_IMETHOD GetPrintSettings(nsIPrintSettings** aPS); NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const; @@ -84,6 +83,9 @@ PrintPreviewContext::PrintPreviewContext() : { SetBackgroundImageDraw(PR_FALSE); SetBackgroundColorDraw(PR_FALSE); + // Printed images are never animated + mImageAnimationMode = imgIContainer::kDontAnimMode; + mNeverAnimate = PR_TRUE; } PrintPreviewContext::~PrintPreviewContext() @@ -165,21 +167,9 @@ PrintPreviewContext::SetPageDim(nsRect* aPageDim) * Ignore any attempt to set an animation mode for images in print * preview */ -NS_IMETHODIMP +void PrintPreviewContext::SetImageAnimationMode(PRUint16 aMode) { - return NS_OK; -} - -/** - * Images in print preview are never animated: always return kDontAnimMode - */ -NS_IMETHODIMP -PrintPreviewContext::GetImageAnimationMode(PRUint16* aModeResult) -{ - NS_PRECONDITION(aModeResult, "null out param"); - *aModeResult = imgIContainer::kDontAnimMode; - return NS_OK; } NS_IMETHODIMP diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 861855a6ecfe..48976b32c75a 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -331,15 +331,12 @@ nsImageFrame::Init(nsIPresContext* aPresContext, // If we already have an image container, OnStartContainer won't be called // Set the animation mode here nsCOMPtr image; - if (currentRequest) + if (currentRequest) { currentRequest->GetImage(getter_AddRefs(image)); - if (image) { - PRUint16 animateMode = imgIContainer::kNormalAnimMode; //default value - nsresult rv = mPresContext->GetImageAnimationMode(&animateMode); - if (NS_SUCCEEDED(rv)) - image->SetAnimationMode(animateMode); + if (image) + image->SetAnimationMode(mPresContext->ImageAnimationMode()); } - + return rv; } @@ -536,18 +533,12 @@ nsImageFrame::OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage) return NS_OK; } - if (aImage) - { - /* Get requested animation policy from the pres context: - * normal = 0 - * one frame = 1 - * one loop = 2 - */ - PRUint16 animateMode = imgIContainer::kNormalAnimMode; //default value - nsresult rv = mPresContext->GetImageAnimationMode(&animateMode); - if (NS_SUCCEEDED(rv)) - aImage->SetAnimationMode(animateMode); - } + /* Get requested animation policy from the pres context: + * normal = 0 + * one frame = 1 + * one loop = 2 + */ + aImage->SetAnimationMode(mPresContext->ImageAnimationMode()); if (IsPendingLoad(aRequest)) { // We don't care diff --git a/layout/html/base/src/nsImageFrame.cpp b/layout/html/base/src/nsImageFrame.cpp index 861855a6ecfe..48976b32c75a 100644 --- a/layout/html/base/src/nsImageFrame.cpp +++ b/layout/html/base/src/nsImageFrame.cpp @@ -331,15 +331,12 @@ nsImageFrame::Init(nsIPresContext* aPresContext, // If we already have an image container, OnStartContainer won't be called // Set the animation mode here nsCOMPtr image; - if (currentRequest) + if (currentRequest) { currentRequest->GetImage(getter_AddRefs(image)); - if (image) { - PRUint16 animateMode = imgIContainer::kNormalAnimMode; //default value - nsresult rv = mPresContext->GetImageAnimationMode(&animateMode); - if (NS_SUCCEEDED(rv)) - image->SetAnimationMode(animateMode); + if (image) + image->SetAnimationMode(mPresContext->ImageAnimationMode()); } - + return rv; } @@ -536,18 +533,12 @@ nsImageFrame::OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage) return NS_OK; } - if (aImage) - { - /* Get requested animation policy from the pres context: - * normal = 0 - * one frame = 1 - * one loop = 2 - */ - PRUint16 animateMode = imgIContainer::kNormalAnimMode; //default value - nsresult rv = mPresContext->GetImageAnimationMode(&animateMode); - if (NS_SUCCEEDED(rv)) - aImage->SetAnimationMode(animateMode); - } + /* Get requested animation policy from the pres context: + * normal = 0 + * one frame = 1 + * one loop = 2 + */ + aImage->SetAnimationMode(mPresContext->ImageAnimationMode()); if (IsPendingLoad(aRequest)) { // We don't care diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 156f51a8a221..eaf1e7b95c47 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -2735,7 +2735,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink) // turn off animated GIFs if (aPO->mPresContext) { - aPO->mPresContext->GetImageAnimationMode(&aPO->mImgAnimationMode); + aPO->mImgAnimationMode = aPO->mPresContext->ImageAnimationMode(); aPO->mPresContext->SetImageAnimationMode(imgIContainer::kDontAnimMode); }