Bug 1404222 Part 3: Define a new imgILoader flag to indicate delay of the load event until decode. draft
authorBrad Werth <bwerth@mozilla.com>
Fri, 16 Feb 2018 11:02:56 -0800
changeset 762583 86caca9827e81cd3edc79d789582eb449201d0f3
parent 762582 998ca82905692a8ddacbfd3bf956d39020ae3bfd
child 762584 53e60d7b78a64370ecaa8ccc436543c436e8e692
push id101211
push userbwerth@mozilla.com
push dateFri, 02 Mar 2018 18:20:33 +0000
bugs1404222
milestone60.0a1
Bug 1404222 Part 3: Define a new imgILoader flag to indicate delay of the load event until decode. MozReview-Commit-ID: jmUkyh0mM0
image/imgILoader.idl
image/imgLoader.cpp
--- a/image/imgILoader.idl
+++ b/image/imgILoader.idl
@@ -30,16 +30,22 @@ interface nsISimpleEnumerator;
 [scriptable, builtinclass, uuid(e61377d2-910e-4c65-a64b-428d150e1fd1)]
 interface imgILoader : nsISupports
 {
   // Extra flags to pass to loadImage if you want a load to use CORS
   // validation.
   const unsigned long LOAD_CORS_ANONYMOUS = 1 << 16;
   const unsigned long LOAD_CORS_USE_CREDENTIALS = 1 << 17;
 
+  // Extra flag to pass to loadImage if you want the load event
+  // delayed until the image is fully decoded, treating this image's
+  // contents -- not just its metadata -- as part of its listeners'
+  // "dependent resources".
+  const unsigned long DELAY_LOAD_EVENT_UNTIL_DECODE = 1 << 18;
+
   /**
    * Start the load and decode of an image.
    * @param aURI the URI to load
    * @param aInitialDocumentURI the URI that 'initiated' the load -- used for
    *           3rd party cookie blocking
    * @param aReferrerURI the 'referring' URI
    * @param aReferrerPolicy the policy to apply to sending referrers.
    *           examples: "default", "never", "always", "origin"
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -2262,16 +2262,21 @@ imgLoader::LoadImage(nsIURI* aURI,
     requestFlags = (requestFlags & ~LOAD_FLAGS_VALIDATE_MASK) |
                    (aLoadFlags & LOAD_FLAGS_VALIDATE_MASK);
   }
   if (aLoadFlags & nsIRequest::LOAD_BACKGROUND) {
     // Propagate background loading...
     requestFlags |= nsIRequest::LOAD_BACKGROUND;
   }
 
+  if (aLoadFlags & imgILoader::DELAY_LOAD_EVENT_UNTIL_DECODE) {
+    // Propagate delay of the load event...
+    requestFlags |= imgILoader::DELAY_LOAD_EVENT_UNTIL_DECODE;
+  }
+
   int32_t corsmode = imgIRequest::CORS_NONE;
   if (aLoadFlags & imgILoader::LOAD_CORS_ANONYMOUS) {
     corsmode = imgIRequest::CORS_ANONYMOUS;
   } else if (aLoadFlags & imgILoader::LOAD_CORS_USE_CREDENTIALS) {
     corsmode = imgIRequest::CORS_USE_CREDENTIALS;
   }
 
   RefPtr<imgCacheEntry> entry;