Backed out 2 changesets (bug 841579) on a CLOSED TREE
authorJoe Drew <joe@drew.ca>
Mon, 04 Mar 2013 17:27:51 -0500
changeset 123746 644043c3de95a65cb58c2fa854ae975b445b3949
parent 123745 a18af07069de59f69910610411bab7ecb959269b
child 123747 6af9594ac0d4a1523ac6a78b6ffe004b5b35607a
push id24029
push userjdrew@mozilla.com
push dateMon, 04 Mar 2013 22:28:05 +0000
treeherdermozilla-inbound@644043c3de95 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs841579
milestone22.0a1
backs outd21d144e3db95d2bd24dc583430a04c01428770d
0222cb04802822e4899cb1998b47de3063354322
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out 2 changesets (bug 841579) on a CLOSED TREE Backed out changeset d21d144e3db9 (bug 841579) Backed out changeset 0222cb048028 (bug 841579)
content/base/src/nsImageLoadingContent.cpp
content/base/src/nsImageLoadingContent.h
image/public/imgIRequest.idl
image/src/imgStatusTracker.cpp
image/test/mochitest/Makefile.in
image/test/mochitest/test_removal_ondecode.html
image/test/mochitest/test_removal_onload.html
--- a/content/base/src/nsImageLoadingContent.cpp
+++ b/content/base/src/nsImageLoadingContent.cpp
@@ -78,17 +78,16 @@ nsImageLoadingContent::nsImageLoadingCon
     mImageBlockingStatus(nsIContentPolicy::ACCEPT),
     mLoadingEnabled(true),
     mIsImageStateForced(false),
     mLoading(false),
     // mBroken starts out true, since an image without a URI is broken....
     mBroken(true),
     mUserDisabled(false),
     mSuppressed(false),
