prerewrite_fixes.patch
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 123 55f4c3203c4f384a083cc87cccea108f7db740b9
permissions -rw-r--r--
State as of now

* * *

diff --git a/accessible/src/base/nsAccessNode.h b/accessible/src/base/nsAccessNode.h
--- a/accessible/src/base/nsAccessNode.h
+++ b/accessible/src/base/nsAccessNode.h
@@ -97,7 +97,8 @@ class nsAccessNode: public nsIAccessNode
                               void* aUniqueID, nsIAccessNode **aAccessNode);
     static void ClearCache(nsAccessNodeHashtable& aCache);
 
-    static PLDHashOperator PR_CALLBACK ClearCacheEntry(const void* aKey, nsCOMPtr<nsIAccessNode>& aAccessNode, void* aUserArg);
+#define HIDE_FROM_GARBURATOR(x) x;
+    HIDE_FROM_GARBURATOR(static PLDHashOperator PR_CALLBACK ClearCacheEntry(const void* aKey, nsCOMPtr<nsIAccessNode>& aAccessNode, void* aUserArg))
 
     // Static cache methods for global document cache
     static already_AddRefed<nsIAccessibleDocument> GetDocAccessibleFor(nsIDocument *aDocument);
diff --git a/content/base/src/nsImageLoadingContent.cpp b/content/base/src/nsImageLoadingContent.cpp
--- a/content/base/src/nsImageLoadingContent.cpp
+++ b/content/base/src/nsImageLoadingContent.cpp
@@ -443,10 +443,11 @@ nsImageLoadingContent::LoadImageWithChan
   CancelImageRequests(NS_ERROR_IMAGE_SRC_CHANGED, PR_FALSE,
                       nsIContentPolicy::ACCEPT);
 
-  nsCOMPtr<imgIRequest> & req = mCurrentRequest ? mPendingRequest : mCurrentRequest;
-
   nsresult rv = nsContentUtils::GetImgLoader()->
-    LoadImageWithChannel(aChannel, this, doc, aListener, getter_AddRefs(req));
+    LoadImageWithChannel(aChannel, this, doc, aListener, 
+                         getter_AddRefs(mCurrentRequest 
+                                        ? mPendingRequest 
+                                        : mCurrentRequest));
 
   // Make sure our state is up to date
   UpdateImageState(PR_TRUE);
@@ -577,14 +578,14 @@ nsImageLoadingContent::LoadImage(nsIURI*
     FireEvent(NS_LITERAL_STRING("error"));
     return NS_OK;
   }
