Replace direct instantiations of nsRunnableMethod with calls to the templatized NS_NewRunnableMethod function (part 3/3 of bug 558498). r=dwitte sr=dbaron
authorBen Newman <bnewman@mozilla.com>
Tue, 20 Apr 2010 16:21:35 -0700
changeset 41361 fa53318b87aa5a1fdc9a278a74ad110471d11ddb
parent 41360 a3733b568431be685ffd2a4d8d76147ee8661705
child 41362 4a02a072129ba5e86badd9669f5306bb629c24ec
push idunknown
push userunknown
push dateunknown
reviewersdwitte, dbaron
bugs558498
milestone1.9.3a5pre
Replace direct instantiations of nsRunnableMethod with calls to the templatized NS_NewRunnableMethod function (part 3/3 of bug 558498). r=dwitte sr=dbaron
content/base/src/nsContentSink.cpp
content/base/src/nsDocument.cpp
content/base/src/nsScriptLoader.cpp
content/base/src/nsTextNode.cpp
content/html/content/src/nsHTMLImageElement.cpp
content/html/content/src/nsHTMLInputElement.cpp
content/html/content/src/nsHTMLLinkElement.cpp
content/html/content/src/nsHTMLMediaElement.cpp
content/html/content/src/nsHTMLObjectElement.cpp
content/html/content/src/nsHTMLSharedObjectElement.cpp
content/html/content/src/nsHTMLStyleElement.cpp
content/html/document/src/nsHTMLDocument.cpp
content/html/document/src/nsImageDocument.cpp
content/html/document/src/nsWyciwygChannel.cpp
content/media/nsMediaStream.cpp
content/media/ogg/nsOggDecoder.cpp
content/media/ogg/nsOggPlayStateMachine.cpp
content/media/ogg/nsOggPlayStateMachine.h
content/media/wave/nsWaveDecoder.cpp
content/svg/content/src/nsSVGFilters.cpp
content/svg/content/src/nsSVGImageElement.cpp
content/svg/content/src/nsSVGStyleElement.cpp
content/xbl/src/nsBindingManager.cpp
content/xml/content/src/nsXMLStylesheetPI.cpp
content/xul/document/src/nsXULDocument.cpp
content/xul/templates/src/nsXULTemplateBuilder.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsGlobalWindow.cpp
dom/src/jsurl/nsJSProtocolHandler.cpp
dom/src/threads/nsDOMWorkerXHR.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresShell.cpp
layout/base/nsRefreshDriver.cpp
modules/libpr0n/src/imgRequestProxy.cpp
netwerk/base/src/nsPACMan.cpp
netwerk/base/src/nsServerSocket.cpp
netwerk/protocol/file/src/nsFileChannel.cpp
netwerk/protocol/http/src/nsHttpChannel.cpp
xpcom/threads/nsProcessCommon.cpp
--- a/content/base/src/nsContentSink.cpp
+++ b/content/base/src/nsContentSink.cpp
@@ -439,17 +439,17 @@ nsContentSink::ProcessHTTPHeaders(nsICha
   if (NS_SUCCEEDED(rv) && !linkHeader.IsEmpty()) {
     mDocument->SetHeaderData(nsGkAtoms::link,
                              NS_ConvertASCIItoUTF16(linkHeader));
 
     NS_ASSERTION(!mProcessLinkHeaderEvent.get(),
                  "Already dispatched an event?");
 
     mProcessLinkHeaderEvent =
-      new nsRunnableMethod<nsContentSink, void, false>(this,
+      NS_NewNonOwningRunnableMethod(this,
         &nsContentSink::DoProcessLinkHeader);
     rv = NS_DispatchToCurrentThread(mProcessLinkHeaderEvent.get());
     if (NS_FAILED(rv)) {
       mProcessLinkHeaderEvent.Forget();
     }
   }
   
   return NS_OK;
@@ -1733,17 +1733,17 @@ nsContentSink::ContinueInterruptedParsin
     mParser->ContinueInterruptedParsing();
   }
 }
 
 // Overridden in the HTML5 case
 void
 nsContentSink::ContinueInterruptedParsingAsync()
 {
-  nsCOMPtr<nsIRunnable> ev = new nsRunnableMethod<nsContentSink>(this,
+  nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this,
     &nsContentSink::ContinueInterruptedParsingIfEnabled);
 
   NS_DispatchToCurrentThread(ev);
 }
 
 // URIs: action, href, src, longdesc, usemap, cite
 PRBool 
 IsAttrURI(nsIAtom *aName)
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -3880,17 +3880,17 @@ nsDocument::MaybeEndOutermostXBLUpdate()
   // Only call BindingManager()->EndOutermostUpdate() when
   // we're not in an update and it is safe to run scripts.
   if (mUpdateNestLevel == 0 && mInXBLUpdate) {
     if (nsContentUtils::IsSafeToRunScript()) {
       mInXBLUpdate = PR_FALSE;
       BindingManager()->EndOutermostUpdate();
     } else if (!mInDestructor) {
       nsContentUtils::AddScriptRunner(
-        NS_NEW_RUNNABLE_METHOD(nsDocument, this, MaybeEndOutermostXBLUpdate));
+        NS_NewRunnableMethod(this, &nsDocument::MaybeEndOutermostXBLUpdate));
     }
   }
 }
 
 void
 nsDocument::BeginUpdate(nsUpdateType aUpdateType)
 {
   if (mUpdateNestLevel == 0 && !mInXBLUpdate) {
@@ -4148,18 +4148,17 @@ nsDocument::EndLoad()
     mWeakSink = do_GetWeakReference(mParser->GetContentSink());
     mParser = nsnull;
   }
   
   NS_DOCUMENT_NOTIFY_OBSERVERS(EndLoad, (this));
   
   if (!mSynchronousDOMContentLoaded) {
     nsRefPtr<nsIRunnable> ev =
-      new nsRunnableMethod<nsDocument>(this,
-                                       &nsDocument::DispatchContentLoadedEvents);
+      NS_NewRunnableMethod(this, &nsDocument::DispatchContentLoadedEvents);
     NS_DispatchToCurrentThread(ev);
   } else {
     DispatchContentLoadedEvents();
   }
 }
 
 void
 nsDocument::ContentStatesChanged(nsIContent* aContent1, nsIContent* aContent2,
@@ -5155,17 +5154,17 @@ nsDocument::NotifyPossibleTitleChange(PR
 {
   if (aBoundTitleElement) {
     mMayHaveTitleElement = PR_TRUE;
   }
   if (mPendingTitleChangeEvent.IsPending())
     return;
 
   nsRefPtr<nsRunnableMethod<nsDocument, void, false> > event =
-    new nsRunnableMethod<nsDocument, void, false>(this,
+    NS_NewNonOwningRunnableMethod(this,
       &nsDocument::DoNotifyPossibleTitleChange);
   nsresult rv = NS_DispatchToCurrentThread(event);
   if (NS_SUCCEEDED(rv)) {
     mPendingTitleChangeEvent = event;
   }
 }
 
 void
@@ -5311,18 +5310,17 @@ nsDocument::InitializeFrameLoader(nsFram
     NS_WARNING("Trying to initialize a frame loader while"
                "document is being deleted");
     return NS_ERROR_FAILURE;
   }
 
   mInitializableFrameLoaders.AppendElement(aLoader);
   if (!mFrameLoaderRunner) {
     mFrameLoaderRunner =
-      NS_NEW_RUNNABLE_METHOD(nsDocument, this,
-                             MaybeInitializeFinalizeFrameLoaders);
+      NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders);
     NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY);
     nsContentUtils::AddScriptRunner(mFrameLoaderRunner);
   }
   return NS_OK;
 }
 
 nsresult
 nsDocument::FinalizeFrameLoader(nsFrameLoader* aLoader)
