From 03597ef9591bd0978fe11902936937022c3955dc Mon Sep 17 00:00:00 2001 From: "pavlov%netscape.com" Date: Fri, 24 May 2002 20:54:44 +0000 Subject: [PATCH] checking in fix for topcrash bug 145147. r=bienvenu sr=mscott --- modules/libpr0n/src/imgLoader.cpp | 6 ++++++ modules/libpr0n/src/imgLoader.h | 2 ++ modules/libpr0n/src/imgRequest.cpp | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/libpr0n/src/imgLoader.cpp b/modules/libpr0n/src/imgLoader.cpp index 384a3b4b819..b6aa60c65fe 100644 --- a/modules/libpr0n/src/imgLoader.cpp +++ b/modules/libpr0n/src/imgLoader.cpp @@ -541,6 +541,12 @@ NS_IMETHODIMP imgLoader::SupportImageWithMimeType(const char* aMimeType, PRBool } NS_IMETHODIMP imgLoader::SupportImageWithContents(const char* aContents, PRUint32 aLength, char** aContentType) +{ + return GetMimeTypeFromContent(aContents, aLength, aContentType); +} + +/* static */ +nsresult imgLoader::GetMimeTypeFromContent(const char* aContents, PRUint32 aLength, char** aContentType) { *aContentType = nsnull; /* Is it a GIF? */ diff --git a/modules/libpr0n/src/imgLoader.h b/modules/libpr0n/src/imgLoader.h index f738c5a1a70..e096c4b67e6 100644 --- a/modules/libpr0n/src/imgLoader.h +++ b/modules/libpr0n/src/imgLoader.h @@ -50,6 +50,8 @@ public: imgLoader(); virtual ~imgLoader(); + static nsresult GetMimeTypeFromContent(const char* aContents, PRUint32 aLength, char** aContentType); + private: nsresult CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup *aLoadGroup, imgIDecoderObserver *aObserver, nsISupports *cx, diff --git a/modules/libpr0n/src/imgRequest.cpp b/modules/libpr0n/src/imgRequest.cpp index ccf8fa05c56..e5cf9a46bf5 100644 --- a/modules/libpr0n/src/imgRequest.cpp +++ b/modules/libpr0n/src/imgRequest.cpp @@ -23,6 +23,7 @@ #include "imgRequest.h" +#include "imgLoader.h" #include "imgCache.h" #include "imgRequestProxy.h" @@ -783,6 +784,5 @@ static NS_METHOD sniff_mimetype_callback(nsIInputStream* in, void imgRequest::SniffMimeType(const char *buf, PRUint32 len) { - nsCOMPtr loader(do_GetService("@mozilla.org/image/loader;1")); - loader->SupportImageWithContents(buf, len, getter_Copies(mContentType)); + imgLoader::GetMimeTypeFromContent(buf, len, getter_Copies(mContentType)); }