2012-12-17 22:05:18 +00: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/. */
|
|
|
|
|
2015-05-15 03:52:05 +00:00
|
|
|
#ifndef mozilla_image_ImageFactory_h
|
|
|
|
#define mozilla_image_ImageFactory_h
|
2012-12-17 22:05:18 +00:00
|
|
|
|
2013-03-11 01:43:38 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2013-09-28 18:28:42 +00:00
|
|
|
#include "nsProxyRelease.h"
|
2017-08-16 23:48:52 +00:00
|
|
|
#include "nsStringFwd.h"
|
2013-03-11 01:43:38 +00:00
|
|
|
|
2013-02-13 21:53:42 +00:00
|
|
|
class nsIRequest;
|
2012-12-17 22:05:18 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace image {
|
|
|
|
|
2013-02-13 21:53:42 +00:00
|
|
|
class Image;
|
2013-09-28 18:28:42 +00:00
|
|
|
class ImageURL;
|
2015-04-28 23:32:02 +00:00
|
|
|
class MultipartImage;
|
2014-11-15 04:10:47 +00:00
|
|
|
class ProgressTracker;
|
2013-02-13 21:53:42 +00:00
|
|
|
|
2013-01-05 03:55:23 +00:00
|
|
|
class ImageFactory
|
2012-12-17 22:05:18 +00:00
|
|
|
{
|
2013-01-05 03:55:23 +00:00
|
|
|
public:
|
2013-09-28 18:28:42 +00:00
|
|
|
/**
|
|
|
|
* Registers vars with Preferences. Should only be called on the main thread.
|
|
|
|
*/
|
|
|
|
static void Initialize();
|
|
|
|
|
2014-04-03 02:20:25 +00:00
|
|
|
/**
|
2012-12-17 22:05:18 +00:00
|
|
|
* Creates a new image with the given properties.
|
2013-09-28 18:28:42 +00:00
|
|
|
* Can be called on or off the main thread.
|
2012-12-17 22:05:18 +00:00
|
|
|
*
|
2014-11-15 04:10:47 +00:00
|
|
|
* @param aRequest The associated request.
|
|
|
|
* @param aProgressTracker 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.
|
2012-12-17 22:05:18 +00:00
|
|
|
*/
|
|
|
|
static already_AddRefed<Image> CreateImage(nsIRequest* aRequest,
|
2014-11-15 04:10:47 +00:00
|
|
|
ProgressTracker* aProgressTracker,
|
2012-12-17 22:05:18 +00:00
|
|
|
const nsCString& aMimeType,
|
2013-09-28 18:28:42 +00:00
|
|
|
ImageURL* aURI,
|
2012-12-17 22:05:18 +00:00
|
|
|
bool aIsMultiPart,
|
2017-07-25 12:33:51 +00:00
|
|
|
uint32_t aInnerWindowId);
|
2012-12-18 01:35:07 +00: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.
|
2017-08-01 10:59:12 +00:00
|
|
|
* @param aSizeHint The length of the source data for the image.
|
2012-12-18 01:35:07 +00:00
|
|
|
*/
|
2014-12-06 00:35:00 +00:00
|
|
|
static already_AddRefed<Image>
|
2017-08-01 10:59:12 +00:00
|
|
|
CreateAnonymousImage(const nsCString& aMimeType, uint32_t aSizeHint = 0);
|
2012-12-18 01:35:07 +00:00
|
|
|
|
2015-04-28 23:32:02 +00:00
|
|
|
/**
|
|
|
|
* Creates a new multipart/x-mixed-replace image wrapper, and initializes it
|
|
|
|
* with the first part. Subsequent parts should be passed to the existing
|
|
|
|
* MultipartImage via MultipartImage::BeginTransitionToPart().
|
|
|
|
*
|
|
|
|
* @param aFirstPart An image containing the first part of the multipart
|
|
|
|
* stream.
|
|
|
|
* @param aProgressTracker A progress tracker for the multipart image.
|
|
|
|
*/
|
|
|
|
static already_AddRefed<MultipartImage>
|
|
|
|
CreateMultipartImage(Image* aFirstPart, ProgressTracker* aProgressTracker);
|
|
|
|
|
2012-12-17 22:05:18 +00:00
|
|
|
private:
|
|
|
|
// Factory functions that create specific types of image containers.
|
2014-12-06 00:35:00 +00:00
|
|
|
static already_AddRefed<Image>
|
|
|
|
CreateRasterImage(nsIRequest* aRequest,
|
|
|
|
ProgressTracker* aProgressTracker,
|
|
|
|
const nsCString& aMimeType,
|
|
|
|
ImageURL* aURI,
|
|
|
|
uint32_t aImageFlags,
|
|
|
|
uint32_t aInnerWindowId);
|
2012-12-17 22:05:18 +00:00
|
|
|
|
2014-12-06 00:35:00 +00:00
|
|
|
static already_AddRefed<Image>
|
|
|
|
CreateVectorImage(nsIRequest* aRequest,
|
|
|
|
ProgressTracker* aProgressTracker,
|
|
|
|
const nsCString& aMimeType,
|
|
|
|
ImageURL* aURI,
|
|
|
|
uint32_t aImageFlags,
|
2017-07-25 12:33:51 +00:00
|
|
|
uint32_t aInnerWindowId);
|
2012-12-17 22:05:18 +00:00
|
|
|
|
|
|
|
// This is a static factory class, so disallow instantiation.
|
|
|
|
virtual ~ImageFactory() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
2013-02-13 21:53:42 +00:00
|
|
|
|
2015-05-15 03:52:05 +00:00
|
|
|
#endif // mozilla_image_ImageFactory_h
|