Bug 794884. Make SupportImageWithMimeType a static function. r=joe,r=bz

This removes supportImageWithMimeType from the idl and makes all the
callers call the static function directly. To do this we also need
to export imgLoader.h and imgRequest.h.
---
 content/base/src/nsObjectLoadingContent.cpp |    9 ++-------
 docshell/base/nsWebNavigationInfo.cpp       |    8 +++++---
 docshell/base/nsWebNavigationInfo.h         |    5 -----
 image/public/imgILoader.idl                 |    9 +--------
 image/src/Makefile.in                       |    4 ++++
 image/src/imgLoader.cpp                     |    2 +-
 image/src/imgLoader.h                       |    1 +
 layout/build/nsContentDLF.cpp               |    5 ++---
 8 files changed, 16 insertions(+), 27 deletions(-)
This commit is contained in:
Jeff Muizelaar 2012-10-03 16:17:40 -04:00
Родитель 41c47cc70c
Коммит bd55aae8e0
8 изменённых файлов: 16 добавлений и 27 удалений

Просмотреть файл

@ -11,7 +11,7 @@
*/
// Interface headers
#include "imgILoader.h"
#include "imgLoader.h"
#include "nsEventDispatcher.h"
#include "nsIContent.h"
#include "nsIDocShell.h"
@ -477,13 +477,8 @@ URIEquals(nsIURI *a, nsIURI *b)
static bool
IsSupportedImage(const nsCString& aMimeType)
{
nsCOMPtr<imgILoader> loader = nsContentUtils::GetImgLoaderForChannel(nullptr);
if (!loader) {
return false;
}
bool supported;
nsresult rv = loader->SupportImageWithMimeType(aMimeType.get(), &supported);
nsresult rv = imgLoader::SupportImageWithMimeType(aMimeType.get(), &supported);
return NS_SUCCEEDED(rv) && supported;
}

Просмотреть файл

@ -10,6 +10,7 @@
#include "nsIDocumentLoaderFactory.h"
#include "nsIPluginHost.h"
#include "nsContentUtils.h"
#include "imgLoader.h"
NS_IMPL_ISUPPORTS1(nsWebNavigationInfo, nsIWebNavigationInfo)
@ -24,8 +25,6 @@ nsWebNavigationInfo::Init()
mCategoryManager = do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mImgLoader = nsContentUtils::GetImgLoaderForChannel(nullptr);
return NS_OK;
}
@ -97,8 +96,11 @@ nsWebNavigationInfo::IsTypeSupportedInternal(const nsCString& aType,
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;
mImgLoader->SupportImageWithMimeType(aType.get(), &isImage);
imgLoader::SupportImageWithMimeType(aType.get(), &isImage);
if (isImage) {
*aIsSupported = nsIWebNavigationInfo::IMAGE;
}

Просмотреть файл

@ -9,7 +9,6 @@
#include "nsIWebNavigationInfo.h"
#include "nsCOMPtr.h"
#include "nsICategoryManager.h"
#include "imgILoader.h"
#include "nsStringFwd.h"
#include "mozilla/Attributes.h"
@ -37,10 +36,6 @@ private:
uint32_t* aIsSupported);
nsCOMPtr<nsICategoryManager> mCategoryManager;
// XXXbz we only need this because images register for the same
// contractid as documents, so we can't tell them apart based on
// contractid.
nsCOMPtr<imgILoader> mImgLoader;
};
#endif // nsWebNavigationInfo_h__

Просмотреть файл

@ -27,7 +27,7 @@ interface nsIChannelPolicy;
* @version 0.3
* @see imagelib2
*/
[scriptable, uuid(20a5e3e9-0d5b-482c-9f41-942b5f19e5a3)]
[scriptable, uuid(f5a7c016-8caf-460a-b1a1-3fe5534d5c9e)]
interface imgILoader : nsISupports
{
// Extra flags to pass to loadImage if you want a load to use CORS
@ -89,11 +89,4 @@ interface imgILoader : nsISupports
in imgIDecoderObserver aObserver,
in nsISupports cx,
out nsIStreamListener aListener);
/**
* Checks if a decoder for the an image with the given mime type is available
* @param mimeType The type to find a decoder for
* @return true if a decoder is available, false otherwise
*/
boolean supportImageWithMimeType(in string mimeType);
};

Просмотреть файл

@ -18,6 +18,10 @@ GRE_MODULE = 1
LIBXUL_LIBRARY = 1
EXPORTS = imgLoader.h \
imgRequest.h \
$(NULL)
CPPSRCS = \
Image.cpp \
Decoder.cpp \

Просмотреть файл

@ -1921,7 +1921,7 @@ NS_IMETHODIMP imgLoader::LoadImageWithChannel(nsIChannel *channel, imgIDecoderOb
return rv;
}
NS_IMETHODIMP imgLoader::SupportImageWithMimeType(const char* aMimeType, bool *_retval)
nsresult imgLoader::SupportImageWithMimeType(const char* aMimeType, bool *_retval)
{
*_retval = false;
nsAutoCString mimeType(aMimeType);

Просмотреть файл

@ -226,6 +226,7 @@ public:
nsresult Init();
static nsresult GetMimeTypeFromContent(const char* aContents, uint32_t aLength, nsACString& aContentType);
static nsresult SupportImageWithMimeType(const char* aMimeType, bool *_retval);
static void GlobalInit(); // for use by the factory
static void Shutdown(); // for use by the factory

Просмотреть файл

@ -27,7 +27,7 @@
#include "nsHTMLMediaElement.h"
#endif
#include "nsContentUtils.h"
#include "imgILoader.h"
#include "imgLoader.h"
#include "nsCharsetSource.h"
#include "nsMimeTypes.h"
@ -462,8 +462,7 @@ nsContentDLF::CreateXULDocument(const char* aCommand,
}
bool nsContentDLF::IsImageContentType(const char* aContentType) {
nsCOMPtr<imgILoader> loader(do_CreateInstance("@mozilla.org/image/loader;1"));
bool isDecoderAvailable = false;
loader->SupportImageWithMimeType(aContentType, &isDecoderAvailable);
imgLoader::SupportImageWithMimeType(aContentType, &isDecoderAvailable);
return isDecoderAvailable;
}