@@ -5330,18 +5328,17 @@ nsDocument::FinalizeFrameLoader(nsFrameL
   mInitializableFrameLoaders.RemoveElement(aLoader);
   if (mInDestructor) {
     return NS_ERROR_FAILURE;
   }
 
   mFinalizableFrameLoaders.AppendElement(aLoader);
   if (!mFrameLoaderRunner) {
     mFrameLoaderRunner =
-      NS_NEW_RUNNABLE_METHOD(nsDocument, this,
-                             MaybeInitializeFinalizeFrameLoaders);
+      NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders);
     NS_ENSURE_TRUE(mFrameLoaderRunner, NS_ERROR_OUT_OF_MEMORY);
     nsContentUtils::AddScriptRunner(mFrameLoaderRunner);
   }
   return NS_OK;
 }
 
 void
 nsDocument::MaybeInitializeFinalizeFrameLoaders()
@@ -5355,18 +5352,17 @@ nsDocument::MaybeInitializeFinalizeFrame
 
   // We're not in an update, but it is not safe to run scripts, so
   // postpone frameloader initialization and finalization.
   if (!nsContentUtils::IsSafeToRunScript()) {
     if (!mInDestructor && !mFrameLoaderRunner &&
         (mInitializableFrameLoaders.Length() ||
          mFinalizableFrameLoaders.Length())) {
       mFrameLoaderRunner =
-        NS_NEW_RUNNABLE_METHOD(nsDocument, this,
-                               MaybeInitializeFinalizeFrameLoaders);
+        NS_NewRunnableMethod(this, &nsDocument::MaybeInitializeFinalizeFrameLoaders);
       nsContentUtils::AddScriptRunner(mFrameLoaderRunner);
     }
     return;
   }
   mFrameLoaderRunner = nsnull;
 
   // Don't use a temporary array for mInitializableFrameLoaders, because
   // loading a frame may cause some other frameloader to be removed from the
--- a/content/base/src/nsScriptLoader.cpp
+++ b/content/base/src/nsScriptLoader.cpp
@@ -559,17 +559,17 @@ nsScriptLoader::ProcessScriptElement(nsI
       if (aElement->GetScriptAsync()) {
         mAsyncRequests.AppendObject(request);
       }
       else {
         mRequests.AppendObject(request);
       }
 
       if (readyToRun) {
-        nsContentUtils::AddScriptRunner(new nsRunnableMethod<nsScriptLoader>(this,
+        nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this,
           &nsScriptLoader::ProcessPendingRequests));
       }
 
       return request->mDefer || aElement->GetScriptAsync() ?
         NS_OK : NS_ERROR_HTMLPARSER_BLOCK;
     }
   }
 
@@ -631,17 +631,17 @@ nsScriptLoader::ProcessScriptElement(nsI
 
   if (request->mDefer || aElement->GetScriptAsync()) {
     return NS_OK;
   }
 
   // If there weren't any pending requests before, and this one is
   // ready to execute, do that as soon as it's safe.
   if (!request->mLoading && !hadPendingRequests && ReadyToExecuteScripts()) {
-    nsContentUtils::AddScriptRunner(new nsRunnableMethod<nsScriptLoader>(this,
+    nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this,
       &nsScriptLoader::ProcessPendingRequests));
   }
 
   // Added as pending request, now we can send blocking back
   return NS_ERROR_HTMLPARSER_BLOCK;
 }
 
 nsresult
@@ -789,17 +789,17 @@ nsScriptLoader::GetFirstPendingRequest()
 
   return nsnull;
 }
 
 void
 nsScriptLoader::ProcessPendingRequestsAsync()
 {
   if (GetFirstPendingRequest() || !mPendingChildLoaders.IsEmpty()) {
-    nsCOMPtr<nsIRunnable> ev = new nsRunnableMethod<nsScriptLoader>(this,
+    nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this,
       &nsScriptLoader::ProcessPendingRequests);
 
     NS_DispatchToCurrentThread(ev);
   }
 }
 
 void
 nsScriptLoader::ProcessPendingRequests()
--- a/content/base/src/nsTextNode.cpp
+++ b/content/base/src/nsTextNode.cpp
@@ -340,18 +340,18 @@ nsAttributeTextNode::AttributeChanged(ns
   if (aNameSpaceID == mNameSpaceID && aAttribute == mAttrName &&
       aContent == mGrandparent) {
     // Since UpdateText notifies, do it asynchronously.  Note that if we get
     // unbound while the event is up that's ok -- we'll just have no
     // grandparent when it fires, and will do nothing.    
     // XXXbz ideally we'd either process this on layout flushes or do it right
     // after nsIMutationObserver notifications are over or something, instead
     // of doing it fully async.
-    nsCOMPtr<nsIRunnable> ev = new nsRunnableMethod<nsAttributeTextNode>(
-            this, &nsAttributeTextNode::UpdateText);
+    void (nsAttributeTextNode::*update)() = &nsAttributeTextNode::UpdateText;
+    nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this, update);
     NS_DispatchToCurrentThread(ev);
   }
 }
 
 void
 nsAttributeTextNode::NodeWillBeDestroyed(const nsINode* aNode)
 {
   NS_ASSERTION(aNode == static_cast<nsINode*>(mGrandparent), "Wrong node!");
--- a/content/html/content/src/nsHTMLImageElement.cpp
+++ b/content/html/content/src/nsHTMLImageElement.cpp
@@ -556,18 +556,17 @@ nsHTMLImageElement::BindToTree(nsIDocume
 
   if (HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
     ClearBrokenState();
     // If loading is temporarily disabled, don't even launch MaybeLoadImage.
     // Otherwise MaybeLoadImage may run later when someone has reenabled
     // loading.
     if (LoadingEnabled()) {
       nsContentUtils::AddScriptRunner(
-        new nsRunnableMethod<nsHTMLImageElement>(this,
-                                                 &nsHTMLImageElement::MaybeLoadImage));
+        NS_NewRunnableMethod(this, &nsHTMLImageElement::MaybeLoadImage));
     }
   }
 
   return rv;
 }
 
 void
 nsHTMLImageElement::MaybeLoadImage()
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -2176,18 +2176,17 @@ nsHTMLInputElement::BindToTree(nsIDocume
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (mType == NS_FORM_INPUT_IMAGE) {
     // Our base URI may have changed; claim that our URI changed, and the
     // nsImageLoadingContent will decide whether a new image load is warranted.
     if (HasAttr(kNameSpaceID_None, nsGkAtoms::src)) {
       ClearBrokenState();
       nsContentUtils::AddScriptRunner(
-        new nsRunnableMethod<nsHTMLInputElement>(this,
-                                                 &nsHTMLInputElement::MaybeLoadImage));
+        NS_NewRunnableMethod(this, &nsHTMLInputElement::MaybeLoadImage));
     }
   }
 
   // Add radio to document if we don't have a form already (if we do it's
   // already been added into that group)
   if (aDocument && !mForm && mType == NS_FORM_INPUT_RADIO) {
     AddedToRadioGroup();
   }
