Changed GetLoadImageFailed() so it checks with the image loader rather

than just using the value of mLoadImageFailed. Fixes bug #1287
This commit is contained in:
troy%netscape.com 1998-11-13 21:31:50 +00:00
parent d28f4a59b4
commit 87eff9d2bf
3 changed files with 57 additions and 13 deletions

View File

@ -45,7 +45,9 @@
#include "nsIDOMHTMLImageElement.h"
#include "nsIDeviceContext.h"
#ifndef _WIN32
#define BROKEN_IMAGE_URL "resource:/res/html/broken-image.gif"
#endif
#define XP_IS_SPACE(_ch) \
(((_ch) == ' ') || ((_ch) == '\t') || ((_ch) == '\n'))
@ -68,7 +70,9 @@ nsHTMLImageLoader::nsHTMLImageLoader()
{
mImageLoader = nsnull;
mLoadImageFailed = PR_FALSE;
#ifndef _WIN32
mLoadBrokenImageFailed = PR_FALSE;
#endif
mURLSpec = nsnull;
mBaseHREF = nsnull;
}
@ -189,21 +193,21 @@ nsHTMLImageLoader::StartLoadImage(nsIPresContext* aPresContext,
mImageLoader->GetImageLoadStatus(aLoadStatus);
if (0 != (aLoadStatus & NS_IMAGE_LOAD_STATUS_ERROR)) {
NS_RELEASE(mImageLoader);
#ifdef _WIN32
// Display broken icon along with alt-text
mLoadImageFailed = PR_TRUE;
#else
if (mLoadImageFailed) {
// We are doomed. Loading the broken image has just failed.
mLoadBrokenImageFailed = PR_TRUE;
}
else {
#ifdef _WIN32
// Display broken icon along with alt-text
mLoadImageFailed = PR_TRUE;
#else
// Try again, this time using the broke-image url
mLoadImageFailed = PR_TRUE;
return StartLoadImage(aPresContext, aForFrame, nsnull,
aNeedSizeUpdate, aLoadStatus);
#endif
}
#endif
}
return NS_OK;
}
@ -288,6 +292,23 @@ nsHTMLImageLoader::GetDesiredSize(nsIPresContext* aPresContext,
}
}
PRBool
nsHTMLImageLoader::GetLoadImageFailed() const
{
PRBool result = PR_FALSE;
if (nsnull != mImageLoader) {
PRIntn loadStatus;
// Ask the image loader whether the load failed
mImageLoader->GetImageLoadStatus(loadStatus);
result = (loadStatus & NS_IMAGE_LOAD_STATUS_ERROR) == NS_IMAGE_LOAD_STATUS_ERROR;
}
result |= PRBool(mLoadImageFailed);
return result;
}
//----------------------------------------------------------------------
nsresult

View File

@ -45,7 +45,9 @@ public:
void DestroyLoader() {
NS_IF_RELEASE(mImageLoader);
mLoadImageFailed = PR_FALSE;
#ifndef _WIN32
mLoadBrokenImageFailed = PR_FALSE;
#endif
}
nsIImage* GetImage();
@ -79,16 +81,16 @@ public:
nsFrameImageLoaderCB aCallBack,
nsHTMLReflowMetrics& aDesiredSize);
PRBool GetLoadImageFailed() {
return mLoadImageFailed;
}
PRBool GetLoadImageFailed() const;
void SizeOf(nsISizeOfHandler* aHandler) const;
protected:
nsIFrameImageLoader* mImageLoader;
PRPackedBool mLoadImageFailed;
#ifndef _WIN32
PRPackedBool mLoadBrokenImageFailed;
#endif
nsString* mURLSpec;
nsString* mBaseHREF;
};

View File

@ -45,7 +45,9 @@
#include "nsIDOMHTMLImageElement.h"
#include "nsIDeviceContext.h"
#ifndef _WIN32
#define BROKEN_IMAGE_URL "resource:/res/html/broken-image.gif"
#endif
#define XP_IS_SPACE(_ch) \
(((_ch) == ' ') || ((_ch) == '\t') || ((_ch) == '\n'))
@ -68,7 +70,9 @@ nsHTMLImageLoader::nsHTMLImageLoader()
{
mImageLoader = nsnull;
mLoadImageFailed = PR_FALSE;
#ifndef _WIN32
mLoadBrokenImageFailed = PR_FALSE;
#endif
mURLSpec = nsnull;
mBaseHREF = nsnull;
}
@ -189,21 +193,21 @@ nsHTMLImageLoader::StartLoadImage(nsIPresContext* aPresContext,
mImageLoader->GetImageLoadStatus(aLoadStatus);
if (0 != (aLoadStatus & NS_IMAGE_LOAD_STATUS_ERROR)) {
NS_RELEASE(mImageLoader);
#ifdef _WIN32
// Display broken icon along with alt-text
mLoadImageFailed = PR_TRUE;
#else
if (mLoadImageFailed) {
// We are doomed. Loading the broken image has just failed.
mLoadBrokenImageFailed = PR_TRUE;
}
else {
#ifdef _WIN32
// Display broken icon along with alt-text
mLoadImageFailed = PR_TRUE;
#else
// Try again, this time using the broke-image url
mLoadImageFailed = PR_TRUE;
return StartLoadImage(aPresContext, aForFrame, nsnull,
aNeedSizeUpdate, aLoadStatus);
#endif
}
#endif
}
return NS_OK;
}
@ -288,6 +292,23 @@ nsHTMLImageLoader::GetDesiredSize(nsIPresContext* aPresContext,
}
}
PRBool
nsHTMLImageLoader::GetLoadImageFailed() const
{
PRBool result = PR_FALSE;
if (nsnull != mImageLoader) {
PRIntn loadStatus;
// Ask the image loader whether the load failed
mImageLoader->GetImageLoadStatus(loadStatus);
result = (loadStatus & NS_IMAGE_LOAD_STATUS_ERROR) == NS_IMAGE_LOAD_STATUS_ERROR;
}
result |= PRBool(mLoadImageFailed);
return result;
}
//----------------------------------------------------------------------
nsresult