Bug 1418930 Part 2: Extend ImageLoader with a parameter to add anonymous CORS headers. r=bz,emilio

MozReview-Commit-ID: LobEEXmuNZ2

--HG--
extra : rebase_source : de661d5789162b0be3202c2a1b03d0515e5de01f
This commit is contained in:
Brad Werth 2018-01-25 14:14:13 -08:00
parent e7b31713ef
commit f168a6a02d
3 changed files with 12 additions and 4 deletions

View File

@ -244,7 +244,8 @@ ImageLoader::ClearFrames(nsPresContext* aPresContext)
void
ImageLoader::LoadImage(nsIURI* aURI, nsIPrincipal* aOriginPrincipal,
nsIURI* aReferrer, ImageLoader::Image* aImage)
nsIURI* aReferrer, ImageLoader::Image* aImage,
CORSMode aCorsMode)
{
NS_ASSERTION(aImage->mRequests.Count() == 0, "Huh?");
@ -254,11 +255,14 @@ ImageLoader::LoadImage(nsIURI* aURI, nsIPrincipal* aOriginPrincipal,
return;
}
int32_t loadFlags = nsIRequest::LOAD_NORMAL |
nsContentUtils::CORSModeToLoadImageFlags(aCorsMode);
RefPtr<imgRequestProxy> request;
nsresult rv = nsContentUtils::LoadImage(aURI, mDocument, mDocument,
aOriginPrincipal, 0, aReferrer,
mDocument->GetReferrerPolicy(),
nullptr, nsIRequest::LOAD_NORMAL,
nullptr, loadFlags,
NS_LITERAL_STRING("css"),
getter_AddRefs(request));

View File

@ -10,6 +10,7 @@
#ifndef mozilla_css_ImageLoader_h___
#define mozilla_css_ImageLoader_h___
#include "CORSMode.h"
#include "nsClassHashtable.h"
#include "nsHashKeys.h"
#include "nsTArray.h"
@ -65,7 +66,7 @@ public:
void ClearFrames(nsPresContext* aPresContext);
void LoadImage(nsIURI* aURI, nsIPrincipal* aPrincipal, nsIURI* aReferrer,
Image* aCSSValue);
Image* aCSSValue, CORSMode aCorsMode);
void DestroyRequest(imgIRequest* aRequest);

View File

@ -8,6 +8,7 @@
#include "nsCSSValue.h"
#include "mozilla/CORSMode.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/ServoStyleSet.h"
#include "mozilla/ServoTypes.h"
@ -3166,7 +3167,9 @@ css::ImageValue::Initialize(nsIDocument* aDocument)
if (!mLoadedImage) {
loadingDoc->StyleImageLoader()->LoadImage(GetURI(),
mExtraData->GetPrincipal(),
mExtraData->GetReferrer(), this);
mExtraData->GetReferrer(),
this,
CORSMode::CORS_NONE);
mLoadedImage = true;
}