1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/image/src/ImageFactory.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,87 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef MOZILLA_IMAGELIB_IMAGEFACTORY_H_ 1.11 +#define MOZILLA_IMAGELIB_IMAGEFACTORY_H_ 1.12 + 1.13 +#include "nsCOMPtr.h" 1.14 +#include "nsProxyRelease.h" 1.15 + 1.16 +class nsCString; 1.17 +class nsIRequest; 1.18 +class imgStatusTracker; 1.19 + 1.20 +namespace mozilla { 1.21 +namespace image { 1.22 + 1.23 +class Image; 1.24 +class ImageURL; 1.25 + 1.26 +class ImageFactory 1.27 +{ 1.28 +public: 1.29 + /** 1.30 + * Registers vars with Preferences. Should only be called on the main thread. 1.31 + */ 1.32 + static void Initialize(); 1.33 + 1.34 + /** 1.35 + * Determines whether it's safe to retarget OnDataAvailable for an image. 1.36 + * 1.37 + * @param aURI The URI of the image. 1.38 + * @param aIsMultipart Whether the image is part of a multipart request. 1.39 + */ 1.40 + static bool CanRetargetOnDataAvailable(ImageURL* aURI, bool aIsMultiPart); 1.41 + 1.42 + /** 1.43 + * Creates a new image with the given properties. 1.44 + * Can be called on or off the main thread. 1.45 + * 1.46 + * @param aRequest The associated request. 1.47 + * @param aStatusTracker A status tracker for the image to use. 1.48 + * @param aMimeType The mimetype of the image. 1.49 + * @param aURI The URI of the image. 1.50 + * @param aIsMultiPart Whether the image is part of a multipart request. 1.51 + * @param aInnerWindowId The window this image belongs to. 1.52 + */ 1.53 + static already_AddRefed<Image> CreateImage(nsIRequest* aRequest, 1.54 + imgStatusTracker* aStatusTracker, 1.55 + const nsCString& aMimeType, 1.56 + ImageURL* aURI, 1.57 + bool aIsMultiPart, 1.58 + uint32_t aInnerWindowId); 1.59 + /** 1.60 + * Creates a new image which isn't associated with a URI or loaded through 1.61 + * the usual image loading mechanism. 1.62 + * 1.63 + * @param aMimeType The mimetype of the image. 1.64 + */ 1.65 + static already_AddRefed<Image> CreateAnonymousImage(const nsCString& aMimeType); 1.66 + 1.67 +private: 1.68 + // Factory functions that create specific types of image containers. 1.69 + static already_AddRefed<Image> CreateRasterImage(nsIRequest* aRequest, 1.70 + imgStatusTracker* aStatusTracker, 1.71 + const nsCString& aMimeType, 1.72 + ImageURL* aURI, 1.73 + uint32_t aImageFlags, 1.74 + uint32_t aInnerWindowId); 1.75 + 1.76 + static already_AddRefed<Image> CreateVectorImage(nsIRequest* aRequest, 1.77 + imgStatusTracker* aStatusTracker, 1.78 + const nsCString& aMimeType, 1.79 + ImageURL* aURI, 1.80 + uint32_t aImageFlags, 1.81 + uint32_t aInnerWindowId); 1.82 + 1.83 + // This is a static factory class, so disallow instantiation. 1.84 + virtual ~ImageFactory() = 0; 1.85 +}; 1.86 + 1.87 +} // namespace image 1.88 +} // namespace mozilla 1.89 + 1.90 +#endif // MOZILLA_IMAGELIB_IMAGEFACTORY_H_