--- a/content/html/content/src/nsHTMLLinkElement.cpp
+++ b/content/html/content/src/nsHTMLLinkElement.cpp
@@ -208,19 +208,18 @@ nsHTMLLinkElement::BindToTree(nsIDocumen
 {
   Link::ResetLinkState(false);
 
   nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
                                                  aBindingParent,
                                                  aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsContentUtils::AddScriptRunner(
-    new nsRunnableMethod<nsHTMLLinkElement>(this,
-                                            &nsHTMLLinkElement::UpdateStyleSheetInternal));
+  void (nsHTMLLinkElement::*update)() = &nsHTMLLinkElement::UpdateStyleSheetInternal;
+  nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update));
 
   CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMLinkAdded"));
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsHTMLLinkElement::LinkAdded()
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -2018,17 +2018,17 @@ void nsHTMLMediaElement::AddRemoveSelfRe
       // The observer service will hold a strong reference to us. This
       // will do to keep us alive. We need to know about shutdown so that
       // we can release our self-reference.
       nsContentUtils::RegisterShutdownObserver(this);
     } else {
       // Dispatch Release asynchronously so that we don't destroy this object
       // inside a call stack of method calls on this object
       nsCOMPtr<nsIRunnable> event =
-        NS_NEW_RUNNABLE_METHOD(nsHTMLMediaElement, this, DoRemoveSelfReference);
+        NS_NewRunnableMethod(this, &nsHTMLMediaElement::DoRemoveSelfReference);
       NS_DispatchToMainThread(event);
     }
   }
 }
 
 void nsHTMLMediaElement::DoRemoveSelfReference()
 {
   // We don't need the shutdown observer anymore. Unregistering releases
--- a/content/html/content/src/nsHTMLObjectElement.cpp
+++ b/content/html/content/src/nsHTMLObjectElement.cpp
@@ -224,19 +224,18 @@ nsHTMLObjectElement::BindToTree(nsIDocum
 {
   nsresult rv = nsGenericHTMLFormElement::BindToTree(aDocument, aParent,
                                                      aBindingParent,
                                                      aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If we already have all the children, start the load.
   if (mIsDoneAddingChildren) {
-    nsContentUtils::AddScriptRunner(
-      new nsRunnableMethod<nsHTMLObjectElement>(this,
-                                                &nsHTMLObjectElement::StartObjectLoad));
+    void (nsHTMLObjectElement::*start)() = &nsHTMLObjectElement::StartObjectLoad;
+    nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start));
   }
 
   return NS_OK;
 }
 
 void
 nsHTMLObjectElement::UnbindFromTree(PRBool aDeep,
                                     PRBool aNullParent)
--- a/content/html/content/src/nsHTMLSharedObjectElement.cpp
+++ b/content/html/content/src/nsHTMLSharedObjectElement.cpp
@@ -255,19 +255,19 @@ nsHTMLSharedObjectElement::BindToTree(ns
 {
   nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
                                                  aBindingParent,
                                                  aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If we already have all the children, start the load.
   if (mIsDoneAddingChildren) {
-    nsContentUtils::AddScriptRunner(
-      new nsRunnableMethod<nsHTMLSharedObjectElement>(this,
-                                                      &nsHTMLSharedObjectElement::StartObjectLoad));
+    void (nsHTMLSharedObjectElement::*start)() =
+      &nsHTMLSharedObjectElement::StartObjectLoad;
+    nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, start));
   }
 
   return NS_OK;
 }
 
 void
 nsHTMLSharedObjectElement::UnbindFromTree(PRBool aDeep,
                                           PRBool aNullParent)
--- a/content/html/content/src/nsHTMLStyleElement.cpp
+++ b/content/html/content/src/nsHTMLStyleElement.cpp
@@ -237,19 +237,18 @@ nsHTMLStyleElement::BindToTree(nsIDocume
                                nsIContent* aBindingParent,
                                PRBool aCompileEventHandlers)
 {
   nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
                                                  aBindingParent,
                                                  aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsContentUtils::AddScriptRunner(
-    new nsRunnableMethod<nsHTMLStyleElement>(this,
-                                             &nsHTMLStyleElement::UpdateStyleSheetInternal));
+  void (nsHTMLStyleElement::*update)() = &nsHTMLStyleElement::UpdateStyleSheetInternal;
+  nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update));
 
   return rv;  
 }
 
 void
 nsHTMLStyleElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
 {
   nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -2998,17 +2998,17 @@ nsHTMLDocument::GetDesignMode(nsAString 
 void
 nsHTMLDocument::MaybeEditingStateChanged()
 {
   if (mUpdateNestLevel == 0 && (mContentEditableCount > 0) != IsEditingOn()) {
     if (nsContentUtils::IsSafeToRunScript()) {
       EditingStateChanged();
     } else if (!mInDestructor) {
       nsContentUtils::AddScriptRunner(
-        NS_NEW_RUNNABLE_METHOD(nsHTMLDocument, this, MaybeEditingStateChanged));
+        NS_NewRunnableMethod(this, &nsHTMLDocument::MaybeEditingStateChanged));
     }
   }
 }
 
 void
 nsHTMLDocument::EndUpdate(nsUpdateType aUpdateType)
 {
   nsDocument::EndUpdate(aUpdateType);
--- a/content/html/document/src/nsImageDocument.cpp
+++ b/content/html/document/src/nsImageDocument.cpp
@@ -564,17 +564,17 @@ nsImageDocument::ToggleImageSize()
 }
 
 NS_IMETHODIMP
 nsImageDocument::OnStartContainer(imgIRequest* aRequest, imgIContainer* aImage)
 {
   aImage->GetWidth(&mImageWidth);
   aImage->GetHeight(&mImageHeight);
   nsCOMPtr<nsIRunnable> runnable =
-    NS_NEW_RUNNABLE_METHOD(nsImageDocument, this, DefaultCheckOverflowing);
+    NS_NewRunnableMethod(this, &nsImageDocument::DefaultCheckOverflowing);
   nsContentUtils::AddScriptRunner(runnable);
   UpdateTitleAndCharset();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsImageDocument::HandleEvent(nsIDOMEvent* aEvent)
--- a/content/html/document/src/nsWyciwygChannel.cpp
+++ b/content/html/document/src/nsWyciwygChannel.cpp
@@ -301,18 +301,17 @@ nsWyciwygChannel::AsyncOpen(nsIStreamLis
   nsCAutoString spec;
   mURI->GetSpec(spec);
 
   // open a cache entry for this channel...
   PRBool delayed = PR_FALSE;
   nsresult rv = OpenCacheEntry(spec, nsICache::ACCESS_READ, &delayed);
   if (rv == NS_ERROR_CACHE_KEY_NOT_FOUND) {
     nsCOMPtr<nsIRunnable> ev =
-      new nsRunnableMethod<nsWyciwygChannel>(this,
-                                             &nsWyciwygChannel::NotifyListener);
+      NS_NewRunnableMethod(this, &nsWyciwygChannel::NotifyListener);
     // Overwrite rv on purpose; if event dispatch fails we'll bail, and
     // otherwise we'll wait until the event fires before calling back.
     rv = NS_DispatchToCurrentThread(ev);
     delayed = PR_TRUE;
   }
 
   if (NS_FAILED(rv)) {
     LOG(("nsWyciwygChannel::OpenCacheEntry failed [rv=%x]\n", rv));
--- a/content/media/nsMediaStream.cpp
+++ b/content/media/nsMediaStream.cpp
@@ -668,17 +668,17 @@ nsMediaChannelStream::CacheClientNotifyD
   NS_ASSERTION(NS_IsMainThread(), "Don't call on non-main thread");
   // NOTE: this can be called with the media cache lock held, so don't
   // block or do anything which might try to acquire a lock!
 
   if (mDataReceivedEvent.IsPending())
     return;
 
   mDataReceivedEvent =
-    new nsRunnableMethod<nsMediaChannelStream, void, false>(this, &nsMediaChannelStream::DoNotifyDataReceived);
+    NS_NewNonOwningRunnableMethod(this, &nsMediaChannelStream::DoNotifyDataReceived);
   NS_DispatchToMainThread(mDataReceivedEvent.get(), NS_DISPATCH_NORMAL);
 }
 
 class DataEnded : public nsRunnable {
 public:
   DataEnded(nsMediaDecoder* aDecoder, nsresult aStatus) :
     mDecoder(aDecoder), mStatus(aStatus) {}
   NS_IMETHOD Run() {
--- a/content/media/ogg/nsOggDecoder.cpp
+++ b/content/media/ogg/nsOggDecoder.cpp
@@ -164,17 +164,17 @@ void nsOggDecoder::Shutdown()
   // We can't destroy mDecodeStateMachine until mStateMachineThread is shut down.
   // It's unsafe to Shutdown() the decode thread here, as
   // nsIThread::Shutdown() may run events, such as JS event handlers,
   // and we could be running at an unsafe time such as during element
   // destruction.
   // So we destroy the decoder on the main thread in an asynchronous event.
   // See bug 468721.
   nsCOMPtr<nsIRunnable> event =
-    NS_NEW_RUNNABLE_METHOD(nsOggDecoder, this, Stop);
+    NS_NewRunnableMethod(this, &nsOggDecoder::Stop);
   NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
 
   nsContentUtils::UnregisterShutdownObserver(this);
 }
 
 nsOggDecoder::~nsOggDecoder()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
--- a/content/media/ogg/nsOggPlayStateMachine.cpp
+++ b/content/media/ogg/nsOggPlayStateMachine.cpp
@@ -465,23 +465,23 @@ void nsOggPlayStateMachine::UpdatePlayba
   NS_ASSERTION(mStartTime >= 0, "Should have positive mStartTime");
   mCurrentFrameTime = aTime - mStartTime;
   NS_ASSERTION(mCurrentFrameTime >= 0, "CurrentTime should be positive!");
   if (aTime > mEndTime) {
     NS_ASSERTION(mCurrentFrameTime > GetDuration(),
                  "CurrentTime must be after duration if aTime > endTime!");
     mEndTime = aTime;
     nsCOMPtr<nsIRunnable> event =
-      NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, DurationChanged);
+      NS_NewRunnableMethod(mDecoder, &nsOggDecoder::DurationChanged);
     NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
   }
   if (!mPositionChangeQueued) {
     mPositionChangeQueued = PR_TRUE;
     nsCOMPtr<nsIRunnable> event =
-      NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, PlaybackPositionChanged);
+      NS_NewRunnableMethod(mDecoder, &nsOggDecoder::PlaybackPositionChanged);
     NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
   }
 }
 
 void nsOggPlayStateMachine::ClearPositionChangeFlag()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
   mDecoder->GetMonitor().AssertCurrentThreadIn();
@@ -651,27 +651,27 @@ nsOggPlayStateMachine::StartDecodeThread
   mStopDecodeThreads = PR_FALSE;
   if (!mDecodeThread && mState < DECODER_STATE_COMPLETED) {
     nsresult rv = NS_NewThread(getter_AddRefs(mDecodeThread));
     if (NS_FAILED(rv)) {
       mState = DECODER_STATE_SHUTDOWN;
       return rv;
     }
     nsCOMPtr<nsIRunnable> event =
-      NS_NEW_RUNNABLE_METHOD(nsOggPlayStateMachine, this, DecodeLoop);
+      NS_NewRunnableMethod(this, &nsOggPlayStateMachine::DecodeLoop);
     mDecodeThread->Dispatch(event, NS_DISPATCH_NORMAL);
   }
   if (HasAudio() && !mAudioThread) {
     nsresult rv = NS_NewThread(getter_AddRefs(mAudioThread));
     if (NS_FAILED(rv)) {
       mState = DECODER_STATE_SHUTDOWN;
       return rv;
     }
     nsCOMPtr<nsIRunnable> event =
-      NS_NEW_RUNNABLE_METHOD(nsOggPlayStateMachine, this, AudioLoop);
+      NS_NewRunnableMethod(this, &nsOggPlayStateMachine::AudioLoop);
     mAudioThread->Dispatch(event, NS_DISPATCH_NORMAL);
   }
   return NS_OK;
 }
 
 nsresult nsOggPlayStateMachine::Run()
 {
   NS_ASSERTION(IsThread(mDecoder->mStateMachineThread),
@@ -719,17 +719,17 @@ nsresult nsOggPlayStateMachine::Run()
                            mDecoder, mStartTime, mEndTime, GetDuration(), mSeekable));
 
         if (mState == DECODER_STATE_SHUTDOWN)
           continue;
 
         // Inform the element that we've loaded the Ogg metadata and the
         // first frame.
         nsCOMPtr<nsIRunnable> metadataLoadedEvent =
