Bug 831095: Remove LOOP_OVER_OBSERVERS. r=bz a=akeybl
authorKyle Huey <khuey@kylehuey.com>
Fri, 18 Jan 2013 09:49:59 -0800
changeset 127256 e6cbd9c26842b95d8d8c65a40006c0f70218f7e2
parent 127255 ac84cba81cc9241eec47f5258996ca8133d4a383
child 127257 03685ebd4b2bf46cc064affd3665db97c15fe714
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, akeybl
bugs831095
milestone20.0a2
Bug 831095: Remove LOOP_OVER_OBSERVERS. r=bz a=akeybl
content/base/src/nsImageLoadingContent.cpp
--- a/content/base/src/nsImageLoadingContent.cpp
+++ b/content/base/src/nsImageLoadingContent.cpp
@@ -104,29 +104,16 @@ nsImageLoadingContent::DestroyImageLoadi
 nsImageLoadingContent::~nsImageLoadingContent()
 {
   NS_ASSERTION(!mCurrentRequest && !mPendingRequest,
                "DestroyImageLoadingContent not called");
   NS_ASSERTION(!mObserverList.mObserver && !mObserverList.mNext,
                "Observers still registered?");
 }
 
-// Macro to call some func on each observer.  This handles observers
-// removing themselves.
-#define LOOP_OVER_OBSERVERS(func_)                                       \
-  PR_BEGIN_MACRO                                                         \
-    for (ImageObserver* observer = &mObserverList, *next; observer;      \
-         observer = next) {                                              \
-      next = observer->mNext;                                            \
-      if (observer->mObserver) {                                         \
-        observer->mObserver->func_;                                      \
-      }                                                                  \
-    }                                                                    \
-  PR_END_MACRO
-
 /*
  * imgINotificationObserver impl
  */
 NS_IMETHODIMP
 nsImageLoadingContent::Notify(imgIRequest* aRequest,
                               int32_t aType,
                               const nsIntRect* aData)
 {
@@ -137,17 +124,27 @@ nsImageLoadingContent::Notify(imgIReques
   if (aType == imgINotificationObserver::LOAD_COMPLETE) {
     // We should definitely have a request here
     NS_ABORT_IF_FALSE(aRequest, "no request?");
 
     NS_PRECONDITION(aRequest == mCurrentRequest || aRequest == mPendingRequest,
                     "Unknown request");
   }
 
-  LOOP_OVER_OBSERVERS(Notify(aRequest, aType, aData));
+  {
+    nsAutoScriptBlocker scriptBlocker;
+
+    for (ImageObserver* observer = &mObserverList, *next; observer;
+         observer = next) {
+      next = observer->mNext;
+      if (observer->mObserver) {
+        observer->mObserver->Notify(aRequest, aType, aData);
+      }
+    }
+  }
 
   if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
     // Have to check for state changes here, since we might have been in
     // the LOADING state before.
     UpdateImageState(true);
   }
 
   if (aType == imgINotificationObserver::LOAD_COMPLETE) {