Bug 1377158 - (Part 4) Add a new parameter to pass style backend type to create image.
MozReview-Commit-ID: 74gWTbUyYOZ
--- a/image/ImageFactory.cpp
+++ b/image/ImageFactory.cpp
@@ -79,17 +79,18 @@ ComputeImageFlags(ImageURL* uri, const n
}
/* static */ already_AddRefed<Image>
ImageFactory::CreateImage(nsIRequest* aRequest,
ProgressTracker* aProgressTracker,
const nsCString& aMimeType,
ImageURL* aURI,
bool aIsMultiPart,
- uint32_t aInnerWindowId)
+ uint32_t aInnerWindowId,
+ StyleBackendType aStyleBackendType /* = StyleBackendType::None */)
{
MOZ_ASSERT(gfxPrefs::SingletonExists(),
"Pref observers should have been initialized already");
// Compute the image's initialization flags.
uint32_t imageFlags = ComputeImageFlags(aURI, aMimeType, aIsMultiPart);
#ifdef DEBUG
@@ -103,17 +104,17 @@ ImageFactory::CreateImage(nsIRequest* aR
obs->NotifyObservers(nullptr, "image-loading", NS_ConvertUTF8toUTF16(spec).get());
}
}
#endif
// Select the type of image to create based on MIME type.
if (aMimeType.EqualsLiteral(IMAGE_SVG_XML)) {
return CreateVectorImage(aRequest, aProgressTracker, aMimeType,
- aURI, imageFlags, aInnerWindowId);
+ aURI, imageFlags, aInnerWindowId, aStyleBackendType);
} else {
return CreateRasterImage(aRequest, aProgressTracker, aMimeType,
aURI, imageFlags, aInnerWindowId);
}
}
// Marks an image as having an error before returning it.
template <typename T>
@@ -255,23 +256,24 @@ ImageFactory::CreateRasterImage(nsIReque
}
/* static */ already_AddRefed<Image>
ImageFactory::CreateVectorImage(nsIRequest* aRequest,
ProgressTracker* aProgressTracker,
const nsCString& aMimeType,
ImageURL* aURI,
uint32_t aImageFlags,
- uint32_t aInnerWindowId)
+ uint32_t aInnerWindowId,
+ StyleBackendType aStyleBackendType)
{
MOZ_ASSERT(aProgressTracker);
nsresult rv;
- RefPtr<VectorImage> newImage = new VectorImage(aURI);
+ RefPtr<VectorImage> newImage = new VectorImage(aURI, aStyleBackendType);
aProgressTracker->SetImage(newImage);
newImage->SetProgressTracker(aProgressTracker);
rv = newImage->Init(aMimeType.get(), aImageFlags);
if (NS_FAILED(rv)) {
return BadImage("VectorImage::Init failed", newImage);
}
--- a/image/ImageFactory.h
+++ b/image/ImageFactory.h
@@ -2,16 +2,17 @@
*
* 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/. */
#ifndef mozilla_image_ImageFactory_h
#define mozilla_image_ImageFactory_h
+#include "mozilla/StyleBackendType.h"
#include "nsCOMPtr.h"
#include "nsProxyRelease.h"
class nsCString;
class nsIRequest;
namespace mozilla {
namespace image {
@@ -40,17 +41,18 @@ public:
* @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,
ProgressTracker* aProgressTracker,
const nsCString& aMimeType,
ImageURL* aURI,
bool aIsMultiPart,
- uint32_t aInnerWindowId);
+ uint32_t aInnerWindowId,
+ StyleBackendType aStyleBackendType = StyleBackendType::None);
/**
* 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.
* @param aSizeHint The length of the source data for the image.
*/
static already_AddRefed<Image>
@@ -79,17 +81,18 @@ private:
uint32_t aInnerWindowId);
static already_AddRefed<Image>
CreateVectorImage(nsIRequest* aRequest,
ProgressTracker* aProgressTracker,
const nsCString& aMimeType,
ImageURL* aURI,
uint32_t aImageFlags,
- uint32_t aInnerWindowId);
+ uint32_t aInnerWindowId,
+ StyleBackendType aStyleBackendType);
// This is a static factory class, so disallow instantiation.
virtual ~ImageFactory() = 0;
};
} // namespace image
} // namespace mozilla