-          NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, MetadataLoaded);
+          NS_NewRunnableMethod(mDecoder, &nsOggDecoder::MetadataLoaded);
         NS_DispatchToMainThread(metadataLoadedEvent, NS_DISPATCH_NORMAL);
 
         if (mState == DECODER_STATE_DECODING_METADATA) {
           LOG(PR_LOG_DEBUG, ("%p Changed state from DECODING_METADATA to DECODING", mDecoder));
           mState = DECODER_STATE_DECODING;
         }
 
         // Start playback.
@@ -812,17 +812,17 @@ nsresult nsOggPlayStateMachine::Run()
         ResetPlayback();
 
         // SeekingStarted will do a UpdateReadyStateForData which will
         // inform the element and its users that we have no frames
         // to display
         {
           MonitorAutoExit exitMon(mDecoder->GetMonitor());
           nsCOMPtr<nsIRunnable> startEvent =
-            NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, SeekingStarted);
+            NS_NewRunnableMethod(mDecoder, &nsOggDecoder::SeekingStarted);
           NS_DispatchToMainThread(startEvent, NS_DISPATCH_SYNC);
         }
         if (mCurrentFrameTime != mSeekTime - mStartTime) {
           nsresult res;
           {
             MonitorAutoExit exitMon(mDecoder->GetMonitor());
             // Now perform the seek. We must not hold the state machine monitor
             // while we seek, since the seek decodes.
@@ -859,22 +859,22 @@ nsresult nsOggPlayStateMachine::Run()
         // Change state to DECODING or COMPLETED now. SeekingStopped will
         // call nsOggPlayStateMachine::Seek to reset our state to SEEKING
         // if we need to seek again.
         
         nsCOMPtr<nsIRunnable> stopEvent;
         if (mCurrentFrameTime == mEndTime) {
           LOG(PR_LOG_DEBUG, ("%p Changed state from SEEKING (to %lldms) to COMPLETED",
                              mDecoder, seekTime));
-          stopEvent = NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, SeekingStoppedAtEnd);
+          stopEvent = NS_NewRunnableMethod(mDecoder, &nsOggDecoder::SeekingStoppedAtEnd);
           mState = DECODER_STATE_COMPLETED;
         } else {
           LOG(PR_LOG_DEBUG, ("%p Changed state from SEEKING (to %lldms) to DECODING",
                              mDecoder, seekTime));
-          stopEvent = NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, SeekingStopped);
+          stopEvent = NS_NewRunnableMethod(mDecoder, &nsOggDecoder::SeekingStopped);
           mState = DECODER_STATE_DECODING;
         }
         mBufferExhausted = PR_FALSE;
         mDecoder->GetMonitor().NotifyAll();
 
         {
           MonitorAutoExit exitMon(mDecoder->GetMonitor());
           NS_DispatchToMainThread(stopEvent, NS_DISPATCH_SYNC);
@@ -948,17 +948,17 @@ nsresult nsOggPlayStateMachine::Run()
 
         if (mDecoder->GetState() == nsOggDecoder::PLAY_STATE_PLAYING) {
           PRInt64 videoTime = HasVideo() ? (mVideoFrameTime + mInfo.mCallbackPeriod) : 0;
           PRInt64 clockTime = NS_MAX(mEndTime, NS_MAX(videoTime, GetAudioClock()));
           UpdatePlaybackPosition(clockTime);
           {
             MonitorAutoExit exitMon(mDecoder->GetMonitor());
             nsCOMPtr<nsIRunnable> event =
-              NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, PlaybackEnded);
+              NS_NewRunnableMethod(mDecoder, &nsOggDecoder::PlaybackEnded);
             NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);
           }
         }
 
         while (mState == DECODER_STATE_COMPLETED) {
           mDecoder->GetMonitor().Wait();
         }
       }
