зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1418930 Part 3: Update css::ImageValue to carry a parameter that indicates anonymous CORS headers should be used during loading. r=emilio
MozReview-Commit-ID: JJ5lZRwS6Be --HG-- extra : rebase_source : 04f1763498d673bd7b57c1ca415f4669f2634b03
This commit is contained in:
Родитель
1c1244f196
Коммит
43275caf98
|
@ -16,6 +16,7 @@
|
|||
#include "nsAttrValueInlines.h"
|
||||
#include "nsAtom.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/ServoBindingTypes.h"
|
||||
#include "mozilla/ServoUtils.h"
|
||||
|
@ -1692,7 +1693,9 @@ nsAttrValue::LoadImage(nsIDocument* aDocument)
|
|||
"How did we end up with an empty string for eURL");
|
||||
|
||||
mozilla::css::ImageValue* image =
|
||||
mozilla::css::ImageValue::CreateFromURLValue(url, aDocument);
|
||||
mozilla::css::ImageValue::CreateFromURLValue(url,
|
||||
aDocument,
|
||||
mozilla::CORSMode::CORS_NONE);
|
||||
|
||||
NS_ADDREF(image);
|
||||
cont->mValue.mImage = image;
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "nsTArray.h"
|
||||
#include "nsTransitionManager.h"
|
||||
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/DeclarationBlockInlines.h"
|
||||
#include "mozilla/EffectCompositor.h"
|
||||
#include "mozilla/EffectSet.h"
|
||||
|
@ -1507,8 +1508,11 @@ CreateStyleImageRequest(nsStyleImageRequest::Mode aModeFlags,
|
|||
mozilla::css::ImageValue*
|
||||
Gecko_ImageValue_Create(ServoBundledURI aURI, ServoRawOffsetArc<RustString> aURIString)
|
||||
{
|
||||
// Bug 1434963: Change this to accept a CORS mode from the caller.
|
||||
RefPtr<css::ImageValue> value(
|
||||
new css::ImageValue(aURIString, do_AddRef(aURI.mExtraData)));
|
||||
new css::ImageValue(aURIString,
|
||||
do_AddRef(aURI.mExtraData),
|
||||
mozilla::CORSMode::CORS_NONE));
|
||||
return value.forget().take();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "CSSVariableImageTable.h"
|
||||
#include "mozilla/css/Declaration.h"
|
||||
#include "mozilla/css/ImageLoader.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/WritingModes.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
@ -94,7 +95,7 @@ TryToStartImageLoadOnValue(const nsCSSValue& aValue, nsIDocument* aDocument,
|
|||
}
|
||||
}
|
||||
|
||||
aValue.StartImageLoad(aDocument);
|
||||
aValue.StartImageLoad(aDocument, CORSMode::CORS_NONE);
|
||||
if (aForTokenStream && aContext) {
|
||||
CSSVariableImageTable::Add(aContext, aProperty,
|
||||
aValue.GetImageStructValue());
|
||||
|
|
|
@ -894,11 +894,14 @@ nsCSSValue::GetCalcValue() const
|
|||
return result;
|
||||
}
|
||||
|
||||
void nsCSSValue::StartImageLoad(nsIDocument* aDocument) const
|
||||
void nsCSSValue::StartImageLoad(nsIDocument* aDocument,
|
||||
mozilla::CORSMode aCORSMode) const
|
||||
{
|
||||
MOZ_ASSERT(eCSSUnit_URL == mUnit, "Not a URL value!");
|
||||
mozilla::css::ImageValue* image =
|
||||
mozilla::css::ImageValue::CreateFromURLValue(mValue.mURL, aDocument);
|
||||
mozilla::css::ImageValue::CreateFromURLValue(mValue.mURL,
|
||||
aDocument,
|
||||
aCORSMode);
|
||||
|
||||
nsCSSValue* writable = const_cast<nsCSSValue*>(this);
|
||||
writable->SetImageValue(image);
|
||||
|
@ -3111,44 +3114,59 @@ css::URLValue::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
|||
|
||||
css::ImageValue::ImageValue(nsIURI* aURI, const nsAString& aString,
|
||||
already_AddRefed<URLExtraData> aExtraData,
|
||||
nsIDocument* aDocument)
|
||||
nsIDocument* aDocument,
|
||||
CORSMode aCORSMode)
|
||||
: URLValueData(do_AddRef(new PtrHolder<nsIURI>("URLValueData::mURI", aURI)),
|
||||
aString, Move(aExtraData))
|
||||
{
|
||||
mCORSMode = aCORSMode;
|
||||
Initialize(aDocument);
|
||||
}
|
||||
|
||||
css::ImageValue::ImageValue(nsIURI* aURI, ServoRawOffsetArc<RustString> aString,
|
||||
already_AddRefed<URLExtraData> aExtraData,
|
||||
nsIDocument* aDocument)
|
||||
nsIDocument* aDocument,
|
||||
CORSMode aCORSMode)
|
||||
: URLValueData(do_AddRef(new PtrHolder<nsIURI>("URLValueData::mURI", aURI)),
|
||||
aString, Move(aExtraData))
|
||||
{
|
||||
mCORSMode = aCORSMode;
|
||||
Initialize(aDocument);
|
||||
}
|
||||
|
||||
css::ImageValue::ImageValue(const nsAString& aString,
|
||||
already_AddRefed<URLExtraData> aExtraData)
|
||||
already_AddRefed<URLExtraData> aExtraData,
|
||||
CORSMode aCORSMode)
|
||||
: URLValueData(aString, Move(aExtraData))
|
||||
{
|
||||
mCORSMode = aCORSMode;
|
||||
}
|
||||
|
||||
css::ImageValue::ImageValue(ServoRawOffsetArc<RustString> aString,
|
||||
already_AddRefed<URLExtraData> aExtraData)
|
||||
already_AddRefed<URLExtraData> aExtraData,
|
||||
CORSMode aCORSMode)
|
||||
: URLValueData(aString, Move(aExtraData))
|
||||
{
|
||||
mCORSMode = aCORSMode;
|
||||
}
|
||||
|
||||
/*static*/ css::ImageValue*
|
||||
css::ImageValue::CreateFromURLValue(URLValue* aUrl, nsIDocument* aDocument)
|
||||
css::ImageValue::CreateFromURLValue(URLValue* aUrl,
|
||||
nsIDocument* aDocument,
|
||||
CORSMode aCORSMode)
|
||||
{
|
||||
if (aUrl->mUsingRustString) {
|
||||
return new css::ImageValue(aUrl->GetURI(),
|
||||
Servo_CloneArcStringData(&aUrl->mStrings.mRustString),
|
||||
do_AddRef(aUrl->mExtraData), aDocument);
|
||||
do_AddRef(aUrl->mExtraData),
|
||||
aDocument,
|
||||
aCORSMode);
|
||||
}
|
||||
return new css::ImageValue(aUrl->GetURI(), aUrl->mStrings.mString,
|
||||
do_AddRef(aUrl->mExtraData), aDocument);
|
||||
return new css::ImageValue(aUrl->GetURI(),
|
||||
aUrl->mStrings.mString,
|
||||
do_AddRef(aUrl->mExtraData),
|
||||
aDocument,
|
||||
aCORSMode);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3169,9 +3187,9 @@ css::ImageValue::Initialize(nsIDocument* aDocument)
|
|||
mExtraData->GetPrincipal(),
|
||||
mExtraData->GetReferrer(),
|
||||
this,
|
||||
CORSMode::CORS_NONE);
|
||||
mCORSMode);
|
||||
|
||||
mLoadedImage = true;
|
||||
mLoadedImage = true;
|
||||
}
|
||||
|
||||
aDocument->StyleImageLoader()->MaybeRegisterCSSImage(this);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define nsCSSValue_h___
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/ServoTypes.h"
|
||||
#include "mozilla/SheetType.h"
|
||||
|
@ -204,11 +205,17 @@ protected:
|
|||
// confused by the non-standard-layout packing of the variable up into
|
||||
// URLValueData.
|
||||
bool mLoadedImage = false;
|
||||
CORSMode mCORSMode = CORSMode::CORS_NONE;
|
||||
|
||||
virtual ~URLValueData();
|
||||
|
||||
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
public:
|
||||
void SetCORSMode(CORSMode aCORSMode) {
|
||||
mCORSMode = aCORSMode;
|
||||
}
|
||||
|
||||
private:
|
||||
URLValueData(const URLValueData& aOther) = delete;
|
||||
URLValueData& operator=(const URLValueData& aOther) = delete;
|
||||
|
@ -237,7 +244,9 @@ struct URLValue final : public URLValueData
|
|||
|
||||
struct ImageValue final : public URLValueData
|
||||
{
|
||||
static ImageValue* CreateFromURLValue(URLValue* url, nsIDocument* aDocument);
|
||||
static ImageValue* CreateFromURLValue(URLValue* url,
|
||||
nsIDocument* aDocument,
|
||||
CORSMode aCORSMode);
|
||||
|
||||
// Not making the constructor and destructor inline because that would
|
||||
// force us to include imgIRequest.h, which leads to REQUIRES hell, since
|
||||
|
@ -246,22 +255,26 @@ struct ImageValue final : public URLValueData
|
|||
// This constructor is only safe to call from the main thread.
|
||||
ImageValue(nsIURI* aURI, const nsAString& aString,
|
||||
already_AddRefed<URLExtraData> aExtraData,
|
||||
nsIDocument* aDocument);
|
||||
nsIDocument* aDocument,
|
||||
CORSMode aCORSMode);
|
||||
|
||||
// This constructor is only safe to call from the main thread.
|
||||
ImageValue(nsIURI* aURI, ServoRawOffsetArc<RustString> aString,
|
||||
already_AddRefed<URLExtraData> aExtraData,
|
||||
nsIDocument* aDocument);
|
||||
nsIDocument* aDocument,
|
||||
CORSMode aCORSMode);
|
||||
|
||||
// This constructor is safe to call from any thread, but Initialize
|
||||
// must be called later for the object to be useful.
|
||||
ImageValue(const nsAString& aString,
|
||||
already_AddRefed<URLExtraData> aExtraData);
|
||||
already_AddRefed<URLExtraData> aExtraData,
|
||||
CORSMode aCORSMode);
|
||||
|
||||
// This constructor is safe to call from any thread, but Initialize
|
||||
// must be called later for the object to be useful.
|
||||
ImageValue(ServoRawOffsetArc<RustString> aURIString,
|
||||
already_AddRefed<URLExtraData> aExtraData);
|
||||
already_AddRefed<URLExtraData> aExtraData,
|
||||
CORSMode aCORSMode);
|
||||
|
||||
ImageValue(const ImageValue&) = delete;
|
||||
ImageValue& operator=(const ImageValue&) = delete;
|
||||
|
|
Загрузка…
Ссылка в новой задаче