Bug 1418930 Part 2: Update css::ImageValue to carry a parameter that indicates anonymous CORS headers should be used during loading. draft
authorBrad Werth <bwerth@mozilla.com>
Mon, 29 Jan 2018 13:55:38 -0500
changeset 748484 43a1fbb94a19084566a54c6cc5e6f8625cf953fc
parent 748483 337d5e781945c5223af3fae245ecd9f5ad930337
child 748485 56bd0c5c8560a71deca7b2af173e6e3be808c255
push id97186
push userbwerth@mozilla.com
push dateMon, 29 Jan 2018 22:11:39 +0000
bugs1418930
milestone60.0a1
Bug 1418930 Part 2: Update css::ImageValue to carry a parameter that indicates anonymous CORS headers should be used during loading. MozReview-Commit-ID: JJ5lZRwS6Be
layout/style/nsCSSValue.cpp
layout/style/nsCSSValue.h
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -3163,19 +3163,19 @@ css::ImageValue::Initialize(nsIDocument*
     loadingDoc = aDocument;
   }
 
   if (!mLoadedImage) {
     loadingDoc->StyleImageLoader()->LoadImage(GetURI(),
                                               mExtraData->GetPrincipal(),
                                               mExtraData->GetReferrer(),
                                               this,
-                                              false);
-
-     mLoadedImage = true;
+                                              mUseAnonymousCORS);
+
+    mLoadedImage = true;
   }
 
   aDocument->StyleImageLoader()->MaybeRegisterCSSImage(this);
 }
 
 css::ImageValue::~ImageValue()
 {
   MOZ_ASSERT(NS_IsMainThread() || mRequests.Count() == 0,
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -199,21 +199,27 @@ private:
   } mStrings;
   mutable bool mUsingRustString;
 
 protected:
   // Only used by ImageValue.  Declared up here because otherwise bindgen gets
   // confused by the non-standard-layout packing of the variable up into
   // URLValueData.
   bool mLoadedImage = false;
+  bool mUseAnonymousCORS = false;
 
   virtual ~URLValueData();
 
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
+public:
+  void SetUseAnonymousCORS(bool aUseAnonymousCORS) {
+    mUseAnonymousCORS = aUseAnonymousCORS;
+  }
+
 private:
   URLValueData(const URLValueData& aOther) = delete;
   URLValueData& operator=(const URLValueData& aOther) = delete;
 
   friend struct ImageValue;
 };
 
 struct URLValue final : public URLValueData