@@ -1198,17 +1198,17 @@ void nsOggPlayStateMachine::LoadOggHeade
     mReader->ReadOggHeaders(info);
   }
   mInfo = info;
   mDecoder->StartProgressUpdates();
 
   if (!mInfo.mHasVideo && !mInfo.mHasAudio) {
     mState = DECODER_STATE_SHUTDOWN;      
     nsCOMPtr<nsIRunnable> event =
-      NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, DecodeError);
+      NS_NewRunnableMethod(mDecoder, &nsOggDecoder::DecodeError);
     NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
     return;
   }
 
   if (!mInfo.mHasVideo) {
     mInfo.mCallbackPeriod = 1000 / AUDIO_FRAME_RATE;
   }
   LOG(PR_LOG_DEBUG, ("%p Callback Period: %u", mDecoder, mInfo.mCallbackPeriod));
@@ -1290,23 +1290,23 @@ void nsOggPlayStateMachine::FindEndTime(
 }
 
 void nsOggPlayStateMachine::UpdateReadyState() {
   mDecoder->GetMonitor().AssertCurrentThreadIn();
 
   nsCOMPtr<nsIRunnable> event;
   switch (GetNextFrameStatus()) {
     case nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE_BUFFERING:
-      event = NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, NextFrameUnavailableBuffering);
+      event = NS_NewRunnableMethod(mDecoder, &nsOggDecoder::NextFrameUnavailableBuffering);
       break;
     case nsHTMLMediaElement::NEXT_FRAME_AVAILABLE:
-      event = NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, NextFrameAvailable);
+      event = NS_NewRunnableMethod(mDecoder, &nsOggDecoder::NextFrameAvailable);
       break;
     case nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE:
-      event = NS_NEW_RUNNABLE_METHOD(nsOggDecoder, mDecoder, NextFrameUnavailable);
+      event = NS_NewRunnableMethod(mDecoder, &nsOggDecoder::NextFrameUnavailable);
       break;
     default:
       PR_NOT_REACHED("unhandled frame state");
   }
 
   NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
 }
 
--- a/content/media/ogg/nsOggPlayStateMachine.h
+++ b/content/media/ogg/nsOggPlayStateMachine.h
@@ -259,17 +259,17 @@ private:
   nsresult StartDecodeThreads();
 
   // Reads the Ogg headers using the nsOggReader, and initializes playback.
   // Called on the state machine thread. The decoder monitor must be held with
   // exactly one lock count.
   void LoadOggHeaders();
 
   // The main loop for the audio thread. Sent to the thread as
-  // an NS_NEW_RUNNABLE_METHOD. This continually does blocking writes to
+  // an nsRunnableMethod. This continually does blocking writes to
   // to audio stream to play audio data.
   void AudioLoop();
 
   // Stop or pause playback of media. This has two modes, denoted by
   // aMode being either AUDIO_PAUSE or AUDIO_SHUTDOWN.
   //
   // AUDIO_PAUSE: Suspends the audio stream to be resumed later.
   // This does not close the OS based audio stream 
--- a/content/media/wave/nsWaveDecoder.cpp
+++ b/content/media/wave/nsWaveDecoder.cpp
@@ -179,23 +179,23 @@ private:
   PRBool ReadAll(char* aBuf, PRInt64 aSize, PRInt64* aBytesRead);
 
   void UpdateReadyState() {
     PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mMonitor);
 
     nsCOMPtr<nsIRunnable> event;
     switch (GetNextFrameStatus()) {
       case nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE_BUFFERING:
-        event = NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, NextFrameUnavailableBuffering);
+        event = NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::NextFrameUnavailableBuffering);
         break;
       case nsHTMLMediaElement::NEXT_FRAME_AVAILABLE:
-        event = NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, NextFrameAvailable);
+        event = NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::NextFrameAvailable);
         break;
       case nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE:
-        event = NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, NextFrameUnavailable);
+        event = NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::NextFrameUnavailable);
         break;
       default:
         PR_NOT_REACHED("unhandled frame state");
     }
 
     NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
   }
 
@@ -524,17 +524,17 @@ nsWaveStateMachine::Run()
 
         if (!loaded) {
           ChangeState(STATE_ERROR);
         }
 
         if (mState == STATE_LOADING_METADATA) {
           mMetadataValid = PR_TRUE;
           if (mNextState != STATE_SEEKING) {
-            nsCOMPtr<nsIRunnable> event = NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, MetadataLoaded);
+            nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::MetadataLoaded);
             NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
           }
           ChangeState(mNextState);
         }
       }
       break;
 
     case STATE_BUFFERING: {
@@ -666,17 +666,17 @@ nsWaveStateMachine::Run()
       {
         CloseAudioStream();
 
         mSeekTime = NS_MIN(mSeekTime, GetDuration());
         float seekTime = mSeekTime;
 
         monitor.Exit();
         nsCOMPtr<nsIRunnable> startEvent =
-          NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, SeekingStarted);
+          NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::SeekingStarted);
         NS_DispatchToMainThread(startEvent, NS_DISPATCH_SYNC);
         monitor.Enter();
 
         if (mState == STATE_SHUTDOWN) {
           break;
         }
 
         // Calculate relative offset within PCM data.
@@ -723,17 +723,17 @@ nsWaveStateMachine::Run()
           }
           ChangeState(nextState);
         }
 
         FirePositionChanged(PR_TRUE);
 
         monitor.Exit();
         nsCOMPtr<nsIRunnable> stopEvent =
-          NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, SeekingStopped);
+          NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::SeekingStopped);
         NS_DispatchToMainThread(stopEvent, NS_DISPATCH_SYNC);
         monitor.Enter();
       }
       break;
 
     case STATE_PAUSED:
       monitor.Wait();
       break;
@@ -748,28 +748,28 @@ nsWaveStateMachine::Run()
 
         // After the drain call the audio stream is unusable. Close it so that
         // next time audio is used a new stream is created.
         CloseAudioStream();
       }
 
       if (mState == STATE_ENDED) {
         nsCOMPtr<nsIRunnable> event =
-          NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, PlaybackEnded);
+          NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::PlaybackEnded);
         NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
 
         do {
           monitor.Wait();
         } while (mState == STATE_ENDED);
       }
       break;
 
     case STATE_ERROR:
       {
-        nsCOMPtr<nsIRunnable> event = NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, DecodeError);
+        nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::DecodeError);
         NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
 
         monitor.Wait();
 
         if (mState != STATE_SHUTDOWN) {
           NS_WARNING("Invalid state transition");
           ChangeState(STATE_ERROR);
         }
@@ -1166,17 +1166,17 @@ nsWaveStateMachine::GetDataLength()
 void
 nsWaveStateMachine::FirePositionChanged(PRBool aCoalesce)
 {
   if (aCoalesce && mPositionChangeQueued) {
     return;
   }
 
   mPositionChangeQueued = PR_TRUE;
-  nsCOMPtr<nsIRunnable> event = NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, mDecoder, PlaybackPositionChanged);
+  nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(mDecoder, &nsWaveDecoder::PlaybackPositionChanged);
   NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
 }
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(nsWaveDecoder, nsIObserver)
 
 nsWaveDecoder::nsWaveDecoder()
   : mInitialVolume(1.0),
     mCurrentTime(0.0),
@@ -1484,17 +1484,17 @@ nsWaveDecoder::Shutdown()
   nsMediaDecoder::Shutdown();
 
   // An event that gets posted to the main thread, when the media element is
   // being destroyed, to destroy the decoder. Since the decoder shutdown can
   // block and post events this cannot be done inside destructor calls. So
   // this event is posted asynchronously to the main thread to perform the
   // shutdown.
   nsCOMPtr<nsIRunnable> event =
