/* static */ already_AddRefed<Image> ImageFactory::CreateImage(nsIRequest* aRequest, ProgressTracker* aProgressTracker, const nsCString& aMimeType, ImageURL* aURI, bool aIsMultiPart, uint32_t aInnerWindowId) { MOZ_ASSERT(gfxPrefs::SingletonExists(), "Pref observers should have been initialized already"); // Compute the image's initialization flags. uint32_t imageFlags = ComputeImageFlags(aURI, aMimeType, aIsMultiPart); // Select the type of image to create based on MIME type. if (aMimeType.EqualsLiteral(IMAGE_SVG_XML)) { nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest)); if (!NS_SVGEnabledForChannel(channel)) { // SVG is disabled. We must return an image object that is marked // "bad", but we want to avoid invoking the VectorImage class (SVG code), // so we return a PNG with the error flag set. nsRefPtr<RasterImage> badImage = new RasterImage(aProgressTracker, aURI); (void)badImage->Init(IMAGE_PNG, Image::INIT_FLAG_NONE); return BadImage(badImage); } return CreateVectorImage(aRequest, aProgressTracker, aMimeType, aURI, imageFlags, aInnerWindowId); } else { return CreateRasterImage(aRequest, aProgressTracker, aMimeType, aURI, imageFlags, aInnerWindowId); } }
/* static */ already_AddRefed<Image> ImageFactory::CreateImage(nsIRequest* aRequest, imgStatusTracker* aStatusTracker, const nsCString& aMimeType, ImageURL* aURI, bool aIsMultiPart, uint32_t aInnerWindowId) { MOZ_ASSERT(gInitializedPrefCaches, "Pref observers should have been initialized already"); // Compute the image's initialization flags. uint32_t imageFlags = ComputeImageFlags(aURI, aIsMultiPart); // Select the type of image to create based on MIME type. if (aMimeType.EqualsLiteral(IMAGE_SVG_XML)) { return CreateVectorImage(aRequest, aStatusTracker, aMimeType, aURI, imageFlags, aInnerWindowId); } else { return CreateRasterImage(aRequest, aStatusTracker, aMimeType, aURI, imageFlags, aInnerWindowId); } }
/* static */ already_AddRefed<Image> ImageFactory::CreateImage(nsIRequest* aRequest, imgStatusTracker* aStatusTracker, const nsCString& aMimeType, nsIURI* aURI, bool aIsMultiPart, uint32_t aInnerWindowId) { // Register our pref observers if we haven't yet. if (MOZ_UNLIKELY(!gInitializedPrefCaches)) InitPrefCaches(); // Compute the image's initialization flags. uint32_t imageFlags = ComputeImageFlags(aURI, aIsMultiPart); // Select the type of image to create based on MIME type. if (aMimeType.EqualsLiteral(IMAGE_SVG_XML)) { return CreateVectorImage(aRequest, aStatusTracker, aMimeType, aURI, imageFlags, aInnerWindowId); } else { return CreateRasterImage(aRequest, aStatusTracker, aMimeType, aURI, imageFlags, aInnerWindowId); } }