michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_IMAGELIB_IMAGEFACTORY_H_ michael@0: #define MOZILLA_IMAGELIB_IMAGEFACTORY_H_ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsProxyRelease.h" michael@0: michael@0: class nsCString; michael@0: class nsIRequest; michael@0: class imgStatusTracker; michael@0: michael@0: namespace mozilla { michael@0: namespace image { michael@0: michael@0: class Image; michael@0: class ImageURL; michael@0: michael@0: class ImageFactory michael@0: { michael@0: public: michael@0: /** michael@0: * Registers vars with Preferences. Should only be called on the main thread. michael@0: */ michael@0: static void Initialize(); michael@0: michael@0: /** michael@0: * Determines whether it's safe to retarget OnDataAvailable for an image. michael@0: * michael@0: * @param aURI The URI of the image. michael@0: * @param aIsMultipart Whether the image is part of a multipart request. michael@0: */ michael@0: static bool CanRetargetOnDataAvailable(ImageURL* aURI, bool aIsMultiPart); michael@0: michael@0: /** michael@0: * Creates a new image with the given properties. michael@0: * Can be called on or off the main thread. michael@0: * michael@0: * @param aRequest The associated request. michael@0: * @param aStatusTracker A status tracker for the image to use. michael@0: * @param aMimeType The mimetype of the image. michael@0: * @param aURI The URI of the image. michael@0: * @param aIsMultiPart Whether the image is part of a multipart request. michael@0: * @param aInnerWindowId The window this image belongs to. michael@0: */ michael@0: static already_AddRefed CreateImage(nsIRequest* aRequest, michael@0: imgStatusTracker* aStatusTracker, michael@0: const nsCString& aMimeType, michael@0: ImageURL* aURI, michael@0: bool aIsMultiPart, michael@0: uint32_t aInnerWindowId); michael@0: /** michael@0: * Creates a new image which isn't associated with a URI or loaded through michael@0: * the usual image loading mechanism. michael@0: * michael@0: * @param aMimeType The mimetype of the image. michael@0: */ michael@0: static already_AddRefed CreateAnonymousImage(const nsCString& aMimeType); michael@0: michael@0: private: michael@0: // Factory functions that create specific types of image containers. michael@0: static already_AddRefed CreateRasterImage(nsIRequest* aRequest, michael@0: imgStatusTracker* aStatusTracker, michael@0: const nsCString& aMimeType, michael@0: ImageURL* aURI, michael@0: uint32_t aImageFlags, michael@0: uint32_t aInnerWindowId); michael@0: michael@0: static already_AddRefed CreateVectorImage(nsIRequest* aRequest, michael@0: imgStatusTracker* aStatusTracker, michael@0: const nsCString& aMimeType, michael@0: ImageURL* aURI, michael@0: uint32_t aImageFlags, michael@0: uint32_t aInnerWindowId); michael@0: michael@0: // This is a static factory class, so disallow instantiation. michael@0: virtual ~ImageFactory() = 0; michael@0: }; michael@0: michael@0: } // namespace image michael@0: } // namespace mozilla michael@0: michael@0: #endif // MOZILLA_IMAGELIB_IMAGEFACTORY_H_