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