Bug 1418930 Part 4: Define a CSS property flag to accompany the image preload flag -- to also use anonymous CORS.
MozReview-Commit-ID: 9iQgT3g1m9J
--- a/layout/style/nsCSSDataBlock.cpp
+++ b/layout/style/nsCSSDataBlock.cpp
@@ -90,17 +90,21 @@ TryToStartImageLoadOnValue(const nsCSSVa
bool isEqualExceptRef = false;
nsresult rv = imageURI->EqualsExceptRef(docURI, &isEqualExceptRef);
if (NS_SUCCEEDED(rv) && isEqualExceptRef) {
return;
}
}
}
- aValue.StartImageLoad(aDocument, CORSMode::CORS_NONE);
+ CORSMode mode =
+ nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_LOAD_USE_CORS) ?
+ CORSMode::CORS_ANONYMOUS :
+ CORSMode::CORS_NONE;
+ aValue.StartImageLoad(aDocument, mode);
if (aForTokenStream && aContext) {
CSSVariableImageTable::Add(aContext, aProperty,
aValue.GetImageStructValue());
}
}
else if (aValue.GetUnit() == eCSSUnit_Image) {
// If we already have a request, see if this document needs to clone it.
imgIRequest* request = aValue.GetImageValue(nullptr);
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -3748,16 +3748,17 @@ CSS_PROP_DISPLAY(
CSS_PROP_DISPLAY(
shape-outside,
shape_outside,
ShapeOutside,
CSS_PROPERTY_PARSE_VALUE |
CSS_PROPERTY_VALUE_PARSER_FUNCTION |
CSS_PROPERTY_APPLIES_TO_FIRST_LETTER |
CSS_PROPERTY_START_IMAGE_LOADS |
+ CSS_PROPERTY_LOAD_USE_CORS |
CSS_PROPERTY_STORES_CALC,
"layout.css.shape-outside.enabled",
0,
nullptr,
CSS_PROP_NO_OFFSET,
eStyleAnimType_Custom)
CSS_PROP_SVG(
shape-rendering,
--- a/layout/style/nsCSSProps.h
+++ b/layout/style/nsCSSProps.h
@@ -279,16 +279,21 @@ static_assert((CSS_PROPERTY_PARSE_PROPER
// absolutely positioned elements.
// This should be set for any properties that can cause an element to be
// such a containing block, as implemented in
// nsStyleDisplay::IsAbsPosContainingBlock.
// It does not need to be set for properties that also have
// CSS_PROPERTY_FIXPOS_CB set.
#define CSS_PROPERTY_ABSPOS_CB (1<<30)
+// This property should add Cross Origin Request headers to any loads
+// that it triggers. Currently this is only used for properties that
+// also use CSS_PROPERTY_START_IMAGE_LOADS.
+#define CSS_PROPERTY_LOAD_USE_CORS (1U<<31)
+
/**
* Types of animatable values.
*/
enum nsStyleAnimType {
// requires a custom implementation in
// StyleAnimationValue::ExtractComputedValue
eStyleAnimType_Custom,
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -979,17 +979,18 @@ public:
nsCSSRect& SetRectValue();
nsCSSValueList* SetListValue();
nsCSSValuePairList* SetPairListValue();
// These take ownership of the passed-in resource.
void AdoptListValue(mozilla::UniquePtr<nsCSSValueList> aValue);
void AdoptPairListValue(mozilla::UniquePtr<nsCSSValuePairList> aValue);
- void StartImageLoad(nsIDocument* aDocument) const; // Only pretend const
+ void StartImageLoad(nsIDocument* aDocument,
+ mozilla::CORSMode aCORSMode) const; // Only pretend const
// Initializes as a function value with the specified function id.
Array* InitFunction(nsCSSKeyword aFunctionId, uint32_t aNumArgs);
// Checks if this is a function value with the specified function id.
bool EqualsFunction(nsCSSKeyword aFunctionId) const;
// Returns an already addrefed buffer. Guaranteed to return non-null.
// (Will abort on allocation failure.)