Bug 794884. Make SupportImageWithMimeType return a bool. r=joe.
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Wed, 03 Oct 2012 16:17:47 -0400
changeset 109225 9a71c92af5a43c44baf8975e8163b5c170f505d8
parent 109224 bc14486d074234e024f314abe52ecb90e6910a1a
child 109226 9737260d16470434ce722c7c15f8e1e56562db77
child 109229 14fe82a53d68c7be9e6042e8971fddd6ebbf5e76
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersjoe
bugs794884
milestone18.0a1
Bug 794884. Make SupportImageWithMimeType return a bool. r=joe. This cleans things up quite a bit. --- content/base/src/nsObjectLoadingContent.cpp | 4 +--- docshell/base/nsWebNavigationInfo.cpp | 4 +--- image/src/imgLoader.cpp | 7 ++----- image/src/imgLoader.h | 2 +- layout/build/nsContentDLF.cpp | 4 +--- 5 files changed, 6 insertions(+), 15 deletions(-)
content/base/src/nsObjectLoadingContent.cpp
docshell/base/nsWebNavigationInfo.cpp
image/src/imgLoader.cpp
image/src/imgLoader.h
layout/build/nsContentDLF.cpp
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -472,19 +472,17 @@ URIEquals(nsIURI *a, nsIURI *b)
 {
   bool equal;
   return (!a && !b) || (a && b && NS_SUCCEEDED(a->Equals(b, &equal)) && equal);
 }
 
 static bool
 IsSupportedImage(const nsCString& aMimeType)
 {
-  bool supported;
-  nsresult rv = imgLoader::SupportImageWithMimeType(aMimeType.get(), &supported);
-  return NS_SUCCEEDED(rv) && supported;
+  return imgLoader::SupportImageWithMimeType(aMimeType.get());
 }
 
 static void
 GetExtensionFromURI(nsIURI* uri, nsCString& ext)
 {
   nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
   if (url) {
     url->GetFileExtension(ext);
--- a/docshell/base/nsWebNavigationInfo.cpp
+++ b/docshell/base/nsWebNavigationInfo.cpp
@@ -94,19 +94,17 @@ nsWebNavigationInfo::IsTypeSupportedInte
   case nsContentUtils::TYPE_UNKNOWN:
     *aIsSupported = nsIWebNavigationInfo::OTHER;
     break;
 
   case nsContentUtils::TYPE_CONTENT:
     // XXXbz we only need this because images register for the same
     // contractid as documents, so we can't tell them apart based on
     // contractid.
-    bool isImage = false;
-    imgLoader::SupportImageWithMimeType(aType.get(), &isImage);
-    if (isImage) {
+    if (imgLoader::SupportImageWithMimeType(aType.get())) {
       *aIsSupported = nsIWebNavigationInfo::IMAGE;
     }
     else {
       *aIsSupported = nsIWebNavigationInfo::OTHER;
     }
     break;
   }
 
--- a/image/src/imgLoader.cpp
+++ b/image/src/imgLoader.cpp
@@ -1916,24 +1916,21 @@ NS_IMETHODIMP imgLoader::LoadImageWithCh
     // and we can't make it further asynchronous because observers might rely
     // on imagelib completing its work between the channel's OnStartRequest and
     // OnStopRequest.
   }
 
   return rv;
 }
 
-nsresult imgLoader::SupportImageWithMimeType(const char* aMimeType, bool *_retval)
+bool imgLoader::SupportImageWithMimeType(const char* aMimeType)
 {
-  *_retval = false;
   nsAutoCString mimeType(aMimeType);
   ToLowerCase(mimeType);
-  *_retval = (Image::GetDecoderType(mimeType.get()) == Image::eDecoderType_unknown)
-    ? false : true;
-  return NS_OK;
+  return Image::GetDecoderType(mimeType.get()) != Image::eDecoderType_unknown;
 }
 
 NS_IMETHODIMP imgLoader::GetMIMETypeFromContent(nsIRequest* aRequest,
                                                 const uint8_t* aContents,
                                                 uint32_t aLength,
                                                 nsACString& aContentType)
 {
   return GetMimeTypeFromContent((const char*)aContents, aLength, aContentType);
--- a/image/src/imgLoader.h
+++ b/image/src/imgLoader.h
@@ -221,17 +221,17 @@ public:
   NS_DECL_NSIOBSERVER
 
   imgLoader();
   virtual ~imgLoader();
 
   nsresult Init();
 
   static nsresult GetMimeTypeFromContent(const char* aContents, uint32_t aLength, nsACString& aContentType);
-  static nsresult SupportImageWithMimeType(const char* aMimeType, bool *_retval);
+  static bool SupportImageWithMimeType(const char* aMimeType);
 
   static void GlobalInit(); // for use by the factory
   static void Shutdown(); // for use by the factory
 
   nsresult ClearChromeImageCache();
   nsresult ClearImageCache();
   void MinimizeCaches();
 
--- a/layout/build/nsContentDLF.cpp
+++ b/layout/build/nsContentDLF.cpp
@@ -457,12 +457,10 @@ nsContentDLF::CreateXULDocument(const ch
    * Bind the document to the Content Viewer...
    */
   rv = contentViewer->LoadStart(doc);
   contentViewer.forget(aContentViewer);
   return rv;
 }
 
 bool nsContentDLF::IsImageContentType(const char* aContentType) {
-  bool isDecoderAvailable = false;
-  imgLoader::SupportImageWithMimeType(aContentType, &isDecoderAvailable);
-  return isDecoderAvailable;
+  return imgLoader::SupportImageWithMimeType(aContentType);
 }