-    NS_NEW_RUNNABLE_METHOD(nsWaveDecoder, this, Stop);
+    NS_NewRunnableMethod(this, &nsWaveDecoder::Stop);
   NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
 }
 
 nsresult
 nsWaveDecoder::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData)
 {
   if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
     Shutdown();
--- a/content/svg/content/src/nsSVGFilters.cpp
+++ b/content/svg/content/src/nsSVGFilters.cpp
@@ -5438,18 +5438,17 @@ nsSVGFEImageElement::BindToTree(nsIDocum
   nsresult rv = nsSVGFEImageElementBase::BindToTree(aDocument, aParent,
                                                     aBindingParent,
                                                     aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (HasAttr(kNameSpaceID_XLink, nsGkAtoms::href)) {
     ClearBrokenState();
     nsContentUtils::AddScriptRunner(
-      new nsRunnableMethod<nsSVGFEImageElement>(this,
-                                                &nsSVGFEImageElement::MaybeLoadSVGImage));
+      NS_NewRunnableMethod(this, &nsSVGFEImageElement::MaybeLoadSVGImage));
   }
 
   return rv;
 }
 
 PRInt32
 nsSVGFEImageElement::IntrinsicState() const
 {
--- a/content/svg/content/src/nsSVGImageElement.cpp
+++ b/content/svg/content/src/nsSVGImageElement.cpp
@@ -201,18 +201,17 @@ nsSVGImageElement::BindToTree(nsIDocumen
   nsresult rv = nsSVGImageElementBase::BindToTree(aDocument, aParent,
                                                   aBindingParent,
                                                   aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (HasAttr(kNameSpaceID_XLink, nsGkAtoms::href)) {
     ClearBrokenState();
     nsContentUtils::AddScriptRunner(
-      new nsRunnableMethod<nsSVGImageElement>(this,
-                                              &nsSVGImageElement::MaybeLoadSVGImage));
+      NS_NewRunnableMethod(this, &nsSVGImageElement::MaybeLoadSVGImage));
   }
 
   return rv;
 }
 
 PRInt32
 nsSVGImageElement::IntrinsicState() const
 {
--- a/content/svg/content/src/nsSVGStyleElement.cpp
+++ b/content/svg/content/src/nsSVGStyleElement.cpp
@@ -158,19 +158,18 @@ nsSVGStyleElement::BindToTree(nsIDocumen
                               nsIContent* aBindingParent,
                               PRBool aCompileEventHandlers)
 {
   nsresult rv = nsSVGStyleElementBase::BindToTree(aDocument, aParent,
                                                   aBindingParent,
                                                   aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsContentUtils::AddScriptRunner(
-    new nsRunnableMethod<nsSVGStyleElement>(this,
-                                            &nsSVGStyleElement::UpdateStyleSheetInternal));
+  void (nsSVGStyleElement::*update)() = &nsSVGStyleElement::UpdateStyleSheetInternal;
+  nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update));
 
   return rv;  
 }
 
 void
 nsSVGStyleElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
 {
   nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
--- a/content/xbl/src/nsBindingManager.cpp
+++ b/content/xbl/src/nsBindingManager.cpp
@@ -960,17 +960,17 @@ nsBindingManager::AddToAttachedQueue(nsX
   return NS_OK;
 
 }
 
 void
 nsBindingManager::PostProcessAttachedQueueEvent()
 {
   mProcessAttachedQueueEvent =
-    NS_NEW_RUNNABLE_METHOD(nsBindingManager, this, DoProcessAttachedQueue);
+    NS_NewRunnableMethod(this, &nsBindingManager::DoProcessAttachedQueue);
   nsresult rv = NS_DispatchToCurrentThread(mProcessAttachedQueueEvent);
   if (NS_SUCCEEDED(rv) && mDocument) {
     mDocument->BlockOnload();
   }
 }
 
 void
 nsBindingManager::DoProcessAttachedQueue()
--- a/content/xml/content/src/nsXMLStylesheetPI.cpp
+++ b/content/xml/content/src/nsXMLStylesheetPI.cpp
@@ -120,19 +120,18 @@ nsXMLStylesheetPI::BindToTree(nsIDocumen
                               nsIContent* aBindingParent,
                               PRBool aCompileEventHandlers)
 {
   nsresult rv = nsXMLProcessingInstruction::BindToTree(aDocument, aParent,
                                                        aBindingParent,
                                                        aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsContentUtils::AddScriptRunner(
-    new nsRunnableMethod<nsXMLStylesheetPI>(this,
-                                            &nsXMLStylesheetPI::UpdateStyleSheetInternal));
+  void (nsXMLStylesheetPI::*update)() = &nsXMLStylesheetPI::UpdateStyleSheetInternal;
+  nsContentUtils::AddScriptRunner(NS_NewRunnableMethod(this, update));
 
   return rv;  
 }
 
 void
 nsXMLStylesheetPI::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
 {
   nsCOMPtr<nsIDocument> oldDoc = GetCurrentDoc();
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -3274,17 +3274,17 @@ nsXULDocument::MaybeBroadcast()
 {
     // Only broadcast when not in an update and when safe to run scripts.
     if (mUpdateNestLevel == 0 &&
         (mDelayedAttrChangeBroadcasts.Length() ||
          mDelayedBroadcasters.Length())) {
         if (!nsContentUtils::IsSafeToRunScript()) {
             if (!mInDestructor) {
                 nsContentUtils::AddScriptRunner(
-                  NS_NEW_RUNNABLE_METHOD(nsXULDocument, this, MaybeBroadcast));
+                    NS_NewRunnableMethod(this, &nsXULDocument::MaybeBroadcast));
             }
             return;
         }
         if (!mHandlingDelayedAttrChange) {
             mHandlingDelayedAttrChange = PR_TRUE;
             for (PRUint32 i = 0; i < mDelayedAttrChangeBroadcasts.Length(); ++i) {
                 nsIAtom* attrName = mDelayedAttrChangeBroadcasts[i].mAttrName;
                 if (mDelayedAttrChangeBroadcasts[i].mNeedsAttrChange) {
--- a/content/xul/templates/src/nsXULTemplateBuilder.cpp
+++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp
@@ -1116,30 +1116,28 @@ nsXULTemplateBuilder::AttributeChanged(n
                                        PRInt32      aModType)
 {
     if (aContent == mRoot && aNameSpaceID == kNameSpaceID_None) {
         // Check for a change to the 'ref' attribute on an atom, in which
         // case we may need to nuke and rebuild the entire content model
         // beneath the element.
         if (aAttribute == nsGkAtoms::ref)
             nsContentUtils::AddScriptRunner(
-                NS_NEW_RUNNABLE_METHOD(nsXULTemplateBuilder, this,
-                                       RunnableRebuild));
+                NS_NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableRebuild));
 
         // Check for a change to the 'datasources' attribute. If so, setup
         // mDB by parsing the new value and rebuild.
         else if (aAttribute == nsGkAtoms::datasources) {
             Uninit(PR_FALSE);  // Reset results
             
             PRBool shouldDelay;
             LoadDataSources(aDocument, &shouldDelay);
             if (!shouldDelay)
                 nsContentUtils::AddScriptRunner(
-                    NS_NEW_RUNNABLE_METHOD(nsXULTemplateBuilder, this,
-                                           RunnableRebuild));
+                    NS_NewRunnableMethod(this, &nsXULTemplateBuilder::RunnableRebuild));
         }
     }
 }
 
 void
 nsXULTemplateBuilder::ContentRemoved(nsIDocument* aDocument,
                                      nsIContent* aContainer,
                                      nsIContent* aChild,
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -7757,18 +7757,18 @@ nsElementSH::PostCreate(nsIXPConnectWrap
   xblService->LoadBindings(content, uri, principal, PR_FALSE,
                            getter_AddRefs(binding), &dummy);
   
   if (binding) {
     if (nsContentUtils::IsSafeToRunScript()) {
       binding->ExecuteAttachedHandler();
     }
     else {
-      nsContentUtils::AddScriptRunner(new nsRunnableMethod<nsXBLBinding>(
-        binding, &nsXBLBinding::ExecuteAttachedHandler));
+      nsContentUtils::AddScriptRunner(
+        NS_NewRunnableMethod(binding, &nsXBLBinding::ExecuteAttachedHandler));
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsElementSH::Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -2459,19 +2459,18 @@ nsGlobalWindow::OnFinalize(PRUint32 aLan
 void
 nsGlobalWindow::SetScriptsEnabled(PRBool aEnabled, PRBool aFireTimeouts)
 {
   FORWARD_TO_INNER_VOID(SetScriptsEnabled, (aEnabled, aFireTimeouts));
 
   if (aEnabled && aFireTimeouts) {
     // Scripts are enabled (again?) on this context, run timeouts that
     // fired on this context while scripts were disabled.
-    nsCOMPtr<nsIRunnable> event =
-      NS_NEW_RUNNABLE_METHOD(nsGlobalWindow, this, RunTimeout);
-    NS_DispatchToCurrentThread(event);
+    void (nsGlobalWindow::*run)() = &nsGlobalWindow::RunTimeout;
+    NS_DispatchToCurrentThread(NS_NewRunnableMethod(this, run));
   }
 }
 
 nsresult
 nsGlobalWindow::SetArguments(nsIArray *aArguments, nsIPrincipal *aOrigin)
 {
   FORWARD_TO_OUTER(SetArguments, (aArguments, aOrigin),
                    NS_ERROR_NOT_INITIALIZED);
--- a/dom/src/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/src/jsurl/nsJSProtocolHandler.cpp
@@ -688,17 +688,17 @@ nsJSChannel::AsyncOpen(nsIStreamListener
     }
     if (mDocumentOnloadBlockedOn) {
         mDocumentOnloadBlockedOn->BlockOnload();
     }
 
 
     mPopupState = win->GetPopupControlState();
 
-    nsRunnableMethod<nsJSChannel>::Method method;
+    void (nsJSChannel::*method)();
     if (mIsAsync) {
         // post an event to do the rest
         method = &nsJSChannel::EvaluateScript;
     } else {   
         EvaluateScript();
         if (mOpenedStreamChannel) {
             // That will handle notifying things
             return NS_OK;
@@ -719,17 +719,17 @@ nsJSChannel::AsyncOpen(nsIStreamListener
         }
 
         // We're returning success from asyncOpen(), but we didn't open a
         // stream channel.  We'll have to notify ourselves, but make sure to do
         // it asynchronously.
         method = &nsJSChannel::NotifyListener;            
     }
 
-    nsCOMPtr<nsIRunnable> ev = new nsRunnableMethod<nsJSChannel>(this, method);
+    nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(this, method);
     nsresult rv = NS_DispatchToCurrentThread(ev);
 
     if (NS_FAILED(rv)) {
         loadGroup->RemoveRequest(this, nsnull, rv);
         mIsActive = PR_FALSE;
         CleanupStrongRefs();
     }
     return rv;
--- a/dom/src/threads/nsDOMWorkerXHR.cpp
+++ b/dom/src/threads/nsDOMWorkerXHR.cpp
@@ -349,17 +349,17 @@ nsDOMWorkerXHR::nsDOMWorkerXHR(nsDOMWork
   NS_ASSERTION(aWorker, "Must have a worker!");
 }
 
 nsDOMWorkerXHR::~nsDOMWorkerXHR()
 {
   if (mXHRProxy) {
     if (!NS_IsMainThread()) {
       nsCOMPtr<nsIRunnable> runnable =
-        NS_NEW_RUNNABLE_METHOD(nsDOMWorkerXHRProxy, mXHRProxy.get(), Destroy);
+        NS_NewRunnableMethod(mXHRProxy, &nsDOMWorkerXHRProxy::Destroy);
 
       if (runnable) {
         mXHRProxy = nsnull;
         NS_DispatchToMainThread(runnable, NS_DISPATCH_NORMAL);
       }
     }
     else {
       mXHRProxy->Destroy();
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1465,18 +1465,17 @@ nsPresContext::GetTheme()
 void
 nsPresContext::ThemeChanged()
 {
   if (!mPendingThemeChanged) {
     sLookAndFeelChanged = PR_TRUE;
     sThemeChanged = PR_TRUE;
 
     nsCOMPtr<nsIRunnable> ev =
-      new nsRunnableMethod<nsPresContext>(this,
-                                          &nsPresContext::ThemeChangedInternal);
+      NS_NewRunnableMethod(this, &nsPresContext::ThemeChangedInternal);
     if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
       mPendingThemeChanged = PR_TRUE;
     }
   }    
 }
 
 void
 nsPresContext::ThemeChangedInternal()
@@ -1510,18 +1509,17 @@ nsPresContext::ThemeChangedInternal()
 }
 
 void
 nsPresContext::SysColorChanged()
 {
   if (!mPendingSysColorChanged) {
     sLookAndFeelChanged = PR_TRUE;
     nsCOMPtr<nsIRunnable> ev =
-      new nsRunnableMethod<nsPresContext>(this,
-                                          &nsPresContext::SysColorChangedInternal);
+      NS_NewRunnableMethod(this, &nsPresContext::SysColorChangedInternal);
     if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
       mPendingSysColorChanged = PR_TRUE;
     }
   }
 }
 
 void
 nsPresContext::SysColorChangedInternal()
@@ -1577,18 +1575,17 @@ nsPresContext::MediaFeatureValuesChanged
   }
 }
 
 void
 nsPresContext::PostMediaFeatureValuesChangedEvent()
 {
   if (!mPendingMediaFeatureValuesChanged) {
     nsCOMPtr<nsIRunnable> ev =
-      new nsRunnableMethod<nsPresContext>(this,
-                         &nsPresContext::HandleMediaFeatureValuesChangedEvent);
+      NS_NewRunnableMethod(this, &nsPresContext::HandleMediaFeatureValuesChangedEvent);
     if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
       mPendingMediaFeatureValuesChanged = PR_TRUE;
     }
   }
 }
 
 void
 nsPresContext::HandleMediaFeatureValuesChangedEvent()
@@ -1963,18 +1960,17 @@ nsPresContext::RebuildUserFontSet()
   // post an event to rebuild it.  Setting the user font set to be dirty
   // and lazily rebuilding it isn't sufficient, since it is only the act
   // of rebuilding it that will trigger the style change reflow that
   // calls GetUserFontSet.  (This reflow causes rebuilding of text runs,
   // which starts font loads, whose completion causes another style
   // change reflow).
   if (!mPostedFlushUserFontSet) {
     nsCOMPtr<nsIRunnable> ev =
-      new nsRunnableMethod<nsPresContext>(this,
-                                     &nsPresContext::HandleRebuildUserFontSet);
+      NS_NewRunnableMethod(this, &nsPresContext::HandleRebuildUserFontSet);
     if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
       mPostedFlushUserFontSet = PR_TRUE;
     }
   }    
 }
 
 void
 nsPresContext::UserFontSetUpdated()
@@ -2106,18 +2102,17 @@ nsPresContext::NotifyInvalidation(const 
   // even cheaper by providing a more efficient
   // nsPIDOMWindow::GetListenerManager.
   if (aRect.IsEmpty() || !MayHavePaintEventListener())
     return;
 
   if (!IsDOMPaintEventPending()) {
     // No event is pending. Dispatch one now.
     nsCOMPtr<nsIRunnable> ev =
-      new nsRunnableMethod<nsPresContext>(this,
-                                          &nsPresContext::FireDOMPaintEvent);
+      NS_NewRunnableMethod(this, &nsPresContext::FireDOMPaintEvent);
     NS_DispatchToCurrentThread(ev);
   }
 
   nsInvalidateRequestList::Request* request =
     mInvalidateRequests.mRequests.AppendElement();
   if (!request)
     return;
 
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -2669,17 +2669,17 @@ PresShell::ResizeReflow(nscoord aWidth, 
       if (mAsyncResizeEventTimer) {
         mAsyncResizeTimerIsActive = PR_TRUE;
         mAsyncResizeEventTimer->InitWithFuncCallback(AsyncResizeEventCallback,
                                                      this, 15,
                                                      nsITimer::TYPE_ONE_SHOT);
       }
     } else {
       nsRefPtr<nsRunnableMethod<PresShell> > resizeEvent =
-        NS_NEW_RUNNABLE_METHOD(PresShell, this, FireResizeEvent);
+        NS_NewRunnableMethod(this, &PresShell::FireResizeEvent);
       if (NS_SUCCEEDED(NS_DispatchToCurrentThread(resizeEvent))) {
         mResizeEvent = resizeEvent;
       }
     }
   }
 
   return NS_OK; //XXX this needs to be real. MMP
 }
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -237,18 +237,17 @@ nsRefreshDriver::Freeze()
 }
 
 void
 nsRefreshDriver::Thaw()
 {
   NS_ASSERTION(mFrozen, "Thaw called on an unfrozen refresh driver");
   mFrozen = PR_FALSE;
   if (ObserverCount()) {
-    NS_DispatchToCurrentThread(NS_NEW_RUNNABLE_METHOD(nsRefreshDriver, this,
-                                                      DoRefresh));
+    NS_DispatchToCurrentThread(NS_NewRunnableMethod(this, &nsRefreshDriver::DoRefresh));
     EnsureTimerStarted();
   }
 }
 
 void
 nsRefreshDriver::DoRefresh()
 {
   // Don't do a refresh unless we're in a state where we should be refreshing.
--- a/modules/libpr0n/src/imgRequestProxy.cpp
+++ b/modules/libpr0n/src/imgRequestProxy.cpp
@@ -269,17 +269,17 @@ NS_IMETHODIMP imgRequestProxy::CancelAnd
   // Passing false to aNotify means that mListener will still get
   // OnStopRequest, if needed.
   mOwner->RemoveProxy(this, aStatus, PR_FALSE);
 
   mIsInLoadGroup = oldIsInLoadGroup;
 
   if (mIsInLoadGroup) {
     nsCOMPtr<nsIRunnable> ev =
-      NS_NEW_RUNNABLE_METHOD(imgRequestProxy, this, DoRemoveFromLoadGroup);
+      NS_NewRunnableMethod(this, &imgRequestProxy::DoRemoveFromLoadGroup);
     NS_DispatchToCurrentThread(ev);
   }
 
   NullOutListener();
 
   return NS_OK;
 }
 
--- a/netwerk/base/src/nsPACMan.cpp
+++ b/netwerk/base/src/nsPACMan.cpp
@@ -263,17 +263,17 @@ nsPACMan::LoadPACFromURI(nsIURI *pacURI)
   // Since we might get called from nsProtocolProxyService::Init, we need to
   // post an event back to the main thread before we try to use the IO service.
   //
   // But, we need to flag ourselves as loading, so that we queue up any PAC
   // queries the enter between now and when we actually load the PAC file.
 
   if (!mLoadPending) {
     nsCOMPtr<nsIRunnable> event =
-        NS_NEW_RUNNABLE_METHOD(nsPACMan, this, StartLoading);
+      NS_NewRunnableMethod(this, &nsPACMan::StartLoading);
     nsresult rv;
     if (NS_FAILED(rv = NS_DispatchToCurrentThread(event)))
       return rv;
     mLoadPending = PR_TRUE;
   }
 
   CancelExistingLoad();
 
--- a/netwerk/base/src/nsServerSocket.cpp
+++ b/netwerk/base/src/nsServerSocket.cpp
@@ -51,17 +51,17 @@ static NS_DEFINE_CID(kSocketTransportSer
 
 //-----------------------------------------------------------------------------
 
 typedef void (nsServerSocket:: *nsServerSocketFunc)(void);
 
 static nsresult
 PostEvent(nsServerSocket *s, nsServerSocketFunc func)
 {
-  nsCOMPtr<nsIRunnable> ev = new nsRunnableMethod<nsServerSocket>(s, func);
+  nsCOMPtr<nsIRunnable> ev = NS_NewRunnableMethod(s, func);
   if (!ev)
     return NS_ERROR_OUT_OF_MEMORY;
 
   return gSocketTransportService->Dispatch(ev, NS_DISPATCH_NORMAL);
 }
 
 //-----------------------------------------------------------------------------
 // nsServerSocket
@@ -146,17 +146,17 @@ nsServerSocket::TryAttach()
   // with the race condition.  though it isn't the most elegant solution,
   // it is far simpler than trying to build a system that would guarantee
   // FIFO ordering (which wouldn't even be that valuable IMO).  see bug
   // 194402 for more info.
   //
   if (!gSocketTransportService->CanAttachSocket())
   {
     nsCOMPtr<nsIRunnable> event =
-        NS_NEW_RUNNABLE_METHOD(nsServerSocket, this, OnMsgAttach);
+      NS_NewRunnableMethod(this, &nsServerSocket::OnMsgAttach);
     if (!event)
       return NS_ERROR_OUT_OF_MEMORY;
 
     nsresult rv = gSocketTransportService->NotifyWhenCanAttachSocket(event);
     if (NS_FAILED(rv))
       return rv;
   }
 
--- a/netwerk/protocol/file/src/nsFileChannel.cpp
+++ b/netwerk/protocol/file/src/nsFileChannel.cpp
@@ -250,18 +250,17 @@ nsFileUploadContentStream::AsyncWait(nsI
                                      nsIEventTarget *target)
 {
   nsresult rv = nsBaseContentStream::AsyncWait(callback, flags, count, target);
   if (NS_FAILED(rv) || IsClosed())
     return rv;
 
   if (IsNonBlocking()) {
     nsCOMPtr<nsIRunnable> callback =
-        NS_NEW_RUNNABLE_METHOD(nsFileUploadContentStream, this,
-                               OnCopyComplete);
+      NS_NewRunnableMethod(this, &nsFileUploadContentStream::OnCopyComplete);
     mCopyEvent->Dispatch(callback, mSink, target);
   }
 
   return NS_OK;
 }
 
 void
 nsFileUploadContentStream::OnCopyComplete()
--- a/netwerk/protocol/http/src/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/src/nsHttpChannel.cpp
@@ -245,17 +245,17 @@ nsHttpChannel::Init(nsIURI *uri,
 
 nsresult
 nsHttpChannel::AsyncCall(nsAsyncCallback funcPtr,
                          nsRunnableMethod<nsHttpChannel> **retval)
 {
     nsresult rv;
 
     nsRefPtr<nsRunnableMethod<nsHttpChannel> > event =
-            new nsRunnableMethod<nsHttpChannel>(this, funcPtr);
+        NS_NewRunnableMethod(this, funcPtr);
     rv = NS_DispatchToCurrentThread(event);
     if (NS_SUCCEEDED(rv) && retval) {
         *retval = event;
     }
 
     return rv;
 }
 
--- a/xpcom/threads/nsProcessCommon.cpp
+++ b/xpcom/threads/nsProcessCommon.cpp
@@ -279,17 +279,18 @@ void PR_CALLBACK nsProcess::Monitor(void
 #endif
 
     // If we ran a background thread for the monitor then notify on the main
     // thread
     if (NS_IsMainThread()) {
         process->ProcessComplete();
     }
     else {
-        nsCOMPtr<nsIRunnable> event = new nsRunnableMethod<nsProcess>(process, &nsProcess::ProcessComplete);
+        nsCOMPtr<nsIRunnable> event =
+            NS_NewRunnableMethod(process, &nsProcess::ProcessComplete);
         NS_DispatchToMainThread(event);
     }
 }
 
 void nsProcess::ProcessComplete()
 {
     if (mThread) {
         nsCOMPtr<nsIObserverService> os = do_GetService("@mozilla.org/observer-service;1");