diff --git a/mozilla/content/html/content/src/nsHTMLImageElement.cpp b/mozilla/content/html/content/src/nsHTMLImageElement.cpp
index e85b882736d..17d2d3758b9 100644
--- a/mozilla/content/html/content/src/nsHTMLImageElement.cpp
+++ b/mozilla/content/html/content/src/nsHTMLImageElement.cpp
@@ -1012,7 +1012,7 @@ nsHTMLImageElement::SetSrcInner(nsIURI* aBaseURL,
doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
}
- il->LoadImage(uri, loadGroup, this, sup, getter_AddRefs(mRequest));
+ il->LoadImage(uri, loadGroup, this, sup, nsIRequest::LOAD_NORMAL, getter_AddRefs(mRequest));
#else
if (mLoader) {
mLoader->RemoveFrame(this);
diff --git a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp
index 17f898918f2..b0ca3cf57c0 100644
--- a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp
+++ b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp
@@ -512,7 +512,7 @@ nsXBLPrototypeBinding::LoadResources(PRBool* aResult)
// Now kick off the image load
nsCOMPtr req;
- il->LoadImage(url, nsnull, nsnull, nsnull, getter_AddRefs(req));
+ il->LoadImage(url, nsnull, nsnull, nsnull, nsIRequest::LOAD_BACKGROUND, getter_AddRefs(req));
}
else
#endif
diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp
index 423b65de557..acc45b18553 100644
--- a/mozilla/layout/generic/nsImageFrame.cpp
+++ b/mozilla/layout/generic/nsImageFrame.cpp
@@ -526,7 +526,7 @@ NS_IMETHODIMP nsImageFrame::OnStopDecode(imgIRequest *aRequest, nsIPresContext *
mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::usemap, usemap);
// We failed to load the image. Notify the pres shell if we aren't an image map
if (usemap.IsEmpty()) {
- presShell->CantRenderReplacedElement(aPresContext, this);
+ presShell->CantRenderReplacedElement(aPresContext, this);
}
}
mFailureReplace = PR_TRUE;
@@ -1513,7 +1513,7 @@ nsImageFrame::LoadImage(const nsAReadableString& aSpec, nsIPresContext *aPresCon
/* set this back to FALSE before we do the real load */
mInitialLoadCompleted = PR_FALSE;
- return il->LoadImage(uri, loadGroup, mListener, aPresContext, aRequest);
+ return il->LoadImage(uri, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, aRequest);
}
#define INTERNAL_GOPHER_LENGTH 16 /* "internal-gopher-" length */
diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp
index 423b65de557..acc45b18553 100644
--- a/mozilla/layout/html/base/src/nsImageFrame.cpp
+++ b/mozilla/layout/html/base/src/nsImageFrame.cpp
@@ -526,7 +526,7 @@ NS_IMETHODIMP nsImageFrame::OnStopDecode(imgIRequest *aRequest, nsIPresContext *
mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::usemap, usemap);
// We failed to load the image. Notify the pres shell if we aren't an image map
if (usemap.IsEmpty()) {
- presShell->CantRenderReplacedElement(aPresContext, this);
+ presShell->CantRenderReplacedElement(aPresContext, this);
}
}
mFailureReplace = PR_TRUE;
@@ -1513,7 +1513,7 @@ nsImageFrame::LoadImage(const nsAReadableString& aSpec, nsIPresContext *aPresCon
/* set this back to FALSE before we do the real load */
mInitialLoadCompleted = PR_FALSE;
- return il->LoadImage(uri, loadGroup, mListener, aPresContext, aRequest);
+ return il->LoadImage(uri, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, aRequest);
}
#define INTERNAL_GOPHER_LENGTH 16 /* "internal-gopher-" length */
diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp
index c7a1244b34c..d03ab67eefd 100644
--- a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp
+++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp
@@ -286,7 +286,7 @@ nsImageBoxFrame::UpdateImage(nsIPresContext* aPresContext, PRBool& aResize)
nsCOMPtr loadGroup;
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
- il->LoadImage(srcURI, loadGroup, mListener, aPresContext, getter_AddRefs(mImageRequest));
+ il->LoadImage(srcURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(mImageRequest));
aResize = PR_TRUE;
diff --git a/mozilla/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp b/mozilla/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp
index b487db03cfd..1d61016578b 100644
--- a/mozilla/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp
+++ b/mozilla/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp
@@ -1305,7 +1305,7 @@ nsOutlinerBodyFrame::GetImage(PRInt32 aRowIndex, const PRUnichar* aColID,
nsresult rv;
nsCOMPtr il(do_GetService("@mozilla.org/image/loader;1", &rv));
- il->LoadImage(srcURI, nsnull, listener, mPresContext, getter_AddRefs(imageRequest));
+ il->LoadImage(srcURI, nsnull, listener, mPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(imageRequest));
if (!mImageCache) {
mImageCache = new nsSupportsHashtable(32);
diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
index b487db03cfd..1d61016578b 100644
--- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -1305,7 +1305,7 @@ nsOutlinerBodyFrame::GetImage(PRInt32 aRowIndex, const PRUnichar* aColID,
nsresult rv;
nsCOMPtr il(do_GetService("@mozilla.org/image/loader;1", &rv));
- il->LoadImage(srcURI, nsnull, listener, mPresContext, getter_AddRefs(imageRequest));
+ il->LoadImage(srcURI, nsnull, listener, mPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(imageRequest));
if (!mImageCache) {
mImageCache = new nsSupportsHashtable(32);
diff --git a/mozilla/modules/libpr0n/decoders/png/nsPNGDecoder.cpp b/mozilla/modules/libpr0n/decoders/png/nsPNGDecoder.cpp
index 8fce1a459f9..96d56a68a85 100644
--- a/mozilla/modules/libpr0n/decoders/png/nsPNGDecoder.cpp
+++ b/mozilla/modules/libpr0n/decoders/png/nsPNGDecoder.cpp
@@ -142,7 +142,7 @@ static NS_METHOD ReadDataOut(nsIInputStream* in,
// we need to do the setjmp here otherwise bad things will happen
if (setjmp(decoder->mPNG->jmpbuf)) {
png_destroy_read_struct(&decoder->mPNG, &decoder->mInfo, NULL);
-
+ *writeCount = 0;
return NS_ERROR_FAILURE;
}
diff --git a/mozilla/modules/libpr0n/public/imgILoader.idl b/mozilla/modules/libpr0n/public/imgILoader.idl
index bd3585678b2..8fa8f472871 100644
--- a/mozilla/modules/libpr0n/public/imgILoader.idl
+++ b/mozilla/modules/libpr0n/public/imgILoader.idl
@@ -34,11 +34,13 @@ interface nsIURI;
interface nsISimpleEnumerator;
+#include "nsIRequest.idl" // for nsLoadFlags
+
/**
* imgILoader interface
*
* @author Stuart Parmenter
- * @version 0.1
+ * @version 0.2
* @see imagelib2
*/
[scriptable, uuid(4c8cf1e0-1dd2-11b2-aff9-c51cdbfcb6da)]
@@ -46,11 +48,13 @@ interface imgILoader : nsISupports
{
/**
* Start the load and decode of an image.
- * @param uri the URI to load
+ * @param aURI the URI to load
+ * @param aLoadGroup Loadgroup to put the image load into
* @param aObserver the observer
- * @param cx some random data
+ * @param aCX some random data
+ * @param aLoadFlags Load flags for the request
*/
- imgIRequest loadImage(in nsIURI uri, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports cx);
+ imgIRequest loadImage(in nsIURI aURI, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports aCX, in nsLoadFlags aLoadFlags);
/**
* Start the load and decode of an image.
diff --git a/mozilla/modules/libpr0n/src/imgLoader.cpp b/mozilla/modules/libpr0n/src/imgLoader.cpp
index dae4cf762dc..b81a81d4b47 100644
--- a/mozilla/modules/libpr0n/src/imgLoader.cpp
+++ b/mozilla/modules/libpr0n/src/imgLoader.cpp
@@ -58,8 +58,10 @@ imgLoader::~imgLoader()
/* destructor code */
}
-/* imgIRequest loadImage (in nsIURI uri, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports cx); */
-NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgIDecoderObserver *aObserver, nsISupports *cx, imgIRequest **_retval)
+#define SHOULD_RELOAD(flags) (flags & nsIRequest::LOAD_BYPASS_CACHE || flags & nsIRequest::VALIDATE_ALWAYS)
+
+/* imgIRequest loadImage (in nsIURI aURI, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports aCX, in nsLoadFlags aLoadFlags); */
+NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgIDecoderObserver *aObserver, nsISupports *aCX, nsLoadFlags aLoadFlags, imgIRequest **_retval)
{
NS_ASSERTION(aURI, "imgLoader::LoadImage -- NULL URI pointer");
@@ -77,24 +79,30 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgID
nsCOMPtr entry;
imgCache::Get(aURI, &request, getter_AddRefs(entry)); // addrefs request
- if (request && entry && aLoadGroup) {
+ if (request && entry) {
/* this isn't exactly what I want here. This code will re-doom every
cache hit in a document while it is force reloading. So for multiple
copies of an image on a page, when you force reload, this will cause
you to get seperate loads for each copy of the image... this sucks.
*/
- PRUint32 flags = 0;
PRBool doomRequest = PR_FALSE;
- aLoadGroup->GetLoadFlags(&flags);
- if (flags & nsIRequest::LOAD_BYPASS_CACHE || flags & nsIRequest::VALIDATE_ALWAYS)
+
+ if (SHOULD_RELOAD(aLoadFlags)) {
doomRequest = PR_TRUE;
- else {
- nsCOMPtr r;
- aLoadGroup->GetDefaultLoadRequest(getter_AddRefs(r));
- if (r) {
- r->GetLoadFlags(&flags);
- if (flags & nsIRequest::LOAD_BYPASS_CACHE || flags & nsIRequest::VALIDATE_ALWAYS)
- doomRequest = PR_TRUE;
+ } else if (aLoadGroup) {
+ nsLoadFlags flags = 0;
+ aLoadGroup->GetLoadFlags(&flags);
+ if (SHOULD_RELOAD(flags)) {
+ doomRequest = PR_TRUE;
+ } else {
+ nsCOMPtr r;
+ aLoadGroup->GetDefaultLoadRequest(getter_AddRefs(r));
+ if (r) {
+ flags = 0;
+ r->GetLoadFlags(&flags);
+ if (SHOULD_RELOAD(flags))
+ doomRequest = PR_TRUE;
+ }
}
}
@@ -185,7 +193,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgID
LOG_MSG(gImgLog, "imgLoader::LoadImage", "async open failed.");
nsresult rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver,
- cx, _retval);
+ aCX, aLoadFlags, _retval);
if (NS_SUCCEEDED(rv)) {
request->OnStartRequest(newChannel, nsnull);
request->OnStopRequest(newChannel, nsnull, NS_BINDING_ABORTED);
@@ -203,13 +211,15 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgID
LOG_MSG(gImgLog, "imgLoader::LoadImage", "creating proxy request.");
- nsresult rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver, cx, _retval);
+ nsresult rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver, aCX, aLoadFlags, _retval);
NS_RELEASE(request);
return rv;
}
+#undef SHOULD_RELOAD
+
/* imgIRequest loadImageWithChannel(in nsIChannel, in imgIDecoderObserver aObserver, in nsISupports cx, out nsIStreamListener); */
NS_IMETHODIMP imgLoader::LoadImageWithChannel(nsIChannel *channel, imgIDecoderObserver *aObserver, nsISupports *cx, nsIStreamListener **listener, imgIRequest **_retval)
{
@@ -259,7 +269,7 @@ NS_IMETHODIMP imgLoader::LoadImageWithChannel(nsIChannel *channel, imgIDecoderOb
nsCOMPtr loadGroup;
channel->GetLoadGroup(getter_AddRefs(loadGroup));
- nsresult rv = CreateNewProxyForRequest(request, loadGroup, aObserver, cx, _retval);
+ nsresult rv = CreateNewProxyForRequest(request, loadGroup, aObserver, cx, nsIRequest::LOAD_NORMAL, _retval);
NS_RELEASE(request);
@@ -271,14 +281,14 @@ NS_IMETHODIMP imgLoader::LoadImageWithChannel(nsIChannel *channel, imgIDecoderOb
nsresult
imgLoader::CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup *aLoadGroup,
imgIDecoderObserver *aObserver, nsISupports *cx,
- imgIRequest **_retval)
+ nsLoadFlags aLoadFlags, imgIRequest **_retval)
{
LOG_SCOPE_WITH_PARAM(gImgLog, "imgLoader::CreateNewProxyForRequest", "imgRequest", aRequest);
/* XXX If we move decoding onto seperate threads, we should save off the
calling thread here and pass it off to |proxyRequest| so that it call
proxy calls to |aObserver|.
- */
+ */
imgRequestProxy *proxyRequest;
NS_NEWXPCOM(proxyRequest, imgRequestProxy);
@@ -286,6 +296,11 @@ imgLoader::CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup *aLoadGro
NS_ADDREF(proxyRequest);
+ /* It is important to call |SetLoadFlags()| before calling |Init()| because
+ |Init()| adds the request to the loadgroup.
+ */
+ proxyRequest->SetLoadFlags(aLoadFlags);
+
// init adds itself to imgRequest's list of observers
nsresult rv = proxyRequest->Init(aRequest, aLoadGroup, aObserver, cx);
if (NS_FAILED(rv)) {
diff --git a/mozilla/modules/libpr0n/src/imgLoader.h b/mozilla/modules/libpr0n/src/imgLoader.h
index 69ca516a041..f575a3657f1 100644
--- a/mozilla/modules/libpr0n/src/imgLoader.h
+++ b/mozilla/modules/libpr0n/src/imgLoader.h
@@ -52,7 +52,7 @@ public:
private:
nsresult CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup *aLoadGroup,
imgIDecoderObserver *aObserver, nsISupports *cx,
- imgIRequest **_retval);
+ nsLoadFlags aLoadFlags, imgIRequest **_retval);
};
diff --git a/mozilla/modules/libpr0n/src/imgRequestProxy.cpp b/mozilla/modules/libpr0n/src/imgRequestProxy.cpp
index cad6167ec33..f301cc43814 100644
--- a/mozilla/modules/libpr0n/src/imgRequestProxy.cpp
+++ b/mozilla/modules/libpr0n/src/imgRequestProxy.cpp
@@ -47,6 +47,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS5(imgRequestProxy, imgIRequest, nsIRequest,
nsIRequestObserver)
imgRequestProxy::imgRequestProxy() :
+ mLoadFlags(nsIRequest::LOAD_NORMAL),
mCanceled(PR_FALSE),
mLock(nsnull)
{
@@ -200,12 +201,13 @@ NS_IMETHODIMP imgRequestProxy::SetLoadGroup(nsILoadGroup *loadGroup)
/* attribute nsLoadFlags loadFlags */
NS_IMETHODIMP imgRequestProxy::GetLoadFlags(nsLoadFlags *flags)
{
- *flags = nsIRequest::LOAD_NORMAL;
+ *flags = mLoadFlags;
return NS_OK;
}
NS_IMETHODIMP imgRequestProxy::SetLoadFlags(nsLoadFlags flags)
{
- return NS_OK;
+ mLoadFlags = flags;
+ return NS_OK;
}
/** imgIRequest methods **/
diff --git a/mozilla/modules/libpr0n/src/imgRequestProxy.h b/mozilla/modules/libpr0n/src/imgRequestProxy.h
index d8513ad1fc9..49979e38778 100644
--- a/mozilla/modules/libpr0n/src/imgRequestProxy.h
+++ b/mozilla/modules/libpr0n/src/imgRequestProxy.h
@@ -67,6 +67,7 @@ private:
nsCOMPtr mLoadGroup;
+ nsLoadFlags mLoadFlags;
PRBool mCanceled;
PRLock *mLock;