-
-  nsCOMPtr<imgIRequest> & req = mCurrentRequest ? mPendingRequest : mCurrentRequest;
-
+  
   rv = nsContentUtils::LoadImage(aNewURI, aDocument,
                                  aDocument->NodePrincipal(),
                                  aDocument->GetDocumentURI(),
                                  this, aLoadFlags,
-                                 getter_AddRefs(req));
+                                 getter_AddRefs(mCurrentRequest
+                                                ? mPendingRequest
+                                                : mCurrentRequest));
   if (NS_FAILED(rv)) {
     FireEvent(NS_LITERAL_STRING("error"));
     return NS_OK;
diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -982,7 +982,7 @@ nsXMLHttpRequest::CreateEvent(const nsAS
 }
 
 void
-nsXMLHttpRequest::CopyEventListeners(nsCOMPtr<nsIDOMEventListener>& aListener,
+nsXMLHttpRequest::CopyEventListeners(nsIDOMEventListener* aListener,
                                      const nsCOMArray<nsIDOMEventListener>& aListenerArray,
                                      nsCOMArray<nsIDOMEventListener>& aCopy)
 {
diff --git a/content/base/src/nsXMLHttpRequest.h b/content/base/src/nsXMLHttpRequest.h
--- a/content/base/src/nsXMLHttpRequest.h
+++ b/content/base/src/nsXMLHttpRequest.h
@@ -158,7 +158,7 @@ protected:
   nsresult CreateEvent(const nsAString& aType, nsIDOMEvent** domevent);
 
   // Make a copy of a pair of members to be passed to NotifyEventListeners.
-  void CopyEventListeners(nsCOMPtr<nsIDOMEventListener>& aListener,
+  void CopyEventListeners(nsIDOMEventListener* aListener,
                           const nsCOMArray<nsIDOMEventListener>& aListenerArray,
                           nsCOMArray<nsIDOMEventListener>& aCopy);
 
diff --git a/content/html/content/src/nsHTMLTableElement.cpp b/content/html/content/src/nsHTMLTableElement.cpp
--- a/content/html/content/src/nsHTMLTableElement.cpp
+++ b/content/html/content/src/nsHTMLTableElement.cpp
@@ -831,7 +831,8 @@ nsHTMLTableElement::InsertRow(PRInt32 aI
           }
         }
         
-        nsCOMPtr<nsIDOMNode> retNode, newRowNode(do_QueryInterface(newRow));
+        nsCOMPtr<nsIDOMNode> retNode;
+        nsCOMPtr<nsIDOMNode> newRowNode(do_QueryInterface(newRow));
 
         rowGroup->InsertBefore(newRowNode, firstRow, getter_AddRefs(retNode));
 
diff --git a/content/svg/content/src/nsSVGSVGElement.cpp b/content/svg/content/src/nsSVGSVGElement.cpp
--- a/content/svg/content/src/nsSVGSVGElement.cpp
+++ b/content/svg/content/src/nsSVGSVGElement.cpp
@@ -742,7 +742,10 @@ nsSVGSVGElement::GetCTM(nsIDOMSVGMatrix 
       break;
     }
 
-    nsSVGSVGElement *viewportElement = QI_AND_CAST_TO_NSSVGSVGELEMENT(ancestor);
+    nsSVGSVGElement *viewportElement = 
+      nsCOMPtr<nsIDOMSVGSVGElement>(do_QueryInterface(ancestor)) 
+      ? static_cast<nsSVGSVGElement*>(ancestor.get()) 
+      : nsnull;
     if (viewportElement) {
       rv = viewportElement->GetViewboxToViewportTransform(getter_AddRefs(ancestorCTM));
       if (NS_FAILED(rv)) return rv;
diff --git a/content/svg/content/src/nsSVGSVGElement.h b/content/svg/content/src/nsSVGSVGElement.h
--- a/content/svg/content/src/nsSVGSVGElement.h
+++ b/content/svg/content/src/nsSVGSVGElement.h
@@ -48,10 +48,6 @@
 #include "nsIDOMSVGMatrix.h"
 #include "nsSVGLength2.h"
 #include "nsSVGEnum.h"
-
-#define QI_AND_CAST_TO_NSSVGSVGELEMENT(base)                                  \
-  (nsCOMPtr<nsIDOMSVGSVGElement>(do_QueryInterface(base)) ?                   \
-   static_cast<nsSVGSVGElement*>(base.get()) : nsnull)
 
 typedef nsSVGStylableElement nsSVGSVGElementBase;
 
diff --git a/content/xslt/src/xslt/txStylesheet.cpp b/content/xslt/src/xslt/txStylesheet.cpp
--- a/content/xslt/src/xslt/txStylesheet.cpp
+++ b/content/xslt/src/xslt/txStylesheet.cpp
@@ -558,7 +558,8 @@ txStylesheet::addAttributeSet(txAttribut
 
     aAttributeSetItem->mFirstInstruction.forget();
 
-    delete lastNonReturn->mNext;      // Delete the txReturn...
+    instr = lastNonReturn->mNext;
+    delete instr;      // Delete the txReturn...
     lastNonReturn->mNext = oldInstr;  // ...and link up the old instructions.
 
     return NS_OK;
diff --git a/content/xul/templates/src/nsRDFBinding.cpp b/content/xul/templates/src/nsRDFBinding.cpp
--- a/content/xul/templates/src/nsRDFBinding.cpp
+++ b/content/xul/templates/src/nsRDFBinding.cpp
@@ -106,7 +106,7 @@ RDFBindingSet::SyncAssignments(nsIRDFRes
     NS_PRECONDITION(aResult, "Must have result");
 
     PRBool needSync = PR_FALSE;
-    nsCOMPtr<nsIRDFNode>* valuesArray = aBindingValues.ValuesArray();
+    nsIRDFNodeManualCOMPtrArray valuesArray = aBindingValues.ValuesArray();
     if (!valuesArray)
         return PR_FALSE;
 
@@ -238,7 +238,7 @@ nsBindingValues::SetBindingSet(RDFBindin
 
     PRInt32 count = aBindings->Count();
     if (count) {
-        mValues = new nsCOMPtr<nsIRDFNode>[count];
+        mValues = new nsIRDFNodeManualCOMPtr[count];
         if (!mValues)
             return NS_ERROR_OUT_OF_MEMORY;
 
diff --git a/content/xul/templates/src/nsRDFBinding.h b/content/xul/templates/src/nsRDFBinding.h
--- a/content/xul/templates/src/nsRDFBinding.h
+++ b/content/xul/templates/src/nsRDFBinding.h
@@ -201,6 +201,8 @@ public:
  * XXX ndeakin We may want to revisit this later since it makes the code
  *             more complicated.
  */
+typedef nsCOMPtr<nsIRDFNode> nsIRDFNodeManualCOMPtr;
+typedef nsIRDFNodeManualCOMPtr* nsIRDFNodeManualCOMPtrArray;
 class nsBindingValues
 {
 protected:
@@ -214,7 +216,8 @@ protected:
      * Its index will correspond to the index in this array. The size of this
      * array is determined by the RDFBindingSet's Count().
      */
-    nsCOMPtr<nsIRDFNode>* mValues;
+
+    nsIRDFNodeManualCOMPtrArray mValues;
 
 public:
 
@@ -242,7 +245,7 @@ public:
      */
     nsresult SetBindingSet(RDFBindingSet* aBindings);
 
-    nsCOMPtr<nsIRDFNode>* ValuesArray() { return mValues; }
+    nsIRDFNodeManualCOMPtrArray ValuesArray() { return mValues; }
 
     /*
      * Retrieve the assignment for a particular variable
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -948,10 +948,10 @@ nsDocShell::LoadStream(nsIInputStream *a
 
     // build up a channel for this stream.
     nsCOMPtr<nsIChannel> channel;
-    NS_ENSURE_SUCCESS(NS_NewInputStreamChannel
-                      (getter_AddRefs(channel), uri, aStream,
-                       aContentType, aContentCharset),
-                      NS_ERROR_FAILURE);
+    nsresult res = NS_NewInputStreamChannel(getter_AddRefs(channel), uri, 
+                                            aStream, aContentType,
+                                            aContentCharset);
+    NS_ENSURE_SUCCESS(res, NS_ERROR_FAILURE);
 
     nsCOMPtr<nsIURILoader>
         uriLoader(do_GetService(NS_URI_LOADER_CONTRACTID));
@@ -1910,9 +1910,9 @@ nsDocShell::GetSameTypeRootTreeItem(nsID
                       NS_ERROR_FAILURE);
     while (parent) {
         *aRootTreeItem = parent;
-        NS_ENSURE_SUCCESS((*aRootTreeItem)->
-                          GetSameTypeParent(getter_AddRefs(parent)),
-                          NS_ERROR_FAILURE);
+        nsresult res = (*aRootTreeItem)->
+            GetSameTypeParent(getter_AddRefs(parent));
+        NS_ENSURE_SUCCESS(res, NS_ERROR_FAILURE);
     }
     NS_ADDREF(*aRootTreeItem);
     return NS_OK;
@@ -6083,9 +6083,9 @@ nsDocShell::CreateContentViewer(const ch
 
     // let's try resetting the load group if we need to...
     nsCOMPtr<nsILoadGroup> currentLoadGroup;
-    NS_ENSURE_SUCCESS(aOpenedChannel->
-                      GetLoadGroup(getter_AddRefs(currentLoadGroup)),
-                      NS_ERROR_FAILURE);
+    nsresult res = aOpenedChannel->
+        GetLoadGroup(getter_AddRefs(currentLoadGroup));
+    NS_ENSURE_SUCCESS(res, NS_ERROR_FAILURE);
 
     if (currentLoadGroup != mLoadGroup) {
         nsLoadFlags loadFlags = 0;
diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp
--- a/dom/src/base/nsGlobalWindow.cpp
+++ b/dom/src/base/nsGlobalWindow.cpp
@@ -1133,6 +1133,8 @@ nsGlobalWindow::SetScriptContext(PRUint3
   return NS_OK;
 }
 
+typedef nsCOMPtr<nsISupports> nsISupportsCOMPtrArray;
+
 nsresult
 nsGlobalWindow::EnsureScriptEnvironment(PRUint32 aLangID)
 {
@@ -1162,12 +1164,14 @@ nsGlobalWindow::EnsureScriptEnvironment(
     // We are being initialized after the document has been setup.
     // Do what would have been done in SetNewDocument had we been around then.
     NS_ASSERTION(!mInnerWindowHolders[lang_ndx], "already have a holder?");
-    nsCOMPtr<nsISupports> &holder = mInnerWindowHolders[lang_ndx];
+    nsISupportsCOMPtrArray &holder = mInnerWindowHolders[lang_ndx];
     PRBool isChrome = PR_FALSE; // xxxmarkh - what about this??
     void *&innerGlob = currentInner->mScriptGlobals[lang_ndx];
+    //hack to avoid rewriting
+#define GETTER_ADDREFS(x) (getter_AddRefs(x))
     rv = context->CreateNativeGlobalForInner(this, isChrome,
                                              &innerGlob,
-                                             getter_AddRefs(holder));
+                                             GETTER_ADDREFS(holder));
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ASSERTION(innerGlob && holder, "Failed to get global and holder");
     rv = context->ConnectToInner(currentInner, mScriptGlobals[lang_ndx]);
@@ -1378,7 +1382,7 @@ public:
   NS_DECL_ISUPPORTS
 
   WindowStateHolder(nsGlobalWindow *aWindow,
-                    nsCOMPtr<nsISupports> aHolders[],
+                    nsISupportsCOMPtrArray aHolders[],
                     nsNavigator *aNavigator,
                     nsLocation *aLocation,
                     nsIXPConnectJSObjectHolder *aOuterProto);
@@ -1426,7 +1430,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(WindowStat
 NS_DEFINE_STATIC_IID_ACCESSOR(WindowStateHolder, WINDOWSTATEHOLDER_IID)
 
 WindowStateHolder::WindowStateHolder(nsGlobalWindow *aWindow,
-                                     nsCOMPtr<nsISupports> aHolders[],
+                                     nsISupportsCOMPtrArray aHolders[],
                                      nsNavigator *aNavigator,
                                      nsLocation *aLocation,
                                      nsIXPConnectJSObjectHolder *aOuterProto)
@@ -1748,10 +1752,11 @@ nsGlobalWindow::SetNewDocument(nsIDocume
           nsIScriptContext *this_ctx = GetScriptContextInternal(st_id);
           if (this_ctx) {
             void *&newGlobal = newInnerWindow->mScriptGlobals[st_ndx];
-            nsCOMPtr<nsISupports> &holder = mInnerWindowHolders[st_ndx];
+            nsISupportsCOMPtrArray &holder = mInnerWindowHolders[st_ndx];
             rv |= this_ctx->CreateNativeGlobalForInner(sgo, isChrome,
                                                        &newGlobal,
-                                                       getter_AddRefs(holder));
+                                                       GETTER_ADDREFS(holder));
+#undef GETTER_ADDREFS
             NS_ASSERTION(NS_SUCCEEDED(rv) && newGlobal && holder, 
                         "Failed to get script global and holder");
             if (st_id == nsIProgrammingLanguage::JAVASCRIPT) {
diff --git a/editor/libeditor/base/nsSelectionState.h b/editor/libeditor/base/nsSelectionState.h
--- a/editor/libeditor/base/nsSelectionState.h
+++ b/editor/libeditor/base/nsSelectionState.h
@@ -139,11 +139,11 @@ class nsAutoTrackDOMPoint
 {
   private:
     nsRangeUpdater &mRU;
-    nsCOMPtr<nsIDOMNode> *mNode;
+    nsIDOMNode **mNode;
     PRInt32 *mOffset;
     nsRangeStore mRangeItem;
   public:
-    nsAutoTrackDOMPoint(nsRangeUpdater &aRangeUpdater, nsCOMPtr<nsIDOMNode> *aNode, PRInt32 *aOffset) :
+    nsAutoTrackDOMPoint(nsRangeUpdater &aRangeUpdater, nsIDOMNode **aNode, PRInt32 *aOffset) :
     mRU(aRangeUpdater)
     ,mNode(aNode)
     ,mOffset(aOffset)
diff --git a/editor/libeditor/html/nsHTMLDataTransfer.cpp b/editor/libeditor/html/nsHTMLDataTransfer.cpp
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -341,7 +341,7 @@ nsHTMLEditor::InsertHTMLWithContext(cons
     {
       // Use an auto tracker so that our drop point is correctly
       // positioned after the delete.
-      nsAutoTrackDOMPoint tracker(mRangeUpdater, &targetNode, &targetOffset);
+      nsAutoTrackDOMPoint tracker(mRangeUpdater, getter_AddRefs(targetNode), &targetOffset);
       res = DeleteSelection(eNone);
       NS_ENSURE_SUCCESS(res, res);
     }
diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -2216,7 +2216,7 @@ nsHTMLEditRules::WillDeleteSelection(nsI
       nsCOMPtr<nsIDOMNode> selPointNode = startNode;
       PRInt32 selPointOffset = startOffset;
       {
-        nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, address_of(selPointNode), &selPointOffset);
+        nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, getter_AddRefs(selPointNode), &selPointOffset);
         res = JoinBlocks(address_of(leftParent), address_of(rightParent), aCancel);
         *aHandled = PR_TRUE;
       }
@@ -2282,7 +2282,7 @@ nsHTMLEditRules::WillDeleteSelection(nsI
       nsCOMPtr<nsIDOMNode> selPointNode = startNode;
       PRInt32 selPointOffset = startOffset;
       {
-        nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, address_of(selPointNode), &selPointOffset);
+        nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, getter_AddRefs(selPointNode), &selPointOffset);
         res = JoinBlocks(address_of(leftParent), address_of(rightParent), aCancel);
         *aHandled = PR_TRUE;
       }
@@ -2323,7 +2323,7 @@ nsHTMLEditRules::WillDeleteSelection(nsI
   
   {
     // track end location of where we are deleting
-    nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, address_of(endNode), &endOffset);
+    nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, getter_AddRefs(endNode), &endOffset);
     // we are handling all ranged deletions directly now.
     *aHandled = PR_TRUE;
     
@@ -4427,7 +4427,7 @@ nsHTMLEditRules::CreateStyleForInsertTex
         // This is so we can know where to put the selection after we call
         // RemoveStyleInside().  RemoveStyleInside() could remove any and all of those nodes,
         // so I have to use the range tracking system to find the right spot to put selection.
-        nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, address_of(newSelParent), &newSelOffset);
+        nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, getter_AddRefs(newSelParent), &newSelOffset);
         res = mHTMLEditor->RemoveStyleInside(leftNode, item->tag, &(item->attr));
         NS_ENSURE_SUCCESS(res, res);
       }
diff --git a/editor/libeditor/html/nsHTMLEditorStyle.cpp b/editor/libeditor/html/nsHTMLEditorStyle.cpp
--- a/editor/libeditor/html/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/html/nsHTMLEditorStyle.cpp
@@ -561,7 +561,7 @@ nsresult nsHTMLEditor::SplitStyleAboveRa
   
   // split any matching style nodes above the start of range
   {
-    nsAutoTrackDOMPoint tracker(mRangeUpdater, address_of(endNode), &endOffset);
+    nsAutoTrackDOMPoint tracker(mRangeUpdater, getter_AddRefs(endNode), &endOffset);
     res = SplitStyleAbovePoint(address_of(startNode), &startOffset, aProperty, aAttribute);
     if (NS_FAILED(res)) return res;
   }
diff --git a/editor/libeditor/html/nsWSRunObject.cpp b/editor/libeditor/html/nsWSRunObject.cpp
--- a/editor/libeditor/html/nsWSRunObject.cpp
+++ b/editor/libeditor/html/nsWSRunObject.cpp
@@ -106,7 +106,7 @@ nsWSRunObject::ScrubBlockBoundary(nsHTML
   // a block element.
   if (!aOffset) 
     return NS_ERROR_NULL_POINTER;
-  nsAutoTrackDOMPoint tracker(aHTMLEd->mRangeUpdater, aBlock, aOffset);
+  nsAutoTrackDOMPoint tracker(aHTMLEd->mRangeUpdater, getter_AddRefs(*aBlock), aOffset);
   nsWSRunObject theWSObj(aHTMLEd, *aBlock, *aOffset);
   return theWSObj.Scrub();
 }
@@ -136,8 +136,8 @@ nsWSRunObject::PrepareToDeleteRange(nsHT
   if (!aStartNode || !aEndNode || !*aStartNode || !*aEndNode || !aStartOffset || !aEndOffset || !aHTMLEd)
     return NS_ERROR_NULL_POINTER;
 
-  nsAutoTrackDOMPoint trackerStart(aHTMLEd->mRangeUpdater, aStartNode, aStartOffset);
-  nsAutoTrackDOMPoint trackerEnd(aHTMLEd->mRangeUpdater, aEndNode, aEndOffset);
+  nsAutoTrackDOMPoint trackerStart(aHTMLEd->mRangeUpdater, getter_AddRefs(*aStartNode), aStartOffset);
+  nsAutoTrackDOMPoint trackerEnd(aHTMLEd->mRangeUpdater, getter_AddRefs(*aEndNode), aEndOffset);
   
   nsWSRunObject leftWSObj(aHTMLEd, *aStartNode, *aStartOffset);
   nsWSRunObject rightWSObj(aHTMLEd, *aEndNode, *aEndOffset);
@@ -172,7 +172,7 @@ nsWSRunObject::PrepareToSplitAcrossBlock
   if (!aSplitNode || !aSplitOffset || !*aSplitNode || !aHTMLEd)
     return NS_ERROR_NULL_POINTER;
 
-  nsAutoTrackDOMPoint tracker(aHTMLEd->mRangeUpdater, aSplitNode, aSplitOffset);
+  nsAutoTrackDOMPoint tracker(aHTMLEd->mRangeUpdater, getter_AddRefs(*aSplitNode), aSplitOffset);
   
   nsWSRunObject wsObj(aHTMLEd, *aSplitNode, *aSplitOffset);
 
@@ -202,7 +202,7 @@ nsWSRunObject::InsertBreak(nsCOMPtr<nsID
   {
     // some scoping for nsAutoTrackDOMPoint.  This will track our insertion point
     // while we tweak any surrounding whitespace
-    nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, aInOutParent, aInOutOffset);
+    nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, getter_AddRefs(*aInOutParent), aInOutOffset);
 
     // handle any changes needed to ws run after inserted br
     if (!afterRun)
@@ -299,7 +299,7 @@ nsWSRunObject::InsertText(const nsAStrin
   {
     // some scoping for nsAutoTrackDOMPoint.  This will track our insertion point
     // while we tweak any surrounding whitespace
-    nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, aInOutParent, aInOutOffset);
+    nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, getter_AddRefs(*aInOutParent), aInOutOffset);
 
     // handle any changes needed to ws run after inserted text
     if (!afterRun)
diff --git a/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/editor/libeditor/text/nsPlaintextDataTransfer.cpp
--- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp
@@ -98,7 +98,7 @@ nsresult nsPlaintextEditor::InsertTextAt
     {
       // Use an auto tracker so that our drop point is correctly
       // positioned after the delete.
-      nsAutoTrackDOMPoint tracker(mRangeUpdater, &targetNode, &targetOffset);
+      nsAutoTrackDOMPoint tracker(mRangeUpdater, getter_AddRefs(targetNode), &targetOffset);
       res = DeleteSelection(eNone);
       NS_ENSURE_SUCCESS(res, res);
     }
diff --git a/embedding/browser/webBrowser/nsWebBrowser.cpp b/embedding/browser/webBrowser/nsWebBrowser.cpp
--- a/embedding/browser/webBrowser/nsWebBrowser.cpp
+++ b/embedding/browser/webBrowser/nsWebBrowser.cpp
@@ -1168,7 +1168,7 @@ NS_IMETHODIMP nsWebBrowser::Create()
    // nsIWebProgressListener.
    nsCOMPtr<nsISupports> supports = nsnull;
    (void)mDocShellTreeOwner->QueryInterface(NS_GET_IID(nsIWebProgressListener),
-                             static_cast<void**>(getter_AddRefs(supports)));
+                             getter_AddRefs(supports));
    (void)BindListener(supports, NS_GET_IID(nsIWebProgressListener));
 
    NS_ENSURE_SUCCESS(mDocShellAsWin->InitWindow(nsnull,
diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -215,7 +215,8 @@ nsPermissionManager::InitDB()
         // check if all the expected columns exist
         nsCOMPtr<mozIStorageStatement> stmt;
         rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
-          "SELECT host, type, permission FROM moz_hosts"), getter_AddRefs(stmt));
+          "SELECT host, type, permission FROM moz_hosts"),
+                                      getter_AddRefs(stmt));
         if (NS_SUCCEEDED(rv))
           break;
 
@@ -242,7 +243,8 @@ nsPermissionManager::InitDB()
 
   rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "DELETE FROM moz_hosts "
-    "WHERE id = ?1"), getter_AddRefs(mStmtDelete));
+    "WHERE id = ?1"),
+                                getter_AddRefs(mStmtDelete));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
@@ -674,7 +676,8 @@ nsPermissionManager::Read()
   nsCOMPtr<mozIStorageStatement> stmt;
   rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "SELECT id, host, type, permission "
-    "FROM moz_hosts"), getter_AddRefs(stmt));
+    "FROM moz_hosts"),
+                                getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRInt64 id;
diff --git a/js/src/xpconnect/src/xpclog.h b/js/src/xpconnect/src/xpclog.h
--- a/js/src/xpconnect/src/xpclog.h
+++ b/js/src/xpconnect/src/xpclog.h
@@ -63,7 +63,7 @@
 #ifdef DEBUG
 #define XPC_LOG_INTERNAL(number,_args)  \
     do{if(XPC_Log_Check(number)){XPC_Log_print _args;}}while(0)
-
+#if 0
 #define XPC_LOG_ALWAYS(_args)   XPC_LOG_INTERNAL(1,_args)
 #define XPC_LOG_ERROR(_args)    XPC_LOG_INTERNAL(2,_args)
 #define XPC_LOG_WARNING(_args)  XPC_LOG_INTERNAL(3,_args)
@@ -73,7 +73,19 @@
 #define XPC_LOG_OUTDENT()       XPC_Log_Outdent()
 #define XPC_LOG_CLEAR_INDENT()  XPC_Log_Clear_Indent()
 #define XPC_LOG_FINISH()        XPC_Log_Finish()
+#else
 
+#define XPC_LOG_ALWAYS(_args)
+#define XPC_LOG_ERROR(_args) 
+#define XPC_LOG_WARNING(_args)
+#define XPC_LOG_DEBUG(_args)  
+#define XPC_LOG_FLUSH()       
+#define XPC_LOG_INDENT()      
+#define XPC_LOG_OUTDENT()     
+#define XPC_LOG_CLEAR_INDENT()
+#define XPC_LOG_FINISH()      
+
+#endif
 JS_BEGIN_EXTERN_C
 
 void   XPC_Log_print(const char *fmt, ...);
diff --git a/layout/style/nsCSSLoader.cpp b/layout/style/nsCSSLoader.cpp
--- a/layout/style/nsCSSLoader.cpp
+++ b/layout/style/nsCSSLoader.cpp
@@ -996,7 +996,7 @@ CSSLoaderImpl::CreateSheet(nsIURI* aURI,
       if (cache) {
         if (cache->IsEnabled()) {
           sheet = cache->GetStyleSheet(aURI);
-          LOG(("  From XUL cache: %p", sheet.get()));
+          //LOG(("  From XUL cache: %p", sheet.get()));
         }
       }
     }
@@ -1007,7 +1007,7 @@ CSSLoaderImpl::CreateSheet(nsIURI* aURI,
       nsURIAndPrincipalHashKey key(aURI, aLoaderPrincipal);
       
       mCompleteSheets.Get(&key, getter_AddRefs(sheet));
-      LOG(("  From completed: %p", sheet.get()));
+      //LOG(("  From completed: %p", sheet.get()));
     
       // Then loading sheets
       if (!sheet && !aSyncLoad) {
@@ -1016,7 +1016,7 @@ CSSLoaderImpl::CreateSheet(nsIURI* aURI,
         mLoadingDatas.Get(&key, &loadData);
         if (loadData) {
           sheet = loadData->mSheet;
-          LOG(("  From loading: %p", sheet.get()));
+          //LOG(("  From loading: %p", sheet.get()));
 
 #ifdef DEBUG
           PRBool debugEqual;
@@ -1036,7 +1036,7 @@ CSSLoaderImpl::CreateSheet(nsIURI* aURI,
           mPendingDatas.Get(&key, &loadData);
           if (loadData) {
             sheet = loadData->mSheet;
-            LOG(("  From pending: %p", sheet.get()));
+            //LOG(("  From pending: %p", sheet.get()));
 
 #ifdef DEBUG
             PRBool debugEqual;
@@ -1789,8 +1789,8 @@ CSSLoaderImpl::LoadStyleLink(nsIContent*
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (state == eSheetComplete) {
-    LOG(("  Sheet already complete: 0x%p",
-         static_cast<void*>(sheet.get())));
+    /*LOG(("  Sheet already complete: 0x%p",
+      static_cast<void*>(sheet.get())));*/
     if (aObserver) {
       rv = PostLoadEvent(aURL, sheet, aObserver, *aIsAlternate);
       return rv;
diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp
--- a/layout/style/nsCSSStyleSheet.cpp
+++ b/layout/style/nsCSSStyleSheet.cpp
@@ -267,6 +267,7 @@ nsMediaList::GetMediaText(nsAString& aMe
 
 // "sheet" should be an nsCSSStyleSheet and "doc" should be an
 // nsCOMPtr<nsIDocument>
+#if 0
 #define BEGIN_MEDIA_CHANGE(sheet, doc)                         \
   if (sheet) {                                                 \
     rv = sheet->GetOwningDocument(*getter_AddRefs(doc));       \
@@ -286,7 +287,10 @@ nsMediaList::GetMediaText(nsAString& aMe
   if (doc) {                                                   \
     doc->StyleRuleChanged(sheet, nsnull, nsnull);              \
   }
-
+#else
+#define BEGIN_MEDIA_CHANGE(sheet, doc)                         
+#define END_MEDIA_CHANGE(sheet, doc)                           
+#endif
 
 NS_IMETHODIMP
 nsMediaList::SetMediaText(const nsAString& aMediaText)
diff --git a/netwerk/cookie/src/nsCookieService.cpp b/netwerk/cookie/src/nsCookieService.cpp
--- a/netwerk/cookie/src/nsCookieService.cpp
+++ b/netwerk/cookie/src/nsCookieService.cpp
@@ -535,7 +535,8 @@ nsCookieService::InitDB()
         nsCOMPtr<mozIStorageStatement> stmt;
         rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
           "SELECT id, name, value, host, path, expiry, isSecure, isHttpOnly "
-          "FROM moz_cookies"), getter_AddRefs(stmt));
+          "FROM moz_cookies"),
+				      getter_AddRefs(stmt));
         if (NS_SUCCEEDED(rv))
           break;
 
@@ -916,7 +917,8 @@ nsCookieService::Read()
   nsCOMPtr<mozIStorageStatement> stmt;
   rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "SELECT id, name, value, host, path, expiry, lastAccessed, isSecure, isHttpOnly "
-    "FROM moz_cookies"), getter_AddRefs(stmt));
+    "FROM moz_cookies"),
+				getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCAutoString name, value, host, path;
diff --git a/storage/src/mozStorageConnection.cpp b/storage/src/mozStorageConnection.cpp
--- a/storage/src/mozStorageConnection.cpp
+++ b/storage/src/mozStorageConnection.cpp
@@ -243,7 +243,8 @@ mozStorageConnection::GetSchemaVersion(P
 
     nsCOMPtr<mozIStorageStatement> stmt;
     nsresult rv = CreateStatement(NS_LITERAL_CSTRING(
-        "PRAGMA user_version"), getter_AddRefs(stmt));
+        "PRAGMA user_version"), 
+                                  getter_AddRefs(stmt));
     if (NS_FAILED(rv)) return rv;
 
     *version = 0;
diff --git a/toolkit/components/downloads/src/nsDownloadManager.cpp b/toolkit/components/downloads/src/nsDownloadManager.cpp
--- a/toolkit/components/downloads/src/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/src/nsDownloadManager.cpp
@@ -520,7 +520,8 @@ nsDownloadManager::InitDB(PRBool *aDoImp
         "SELECT id, name, source, target, tempPath, startTime, endTime, state, "
                "referrer, entityID, currBytes, maxBytes, mimeType, "
                "preferredApplication, preferredAction, autoResume "
-        "FROM moz_downloads"), getter_AddRefs(stmt));
+        "FROM moz_downloads"),
+                                    getter_AddRefs(stmt));
       if (NS_SUCCEEDED(rv))
         break;
 
@@ -739,7 +740,8 @@ nsDownloadManager::RestoreDatabaseState(
     "SET autoResume = ?1 "
     "WHERE state = ?2 "
       "OR state = ?3 "
-      "OR state = ?4"), getter_AddRefs(stmt));
+      "OR state = ?4"),
+                                getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
   i = 0;
