Bug 1330487 - Part 4: Use correct referrer policy for image loader draft
authorThomas Nguyen <tnguyen@mozilla.com>
Tue, 16 Jan 2018 15:43:01 +0800
changeset 721907 f4a56a02ba50b1b28c6905df2b5da90889422cb3
parent 721906 2e9830ab5d585b95451ca43159a2ac13526426d9
child 721908 0b1d9635aa9e1bfadfad7745690fe6426e1986e4
push id95995
push userbmo:tnguyen@mozilla.com
push dateThu, 18 Jan 2018 02:41:54 +0000
bugs1330487
milestone59.0a1
Bug 1330487 - Part 4: Use correct referrer policy for image loader MozReview-Commit-ID: 6wgN3ySaG3i
layout/style/ImageLoader.cpp
layout/style/ImageLoader.h
--- a/layout/style/ImageLoader.cpp
+++ b/layout/style/ImageLoader.cpp
@@ -238,30 +238,31 @@ ImageLoader::ClearFrames(nsPresContext* 
   }
 
   mRequestToFrameMap.Clear();
   mFrameToRequestMap.Clear();
 }
 
 void
 ImageLoader::LoadImage(nsIURI* aURI, nsIPrincipal* aOriginPrincipal,
-                       nsIURI* aReferrer, ImageLoader::Image* aImage)
+                       nsIURI* aReferrer, mozilla::net::ReferrerPolicy aPolicy,
+                       ImageLoader::Image* aImage)
 {
   NS_ASSERTION(aImage->mRequests.Count() == 0, "Huh?");
 
   aImage->mRequests.Put(nullptr, nullptr);
 
   if (!aURI) {
     return;
   }
 
   RefPtr<imgRequestProxy> request;
   nsresult rv = nsContentUtils::LoadImage(aURI, mDocument, mDocument,
                                           aOriginPrincipal, 0, aReferrer,
-                                          mDocument->GetReferrerPolicy(),
+                                          aPolicy,
                                           nullptr, nsIRequest::LOAD_NORMAL,
                                           NS_LITERAL_STRING("css"),
                                           getter_AddRefs(request));
 
   if (NS_FAILED(rv) || !request) {
     return;
   }
 
--- a/layout/style/ImageLoader.h
+++ b/layout/style/ImageLoader.h
@@ -11,16 +11,17 @@
 #define mozilla_css_ImageLoader_h___
 
 #include "nsClassHashtable.h"
 #include "nsHashKeys.h"
 #include "nsTArray.h"
 #include "imgIRequest.h"
 #include "imgINotificationObserver.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/net/ReferrerPolicy.h"
 
 class imgIContainer;
 class nsIFrame;
 class nsIDocument;
 class nsPresContext;
 class nsIURI;
 class nsIPrincipal;
 
@@ -60,17 +61,17 @@ public:
   void SetAnimationMode(uint16_t aMode);
 
   // The prescontext for this ImageLoader's document. We need it to be passed
   // in because this can be called during presentation destruction after the
   // presshell pointer on the document has been cleared.
   void ClearFrames(nsPresContext* aPresContext);
 
   void LoadImage(nsIURI* aURI, nsIPrincipal* aPrincipal, nsIURI* aReferrer,
-                 Image* aCSSValue);
+                 mozilla::net::ReferrerPolicy aPolicy, Image* aCSSValue);
 
   void DestroyRequest(imgIRequest* aRequest);
 
   void FlushUseCounters();
 
 private:
   ~ImageLoader() {}