From 290779695aa1ceff5f1befc3b9a31332c28feeeb Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Sat, 13 May 2000 01:39:20 +0000 Subject: [PATCH] WIP for bug 33810 -- add an image animation enum, and getters and setters in the pres context git-svn-id: svn://10.0.0.236/trunk@69516 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsPresContext.cpp | 28 ++++++++++++++----- mozilla/layout/base/nsPresContext.h | 6 ++++ .../layout/base/public/nsIFrameImageLoader.h | 7 +++++ mozilla/layout/base/public/nsIPresContext.h | 6 ++++ mozilla/layout/base/public/nsPresContext.h | 6 ++++ .../layout/base/src/nsFrameImageLoader.cpp | 3 +- mozilla/layout/base/src/nsFrameImageLoader.h | 5 ++-- mozilla/layout/base/src/nsPresContext.cpp | 28 ++++++++++++++----- mozilla/layout/base/src/nsPresContext.h | 12 +++++--- 9 files changed, 80 insertions(+), 21 deletions(-) diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index a33b7a13070..ceccacf1c78 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -93,7 +93,8 @@ nsPresContext::nsPresContext() mCompatibilityMode = eCompatibility_Standard; mCompatibilityLocked = PR_FALSE; mWidgetRenderingMode = eWidgetRendering_Gfx; - + mImageAnimationMode = eImageAnimation_Normal; + mLookAndFeel = nsnull; mShell = nsnull; @@ -403,10 +404,7 @@ nsPresContext::SetCompatibilityMode(nsCompatibility aMode) NS_IMETHODIMP nsPresContext::GetWidgetRenderingMode(nsWidgetRendering* aResult) { - NS_PRECONDITION(nsnull != aResult, "null ptr"); - if (nsnull == aResult) { - return NS_ERROR_NULL_POINTER; - } + NS_ENSURE_ARG_POINTER(aResult); *aResult = mWidgetRenderingMode; return NS_OK; } @@ -419,6 +417,22 @@ nsPresContext::SetWidgetRenderingMode(nsWidgetRendering aMode) return NS_OK; } +NS_IMETHODIMP +nsPresContext::GetImageAnimationMode(nsImageAnimation* aModeResult) +{ + NS_ENSURE_ARG_POINTER(aModeResult); + *aModeResult = mImageAnimationMode; + return NS_OK; +} + + +NS_IMETHODIMP +nsPresContext::SetImageAnimationMode(nsImageAnimation aMode) +{ + mImageAnimationMode = aMode; + return NS_OK; +} + NS_IMETHODIMP nsPresContext::GetLookAndFeel(nsILookAndFeel** aLookAndFeel) @@ -862,7 +876,7 @@ nsPresContext::StartLoadImage(const nsString& aURL, } // Allow for a null target frame argument (for precached images) - if (nsnull != aTargetFrame) { + if (aTargetFrame) { // Mark frame as having loaded an image nsFrameState state; aTargetFrame->GetFrameState(&state); @@ -920,7 +934,7 @@ nsPresContext::StartLoadImage(const nsString& aURL, } rv = loader->Init(this, mImageGroup, aURL, aBackgroundColor, aDesiredSize, - aTargetFrame, aCallBack, aClosure); + aTargetFrame, mImageAnimationMode, aCallBack, aClosure); if (NS_OK != rv) { mImageLoaders.RemoveElement(loader); loader->StopImageLoad(); diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index a4e4fee0a59..92c0435bec8 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -122,6 +122,12 @@ public: NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult) = 0; NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode) = 0; + /** + * Access the image animation mode for this context + */ + NS_IMETHOD GetImageAnimationMode(nsImageAnimation* aModeResult) = 0; + NS_IMETHOD SetImageAnimationMode(nsImageAnimation aMode) = 0; + /** * Get look and feel object */ diff --git a/mozilla/layout/base/public/nsIFrameImageLoader.h b/mozilla/layout/base/public/nsIFrameImageLoader.h index 232e73a7cfe..9161cbda426 100644 --- a/mozilla/layout/base/public/nsIFrameImageLoader.h +++ b/mozilla/layout/base/public/nsIFrameImageLoader.h @@ -37,6 +37,12 @@ struct nsSize; #define NS_IFRAME_IMAGE_LOADER_IID \ { 0xa6cf90ec, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} +enum nsImageAnimation { + eImageAnimation_Normal = 0, // looping controlled by image + eImageAnimation_None = 1, // don't loop; just show first frame + eImageAnimation_LoopOnce = 2 // loop just once +}; + // Type of callback function used during image loading. The frame // image loader will invoke this callback as notifications occur from // the image library. @@ -63,6 +69,7 @@ public: const nscolor* aBackgroundColor, const nsSize* aDesiredSize, nsIFrame* aFrame, + nsImageAnimation aAnimationMode, nsIFrameImageLoaderCB aCallBack, void* aClosure) = 0; diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index a4e4fee0a59..92c0435bec8 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.h @@ -122,6 +122,12 @@ public: NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult) = 0; NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode) = 0; + /** + * Access the image animation mode for this context + */ + NS_IMETHOD GetImageAnimationMode(nsImageAnimation* aModeResult) = 0; + NS_IMETHOD SetImageAnimationMode(nsImageAnimation aMode) = 0; + /** * Get look and feel object */ diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index a4e4fee0a59..92c0435bec8 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -122,6 +122,12 @@ public: NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult) = 0; NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode) = 0; + /** + * Access the image animation mode for this context + */ + NS_IMETHOD GetImageAnimationMode(nsImageAnimation* aModeResult) = 0; + NS_IMETHOD SetImageAnimationMode(nsImageAnimation aMode) = 0; + /** * Get look and feel object */ diff --git a/mozilla/layout/base/src/nsFrameImageLoader.cpp b/mozilla/layout/base/src/nsFrameImageLoader.cpp index ac360424104..5da7af58ce6 100644 --- a/mozilla/layout/base/src/nsFrameImageLoader.cpp +++ b/mozilla/layout/base/src/nsFrameImageLoader.cpp @@ -122,6 +122,7 @@ nsFrameImageLoader::Init(nsIPresContext* aPresContext, const nscolor* aBackgroundColor, const nsSize* aDesiredSize, nsIFrame* aTargetFrame, + nsImageAnimation aAnimationMode, nsIFrameImageLoaderCB aCallBack, void* aClosure) { @@ -133,7 +134,7 @@ nsFrameImageLoader::Init(nsIPresContext* aPresContext, if (nsnull != mPresContext) { return NS_ERROR_ALREADY_INITIALIZED; } - + mPresContext = aPresContext; NS_IF_ADDREF(aPresContext); mURL = aURL; diff --git a/mozilla/layout/base/src/nsFrameImageLoader.h b/mozilla/layout/base/src/nsFrameImageLoader.h index e3fa273d08d..191de942c34 100644 --- a/mozilla/layout/base/src/nsFrameImageLoader.h +++ b/mozilla/layout/base/src/nsFrameImageLoader.h @@ -57,6 +57,7 @@ public: const nscolor* aBackgroundColor, const nsSize* aDesiredSize, nsIFrame* aTargetFrame, + nsImageAnimation aAnimationMode, nsIFrameImageLoaderCB aCallBack, void* aClosure); @@ -111,8 +112,8 @@ protected: nsSize mImageSize; - PRUint32 mImageLoadStatus; - nsImageError mImageLoadError; + PRUint32 mImageLoadStatus; + nsImageError mImageLoadError; PRInt32 mNotifyLockCount; diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index a33b7a13070..ceccacf1c78 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -93,7 +93,8 @@ nsPresContext::nsPresContext() mCompatibilityMode = eCompatibility_Standard; mCompatibilityLocked = PR_FALSE; mWidgetRenderingMode = eWidgetRendering_Gfx; - + mImageAnimationMode = eImageAnimation_Normal; + mLookAndFeel = nsnull; mShell = nsnull; @@ -403,10 +404,7 @@ nsPresContext::SetCompatibilityMode(nsCompatibility aMode) NS_IMETHODIMP nsPresContext::GetWidgetRenderingMode(nsWidgetRendering* aResult) { - NS_PRECONDITION(nsnull != aResult, "null ptr"); - if (nsnull == aResult) { - return NS_ERROR_NULL_POINTER; - } + NS_ENSURE_ARG_POINTER(aResult); *aResult = mWidgetRenderingMode; return NS_OK; } @@ -419,6 +417,22 @@ nsPresContext::SetWidgetRenderingMode(nsWidgetRendering aMode) return NS_OK; } +NS_IMETHODIMP +nsPresContext::GetImageAnimationMode(nsImageAnimation* aModeResult) +{ + NS_ENSURE_ARG_POINTER(aModeResult); + *aModeResult = mImageAnimationMode; + return NS_OK; +} + + +NS_IMETHODIMP +nsPresContext::SetImageAnimationMode(nsImageAnimation aMode) +{ + mImageAnimationMode = aMode; + return NS_OK; +} + NS_IMETHODIMP nsPresContext::GetLookAndFeel(nsILookAndFeel** aLookAndFeel) @@ -862,7 +876,7 @@ nsPresContext::StartLoadImage(const nsString& aURL, } // Allow for a null target frame argument (for precached images) - if (nsnull != aTargetFrame) { + if (aTargetFrame) { // Mark frame as having loaded an image nsFrameState state; aTargetFrame->GetFrameState(&state); @@ -920,7 +934,7 @@ nsPresContext::StartLoadImage(const nsString& aURL, } rv = loader->Init(this, mImageGroup, aURL, aBackgroundColor, aDesiredSize, - aTargetFrame, aCallBack, aClosure); + aTargetFrame, mImageAnimationMode, aCallBack, aClosure); if (NS_OK != rv) { mImageLoaders.RemoveElement(loader); loader->StopImageLoad(); diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h index 1f294984cdc..eed3b16f87c 100644 --- a/mozilla/layout/base/src/nsPresContext.h +++ b/mozilla/layout/base/src/nsPresContext.h @@ -66,6 +66,8 @@ public: NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode); NS_IMETHOD GetWidgetRenderingMode(nsWidgetRendering* aModeResult); NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode); + NS_IMETHOD GetImageAnimationMode(nsImageAnimation* aModeResult); + NS_IMETHOD SetImageAnimationMode(nsImageAnimation aMode); NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel); NS_IMETHOD GetBaseURL(nsIURI** aURLResult); NS_IMETHOD GetMedium(nsIAtom** aMediumResult) = 0; @@ -172,11 +174,13 @@ protected: PRUint8 mDefaultBackgroundImageAttachment; nsVoidArray mImageLoaders; nsCOMPtr mEventManager; - nsCompatibility mCompatibilityMode; - PRBool mCompatibilityLocked; - nsWidgetRendering mWidgetRenderingMode; nsCOMPtr mBaseURL; - PRBool mStopped; + nsCompatibility mCompatibilityMode; + PRPackedBool mCompatibilityLocked; + nsWidgetRendering mWidgetRenderingMode; + nsImageAnimation mImageAnimationMode; + PRPackedBool mImageAnimationStopped; // image animation stopped + PRPackedBool mStopped; // loading stopped PRUint8 mDefaultDirection; #ifdef DEBUG