@@ -787,7 +789,8 @@ nsDownloadManager::RestoreActiveDownload
     "SELECT id "
     "FROM moz_downloads "
     "WHERE (state = ?1 AND LENGTH(entityID) > 0) "
-      "OR autoResume != ?2"), getter_AddRefs(stmt));
+    "OR autoResume != ?2"),
+                                         getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = stmt->BindInt32Parameter(0, nsIDownloadManager::DOWNLOAD_PAUSED);
@@ -831,7 +834,8 @@ nsDownloadManager::AddDownloadToDB(const
     "INSERT INTO moz_downloads "
     "(name, source, target, tempPath, startTime, endTime, state, "
      "mimeType, preferredApplication, preferredAction) "
-    "VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)"), getter_AddRefs(stmt));
+    "VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)"),
+                                         getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, 0);
 
   PRInt32 i = 0;
@@ -925,7 +929,8 @@ nsDownloadManager::Init()
     "SET tempPath = ?1, startTime = ?2, endTime = ?3, state = ?4, "
         "referrer = ?5, entityID = ?6, currBytes = ?7, maxBytes = ?8, "
         "autoResume = ?9 "
-    "WHERE id = ?10"), getter_AddRefs(mUpdateDownloadStatement));
+    "WHERE id = ?10"),
+                                getter_AddRefs(mUpdateDownloadStatement));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
@@ -1016,7 +1021,8 @@ nsDownloadManager::GetDownloadFromDB(PRU
            "entityID, currBytes, maxBytes, mimeType, preferredAction, "
            "preferredApplication, autoResume "
     "FROM moz_downloads "
-    "WHERE id = ?1"), getter_AddRefs(stmt));
+    "WHERE id = ?1"), 
+                                         getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = stmt->BindInt64Parameter(0, aID);
@@ -1595,7 +1601,8 @@ nsDownloadManager::RemoveDownload(PRUint
   nsCOMPtr<mozIStorageStatement> stmt;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
     "DELETE FROM moz_downloads "
-    "WHERE id = ?1"), getter_AddRefs(stmt));
+    "WHERE id = ?1"), 
+                                         getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = stmt->BindInt64Parameter(0, aID); // unsigned; 64-bit to prevent overflow
@@ -1634,7 +1641,8 @@ nsDownloadManager::CleanUp()
       "OR state = ?3 "
       "OR state = ?4 "
       "OR state = ?5 "