-    mFireEventsOnDecode(false),
     mNewRequestsWillNeedAnimationReset(false),
     mStateChangerDepth(0),
     mCurrentRequestRegistered(false),
     mPendingRequestRegistered(false),
     mVisibleCount(0)
 {
   if (!nsContentUtils::GetImgLoaderForChannel(nullptr)) {
     mLoadingEnabled = false;
@@ -157,30 +156,16 @@ nsImageLoadingContent::Notify(imgIReques
   if (aType == imgINotificationObserver::LOAD_COMPLETE) {
     uint32_t reqStatus;
     aRequest->GetImageStatus(&reqStatus);
     nsresult status =
         reqStatus & imgIRequest::STATUS_ERROR ? NS_ERROR_FAILURE : NS_OK;
     return OnStopRequest(aRequest, status);
   }
 
-  if (aType == imgINotificationObserver::DECODE_COMPLETE && mFireEventsOnDecode) {
-    mFireEventsOnDecode = false;
-
-    uint32_t reqStatus;
-    aRequest->GetImageStatus(&reqStatus);
-    if (reqStatus & imgIRequest::STATUS_ERROR) {
-      FireEvent(NS_LITERAL_STRING("error"));
-    } else {
-      FireEvent(NS_LITERAL_STRING("load"));
-    }
-
-    UpdateImageState(true);
-  }
-
   return NS_OK;
 }
 
 nsresult
 nsImageLoadingContent::OnStopRequest(imgIRequest* aRequest,
                                      nsresult aStatus)
 {
   uint32_t oldStatus;
@@ -223,44 +208,29 @@ nsImageLoadingContent::OnStopRequest(img
   // (*) IsPaintingSuppressed returns false if we haven't gotten the initial
   // reflow yet, so we have to test !DidInitialize || IsPaintingSuppressed.
   // It's possible for painting to be suppressed for reasons other than the
   // initial paint delay (for example, being in the bfcache), but we probably
   // aren't loading images in those situations.
 
   // XXXkhuey should this be GetOurCurrentDoc?  Decoding if we're not in
   // the document seems silly.
-  bool startedDecoding = false;
   nsIDocument* doc = GetOurOwnerDoc();
   nsIPresShell* shell = doc ? doc->GetShell() : nullptr;
   if (shell && shell->IsVisible() &&
       (!shell->DidInitialize() || shell->IsPaintingSuppressed())) {
 
-    if (NS_SUCCEEDED(mCurrentRequest->StartDecoding())) {
-      startedDecoding = true;
-    }
+    mCurrentRequest->StartDecoding();
   }
 
-  // We want to give the decoder a chance to find errors. If we haven't found
-  // an error yet and we've started decoding, either from the above
-  // StartDecoding or from some other place, we must only fire these events
-  // after we finish decoding.
-  uint32_t reqStatus;
-  aRequest->GetImageStatus(&reqStatus);
-  if (NS_SUCCEEDED(aStatus) && !(reqStatus & imgIRequest::STATUS_ERROR) &&
-      (reqStatus & imgIRequest::STATUS_DECODE_STARTED ||
-       (startedDecoding && !(reqStatus & imgIRequest::STATUS_DECODE_COMPLETE)))) {
-    mFireEventsOnDecode = true;
+  // Fire the appropriate DOM event.
+  if (NS_SUCCEEDED(aStatus)) {
+    FireEvent(NS_LITERAL_STRING("load"));
   } else {
-    // Fire the appropriate DOM event.
-    if (NS_SUCCEEDED(aStatus)) {
-      FireEvent(NS_LITERAL_STRING("load"));
-    } else {
-      FireEvent(NS_LITERAL_STRING("error"));
-    }
+    FireEvent(NS_LITERAL_STRING("error"));
   }
 
   nsCOMPtr<nsINode> thisNode = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
   nsSVGEffects::InvalidateDirectRenderingObservers(thisNode->AsElement());
 
   return NS_OK;
 }
 
--- a/content/base/src/nsImageLoadingContent.h
+++ b/content/base/src/nsImageLoadingContent.h
@@ -392,17 +392,16 @@ private:
   /**
    * The state we had the last time we checked whether we needed to notify the
    * document of a state change.  These are maintained by UpdateImageState.
    */
   bool mLoading : 1;
   bool mBroken : 1;
   bool mUserDisabled : 1;
   bool mSuppressed : 1;
-  bool mFireEventsOnDecode : 1;
 
 protected:
   /**
    * A hack to get animations to reset, see bug 594771. On requests
    * that originate from setting .src, we mark them for needing their animation
    * reset when they are ready. mNewRequestsWillNeedAnimationReset is set to
    * true while preparing such requests (as a hack around needing to change an
    * interface), and the other two booleans store which of the current
--- a/image/public/imgIRequest.idl
+++ b/image/public/imgIRequest.idl
@@ -50,33 +50,29 @@ interface imgIRequest : nsIRequest
    * go away or become a private state flag within imgRequest.
    * Don't rely on it.
    *
    * STATUS_LOAD_COMPLETE: The data has been fully loaded
    * to memory, but not necessarily fully decoded.
    *
    * STATUS_ERROR: An error occurred loading the image.
    *
-   * STATUS_DECODE_STARTED: The decoding process has begun, but not yet
-   * finished.
-   *
    * STATUS_FRAME_COMPLETE: The first frame has been
    * completely decoded.
    *
    * STATUS_DECODE_COMPLETE: The whole image has been decoded.
    */
   //@{
   const long STATUS_NONE             = 0x0;
   const long STATUS_SIZE_AVAILABLE   = 0x1;
   const long STATUS_LOAD_PARTIAL     = 0x2;
   const long STATUS_LOAD_COMPLETE    = 0x4;
   const long STATUS_ERROR            = 0x8;
-  const long STATUS_DECODE_STARTED   = 0x10;
-  const long STATUS_FRAME_COMPLETE   = 0x20;
-  const long STATUS_DECODE_COMPLETE  = 0x40;
+  const long STATUS_FRAME_COMPLETE   = 0x10;
+  const long STATUS_DECODE_COMPLETE  = 0x20;
   //@}
 
   /**
    * Status flags of the STATUS_* variety.
    */
   readonly attribute unsigned long imageStatus;
 
   /**
--- a/image/src/imgStatusTracker.cpp
+++ b/image/src/imgStatusTracker.cpp
@@ -471,25 +471,23 @@ imgStatusTracker::RecordLoaded()
 }
 
 void
 imgStatusTracker::RecordDecoded()
 {
   NS_ABORT_IF_FALSE(mImage, "RecordDecoded called before we have an Image");
   mState |= stateDecodeStarted | stateDecodeStopped | stateFrameStopped;
   mImageStatus |= imgIRequest::STATUS_FRAME_COMPLETE | imgIRequest::STATUS_DECODE_COMPLETE;
-  mImageStatus &= ~imgIRequest::STATUS_DECODE_STARTED;
 }
 
 void
 imgStatusTracker::RecordStartDecode()
 {
   NS_ABORT_IF_FALSE(mImage, "RecordStartDecode without an Image");
   mState |= stateDecodeStarted;
-  mImageStatus |= imgIRequest::STATUS_DECODE_STARTED;
 }
 
 void
 imgStatusTracker::SendStartDecode(imgRequestProxy* aProxy)
 {
   if (!aProxy->NotificationsDeferred())
     aProxy->OnStartDecode();
 }
@@ -547,23 +545,21 @@ imgStatusTracker::SendStopFrame(imgReque
 
 void
 imgStatusTracker::RecordStopDecode(nsresult aStatus)
 {
   NS_ABORT_IF_FALSE(mImage,
                     "RecordStopDecode called before we have an Image");
   mState |= stateDecodeStopped;
 
-  if (NS_SUCCEEDED(aStatus) && mImageStatus != imgIRequest::STATUS_ERROR) {
+  if (NS_SUCCEEDED(aStatus) && mImageStatus != imgIRequest::STATUS_ERROR)
     mImageStatus |= imgIRequest::STATUS_DECODE_COMPLETE;
-    mImageStatus &= ~imgIRequest::STATUS_DECODE_STARTED;
   // If we weren't successful, clear all success status bits and set error.
-  } else {
+  else
     mImageStatus = imgIRequest::STATUS_ERROR;
-  }
 }
 
 void
 imgStatusTracker::SendStopDecode(imgRequestProxy* aProxy,
                                  nsresult aStatus)
 {
   if (!aProxy->NotificationsDeferred())
     aProxy->OnStopDecode();
@@ -574,19 +570,18 @@ imgStatusTracker::RecordDiscard()
 {
   NS_ABORT_IF_FALSE(mImage,
                     "RecordDiscard called before we have an Image");
   // Clear the state bits we no longer deserve.
   uint32_t stateBitsToClear = stateDecodeStopped;
   mState &= ~stateBitsToClear;
 
   // Clear the status bits we no longer deserve.
-  uint32_t statusBitsToClear = imgIRequest::STATUS_DECODE_STARTED |
-                               imgIRequest::STATUS_FRAME_COMPLETE |
-                               imgIRequest::STATUS_DECODE_COMPLETE;
+  uint32_t statusBitsToClear = imgIRequest::STATUS_FRAME_COMPLETE
+                               | imgIRequest::STATUS_DECODE_COMPLETE;
   mImageStatus &= ~statusBitsToClear;
 }
 
 void
 imgStatusTracker::RecordUnlockedDraw()
 {
   NS_ABORT_IF_FALSE(mImage,
                     "RecordUnlockedDraw called before we have an Image");
@@ -645,18 +640,16 @@ imgStatusTracker::SendFrameChanged(imgRe
 void
 imgStatusTracker::RecordStartRequest()
 {
   // We're starting a new load, so clear any status and state bits indicating
   // load/decode
   mImageStatus &= ~imgIRequest::STATUS_LOAD_PARTIAL;
   mImageStatus &= ~imgIRequest::STATUS_LOAD_COMPLETE;
   mImageStatus &= ~imgIRequest::STATUS_FRAME_COMPLETE;
-  mImageStatus &= ~imgIRequest::STATUS_DECODE_STARTED;
-  mImageStatus &= ~imgIRequest::STATUS_DECODE_COMPLETE;
   mState &= ~stateRequestStarted;
   mState &= ~stateDecodeStarted;
   mState &= ~stateDecodeStopped;
   mState &= ~stateRequestStopped;
   mState &= ~stateBlockingOnload;
 
   mState |= stateRequestStarted;
 }
--- a/image/test/mochitest/Makefile.in
+++ b/image/test/mochitest/Makefile.in
@@ -96,18 +96,11 @@ MOCHITEST_CHROME_FILES = imgutils.js \
                 test_changeOfSource.html \
                 test_changeOfSource2.html \
                 test_undisplayed_iframe.html \
                 iframe.html \
                 ref-iframe.html \
                 test_net_failedtoprocess.html \
                 invalid.jpg \
                 damon.jpg \
-                test_removal_onload.html \
-                test_removal_ondecode.html \
-                invalid.jpg \
-                bad.jpg \
-                rillybad.jpg \
-                red.png \
-                lime100x100.svg \
                 $(NULL)
 
 include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/image/test/mochitest/test_removal_ondecode.html
+++ /dev/null
@@ -1,126 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=841579
--->
-<head>
-  <title>Test for Bug 841579</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
-  <script type="application/javascript" src="imgutils.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=841579">Mozilla Bug 841579</a>
-<p id="display"></p>
-<div id="content">
-</div>
-<pre id="test">
-<script type="application/javascript;version=1.8">
-/** Test for Bug 841579**/
-
-SimpleTest.waitForExplicitFinish();
-
-const FAILURE_TIMEOUT = 120000; // Fail early after 120 seconds (2 minutes)
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const gContent = document.getElementById("content");
-
-var gImg;
-var gMyDecoderObserver;
-var gIsTestFinished = false;
-var gFiles;
-var gNotifications = 0;
-var gLoads = 0;
-
-function fileToLoad() {
-  yield "red.png";
-  yield "invalid.jpg";
-  yield "lime100x100.svg";
-  yield "bad.jpg";
-  yield "rillybad.jpg";
-}
-
-function onSizeAvailable(aRequest) {
-  ok(true, "AfterLoad.onSizeAvailable called for " + gImg.src);
-}
-function onLoadComplete(aRequest) {
-  ok(true, "AfterLoad.onLoadComplete called for " + gImg.src);
-  gLoads++;
-}
-function onDecodeComplete(aRequest) {
-  ok(true, "AfterLoad.onDecodeComplete called for " + gImg.src);
-  SimpleTest.executeSoon(function() {
-    try {
-      gContent.removeChild(gImg);
-    } 
-    catch (e) {} 
-  });
-}
-
-function failTest() {
-  ok(false, "timing out after " + FAILURE_TIMEOUT + "ms.  " +
-            "currently displaying " + gImg.src);
-  cleanUpAndFinish();
-}
-
-function onNotification()
-{
-  gNotifications++;
-  try {
-    gImg.src = gFiles.next();
-    gContent.appendChild(gImg);
-  } catch(e) {
-    cleanUpAndFinish();
-  }
-}
-
-function cleanUpAndFinish() {
-  // On the off chance that failTest and myOnStopFrame are triggered
-  // back-to-back, use a flag to prevent multiple calls to SimpleTest.finish.
-  if (gIsTestFinished) {
-    return;
-  }
-  let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
-  imgLoadingContent.removeObserver(gMyDecoderObserver);
-  ok(gNotifications == gLoads, "Should be notified the same number of times as loads");
-  SimpleTest.finish();
-  gIsTestFinished = true;
-}
-
-function main() {
-  gFiles = fileToLoad();
-  gImg = new Image();
-  gImg.onload = onNotification;
-  gImg.onerror = onNotification;
-
-  // Create, customize & attach decoder observer
-  observer = new ImageDecoderObserverStub();
-  observer.sizeAvailable = onSizeAvailable;
-  observer.loadComplete = onLoadComplete;
-  observer.decodeComplete = onDecodeComplete;
-  gMyDecoderObserver =
-    Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
-      .createScriptedObserver(observer);
-  let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
-  imgLoadingContent.addObserver(gMyDecoderObserver);
-
-  // We want to test the cold loading behavior, so clear cache in case an
-  // earlier test got our image in there already.
-  clearImageCache();
-
-  // kick off image-loading! myOnStopFrame handles the rest.
-  gImg.setAttribute("src", gFiles.next());
-
-  // In case something goes wrong, fail earlier than mochitest timeout,
-  // and with more information.
-  setTimeout(failTest, FAILURE_TIMEOUT);
-}
-
-window.onload = main;
-
-</script>
-</pre>
-</body>
-</html>
deleted file mode 100644
--- a/image/test/mochitest/test_removal_onload.html
+++ /dev/null
@@ -1,126 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=841579
--->
-<head>
-  <title>Test for Bug 841579</title>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"></script>
-  <script type="application/javascript" src="imgutils.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
-</head>
-<body>
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=841579">Mozilla Bug 841579</a>
-<p id="display"></p>
-<div id="content">
-</div>
-<pre id="test">
-<script type="application/javascript;version=1.8">
-/** Test for Bug 841579**/
-
-SimpleTest.waitForExplicitFinish();
-
-const FAILURE_TIMEOUT = 120000; // Fail early after 120 seconds (2 minutes)
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-const gContent = document.getElementById("content");
-
-var gImg;
-var gMyDecoderObserver;
-var gIsTestFinished = false;
-var gFiles;
-var gNotifications = 0;
-var gLoads = 0;
-
-function fileToLoad() {
-  yield "red.png";
-  yield "invalid.jpg";
-  yield "lime100x100.svg";
-  yield "bad.jpg";
-  yield "rillybad.jpg";
-}
-
-function onSizeAvailable(aRequest) {
-  ok(true, "AfterLoad.onSizeAvailable called for " + gImg.src);
-}
-function onLoadComplete(aRequest) {
-  ok(true, "AfterLoad.onLoadComplete called for " + gImg.src);
-  gLoads++;
-  SimpleTest.executeSoon(function() {
-    try {
-      gContent.removeChild(gImg);
-    } 
-    catch (e) {} 
-  });
-}
-function onDecodeComplete(aRequest) {
-  ok(true, "AfterLoad.onDecodeComplete called for " + gImg.src);
-}
-
-function failTest() {
-  ok(false, "timing out after " + FAILURE_TIMEOUT + "ms.  " +
-            "currently displaying " + gImg.src);
-  cleanUpAndFinish();
-}
-
-function onNotification()
-{
-  gNotifications++;
-  try {
-    gImg.src = gFiles.next();
-    gContent.appendChild(gImg);
-  } catch(e) {
-    cleanUpAndFinish();
-  }
-}
-
-function cleanUpAndFinish() {
-  // On the off chance that failTest and myOnStopFrame are triggered
-  // back-to-back, use a flag to prevent multiple calls to SimpleTest.finish.
-  if (gIsTestFinished) {
-    return;
-  }
-  let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
-  imgLoadingContent.removeObserver(gMyDecoderObserver);
-  ok(gNotifications == gLoads, "Should be notified the same number of times as loads");
-  SimpleTest.finish();
-  gIsTestFinished = true;
-}
-
-function main() {
-  gFiles = fileToLoad();
-  gImg = new Image();
-  gImg.onload = onNotification;
-  gImg.onerror = onNotification;
-
-  // Create, customize & attach decoder observer
-  observer = new ImageDecoderObserverStub();
-  observer.sizeAvailable = onSizeAvailable;
-  observer.loadComplete = onLoadComplete;
-  observer.decodeComplete = onDecodeComplete;
-  gMyDecoderObserver =
-    Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
-      .createScriptedObserver(observer);
-  let imgLoadingContent = gImg.QueryInterface(Ci.nsIImageLoadingContent);
-  imgLoadingContent.addObserver(gMyDecoderObserver);
-
-  // We want to test the cold loading behavior, so clear cache in case an
-  // earlier test got our image in there already.
-  clearImageCache();
-
-  // kick off image-loading! myOnStopFrame handles the rest.
-  gImg.setAttribute("src", gFiles.next());
-
-  // In case something goes wrong, fail earlier than mochitest timeout,
-  // and with more information.
-  setTimeout(failTest, FAILURE_TIMEOUT);
-}
-
-window.onload = main;
-
-</script>
-</pre>
-</body>
-</html>