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 762260 f9cc0d33cd9174220ec258821816048e985fa44e
parent 762259 a05137d4277329823b6f7d63436d9dbded52f96f
child 762261 db3066bcf5116acafeaacd0d7975f4b56dc3a507
push id101114
push userbwerth@mozilla.com
push dateThu, 01 Mar 2018 23:33:31 +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;