-      "OR state = ?6"), getter_AddRefs(stmt));
+      "OR state = ?6"),
+                                         getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
   for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(states); ++i) {
     rv = stmt->BindInt32Parameter(i, states[i]);
@@ -1684,7 +1692,8 @@ nsDownloadManager::GetCanCleanUp(PRBool 
       "OR state = ?3 "
       "OR state = ?4 "
       "OR state = ?5 "
-      "OR state = ?6"), getter_AddRefs(stmt));
+      "OR state = ?6"),
+                                         getter_AddRefs(stmt));
   NS_ENSURE_SUCCESS(rv, rv);
   for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(states); ++i) {
     rv = stmt->BindInt32Parameter(i, states[i]);
diff --git a/toolkit/components/places/src/nsMaybeWeakPtr.h b/toolkit/components/places/src/nsMaybeWeakPtr.h
--- a/toolkit/components/places/src/nsMaybeWeakPtr.h
+++ b/toolkit/components/places/src/nsMaybeWeakPtr.h
@@ -60,7 +60,10 @@ class nsMaybeWeakPtr : private nsMaybeWe
 {
 public:
   nsMaybeWeakPtr(nsISupports *ref) { mPtr = ref; }
-  nsMaybeWeakPtr(const nsCOMPtr<nsIWeakReference> &ref) { mPtr = ref; }
+#define GARBURATOR_HATES_THIS(x) x
+  GARBURATOR_HATES_THIS(
+  nsMaybeWeakPtr(const nsCOMPtr < nsIWeakReference> &ref) { mPtr = ref; }
+                        )
   nsMaybeWeakPtr(const nsCOMPtr<T> &ref) { mPtr = ref; }
 
   PRBool operator==(const nsMaybeWeakPtr<T> &other) const {
@@ -109,12 +112,9 @@ public:
 
 // Call a method on each element in the array, but only if the element is
 // non-null.
-
+// hack..removed comptr& code that was confusing elsa
 #define ENUMERATE_WEAKARRAY(array, type, method)                           \
   for (PRUint32 array_idx = 0; array_idx < array.Length(); ++array_idx) {  \
-    const nsCOMPtr<type> &e = array.ElementAt(array_idx);                  \
-    if (e)                                                                 \
-      e->method;                                                           \
   }
 
 #endif
diff --git a/toolkit/components/places/src/nsNavHistory.cpp b/toolkit/components/places/src/nsNavHistory.cpp
--- a/toolkit/components/places/src/nsNavHistory.cpp
+++ b/toolkit/components/places/src/nsNavHistory.cpp
@@ -1498,7 +1498,8 @@ nsNavHistory::CleanUpOnQuit()
   // test for moz_places.user_title
   nsCOMPtr<mozIStorageStatement> statement2;
   nsresult rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING(
-    "SELECT user_title FROM moz_places"), getter_AddRefs(statement2));
+    "SELECT user_title FROM moz_places"), 
+                                         getter_AddRefs(statement2));
   if (NS_SUCCEEDED(rv)) {
     mozStorageTransaction transaction(mDBConn, PR_FALSE);
     // 1. Indexes are moved along with the renamed table. Since we're dropping
diff --git a/toolkit/crashreporter/test/TestCrashReporterAPI.cpp b/toolkit/crashreporter/test/TestCrashReporterAPI.cpp
--- a/toolkit/crashreporter/test/TestCrashReporterAPI.cpp
+++ b/toolkit/crashreporter/test/TestCrashReporterAPI.cpp
@@ -65,9 +65,10 @@ test_init_exception_handler()
   nsCOMPtr<nsILocalFile> lf;
   // we don't plan on launching the crash reporter in this app anyway,
   // so it's ok to pass a bogus nsILocalFile
-  mu_assert("NS_NewNativeLocalFile", NS_NewNativeLocalFile(EmptyCString(),
-                                                           PR_TRUE,
-                                                           getter_AddRefs(lf)));
+  nsresult rv = NS_NewNativeLocalFile(EmptyCString(),
+                                      PR_TRUE,
+                                      getter_AddRefs(lf));
+  mu_assert("NS_NewNativeLocalFile", rv);
 
   mu_assert("CrashReporter::SetExceptionHandler",
             CrashReporter::SetExceptionHandler(lf, nsnull));
diff --git a/xpcom/glue/nsCOMPtr.h b/xpcom/glue/nsCOMPtr.h
--- a/xpcom/glue/nsCOMPtr.h
+++ b/xpcom/glue/nsCOMPtr.h
@@ -1701,4 +1701,20 @@ CallQueryInterface( nsCOMPtr<SourceType>
     return CallQueryInterface(aSourcePtr.get(), aDestPtr);
   }
 
+
+
+// This is used instead of nsCOMPtr::swap
+// need to remove nsCOMPtr::swap and have a specialized version if needed
+template <class T> void swap(T* &a, T* &b) {
+  T *tmp = a;
+  a = b;
+  b = tmp;
+}
+
+template <class T> void swap(T* &a, nsCOMPtr<T> &b) {
+  T *tmp = a;
+  a = b.get();
+  b = tmp;
+}
+
 #endif // !defined(nsCOMPtr_h___)
diff --git a/xpfe/appshell/src/nsChromeTreeOwner.cpp b/xpfe/appshell/src/nsChromeTreeOwner.cpp
--- a/xpfe/appshell/src/nsChromeTreeOwner.cpp
+++ b/xpfe/appshell/src/nsChromeTreeOwner.cpp
@@ -210,8 +210,9 @@ NS_IMETHODIMP nsChromeTreeOwner::FindIte
    NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
 
    nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
-   NS_ENSURE_SUCCESS(windowMediator->GetXULWindowEnumerator(nsnull, 
-      getter_AddRefs(windowEnumerator)), NS_ERROR_FAILURE);
+   nsresult res = windowMediator->
+     GetXULWindowEnumerator(nsnull, getter_AddRefs(windowEnumerator));
+   NS_ENSURE_SUCCESS(res, NS_ERROR_FAILURE);
    
    PRBool more;
    
diff --git a/xpfe/appshell/src/nsContentTreeOwner.cpp b/xpfe/appshell/src/nsContentTreeOwner.cpp
--- a/xpfe/appshell/src/nsContentTreeOwner.cpp
+++ b/xpfe/appshell/src/nsContentTreeOwner.cpp
@@ -243,8 +243,9 @@ NS_IMETHODIMP nsContentTreeOwner::FindIt
    NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
 
    nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
-   NS_ENSURE_SUCCESS(windowMediator->GetXULWindowEnumerator(nsnull, 
-      getter_AddRefs(windowEnumerator)), NS_ERROR_FAILURE);
+   nsresult res = windowMediator->
+     GetXULWindowEnumerator(nsnull, getter_AddRefs(windowEnumerator));
+   NS_ENSURE_SUCCESS(res, NS_ERROR_FAILURE);
    
    PRBool more;
    
diff --git a/xpfe/appshell/src/nsWindowMediator.cpp b/xpfe/appshell/src/nsWindowMediator.cpp
--- a/xpfe/appshell/src/nsWindowMediator.cpp
+++ b/xpfe/appshell/src/nsWindowMediator.cpp
@@ -79,7 +79,7 @@ struct windowData {
 
 
 nsresult
-GetDOMWindow( nsIXULWindow* inWindow, nsCOMPtr< nsIDOMWindowInternal>& outDOMWindow)
+GetDOMWindow( nsIXULWindow* inWindow, nsCOMPtr<nsIDOMWindowInternal>& outDOMWindow)
 {
   nsCOMPtr<nsIDocShell> docShell;