From 87eff9d2bf2f2b9ac4558ef192cd6714751a6db7 Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Fri, 13 Nov 1998 21:31:50 +0000 Subject: [PATCH] Changed GetLoadImageFailed() so it checks with the image loader rather than just using the value of mLoadImageFailed. Fixes bug #1287 --- layout/generic/nsImageFrame.cpp | 31 ++++++++++++++++++++++----- layout/html/base/src/nsHTMLImage.h | 8 ++++--- layout/html/base/src/nsImageFrame.cpp | 31 ++++++++++++++++++++++----- 3 files changed, 57 insertions(+), 13 deletions(-) diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 71318af99028..603c0108931a 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -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 diff --git a/layout/html/base/src/nsHTMLImage.h b/layout/html/base/src/nsHTMLImage.h index 1dc3e00ff8dd..e21d1e4878c8 100644 --- a/layout/html/base/src/nsHTMLImage.h +++ b/layout/html/base/src/nsHTMLImage.h @@ -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; }; diff --git a/layout/html/base/src/nsImageFrame.cpp b/layout/html/base/src/nsImageFrame.cpp index 71318af99028..603c0108931a 100644 --- a/layout/html/base/src/nsImageFrame.cpp +++ b/layout/html/base/src/nsImageFrame.cpp @@ -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