image/src/ImageFactory.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     2  *
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef MOZILLA_IMAGELIB_IMAGEFACTORY_H_
     8 #define MOZILLA_IMAGELIB_IMAGEFACTORY_H_
    10 #include "nsCOMPtr.h"
    11 #include "nsProxyRelease.h"
    13 class nsCString;
    14 class nsIRequest;
    15 class imgStatusTracker;
    17 namespace mozilla {
    18 namespace image {
    20 class Image;
    21 class ImageURL;
    23 class ImageFactory
    24 {
    25 public:
    26   /**
    27    * Registers vars with Preferences. Should only be called on the main thread.
    28    */
    29   static void Initialize();
    31   /**
    32    * Determines whether it's safe to retarget OnDataAvailable for an image.
    33    *
    34    * @param aURI          The URI of the image.
    35    * @param aIsMultipart  Whether the image is part of a multipart request.
    36    */
    37   static bool CanRetargetOnDataAvailable(ImageURL* aURI, bool aIsMultiPart);
    39   /**
    40    * Creates a new image with the given properties.
    41    * Can be called on or off the main thread.
    42    *
    43    * @param aRequest       The associated request.
    44    * @param aStatusTracker A status tracker for the image to use.
    45    * @param aMimeType      The mimetype of the image.
    46    * @param aURI           The URI of the image.
    47    * @param aIsMultiPart   Whether the image is part of a multipart request.
    48    * @param aInnerWindowId The window this image belongs to.
    49    */
    50   static already_AddRefed<Image> CreateImage(nsIRequest* aRequest,
    51                                              imgStatusTracker* aStatusTracker,
    52                                              const nsCString& aMimeType,
    53                                              ImageURL* aURI,
    54                                              bool aIsMultiPart,
    55                                              uint32_t aInnerWindowId);
    56   /**
    57    * Creates a new image which isn't associated with a URI or loaded through
    58    * the usual image loading mechanism.
    59    *
    60    * @param aMimeType      The mimetype of the image.
    61    */
    62   static already_AddRefed<Image> CreateAnonymousImage(const nsCString& aMimeType);
    64 private:
    65   // Factory functions that create specific types of image containers.
    66   static already_AddRefed<Image> CreateRasterImage(nsIRequest* aRequest,
    67                                                    imgStatusTracker* aStatusTracker,
    68                                                    const nsCString& aMimeType,
    69                                                    ImageURL* aURI,
    70                                                    uint32_t aImageFlags,
    71                                                    uint32_t aInnerWindowId);
    73   static already_AddRefed<Image> CreateVectorImage(nsIRequest* aRequest,
    74                                                    imgStatusTracker* aStatusTracker,
    75                                                    const nsCString& aMimeType,
    76                                                    ImageURL* aURI,
    77                                                    uint32_t aImageFlags,
    78                                                    uint32_t aInnerWindowId);
    80   // This is a static factory class, so disallow instantiation.
    81   virtual ~ImageFactory() = 0;
    82 };
    84 } // namespace image
    85 } // namespace mozilla
    87 #endif // MOZILLA_IMAGELIB_IMAGEFACTORY_H_

mercurial