WIP for bug 33810 -- add an image animation enum, and getters and setters in the pres context

This commit is contained in:
sfraser%netscape.com 2000-05-13 01:39:20 +00:00
Родитель 04f021dd02
Коммит fc44f5f04b
9 изменённых файлов: 80 добавлений и 21 удалений

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

@ -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();

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

@ -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
*/

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

@ -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;

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

@ -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
*/

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

@ -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
*/

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

@ -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;

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

@ -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;

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

@ -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();

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

@ -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<nsIEventStateManager> mEventManager;
nsCompatibility mCompatibilityMode;
PRBool mCompatibilityLocked;
nsWidgetRendering mWidgetRenderingMode;
nsCOMPtr<nsIURI> mBaseURL;
PRBool mStopped;
nsCompatibility mCompatibilityMode;
PRPackedBool mCompatibilityLocked;
nsWidgetRendering mWidgetRenderingMode;
nsImageAnimation mImageAnimationMode;
PRPackedBool mImageAnimationStopped; // image animation stopped
PRPackedBool mStopped; // loading stopped
PRUint8 mDefaultDirection;
#ifdef DEBUG