Bug 1377158 - (Part 6) Add StyleBackend to hash function to cache different SVG images generated from Gecko and Stylo. r=heycam
☠☠ backed out by cc6128e68428 ☠ ☠
authorKuoE0 <kuoe0.tw@gmail.com>
Mon, 24 Jul 2017 11:51:20 +0800
changeset 409835 30b7a45177bf28e258b8d811c08ef6ab8b4a135d
parent 409834 1310d6d8b5c091998951a05ce7ac05e4ffac7b28
child 409836 2fbce7c066277ffb11fe330467133b6b219cfb0d
push id5
push userbugmail@asutherland.org
push dateSat, 23 Sep 2017 16:52:09 +0000
reviewersheycam
bugs1377158
milestone56.0a1
Bug 1377158 - (Part 6) Add StyleBackend to hash function to cache different SVG images generated from Gecko and Stylo. r=heycam MozReview-Commit-ID: B1r9neL6XzE
image/ImageCacheKey.cpp
image/ImageCacheKey.h
--- a/image/ImageCacheKey.cpp
+++ b/image/ImageCacheKey.cpp
@@ -57,34 +57,38 @@ ImageCacheKey::ImageCacheKey(nsIURI* aUR
   NS_ENSURE_SUCCESS_VOID(aRv);
 
   MOZ_ASSERT(NS_IsMainThread());
 
   if (URISchemeIs(mURI, "blob")) {
     mBlobSerial = BlobSerial(mURI);
   }
 
-  mHash = ComputeHash(mURI, mBlobSerial, mOriginAttributes, mControlledDocument);
+  mHash = ComputeHash(mURI, mBlobSerial, mOriginAttributes, mControlledDocument,
+                      aDocument ? aDocument->GetStyleBackendType()
+                                : StyleBackendType::None);
 }
 
 ImageCacheKey::ImageCacheKey(ImageURL* aURI,
                              const OriginAttributes& aAttrs,
                              nsIDocument* aDocument)
   : mURI(aURI)
   , mOriginAttributes(aAttrs)
   , mControlledDocument(GetControlledDocumentToken(aDocument))
   , mIsChrome(URISchemeIs(mURI, "chrome"))
 {
   MOZ_ASSERT(aURI);
 
   if (URISchemeIs(mURI, "blob")) {
     mBlobSerial = BlobSerial(mURI);
   }
 
-  mHash = ComputeHash(mURI, mBlobSerial, mOriginAttributes, mControlledDocument);
+  mHash = ComputeHash(mURI, mBlobSerial, mOriginAttributes, mControlledDocument,
+                      aDocument ? aDocument->GetStyleBackendType()
+                                : StyleBackendType::None);
 }
 
 ImageCacheKey::ImageCacheKey(const ImageCacheKey& aOther)
   : mURI(aOther.mURI)
   , mBlobSerial(aOther.mBlobSerial)
   , mOriginAttributes(aOther.mOriginAttributes)
   , mControlledDocument(aOther.mControlledDocument)
   , mHash(aOther.mHash)
@@ -127,27 +131,28 @@ ImageCacheKey::Spec() const
 {
   return mURI->Spec();
 }
 
 /* static */ PLDHashNumber
 ImageCacheKey::ComputeHash(ImageURL* aURI,
                            const Maybe<uint64_t>& aBlobSerial,
                            const OriginAttributes& aAttrs,
-                           void* aControlledDocument)
+                           void* aControlledDocument,
+                           StyleBackendType aStyleBackendType)
 {
   // Since we frequently call Hash() several times in a row on the same
   // ImageCacheKey, as an optimization we compute our hash once and store it.
 
   nsPrintfCString ptr("%p", aControlledDocument);
   nsAutoCString suffix;
   aAttrs.CreateSuffix(suffix);
 
   return AddToHash(0, aURI->ComputeHash(aBlobSerial),
-                   HashString(suffix), HashString(ptr));
+                   HashString(suffix), HashString(ptr), (uint8_t)aStyleBackendType);
 }
 
 /* static */ void*
 ImageCacheKey::GetControlledDocumentToken(nsIDocument* aDocument)
 {
   // For non-controlled documents, we just return null.  For controlled
   // documents, we cast the pointer into a void* to avoid dereferencing
   // it (since we only use it for comparisons), and return it.
--- a/image/ImageCacheKey.h
+++ b/image/ImageCacheKey.h
@@ -8,16 +8,17 @@
  */
 
 #ifndef mozilla_image_src_ImageCacheKey_h
 #define mozilla_image_src_ImageCacheKey_h
 
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/RefPtr.h"
+#include "mozilla/StyleBackendType.h"
 
 class nsIDocument;
 class nsIURI;
 
 namespace mozilla {
 namespace image {
 
 class ImageURL;
@@ -53,17 +54,18 @@ public:
   /// A token indicating which service worker controlled document this entry
   /// belongs to, if any.
   void* ControlledDocument() const { return mControlledDocument; }
 
 private:
   static PLDHashNumber ComputeHash(ImageURL* aURI,
                                    const Maybe<uint64_t>& aBlobSerial,
                                    const OriginAttributes& aAttrs,
-                                   void* aControlledDocument);
+                                   void* aControlledDocument,
+                                   mozilla::StyleBackendType aStyleBackendType);
   static void* GetControlledDocumentToken(nsIDocument* aDocument);
 
   RefPtr<ImageURL> mURI;
   Maybe<uint64_t> mBlobSerial;
   OriginAttributes mOriginAttributes;
   void* mControlledDocument;
   PLDHashNumber mHash;
   bool mIsChrome;