2012-12-18 02:05:18 +04: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 06:52:05 +03:00
|
|
|
#ifndef mozilla_image_ImageFactory_h
|
|
|
|
#define mozilla_image_ImageFactory_h
|
2012-12-18 02:05:18 +04:00
|
|
|
|
2013-03-11 05:43:38 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2013-09-28 22:28:42 +04:00
|
|
|
#include "nsProxyRelease.h"
|
2017-08-17 02:48:52 +03:00
|
|
|
#include "nsStringFwd.h"
|
2013-03-11 05:43:38 +04:00
|
|
|
|
2013-02-14 01:53:42 +04:00
|
|
|
class nsIRequest;
|
2018-06-06 03:42:56 +03:00
|
|
|
class nsIURI;
|
2012-12-18 02:05:18 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace image {
|
|
|
|
|
2013-02-14 01:53:42 +04:00
|
|
|
class Image;
|
2015-04-29 02:32:02 +03:00
|
|
|
class MultipartImage;
|
2014-11-15 07:10:47 +03:00
|
|
|
class ProgressTracker;
|
2013-02-14 01:53:42 +04:00
|
|
|
|
2013-01-05 07:55:23 +04:00
|
|
|
class ImageFactory {
|
|
|
|
public:
|
2013-09-28 22:28:42 +04:00
|
|
|
/**
|
|
|
|
* Registers vars with Preferences. Should only be called on the main thread.
|
|
|
|
*/
|
|
|
|
static void Initialize();
|
|
|
|
|
2014-04-03 06:20:25 +04:00
|
|
|
/**
|
2012-12-18 02:05:18 +04:00
|
|
|
* Creates a new image with the given properties.
|
2013-09-28 22:28:42 +04:00
|
|
|
* Can be called on or off the main thread.
|
2012-12-18 02:05:18 +04:00
|
|
|
*
|
2014-11-15 07:10:47 +03: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-18 02:05:18 +04:00
|
|
|
*/
|
|
|
|
static already_AddRefed<Image> CreateImage(nsIRequest* aRequest,
|
2014-11-15 07:10:47 +03:00
|
|
|
ProgressTracker* aProgressTracker,
|
2012-12-18 02:05:18 +04:00
|
|
|
const nsCString& aMimeType,
|
|
|
|
nsIURI* aURI, bool aIsMultiPart,
|
2022-02-26 10:22:44 +03:00
|
|
|
uint64_t aInnerWindowId);
|
2012-12-18 05:35:07 +04: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 13:59:12 +03:00
|
|
|
* @param aSizeHint The length of the source data for the image.
|
2012-12-18 05:35:07 +04:00
|
|
|
*/
|
2014-12-06 03:35:00 +03:00
|
|
|
static already_AddRefed<Image> CreateAnonymousImage(
|
2017-08-01 13:59:12 +03:00
|
|
|
const nsCString& aMimeType, uint32_t aSizeHint = 0);
|
2012-12-18 05:35:07 +04:00
|
|
|
|
2015-04-29 02:32:02 +03: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-18 02:05:18 +04:00
|
|
|
private:
|
|
|
|
// Factory functions that create specific types of image containers.
|
2014-12-06 03:35:00 +03:00
|
|
|
static already_AddRefed<Image> CreateRasterImage(
|
|
|
|
nsIRequest* aRequest, ProgressTracker* aProgressTracker,
|
|
|
|
const nsCString& aMimeType, nsIURI* aURI, uint32_t aImageFlags,
|
2022-02-26 10:22:44 +03:00
|
|
|
uint64_t aInnerWindowId);
|
2012-12-18 02:05:18 +04:00
|
|
|
|
2014-12-06 03:35:00 +03:00
|
|
|
static already_AddRefed<Image> CreateVectorImage(
|
|
|
|
nsIRequest* aRequest, ProgressTracker* aProgressTracker,
|
|
|
|
const nsCString& aMimeType, nsIURI* aURI, uint32_t aImageFlags,
|
2022-02-26 10:22:44 +03:00
|
|
|
uint64_t aInnerWindowId);
|
2012-12-18 02:05:18 +04:00
|
|
|
|
|
|
|
// This is a static factory class, so disallow instantiation.
|
|
|
|
virtual ~ImageFactory() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace image
|
|
|
|
} // namespace mozilla
|
2013-02-14 01:53:42 +04:00
|
|
|
|
2015-05-15 06:52:05 +03:00
|
|
|
#endif // mozilla_image_ImageFactory_h
|