diff --git a/image/imgLoader.cpp b/image/imgLoader.cpp index f8cabae9784f..c6b4d602f2f3 100644 --- a/image/imgLoader.cpp +++ b/image/imgLoader.cpp @@ -2244,9 +2244,14 @@ imgLoader::LoadImage(nsIURI* aURI, nsCOMPtr channelLoadGroup; newChannel->GetLoadGroup(getter_AddRefs(channelLoadGroup)); + // We look at the loading document's style backend type to decide which + // style backend type should be used for the images. So the images in Chrome + // documents would be loaded by Gecko. rv = request->Init(aURI, aURI, /* aHadInsecureRedirect = */ false, channelLoadGroup, newChannel, entry, aLoadingDocument, - aLoadingPrincipal, corsmode, aReferrerPolicy); + aLoadingPrincipal, corsmode, aReferrerPolicy, + aLoadingDocument ? aLoadingDocument->GetStyleBackendType() + : StyleBackendType::None); if (NS_FAILED(rv)) { return NS_ERROR_FAILURE; } diff --git a/image/imgRequest.cpp b/image/imgRequest.cpp index 25dd87ad0bf2..72a467f36fdd 100644 --- a/image/imgRequest.cpp +++ b/image/imgRequest.cpp @@ -69,6 +69,7 @@ imgRequest::imgRequest(imgLoader* aLoader, const ImageCacheKey& aCacheKey) , mDecodeRequested(false) , mNewPartPending(false) , mHadInsecureRedirect(false) + , mStyleBackendType(StyleBackendType::None) { } imgRequest::~imgRequest() @@ -95,7 +96,8 @@ imgRequest::Init(nsIURI *aURI, nsISupports* aCX, nsIPrincipal* aLoadingPrincipal, int32_t aCORSMode, - ReferrerPolicy aReferrerPolicy) + ReferrerPolicy aReferrerPolicy, + StyleBackendType aStyleBackendType) { MOZ_ASSERT(NS_IsMainThread(), "Cannot use nsIURI off main thread!"); @@ -123,6 +125,8 @@ imgRequest::Init(nsIURI *aURI, mCORSMode = aCORSMode; mReferrerPolicy = aReferrerPolicy; + mStyleBackendType = aStyleBackendType; + // If the original URI and the current URI are different, check whether the // original URI is secure. We deliberately don't take the current URI into // account, as it needs to be handled using more complicated rules than @@ -967,7 +971,8 @@ struct NewPartResult final static NewPartResult PrepareForNewPart(nsIRequest* aRequest, nsIInputStream* aInStr, uint32_t aCount, ImageURL* aURI, bool aIsMultipart, image::Image* aExistingImage, - ProgressTracker* aProgressTracker, uint32_t aInnerWindowId) + ProgressTracker* aProgressTracker, uint32_t aInnerWindowId, + StyleBackendType aStyleBackendType) { NewPartResult result(aExistingImage); @@ -1015,7 +1020,7 @@ PrepareForNewPart(nsIRequest* aRequest, nsIInputStream* aInStr, uint32_t aCount, image::ImageFactory::CreateImage(aRequest, progressTracker, result.mContentType, aURI, /* aIsMultipart = */ true, - aInnerWindowId); + aInnerWindowId, aStyleBackendType); if (result.mIsFirstPart) { // First part for a multipart channel. Create the MultipartImage wrapper. @@ -1040,7 +1045,7 @@ PrepareForNewPart(nsIRequest* aRequest, nsIInputStream* aInStr, uint32_t aCount, image::ImageFactory::CreateImage(aRequest, aProgressTracker, result.mContentType, aURI, /* aIsMultipart = */ false, - aInnerWindowId); + aInnerWindowId, aStyleBackendType); } MOZ_ASSERT(result.mImage); @@ -1133,7 +1138,8 @@ imgRequest::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext, if (newPartPending) { NewPartResult result = PrepareForNewPart(aRequest, aInStr, aCount, mURI, isMultipart, image, - progressTracker, mInnerWindowId); + progressTracker, mInnerWindowId, + mStyleBackendType); bool succeeded = result.mSucceeded; if (result.mImage) { diff --git a/image/imgRequest.h b/image/imgRequest.h index 4f8673578368..f21113e6f4bd 100644 --- a/image/imgRequest.h +++ b/image/imgRequest.h @@ -22,6 +22,9 @@ #include "mozilla/net/ReferrerPolicy.h" #include "ImageCacheKey.h" +#include "X11UndefineNone.h" +#include "mozilla/StyleBackendType.h" + class imgCacheValidator; class imgLoader; class imgRequestProxy; @@ -53,6 +56,7 @@ class imgRequest final : public nsIStreamListener, typedef mozilla::image::ImageURL ImageURL; typedef mozilla::image::ProgressTracker ProgressTracker; typedef mozilla::net::ReferrerPolicy ReferrerPolicy; + typedef mozilla::StyleBackendType StyleBackendType; public: imgRequest(imgLoader* aLoader, const ImageCacheKey& aCacheKey); @@ -74,7 +78,8 @@ public: nsISupports* aCX, nsIPrincipal* aLoadingPrincipal, int32_t aCORSMode, - ReferrerPolicy aReferrerPolicy); + ReferrerPolicy aReferrerPolicy, + StyleBackendType aBackendType = StyleBackendType::None); void ClearLoader(); @@ -295,6 +300,9 @@ private: bool mDecodeRequested : 1; bool mNewPartPending : 1; bool mHadInsecureRedirect : 1; + + // The backend used for this image document. + mozilla::StyleBackendType mStyleBackendType; }; #endif // mozilla_image_imgRequest_h