automatic-remove-addrefs
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
permissions -rw-r--r--
State as of now

Automatically generated patch: remove no-op calls to NS_ADDREF and NS_IF_ADDREF

diff --git a/accessible/src/atk/nsXULTreeAccessibleWrap.cpp b/accessible/src/atk/nsXULTreeAccessibleWrap.cpp
--- a/accessible/src/atk/nsXULTreeAccessibleWrap.cpp
+++ b/accessible/src/atk/nsXULTreeAccessibleWrap.cpp
@@ -116,7 +116,6 @@ NS_IMETHODIMP nsXULTreeAccessibleWrap::G
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aColumnHeader = accTable;
-  NS_IF_ADDREF(*aColumnHeader);
 
   return rv;
 }
@@ -539,7 +538,6 @@ NS_IMETHODIMP nsXULTreeColumnsAccessible
   }
 
   *_retval = next;
-  NS_IF_ADDREF(*_retval);
 
   return NS_OK;
 }
diff --git a/accessible/src/base/nsAccessNode.cpp b/accessible/src/base/nsAccessNode.cpp
--- a/accessible/src/base/nsAccessNode.cpp
+++ b/accessible/src/base/nsAccessNode.cpp
@@ -239,7 +239,6 @@ nsAccessNode::GetApplicationAccessible()
       return nsnull;
 
     // Addref on create. Will Release in ShutdownXPAccessibility()
-    NS_ADDREF(gApplicationAccessible);
 
     nsresult rv = gApplicationAccessible->Init();
     if (NS_FAILED(rv)) {
@@ -249,7 +248,6 @@ nsAccessNode::GetApplicationAccessible()
     }
   }
 
-  NS_ADDREF(gApplicationAccessible);   // Addref because we're a getter
   return gApplicationAccessible;
 }
 
@@ -396,7 +394,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsAccessNode::GetDOMNode(nsIDOMNode **aNode)
 {
-  NS_IF_ADDREF(*aNode = mDOMNode);
+  *aNode = mDOMNode;
   return NS_OK;
 }
 
@@ -493,7 +491,7 @@ nsAccessNode::MakeAccessNode(nsIDOMNode 
   }
 
   if (accessNode) {
-    NS_ADDREF(*aAccessNode = accessNode);
+    *aAccessNode = accessNode;
     return NS_OK;
   }
 
@@ -502,7 +500,7 @@ nsAccessNode::MakeAccessNode(nsIDOMNode 
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aAccessNode = newAccessNode);
+  *aAccessNode = newAccessNode;
   newAccessNode->Init();
 
   return NS_OK;
@@ -649,7 +647,7 @@ void nsAccessNode::GetComputedStyleDecla
 
   nsIDOMCSSStyleDeclaration* cssDecl = nsnull;
   viewCSS->GetComputedStyle(aElement, aPseudoElt, &cssDecl);
-  NS_IF_ADDREF(*aCssDecl = cssDecl);
+  *aCssDecl = cssDecl;
 }
 
 /***************** Hashtable of nsIAccessNode's *****************/
@@ -736,7 +734,6 @@ nsAccessNode::GetPresShellFor(nsIDOMNode
   nsIPresShell *presShell = nsnull;
   if (doc) {
     presShell = doc->GetPrimaryShell();
-    NS_IF_ADDREF(presShell);
   }
   return presShell;
 }
diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -197,7 +197,6 @@ NS_IMETHODIMP nsAccessibilityService::On
   if (!timer)
     return NS_OK;
   mLoadTimers.AppendObject(timer);
-  NS_ADDREF(aWebProgress);
 
   if (aStateFlags & STATE_START)
     timer->InitWithFuncCallback(StartLoadCallback, aWebProgress, 0,
@@ -334,7 +333,6 @@ nsAccessibilityService::GetInfo(nsISuppo
   if (!content || !node)
     return NS_ERROR_FAILURE;
   *aNode = node;
-  NS_IF_ADDREF(*aNode);
 
   nsIDocument* document = content->GetDocument();
   if (!document)
@@ -345,7 +343,7 @@ nsAccessibilityService::GetInfo(nsISuppo
   // do_GetWR only works into a |nsCOMPtr| :-(
   nsIWeakReference* weakShell =
     do_GetWeakReference(document->GetPrimaryShell());
-  NS_IF_ADDREF(*aShell = weakShell);
+  *aShell = weakShell;
 
   return NS_OK;
 }
@@ -367,7 +365,6 @@ nsAccessibilityService::GetShellFromNode
   nsIWeakReference* weakRef(do_GetWeakReference(shell));
   
   *aWeakShell = weakRef;
-  NS_IF_ADDREF(*aWeakShell);
 
   return NS_OK;
 }
@@ -392,7 +389,7 @@ nsAccessibilityService::CreateOuterDocAc
     new nsOuterDocAccessible(aDOMNode, outerWeakShell);
   NS_ENSURE_TRUE(outerDocAccessible, NS_ERROR_FAILURE);
 
-  NS_ADDREF(*aOuterDocAccessible = outerDocAccessible);
+  *aOuterDocAccessible = outerDocAccessible;
 
   return NS_OK;
 }
@@ -458,7 +455,6 @@ nsAccessibilityService::CreateRootAccess
     do_QueryInterface(privateAccessNode);
   privateAccessible->SetRoleMapEntry(roleMapEntry);
 
-  NS_ADDREF(*aRootAcc);
 
   return NS_OK;
 }
@@ -480,7 +476,6 @@ nsAccessibilityService::CreateHTML4Butto
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -498,7 +493,6 @@ nsAccessibilityService::CreateHTMLButton
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -553,7 +547,6 @@ nsAccessibilityService::CreateHTMLAccess
            tag == nsAccessibilityAtoms::q) {
     return CreateHyperTextAccessible(aFrame, aAccessible);
   }
-  NS_IF_ADDREF(*aAccessible);
   return NS_OK;
 }
 
@@ -574,7 +567,6 @@ nsAccessibilityService::CreateHTMLLIAcce
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -602,7 +594,6 @@ nsAccessibilityService::CreateHyperTextA
   if (nsnull == *aAccessible)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aAccessible);
   return NS_OK;
 }
 
@@ -620,7 +611,6 @@ nsAccessibilityService::CreateHTMLCheckb
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -631,7 +621,6 @@ nsAccessibilityService::CreateHTMLCombob
   if (! *_retval)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -654,7 +643,6 @@ nsAccessibilityService::CreateHTMLImageA
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -678,7 +666,6 @@ nsAccessibilityService::CreateHTMLGroupb
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -689,7 +676,6 @@ nsAccessibilityService::CreateHTMLListbo
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -735,7 +721,6 @@ nsAccessibilityService::CreateHTMLObject
     if (pluginPort) {
       *aAccessible = new nsHTMLWin32ObjectOwnerAccessible(node, weakShell, pluginPort);
       if (*aAccessible) {
-        NS_ADDREF(*aAccessible);
         return NS_OK;
       }
     }
@@ -765,7 +750,6 @@ nsAccessibilityService::CreateHTMLRadioB
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -779,7 +763,6 @@ nsAccessibilityService::CreateHTMLSelect
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -797,7 +780,6 @@ nsAccessibilityService::CreateHTMLTableA
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -822,7 +804,6 @@ nsAccessibilityService::CreateHTMLTableH
   NS_ENSURE_TRUE(accTableHead, NS_ERROR_OUT_OF_MEMORY);
 
   *_retval = static_cast<nsIAccessible *>(accTableHead);
-  NS_IF_ADDREF(*_retval);
 
   return rv;
 #endif
@@ -842,7 +823,6 @@ nsAccessibilityService::CreateHTMLTableC
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -863,7 +843,6 @@ nsAccessibilityService::CreateHTMLTextAc
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -881,7 +860,6 @@ nsAccessibilityService::CreateHTMLTextFi
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -899,7 +877,6 @@ nsAccessibilityService::CreateHTMLLabelA
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -917,7 +894,6 @@ nsAccessibilityService::CreateHTMLHRAcce
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -935,7 +911,6 @@ nsAccessibilityService::CreateHTMLBRAcce
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -953,7 +928,6 @@ nsAccessibilityService::CreateHTMLCaptio
   if (! *_retval) 
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -964,7 +938,7 @@ NS_IMETHODIMP nsAccessibilityService::Ge
   nsIAccessNode* accessNode = nsnull;
   nsresult rv = GetCachedAccessNode(aNode, aWeakShell, &accessNode);
   nsIAccessible* accessible(do_QueryInterface(accessNode));
-  NS_IF_ADDREF(*aAccessible = accessible);
+  *aAccessible = accessible;
   return rv;
 }
 
@@ -1107,7 +1081,7 @@ nsAccessibilityService::GetStringStates(
   if (!stringStatesLength)
     stringStates->Add(NS_LITERAL_STRING("unknown"));
 
-  NS_ADDREF(*aStringStates = stringStates);
+  *aStringStates = stringStates;
   return NS_OK;
 }
 
@@ -1262,7 +1236,7 @@ nsresult nsAccessibilityService::InitAcc
     nsPIAccessible* privateAccessible =
       do_QueryInterface(privateAccessNode);
     privateAccessible->SetRoleMapEntry(aRoleMapEntry);
-    NS_ADDREF(*aAccessibleOut = aAccessibleIn);
+    *aAccessibleOut = aAccessibleIn;
   }
   return rv;
 }
@@ -1341,7 +1315,7 @@ NS_IMETHODIMP nsAccessibilityService::Ge
     // when it is visible or hidden).
     newAcc = do_QueryInterface(accessNode);
     if (newAcc) {
-      NS_ADDREF(*aAccessible = newAcc);
+      *aAccessible = newAcc;
       return NS_OK;
     }
   }
@@ -1369,7 +1343,7 @@ NS_IMETHODIMP nsAccessibilityService::Ge
     }
 
     *aFrameHint = aPresShell->GetRootFrame();
-    NS_IF_ADDREF(*aAccessible = newAcc);
+    *aAccessible = newAcc;
     return NS_OK;
   }
 
@@ -1691,7 +1665,7 @@ nsAccessibilityService::GetRelevantConte
             PRBool allowsAnonChildren = PR_FALSE;
             paccessible->GetAllowsAnonChildAccessibles(&allowsAnonChildren);
             if (!allowsAnonChildren) {
-              NS_ADDREF(*aRelevantNode = bindingNode);
+              *aRelevantNode = bindingNode;
               return NS_OK;
             }
           }
@@ -1700,7 +1674,7 @@ nsAccessibilityService::GetRelevantConte
     }
   }
 
-  NS_ADDREF(*aRelevantNode = aNode);
+  *aRelevantNode = aNode;
   return NS_OK;
 }
 
@@ -1947,7 +1921,6 @@ nsresult nsAccessibilityService::GetAcce
   if (!*aAccessible)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aAccessible);
   return NS_OK;
 }
 
@@ -1958,7 +1931,6 @@ NS_IMETHODIMP nsAccessibilityService::Ad
     new nsNativeRootAccessibleWrap((AtkObject*)aAtkAccessible);
 
   *aRootAccessible = static_cast<nsIAccessible*>(rootAccWrap);
-  NS_ADDREF(*aRootAccessible);
 
   nsApplicationAccessibleWrap* appRoot =
     nsAccessNode::GetApplicationAccessible();
@@ -2032,7 +2004,6 @@ nsAccessibilityService::GetAccessibility
     }
   }
   *aResult = nsAccessibilityService::gAccessibilityService;
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -2077,7 +2048,6 @@ nsAccessibilityService::GetAccessibleFor
 
       NS_ENSURE_TRUE(*aAccessible, NS_ERROR_OUT_OF_MEMORY);
 
-      NS_ADDREF(*aAccessible);
     }
   }
 
diff --git a/accessible/src/base/nsAccessibilityUtils.cpp b/accessible/src/base/nsAccessibilityUtils.cpp
--- a/accessible/src/base/nsAccessibilityUtils.cpp
+++ b/accessible/src/base/nsAccessibilityUtils.cpp
@@ -383,7 +383,6 @@ nsAccUtils::GetAncestorWithRole(nsIAcces
     testRoleAccessible->GetFinalRole(&testRole);
     if (testRole == aRole) {
       nsIAccessible *returnAccessible = testRoleAccessible;
-      NS_ADDREF(returnAccessible);
       return returnAccessible;
     }
     nsIAccessibleDocument* docAccessible = do_QueryInterface(testRoleAccessible);
@@ -427,7 +426,7 @@ nsAccUtils::GetARIATreeItemParent(nsIAcc
             treeItemContent->GetAttr(kNameSpaceID_None,
                                      nsAccessibilityAtoms::aria_level, levelStr)) {
           if (levelStr.ToInteger(&success) < level && NS_SUCCEEDED(success)) {
-            NS_ADDREF(*aTreeItemParentResult = currentAccessible);
+            *aTreeItemParentResult = currentAccessible;
             return;
           }
         }
@@ -446,7 +445,7 @@ nsAccUtils::GetARIATreeItemParent(nsIAcc
   PRUint32 role;
   parentAccessible->GetFinalRole(&role);
   if (role != nsIAccessibleRole::ROLE_GROUPING) {
-    NS_ADDREF(*aTreeItemParentResult = parentAccessible);
+    *aTreeItemParentResult = parentAccessible;
     return; // The container for the tree items
   }
   nsIAccessible* prevAccessible = nsnull;
@@ -466,7 +465,7 @@ nsAccUtils::GetARIATreeItemParent(nsIAcc
   }
   if (role == nsIAccessibleRole::ROLE_OUTLINEITEM) {
     // Previous sibling of parent group is a tree item -- this is the conceptual tree item parent
-    NS_ADDREF(*aTreeItemParentResult = prevAccessible);
+    *aTreeItemParentResult = prevAccessible;
   }
 }
 
diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -191,13 +191,11 @@ nsresult nsAccessible::QueryInterface(RE
   
   if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
     *aInstancePtr = static_cast<nsIAccessible*>(this);
-    NS_ADDREF_THIS();
     return NS_OK;
   }
 
   if(aIID.Equals(NS_GET_IID(nsPIAccessible))) {
     *aInstancePtr = static_cast<nsPIAccessible*>(this);
-    NS_ADDREF_THIS();
     return NS_OK;
   }
 
@@ -216,7 +214,6 @@ nsresult nsAccessible::QueryInterface(RE
       if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::aria_multiselectable,
                                nsAccessibilityAtoms::_true, eCaseMatters)) {
         *aInstancePtr = static_cast<nsIAccessibleSelectable*>(this);
-        NS_ADDREF_THIS();
         return NS_OK;
       }
     }
@@ -225,7 +222,6 @@ nsresult nsAccessible::QueryInterface(RE
   if (aIID.Equals(NS_GET_IID(nsIAccessibleValue))) {
     if (mRoleMapEntry && mRoleMapEntry->valueRule != eNoValue) {
       *aInstancePtr = static_cast<nsIAccessibleValue*>(this);
-      NS_ADDREF_THIS();
       return NS_OK;
     }
   }                       
@@ -235,7 +231,6 @@ nsresult nsAccessible::QueryInterface(RE
     nsIAccessibleHyperText* hyperTextParent(do_QueryInterface(parent));
     if (hyperTextParent) {
       *aInstancePtr = static_cast<nsIAccessibleHyperLink*>(this);
-      NS_ADDREF_THIS();
       return NS_OK;
     }
     return NS_ERROR_NO_INTERFACE;
@@ -574,7 +569,7 @@ NS_IMETHODIMP nsAccessible::GetCachedPar
     // This node has been shut down
     return NS_ERROR_FAILURE;
   }
-  NS_IF_ADDREF(*aParent = mParent);
+  *aParent = mParent;
   return NS_OK;
 }
 
@@ -585,7 +580,7 @@ NS_IMETHODIMP nsAccessible::GetCachedFir
     // This node has been shut down
     return NS_ERROR_FAILURE;
   }
-  NS_IF_ADDREF(*aFirstChild = mFirstChild);
+  *aFirstChild = mFirstChild;
   return NS_OK;
 }
 
@@ -609,7 +604,7 @@ NS_IMETHODIMP nsAccessible::GetNextSibli
     // If no parent, don't try to calculate a new sibling
     // It either means we're at the root or shutting down the parent
     if (mNextSibling != DEAD_END_ACCESSIBLE) {
-      NS_IF_ADDREF(*aNextSibling = mNextSibling);
+      *aNextSibling = mNextSibling;
     }
     return NS_OK;
   }
@@ -643,7 +638,7 @@ NS_IMETHODIMP nsAccessible::GetPreviousS
     return NS_ERROR_FAILURE;
   }
 
-  NS_ADDREF(*aPreviousSibling = prevSibling);
+  *aPreviousSibling = prevSibling;
   return NS_OK;
 }
 
@@ -666,7 +661,7 @@ NS_IMETHODIMP nsAccessible::GetFirstChil
   }
 #endif
 
-  NS_IF_ADDREF(*aFirstChild = mFirstChild);
+  *aFirstChild = mFirstChild;
 
   return NS_OK;  
 }
@@ -705,7 +700,7 @@ NS_IMETHODIMP nsAccessible::GetChildAt(P
     nextSibling->GetNextSibling(&current);
   }
 
-  NS_IF_ADDREF(*aChild = nextSibling);
+  *aChild = nextSibling;
 
   return NS_OK;
 }
@@ -723,7 +718,7 @@ NS_IMETHODIMP nsAccessible::GetChildren(
     children->AppendElement(curChild, PR_FALSE);
   }
   
-  NS_ADDREF(*aOutChildren = children);
+  *aOutChildren = children;
   return NS_OK;
 }
 
@@ -1084,7 +1079,7 @@ NS_IMETHODIMP nsAccessible::GetFocusedCh
     }
   }
 
-  NS_IF_ADDREF(*aFocusedChild = focusedChild);
+  *aFocusedChild = focusedChild;
   return NS_OK;
 }
 
@@ -1110,7 +1105,7 @@ nsAccessible::GetChildAtPoint(PRInt32 aX
     fallbackAnswer = this;
   }
   if (MustPrune(this)) {  // Do not dig any further
-    NS_IF_ADDREF(*aAccessible = fallbackAnswer);
+    *aAccessible = fallbackAnswer;
     return NS_OK;
   }
 
@@ -1142,7 +1137,7 @@ nsAccessible::GetChildAtPoint(PRInt32 aX
   nsIFrame *foundFrame = presShell->GetFrameForPoint(frame, offset);
   nsIContent* content = nsnull;
   if (!foundFrame || !(content = foundFrame->GetContent())) {
-    NS_IF_ADDREF(*aAccessible = fallbackAnswer);
+    *aAccessible = fallbackAnswer;
     return NS_OK;
   }
 
@@ -1152,7 +1147,7 @@ nsAccessible::GetChildAtPoint(PRInt32 aX
   nsIDOMNode* relevantNode = nsnull;
   accService->GetRelevantContentNodeFor(node, &relevantNode);
   if (!relevantNode) {
-    NS_IF_ADDREF(*aAccessible = fallbackAnswer);
+    *aAccessible = fallbackAnswer;
     return NS_OK;
   }
 
@@ -1164,7 +1159,7 @@ nsAccessible::GetChildAtPoint(PRInt32 aX
     accDocument->GetAccessibleInParentChain(relevantNode, PR_TRUE,
                                             &accessible);
     if (!accessible) {
-      NS_IF_ADDREF(*aAccessible = fallbackAnswer);
+      *aAccessible = fallbackAnswer;
       return NS_OK;
     }
   }
@@ -1182,7 +1177,7 @@ nsAccessible::GetChildAtPoint(PRInt32 aX
           aY >= childY && aY < childY + childHeight &&
           (State(child) & nsIAccessibleStates::STATE_INVISIBLE) == 0) {
         // Don't walk into offscreen or invisible items
-        NS_IF_ADDREF(*aAccessible = child);
+        *aAccessible = child;
         return NS_OK;
       }
     }
@@ -1196,7 +1191,7 @@ nsAccessible::GetChildAtPoint(PRInt32 aX
       if (!parent) {
         // Reached the top of the hierarchy
         // these bounds were inside an accessible that is not a descendant of this one
-        NS_IF_ADDREF(*aAccessible = fallbackAnswer);
+        *aAccessible = fallbackAnswer;
         return NS_OK;
       }
       if (parent == this) {
@@ -1208,7 +1203,7 @@ nsAccessible::GetChildAtPoint(PRInt32 aX
     }
   }
 
-  NS_IF_ADDREF(*aAccessible = accessible);
+  *aAccessible = accessible;
   return NS_OK;
 }
 
@@ -2058,7 +2053,7 @@ nsAccessible::GetAttributes(nsIPersisten
     // Create only if an array wasn't already passed in
     attributes = do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
     NS_ENSURE_TRUE(attributes, NS_ERROR_OUT_OF_MEMORY);
-    NS_ADDREF(*aAttributes = attributes);
+    *aAttributes = attributes;
   }
  
   nsresult rv = GetAttributesInternal(attributes);
@@ -2681,7 +2676,7 @@ nsAccessible::GetKeyBindings(PRUint8 aAc
   if (!defaultKey.IsEmpty())
     keyBindings->Add(defaultKey);
 
-  NS_ADDREF(*aKeyBindings = keyBindings);
+  *aKeyBindings = keyBindings;
   return NS_OK;
 }
 
@@ -3073,7 +3068,7 @@ nsAccessible::GetRelation(PRUint32 aInde
 
   NS_ENSURE_SUCCESS(rv, rv);
 
-  NS_IF_ADDREF(*aRelation = relation);
+  *aRelation = relation;
   return NS_OK;
 }
 
@@ -3100,7 +3095,7 @@ nsAccessible::GetRelations(nsIArray **aR
     }
   }
 
-  NS_ADDREF(*aRelations = relations);
+  *aRelations = relations;
   return NS_OK;
 }
 
@@ -3180,7 +3175,7 @@ nsresult nsAccessible::DoCommand(nsICont
     return NS_ERROR_OUT_OF_MEMORY;
   } 
 
-  NS_ADDREF(gDoCommandTimer = timer);
+  gDoCommandTimer = timer;
   return gDoCommandTimer->InitWithFuncCallback(DoCommandCallback,
                                                (void*)content, 0,
                                                nsITimer::TYPE_ONE_SHOT);
@@ -3237,7 +3232,6 @@ NS_IMETHODIMP nsAccessible::GetSelectedC
   selectedAccessibles->GetLength(&length); 
   if (length) { // length of nsIArray containing selected options
     *aSelectedAccessibles = selectedAccessibles;
-    NS_ADDREF(*aSelectedAccessibles);
   }
 
   return NS_OK;
@@ -3258,7 +3252,7 @@ NS_IMETHODIMP nsAccessible::RefSelection
       return NS_ERROR_FAILURE; // aIndex out of range
     }
   }
-  NS_IF_ADDREF(*aSelected = selected);
+  *aSelected = selected;
   return NS_OK;
 }
 
@@ -3419,7 +3413,6 @@ nsAccessible::GetAnchor(PRInt32 aIndex,
     return NS_ERROR_INVALID_ARG;
 
   *aAccessible = this;
-  NS_ADDREF_THIS();
   return NS_OK;
 }
 
@@ -3526,7 +3519,6 @@ nsAccessible::GetFirstAvailableAccessibl
     accService->GetAccessibleInWeakShell(currentNode, mWeakShell, &accessible); // AddRef'd
     if (accessible && (!aRequireLeaf || IsLeaf(accessible))) {
       nsIAccessible *retAccessible = accessible;
-      NS_ADDREF(retAccessible);
       return retAccessible;
     }
     if (!walker) {
diff --git a/accessible/src/base/nsAccessibleEventData.cpp b/accessible/src/base/nsAccessibleEventData.cpp
--- a/accessible/src/base/nsAccessibleEventData.cpp
+++ b/accessible/src/base/nsAccessibleEventData.cpp
@@ -194,7 +194,7 @@ nsAccEvent::GetAccessible(nsIAccessible 
   if (!mAccessible)
     mAccessible = GetAccessibleByNode();
 
-  NS_IF_ADDREF(*aAccessible = mAccessible);
+  *aAccessible = mAccessible;
   return NS_OK;
 }
 
@@ -210,7 +210,7 @@ nsAccEvent::GetDOMNode(nsIDOMNode **aDOM
     accessNode->GetDOMNode(getter_AddRefs(mDOMNode));
   }
 
-  NS_IF_ADDREF(*aDOMNode = mDOMNode);
+  *aDOMNode = mDOMNode;
   return NS_OK;
 }
 
@@ -231,7 +231,7 @@ nsAccEvent::GetAccessibleDocument(nsIAcc
     accessNode->GetAccessibleDocument(getter_AddRefs(mDocAccessible));
   }
 
-  NS_IF_ADDREF(*aDocAccessible = mDocAccessible);
+  *aDocAccessible = mDocAccessible;
   return NS_OK;
 }
 
@@ -273,7 +273,7 @@ nsAccEvent::GetAccessibleByNode()
                       !treeItemAccessible) {
           return nsnull;
         }
-        NS_IF_ADDREF(accessible = treeItemAccessible);
+        accessible = treeItemAccessible;
       }
     }
   }
diff --git a/accessible/src/base/nsAccessibleRelation.cpp b/accessible/src/base/nsAccessibleRelation.cpp
--- a/accessible/src/base/nsAccessibleRelation.cpp
+++ b/accessible/src/base/nsAccessibleRelation.cpp
@@ -77,7 +77,7 @@ nsAccessibleRelation::GetTarget(PRUint32
   if (aIndex != 0)
     return NS_ERROR_INVALID_ARG;
 
-  NS_IF_ADDREF(*aTarget = mTarget);
+  *aTarget = mTarget;
   return NS_OK;
 }
 
@@ -91,6 +91,6 @@ nsAccessibleRelation::GetTargets(nsIArra
 
   relations->AppendElement(mTarget, PR_FALSE);
 
-  NS_ADDREF(*aRelations = relations);
+  *aRelations = relations;
   return NS_OK;
 }
diff --git a/accessible/src/base/nsApplicationAccessible.cpp b/accessible/src/base/nsApplicationAccessible.cpp
--- a/accessible/src/base/nsApplicationAccessible.cpp
+++ b/accessible/src/base/nsApplicationAccessible.cpp
@@ -148,7 +148,7 @@ nsApplicationAccessible::GetChildAt(PRIn
 
   if (childWeakRef) {
     nsIAccessible* childAcc(do_QueryReferent(childWeakRef));
-    NS_IF_ADDREF(*aChild = childAcc);
+    *aChild = childAcc;
   }
 
   return NS_OK;
diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -457,7 +457,6 @@ NS_IMETHODIMP nsDocAccessible::GetDocume
   *aDOMDoc = domDoc;
 
   if (domDoc) {
-    NS_ADDREF(*aDOMDoc);
     return NS_OK;
   }
 
@@ -488,7 +487,7 @@ NS_IMETHODIMP nsDocAccessible::GetAssoci
   PRBool isEditable;
   editor->GetIsDocumentEditable(&isEditable);
   if (isEditable) {
-    NS_ADDREF(*aEditor = editor);
+    *aEditor = editor;
   }
   return NS_OK;
 }
@@ -957,7 +956,6 @@ NS_IMETHODIMP nsDocAccessible::ScrollPos
   else {
     mScrollWatchTimer = do_CreateInstance("@mozilla.org/timer;1");
     if (mScrollWatchTimer) {
-      NS_ADDREF_THIS(); // Kung fu death grip
       mScrollWatchTimer->InitWithFuncCallback(ScrollTimerCallback, this,
                                               kScrollPosCheckWait,
                                               nsITimer::TYPE_REPEATING_SLACK);
@@ -1476,7 +1474,6 @@ nsDocAccessible::CreateTextChangeEventFo
 
   nsIAccessibleTextChangeEvent *event =
     new nsAccTextChangeEvent(aContainerAccessible, offset, length, aIsInserting, aIsAsynch);
-  NS_IF_ADDREF(event);
 
   return event;
 }
@@ -1508,7 +1505,6 @@ nsDocAccessible::FireDelayedAccessibleEv
   if (mEventsToFire.Count() == 1) {
     // This is be the first delayed event in queue, start timer
     // so that event gets fired via FlushEventsCallback
-    NS_ADDREF_THIS(); // Kung fu death grip to prevent crash in callback
     mFireEventTimer->InitWithFuncCallback(FlushEventsCallback,
                                           static_cast<nsPIAccessibleDocument*>(this),
                                           0, nsITimer::TYPE_ONE_SHOT);
@@ -2030,7 +2026,6 @@ nsDocAccessible::GetAccessibleInParentCh
     currentNode->GetParentNode(&parentNode);
     currentNode = parentNode;
     if (!currentNode) {
-      NS_ADDREF_THIS();
       *aAccessible = this;
       break;
     }
diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp
--- a/accessible/src/base/nsRootAccessible.cpp
+++ b/accessible/src/base/nsRootAccessible.cpp
@@ -157,7 +157,7 @@ NS_IMETHODIMP nsRootAccessible::GetParen
   *aParent = nsnull;
 
   nsApplicationAccessibleWrap* root = GetApplicationAccessible();
-  NS_IF_ADDREF(*aParent = root);
+  *aParent = root;
 
   return NS_OK;
 }
@@ -269,7 +269,6 @@ nsRootAccessible::GetChromeEventHandler(
   nsIDOMEventTarget* target(do_QueryInterface(chromeEventHandler));
 
   *aChromeTarget = target;
-  NS_IF_ADDREF(*aChromeTarget);
 }
 
 const char* const docEvents[] = {
@@ -519,7 +518,6 @@ PRBool nsRootAccessible::FireAccessibleF
 
   NS_IF_RELEASE(gLastFocusedNode);
   gLastFocusedNode = finalFocusNode;
-  NS_IF_ADDREF(gLastFocusedNode);
 
   nsIContent* focusContent = do_QueryInterface(gLastFocusedNode);
   nsIFrame *focusFrame = nsnull;
@@ -951,7 +949,7 @@ void nsRootAccessible::GetTargetNode(nsI
       return;
   }
 
-  NS_ADDREF(*aTargetNode = eventTarget);
+  *aTargetNode = eventTarget;
 }
 
 void nsRootAccessible::FireFocusCallback(nsITimer *aTimer, void *aClosure)
@@ -1024,7 +1022,6 @@ nsRootAccessible::GetContentDocShell(nsI
       swap(accessible, ancestor);
     }
 
-    NS_ADDREF(aStart);
     return aStart;
   }
   nsIDocShellTreeNode* treeNode(do_QueryInterface(aStart));
@@ -1037,7 +1034,7 @@ nsRootAccessible::GetContentDocShell(nsI
       NS_ENSURE_TRUE(treeItemChild, nsnull);
       contentTreeItem = GetContentDocShell(treeItemChild);
       if (contentTreeItem) {
-        NS_ADDREF(aStart = contentTreeItem);
+        aStart = contentTreeItem;
         return aStart;
       }
     }
diff --git a/accessible/src/html/nsHTMLFormControlAccessible.cpp b/accessible/src/html/nsHTMLFormControlAccessible.cpp
--- a/accessible/src/html/nsHTMLFormControlAccessible.cpp
+++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp
@@ -686,7 +686,7 @@ nsHTMLLegendAccessible::GetAccessibleRel
                                                &testLabelAccessible);
       if (testLabelAccessible == this) {
         // We're the first child of the parent groupbox
-        NS_ADDREF(*aRelated = groupboxAccessible);
+        *aRelated = groupboxAccessible;
       }
     }
   }
diff --git a/accessible/src/html/nsHTMLImageAccessible.cpp b/accessible/src/html/nsHTMLImageAccessible.cpp
--- a/accessible/src/html/nsHTMLImageAccessible.cpp
+++ b/accessible/src/html/nsHTMLImageAccessible.cpp
@@ -287,7 +287,7 @@ nsHTMLImageAccessible::GetAnchor(PRInt32
     if (!accessible)
       return NS_ERROR_INVALID_ARG;
 
-    NS_ADDREF(*aAccessible = accessible);
+    *aAccessible = accessible;
   }
 
   return NS_OK;
diff --git a/accessible/src/html/nsHTMLSelectAccessible.cpp b/accessible/src/html/nsHTMLSelectAccessible.cpp
--- a/accessible/src/html/nsHTMLSelectAccessible.cpp
+++ b/accessible/src/html/nsHTMLSelectAccessible.cpp
@@ -227,7 +227,6 @@ NS_IMETHODIMP nsHTMLSelectableAccessible
   selectedAccessibles->GetLength(&uLength); 
   if (uLength != 0) { // length of nsIArray containing selected options
     *_retval = selectedAccessibles;
-    NS_ADDREF(*_retval);
   }
   return NS_OK;
 }
@@ -392,7 +391,6 @@ nsHTMLSelectListAccessible::AccessibleFo
     mFirstChild = accessible;
   }
   nsIAccessible *returnAccessible = accessible;
-  NS_ADDREF(returnAccessible);
   return returnAccessible;
 }
 
@@ -435,7 +433,7 @@ nsHTMLSelectListAccessible::CacheOptSibl
     nsPIAccessible* privateLastAcc =
       do_QueryInterface(lastGoodAccessible);
     privateLastAcc->SetNextSibling(nsnull);
-    NS_ADDREF(aLastGoodAccessible = lastGoodAccessible);
+    aLastGoodAccessible = lastGoodAccessible;
   }
   return aLastGoodAccessible;
 }
@@ -1376,7 +1374,7 @@ NS_IMETHODIMP nsHTMLComboboxButtonAccess
 /** Return our cached parent */
 NS_IMETHODIMP nsHTMLComboboxButtonAccessible::GetParent(nsIAccessible **aParent)
 {   
-  NS_IF_ADDREF(*aParent = mParent);
+  *aParent = mParent;
   return NS_OK;
 }
 
@@ -1479,7 +1477,7 @@ nsHTMLComboboxListAccessible::GetState(P
 /** Return our cached parent */
 NS_IMETHODIMP nsHTMLComboboxListAccessible::GetParent(nsIAccessible **aParent)
 {
-  NS_IF_ADDREF(*aParent = mParent);
+  *aParent = mParent;
   return NS_OK;
 }
 
diff --git a/accessible/src/html/nsHTMLTableAccessible.cpp b/accessible/src/html/nsHTMLTableAccessible.cpp
--- a/accessible/src/html/nsHTMLTableAccessible.cpp
+++ b/accessible/src/html/nsHTMLTableAccessible.cpp
@@ -271,7 +271,7 @@ nsHTMLTableAccessible::GetCaption(nsIAcc
   nsIAccessible* firstChild = nsnull;
   GetFirstChild(&firstChild);
   if (firstChild && Role(firstChild) == nsIAccessibleRole::ROLE_CAPTION) {
-    NS_ADDREF(*aCaption = firstChild);
+    *aCaption = firstChild;
   }
   return NS_OK;
 }
@@ -334,7 +334,6 @@ nsHTMLTableAccessible::GetColumnHeader(n
   NS_ENSURE_TRUE(accTableHead, NS_ERROR_FAILURE);
 
   *aColumnHeader = accTableHead;
-  NS_IF_ADDREF(*aColumnHeader);
 
   return rv;
 }
@@ -894,7 +893,6 @@ nsHTMLTableAccessible::GetTableNode(nsID
   nsIDOMHTMLTableElement* table(do_QueryInterface(mDOMNode));
   if (table) {
     *_retval = table;
-    NS_IF_ADDREF(*_retval);
     return rv;
   }
 
@@ -905,7 +903,6 @@ nsHTMLTableAccessible::GetTableNode(nsID
     NS_ENSURE_SUCCESS(rv, rv);
 
     *_retval = parent;
-    NS_IF_ADDREF(*_retval);
     return rv;
   }
 
diff --git a/accessible/src/html/nsHTMLTextAccessible.cpp b/accessible/src/html/nsHTMLTextAccessible.cpp
--- a/accessible/src/html/nsHTMLTextAccessible.cpp
+++ b/accessible/src/html/nsHTMLTextAccessible.cpp
@@ -345,7 +345,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsHTMLListBulletAccessible::GetParent(nsIAccessible **aParentAccessible)
 {
-  NS_IF_ADDREF(*aParentAccessible = mWeakParent);
+  *aParentAccessible = mWeakParent;
   return NS_OK;
 }
 
diff --git a/accessible/src/html/nsHyperTextAccessible.cpp b/accessible/src/html/nsHyperTextAccessible.cpp
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -90,7 +90,6 @@ nsresult nsHyperTextAccessible::QueryInt
 
     if (aIID.Equals(NS_GET_IID(nsHyperTextAccessible))) {
       *aInstancePtr = static_cast<nsHyperTextAccessible*>(this);
-      NS_ADDREF_THIS();
       return NS_OK;
     }
 
@@ -106,19 +105,16 @@ nsresult nsHyperTextAccessible::QueryInt
 
     if (aIID.Equals(NS_GET_IID(nsIAccessibleText))) {
       *aInstancePtr = static_cast<nsIAccessibleText*>(this);
-      NS_ADDREF_THIS();
       return NS_OK;
     }
 
     if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperText))) {
       *aInstancePtr = static_cast<nsIAccessibleHyperText*>(this);
-      NS_ADDREF_THIS();
       return NS_OK;
     }
 
     if (aIID.Equals(NS_GET_IID(nsIAccessibleEditableText))) {
       *aInstancePtr = static_cast<nsIAccessibleEditableText*>(this);
-      NS_ADDREF_THIS();
       return NS_OK;
     }
   }
@@ -426,7 +422,7 @@ nsHyperTextAccessible::GetPosAndText(PRI
           if (aEndFrame) {
             *aEndFrame = frame; // We ended in the current frame
             if (aEndAcc)
-              NS_ADDREF(*aEndAcc = accessible);
+              *aEndAcc = accessible;
           }
           if (substringEndOffset > endOffset) {
             // Need to stop before the end of the available text
@@ -454,7 +450,7 @@ nsHyperTextAccessible::GetPosAndText(PRI
           startFrame = frame;
           aStartOffset = startOffset;
           if (aStartAcc)
-            NS_ADDREF(*aStartAcc = accessible);
+            *aStartAcc = accessible;
         }
         // We already started copying in this accessible's string,
         // for the next accessible we'll start at offset 0
@@ -496,7 +492,7 @@ nsHyperTextAccessible::GetPosAndText(PRI
           startFrame = frame;
           aStartOffset = 0;
           if (aStartAcc)
-            NS_ADDREF(*aStartAcc = accessible);
+            *aStartAcc = accessible;
         }
       }
       -- endOffset;
@@ -507,12 +503,12 @@ nsHyperTextAccessible::GetPosAndText(PRI
   }
 
   if (aStartAcc && !*aStartAcc) {
-    NS_IF_ADDREF(*aStartAcc = lastAccessible);
+    *aStartAcc = lastAccessible;
   }
   if (aEndFrame && !*aEndFrame) {
     *aEndFrame = startFrame;
     if (aStartAcc && aEndAcc)
-      NS_IF_ADDREF(*aEndAcc = *aStartAcc);
+      *aEndAcc = *aStartAcc;
   }
 
   return startFrame;
@@ -691,7 +687,7 @@ nsresult nsHyperTextAccessible::DOMPoint
     NS_ASSERTION(accessible == childAccessible, "These should be equal whenever we exit loop and accessible != nsnull");
     if (aFinalAccessible && (NextChild(accessible) || static_cast<PRInt32>(addTextOffset) < TextLength(childAccessible))) {  
       // If not at end of last text node, we will return the accessible we were in
-      NS_ADDREF(*aFinalAccessible = childAccessible);
+      *aFinalAccessible = childAccessible;
     }
   }
 
@@ -742,10 +738,10 @@ nsHyperTextAccessible::HypertextOffsetsT
     endOffset = startOffset;
   }
 
-  NS_ADDREF(*aStartNode = startNode);
+  *aStartNode = startNode;
   *aStartOffset = startOffset;
 
-  NS_ADDREF(*aEndNode = endNode);
+  *aEndNode = endNode;
   *aEndOffset = endOffset;
 
   return NS_OK;
@@ -1089,7 +1085,7 @@ NS_IMETHODIMP nsHyperTextAccessible::Get
     NS_ENSURE_TRUE(length >= 0, NS_ERROR_FAILURE);
     if (*aRangeStartOffset + length > aOffset) {
       *aRangeEndOffset = *aRangeStartOffset + length;
-      NS_ADDREF(*aAccessibleWithAttrs = accessible);
+      *aAccessibleWithAttrs = accessible;
       return NS_OK;
     }
     *aRangeStartOffset += length;
@@ -1650,10 +1646,10 @@ nsresult nsHyperTextAccessible::GetSelec
   }
 
   if (aSelCon) {
-    NS_ADDREF(*aSelCon = selCon);
+    *aSelCon = selCon;
   }
   if (aDomSel) {
-    NS_ADDREF(*aDomSel = domSel);
+    *aDomSel = domSel;
   }
   if (aRanges) {
     nsISelection2* selection2(do_QueryInterface(domSel));
@@ -2033,7 +2029,7 @@ nsHyperTextAccessible::GetDOMPointByFram
     node = do_QueryInterface(parent);
   }
 
-  NS_IF_ADDREF(*aNode = node);
+  *aNode = node;
   return NS_OK;
 }
 
diff --git a/accessible/src/msaa/nsAccessNodeWrap.cpp b/accessible/src/msaa/nsAccessNodeWrap.cpp
--- a/accessible/src/msaa/nsAccessNodeWrap.cpp
+++ b/accessible/src/msaa/nsAccessNodeWrap.cpp
@@ -572,7 +572,6 @@ nsAccessNodeWrap::get_localInterface(
 {
 __try {
   *localInterface = static_cast<nsIAccessNode*>(this);
-  NS_ADDREF_THIS();
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return S_OK;
 }
diff --git a/accessible/src/msaa/nsAccessibleWrap.cpp b/accessible/src/msaa/nsAccessibleWrap.cpp
--- a/accessible/src/msaa/nsAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsAccessibleWrap.cpp
@@ -744,7 +744,6 @@ __try {
   *ppenum = new AccessibleEnumerator(*this);
   if (!*ppenum)
     return E_OUTOFMEMORY;
-  NS_ADDREF(*ppenum);
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return S_OK;
 }
@@ -804,7 +803,7 @@ __try {
       if (!pEnum)
         return E_OUTOFMEMORY;
       pvarChildren->vt = VT_UNKNOWN;    // this must be VT_UNKNOWN for an IEnumVARIANT
-      NS_ADDREF(pvarChildren->punkVal = pEnum);
+      pvarChildren->punkVal = pEnum;
     }
   }
 } __except(FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
@@ -1172,7 +1171,6 @@ __try {
   *ppenum = new AccessibleEnumerator(childArray);
   if (!*ppenum)
     return E_OUTOFMEMORY;
-  NS_ADDREF(*ppenum);
 
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return NOERROR;
@@ -1678,7 +1676,6 @@ NS_IMETHODIMP nsAccessibleWrap::GetNativ
 NS_IMETHODIMP nsAccessibleWrap::GetNativeInterface(void **aOutAccessible)
 {
   *aOutAccessible = static_cast<IAccessible*>(this);
-  NS_ADDREF_THIS();
   return NS_OK;
 }
 
@@ -1892,7 +1889,6 @@ void nsAccessibleWrap::GetXPAccessibleFo
       nextAccessible->GetNextSibling(getter_AddRefs(xpAccessible));
     }
   }
-  NS_IF_ADDREF(*aXPAccessible);
 }
 
 void nsAccessibleWrap::UpdateSystemCaret()
diff --git a/accessible/src/msaa/nsDocAccessibleWrap.cpp b/accessible/src/msaa/nsDocAccessibleWrap.cpp
--- a/accessible/src/msaa/nsDocAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsDocAccessibleWrap.cpp
@@ -106,7 +106,7 @@ void nsDocAccessibleWrap::GetXPAccessibl
     nsCOMPtr<nsIAccessNode> accessNode;
     GetCachedAccessNode(uniqueID, getter_AddRefs(accessNode));
     nsCOMPtr<nsIAccessible> accessible(do_QueryInterface(accessNode));
-    NS_IF_ADDREF(*aXPAccessible = accessible);
+    *aXPAccessible = accessible;
     return;
   }
 
diff --git a/accessible/src/msaa/nsHTMLWin32ObjectAccessible.cpp b/accessible/src/msaa/nsHTMLWin32ObjectAccessible.cpp
--- a/accessible/src/msaa/nsHTMLWin32ObjectAccessible.cpp
+++ b/accessible/src/msaa/nsHTMLWin32ObjectAccessible.cpp
@@ -67,7 +67,6 @@ NS_IMETHODIMP nsHTMLWin32ObjectOwnerAcce
     SetFirstChild(mNativeAccessible);
     *aFirstChild = mNativeAccessible;
   }
-  NS_IF_ADDREF(*aFirstChild);
   return NS_OK;
 }
 
diff --git a/accessible/src/xforms/nsXFormsAccessible.cpp b/accessible/src/xforms/nsXFormsAccessible.cpp
--- a/accessible/src/xforms/nsXFormsAccessible.cpp
+++ b/accessible/src/xforms/nsXFormsAccessible.cpp
@@ -402,7 +402,7 @@ nsXFormsSelectableAccessible::GetSelecte
     NS_ENSURE_TRUE(accessible, NS_ERROR_FAILURE);
 
     accessibles->AppendElement(accessible, PR_FALSE);
-    NS_ADDREF(*aAccessibles = accessibles);
+    *aAccessibles = accessibles;
     return NS_OK;
   }
 
@@ -431,7 +431,7 @@ nsXFormsSelectableAccessible::GetSelecte
     accessibles->AppendElement(accessible, PR_FALSE);
   }
 
-  NS_ADDREF(*aAccessibles = accessibles);
+  *aAccessibles = accessibles;
   return NS_OK;
 }
 
diff --git a/accessible/src/xul/nsXULFormControlAccessible.cpp b/accessible/src/xul/nsXULFormControlAccessible.cpp
--- a/accessible/src/xul/nsXULFormControlAccessible.cpp
+++ b/accessible/src/xul/nsXULFormControlAccessible.cpp
@@ -457,7 +457,7 @@ nsXULGroupboxAccessible::GetAccessibleRe
                                                   &testGroupboxAccessible);
         if (testGroupboxAccessible == this) {
           // The <label> points back to this groupbox
-          NS_ADDREF(*aRelated = testLabelAccessible);
+          *aRelated = testLabelAccessible;
           return NS_OK;
         }
       }
diff --git a/accessible/src/xul/nsXULMenuAccessible.cpp b/accessible/src/xul/nsXULMenuAccessible.cpp
--- a/accessible/src/xul/nsXULMenuAccessible.cpp
+++ b/accessible/src/xul/nsXULMenuAccessible.cpp
@@ -160,7 +160,7 @@ NS_IMETHODIMP nsXULSelectableAccessible:
   PRUint32 uLength = 0;
   selectedAccessibles->GetLength(&uLength);
   if (uLength != 0) { // length of nsIArray containing selected options
-    NS_ADDREF(*aChildren = selectedAccessibles);
+    *aChildren = selectedAccessibles;
   }
 
   return NS_OK;
@@ -188,7 +188,6 @@ NS_IMETHODIMP nsXULSelectableAccessible:
     if (accService) {
       accService->GetAccessibleInWeakShell(selectedItem, mWeakShell, aAccessible);
       if (*aAccessible) {
-        NS_ADDREF(*aAccessible);
         return NS_OK;
       }
     }
@@ -665,7 +664,6 @@ nsXULMenupopupAccessible::FindInNodeList
     nsIContent* content = do_QueryInterface(childNode);
     if (content && content->NodeInfo()->Equals(aAtom, kNameSpaceID_XUL)) {
       nsIDOMNode *matchNode = childNode;
-      NS_ADDREF(matchNode);
       return matchNode;
     }
   }
diff --git a/accessible/src/xul/nsXULSelectAccessible.cpp b/accessible/src/xul/nsXULSelectAccessible.cpp
--- a/accessible/src/xul/nsXULSelectAccessible.cpp
+++ b/accessible/src/xul/nsXULSelectAccessible.cpp
@@ -162,7 +162,6 @@ nsXULListboxAccessible::QueryInterface(R
 
   if (aIID.Equals(NS_GET_IID(nsIAccessibleTable)) && IsTree()) {
     *aInstancePtr = static_cast<nsIAccessibleTable*>(this);
-    NS_ADDREF_THIS();
     return NS_OK;
   }
 
diff --git a/accessible/src/xul/nsXULTabAccessible.cpp b/accessible/src/xul/nsXULTabAccessible.cpp
--- a/accessible/src/xul/nsXULTabAccessible.cpp
+++ b/accessible/src/xul/nsXULTabAccessible.cpp
@@ -209,7 +209,7 @@ nsXULTabAccessible::GetAccessibleRelated
   while (childAcc) {
     if (Role(childAcc) == nsIAccessibleRole::ROLE_PROPERTYPAGE) {
       if (tabIndex == 0) {
-        NS_ADDREF(*aRelatedAccessible = childAcc);
+        *aRelatedAccessible = childAcc;
         return NS_OK;
       }
 
@@ -387,7 +387,7 @@ nsXULTabpanelAccessible::GetAccessibleRe
         if (tabContent->AttrValueIs(kNameSpaceID_None,
                                     nsAccessibilityAtoms::linkedPanel, atomID,
                                     eCaseMatters)) {
-          NS_ADDREF(*aRelatedAccessible = childAcc);
+          *aRelatedAccessible = childAcc;
           return NS_OK;
         }
       }
@@ -406,7 +406,7 @@ nsXULTabpanelAccessible::GetAccessibleRe
     swap(childAcc, acc);
   }
 
-  NS_IF_ADDREF(*aRelatedAccessible = foundTabAcc);
+  *aRelatedAccessible = foundTabAcc;
   return NS_OK;
 }
 
diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp
--- a/accessible/src/xul/nsXULTreeAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeAccessible.cpp
@@ -157,7 +157,6 @@ void nsXULTreeAccessible::GetTreeBoxObje
         nsITreeBoxObject* treeBox(do_QueryInterface(box));
         if (treeBox) {
           *aBoxObject = treeBox;
-          NS_ADDREF(*aBoxObject);
           return;
         }
       }
@@ -315,7 +314,7 @@ NS_IMETHODIMP nsXULTreeAccessible::GetFo
       }
     }
   }
-  NS_ADDREF(*aFocusedChild = this);
+  *aFocusedChild = this;
   return NS_OK;
 }
 
@@ -388,7 +387,6 @@ NS_IMETHODIMP nsXULTreeAccessible::GetSe
   selectedAccessibles->GetLength(&length);
   if (length != 0) {
     *_retval = selectedAccessibles;
-    NS_IF_ADDREF(*_retval);
   }
 
   return NS_OK;
@@ -550,7 +548,7 @@ nsXULTreeAccessible::GetCachedTreeitemAc
     PutCacheEntry(*mAccessNodeCache, (void*)(aRow * kMaxTreeColumns + columnIndex), accessNode);
   }
   nsIAccessible* accessible(do_QueryInterface(accessNode));
-  NS_IF_ADDREF(*aAccessible = accessible);
+  *aAccessible = accessible;
   return NS_OK;
 }
 
@@ -1051,7 +1049,6 @@ NS_IMETHODIMP nsXULTreeitemAccessible::G
 
   if (mParent) {
     *aParent = mParent;
-    NS_ADDREF(*aParent);
   }
 
   return NS_OK;
@@ -1277,7 +1274,7 @@ NS_IMETHODIMP nsXULTreeitemAccessible::G
       PRInt32 parentIndex;
       if (NS_SUCCEEDED(mTreeView->GetParentIndex(mRow, &parentIndex))) {
         if (parentIndex == -1) {
-          NS_IF_ADDREF(*aRelated = mParent);
+          *aRelated = mParent;
           return NS_OK;
         } else {
           nsIAccessibleTreeCache* cache =
diff --git a/browser/components/dirprovider/nsBrowserDirectoryProvider.cpp b/browser/components/dirprovider/nsBrowserDirectoryProvider.cpp
--- a/browser/components/dirprovider/nsBrowserDirectoryProvider.cpp
+++ b/browser/components/dirprovider/nsBrowserDirectoryProvider.cpp
@@ -178,7 +178,7 @@ nsBrowserDirectoryProvider::GetFile(cons
   }
 
   *aPersist = PR_TRUE;
-  NS_ADDREF(*aResult = file);
+  *aResult = file;
 
   return NS_OK;
 }
@@ -402,7 +402,7 @@ nsBrowserDirectoryProvider::AppendingEnu
 nsBrowserDirectoryProvider::AppendingEnumerator::GetNext(nsISupports* *aResult)
 {
   if (aResult)
-    NS_ADDREF(*aResult = mNext);
+    *aResult = mNext;
 
   mNext = nsnull;
 
diff --git a/browser/components/feeds/src/nsAboutFeeds.cpp b/browser/components/feeds/src/nsAboutFeeds.cpp
--- a/browser/components/feeds/src/nsAboutFeeds.cpp
+++ b/browser/components/feeds/src/nsAboutFeeds.cpp
@@ -75,7 +75,7 @@ nsAboutFeeds::NewChannel(nsIURI* uri, ns
   if (NS_FAILED(rv))
     return rv;
 
-  NS_ADDREF(*result = channel);
+  *result = channel;
   return NS_OK;
 }
 
@@ -93,7 +93,6 @@ nsAboutFeeds::Create(nsISupports* outer,
   nsAboutFeeds* aboutFeeds = new nsAboutFeeds();
   if (aboutFeeds == nsnull)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(aboutFeeds);
   nsresult rv = aboutFeeds->QueryInterface(iid, result);
   NS_RELEASE(aboutFeeds);
   return rv;
diff --git a/browser/components/migration/src/nsDogbertProfileMigrator.cpp b/browser/components/migration/src/nsDogbertProfileMigrator.cpp
--- a/browser/components/migration/src/nsDogbertProfileMigrator.cpp
+++ b/browser/components/migration/src/nsDogbertProfileMigrator.cpp
@@ -323,7 +323,7 @@ nsDogbertProfileMigrator::GetSourceProfi
     }
   }
   
-  NS_IF_ADDREF(*aResult = mProfiles);
+  *aResult = mProfiles;
   return NS_OK;
 }
 #else // XP_UNIX
@@ -369,7 +369,7 @@ nsDogbertProfileMigrator::GetSourceProfi
 
   nameString->SetData(NS_LITERAL_STRING("Netscape 4.x"));
   mProfiles->AppendElement(nameString);
-  NS_ADDREF(*aResult = mProfiles);
+  *aResult = mProfiles;
   return NS_OK;
 }
 
diff --git a/browser/components/migration/src/nsIEProfileMigrator.cpp b/browser/components/migration/src/nsIEProfileMigrator.cpp
--- a/browser/components/migration/src/nsIEProfileMigrator.cpp
+++ b/browser/components/migration/src/nsIEProfileMigrator.cpp
@@ -1977,7 +1977,6 @@ nsIEProfileMigrator::GetUserStyleSheetFi
     // establish the user content stylesheet file
     userChrome->Append(NS_LITERAL_STRING("userContent.css"));
     *aUserFile = userChrome;
-    NS_ADDREF(*aUserFile);
   }
 }
 
diff --git a/browser/components/migration/src/nsOperaProfileMigrator.cpp b/browser/components/migration/src/nsOperaProfileMigrator.cpp
--- a/browser/components/migration/src/nsOperaProfileMigrator.cpp
+++ b/browser/components/migration/src/nsOperaProfileMigrator.cpp
@@ -278,7 +278,6 @@ nsOperaProfileMigrator::GetSourceProfile
   }
 
   *aResult = mProfiles;
-  NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -1388,6 +1387,5 @@ nsOperaProfileMigrator::GetOperaProfile(
 #endif    
 
   *aFile = file;
-  NS_ADDREF(*aFile);
 }
 
diff --git a/browser/components/migration/src/nsPhoenixProfileMigrator.cpp b/browser/components/migration/src/nsPhoenixProfileMigrator.cpp
--- a/browser/components/migration/src/nsPhoenixProfileMigrator.cpp
+++ b/browser/components/migration/src/nsPhoenixProfileMigrator.cpp
@@ -235,7 +235,7 @@ nsPhoenixProfileMigrator::GetSourceProfi
     FillProfileDataFromPhoenixRegistry();
   }
   
-  NS_IF_ADDREF(*aResult = mProfileNames);
+  *aResult = mProfileNames;
   return NS_OK;
 }
 NS_IMETHODIMP
diff --git a/browser/components/migration/src/nsSafariProfileMigrator.cpp b/browser/components/migration/src/nsSafariProfileMigrator.cpp
--- a/browser/components/migration/src/nsSafariProfileMigrator.cpp
+++ b/browser/components/migration/src/nsSafariProfileMigrator.cpp
@@ -1154,7 +1154,7 @@ nsSafariProfileMigrator::GetSafariUserSt
           PRBool exists = PR_FALSE;
           file->Exists(&exists);
           if (exists) {
-            NS_ADDREF(*aResult = file);
+            *aResult = file;
             rv = NS_OK;
           }
           else
diff --git a/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp b/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp
--- a/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp
+++ b/browser/components/migration/src/nsSeamonkeyProfileMigrator.cpp
@@ -234,7 +234,7 @@ nsSeamonkeyProfileMigrator::GetSourcePro
     FillProfileDataFromSeamonkeyRegistry();
   }
   
-  NS_IF_ADDREF(*aResult = mProfileNames);
+  *aResult = mProfileNames;
   return NS_OK;
 }
 
diff --git a/browser/components/shell/src/nsMacShellService.cpp b/browser/components/shell/src/nsMacShellService.cpp
--- a/browser/components/shell/src/nsMacShellService.cpp
+++ b/browser/components/shell/src/nsMacShellService.cpp
@@ -521,7 +521,7 @@ nsMacShellService::GetDefaultFeedReader(
         rv = NS_ERROR_FAILURE;
         if (NS_FAILED(defaultReader->GetBundleIdentifier(bundleIdentifier)) ||
             !bundleIdentifier.Equals(SAFARI_BUNDLE_IDENTIFIER)) {
-          NS_ADDREF(*_retval = defaultReader);
+          *_retval = defaultReader;
           rv = NS_OK;
         }
       }
diff --git a/browser/components/shell/src/nsWindowsShellService.cpp b/browser/components/shell/src/nsWindowsShellService.cpp
--- a/browser/components/shell/src/nsWindowsShellService.cpp
+++ b/browser/components/shell/src/nsWindowsShellService.cpp
@@ -875,6 +875,6 @@ nsWindowsShellService::GetDefaultFeedRea
   if (!exists)
     return NS_ERROR_FAILURE;
 
-  NS_ADDREF(*_retval = defaultReader);
+  *_retval = defaultReader;
   return NS_OK;
 }
diff --git a/caps/src/nsPrincipal.cpp b/caps/src/nsPrincipal.cpp
--- a/caps/src/nsPrincipal.cpp
+++ b/caps/src/nsPrincipal.cpp
@@ -604,7 +604,7 @@ nsPrincipal::GetURI(nsIURI** aURI)
 nsPrincipal::GetURI(nsIURI** aURI)
 {
   if (mCodebaseImmutable) {
-    NS_ADDREF(*aURI = mCodebase);
+    *aURI = mCodebase;
     return NS_OK;
   }
 
@@ -678,7 +678,7 @@ nsPrincipal::GetCertificate(nsISupports*
 nsPrincipal::GetCertificate(nsISupports** aCertificate)
 {
   if (mCert) {
-    NS_IF_ADDREF(*aCertificate = mCert->cert);
+    *aCertificate = mCert->cert;
   }
   else {
     *aCertificate = nsnull;
@@ -713,7 +713,7 @@ nsPrincipal::GetDomain(nsIURI** aDomain)
   }
 
   if (mDomainImmutable) {
-    NS_ADDREF(*aDomain = mDomain);
+    *aDomain = mDomain;
     return NS_OK;
   }
 
diff --git a/caps/src/nsScriptSecurityManager.cpp b/caps/src/nsScriptSecurityManager.cpp
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -1864,7 +1864,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsScriptSecurityManager::GetSystemPrincipal(nsIPrincipal **result)
 {
-    NS_ADDREF(*result = mSystemPrincipal);
+    *result = mSystemPrincipal;
 
     return NS_OK;
 }
@@ -1953,7 +1953,7 @@ nsScriptSecurityManager::DoGetCertificat
                 // We have a subject name mismatch for the same cert id.
                 // Hand back the |certificate| object we created and don't give
                 // it any rights from the table.
-                NS_ADDREF(*result = certificate);
+                *result = certificate;
                 return NS_OK;
             }                
         }
@@ -2002,7 +2002,7 @@ nsScriptSecurityManager::DoGetCertificat
         }
     }
 
-    NS_ADDREF(*result = certificate);
+    *result = certificate;
 
     return rv;
 }
@@ -2022,7 +2022,7 @@ nsScriptSecurityManager::CreateCodebaseP
     if (NS_FAILED(rv))
         return rv;
 
-    NS_ADDREF(*result = codebase);
+    *result = codebase;
 
     return NS_OK;
 }
@@ -2111,7 +2111,7 @@ nsScriptSecurityManager::GetCodebasePrin
         }
     }
 
-    NS_IF_ADDREF(*result = principal);
+    *result = principal;
 
     return NS_OK;
 }
@@ -2132,7 +2132,7 @@ nsScriptSecurityManager::GetPrincipalFro
     nsIScriptObjectPrincipal* globalData =
         do_QueryInterface(scriptContext->GetGlobalObject());
     if (globalData)
-        NS_IF_ADDREF(*result = globalData->GetPrincipal());
+        *result = globalData->GetPrincipal();
 
     return NS_OK;
 }
@@ -2317,7 +2317,6 @@ nsScriptSecurityManager::GetObjectPrinci
     *result = doGetObjectPrincipal(aObj);
     if (!*result)
         return NS_ERROR_FAILURE;
-    NS_ADDREF(*result);
     return NS_OK;
 }
 
@@ -3402,7 +3401,7 @@ nsScriptSecurityManager::SystemPrincipal
 {
     nsIPrincipal *sysprin = nsnull;
     if (gScriptSecMan)
-        NS_ADDREF(sysprin = gScriptSecMan->mSystemPrincipal);
+        sysprin = gScriptSecMan->mSystemPrincipal;
     return static_cast<nsSystemPrincipal*>(sysprin);
 }
 
diff --git a/chrome/src/nsChromeProtocolHandler.cpp b/chrome/src/nsChromeProtocolHandler.cpp
--- a/chrome/src/nsChromeProtocolHandler.cpp
+++ b/chrome/src/nsChromeProtocolHandler.cpp
@@ -182,7 +182,6 @@ nsCachedChromeChannel::GetOriginalURI(ns
 nsCachedChromeChannel::GetOriginalURI(nsIURI* *aOriginalURI)
 {
     *aOriginalURI = mOriginalURI ? mOriginalURI : mURI;
-    NS_ADDREF(*aOriginalURI);
     return NS_OK;
 }
 
@@ -197,7 +196,6 @@ nsCachedChromeChannel::GetURI(nsIURI* *a
 nsCachedChromeChannel::GetURI(nsIURI* *aURI)
 {
     *aURI = mURI;
-    NS_ADDREF(*aURI);
     return NS_OK;
 }
 
@@ -267,7 +265,6 @@ nsCachedChromeChannel::GetOwner(nsISuppo
 nsCachedChromeChannel::GetOwner(nsISupports * *aOwner)
 {
     *aOwner = mOwner;
-    NS_IF_ADDREF(*aOwner);
     return NS_OK;
 }
 
@@ -282,7 +279,6 @@ nsCachedChromeChannel::GetLoadGroup(nsIL
 nsCachedChromeChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
 {
     *aLoadGroup = mLoadGroup;
-    NS_IF_ADDREF(*aLoadGroup);
     return NS_OK;
 }
 
@@ -451,7 +447,7 @@ nsChromeProtocolHandler::NewURI(const ns
 
     surl->SetMutable(PR_FALSE);
 
-    NS_ADDREF(*result = url);
+    *result = url;
     return NS_OK;
 }
 
@@ -655,7 +651,6 @@ nsChromeProtocolHandler::NewChannel(nsIU
 #endif
 
     *aResult = result;
-    NS_ADDREF(*aResult);
     return NS_OK;
 }
 
diff --git a/content/base/src/mozSanitizingSerializer.cpp b/content/base/src/mozSanitizingSerializer.cpp
--- a/content/base/src/mozSanitizingSerializer.cpp
+++ b/content/base/src/mozSanitizingSerializer.cpp
@@ -86,7 +86,6 @@ nsresult NS_NewSanitizingHTMLSerializer(
   if (!it) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  NS_ADDREF(it);
   *aSerializer = it;
   return NS_OK;
 }
@@ -683,7 +682,6 @@ mozSanitizingHTMLSerializer::ParseTagPre
     }
 
     nsIProperties* attr_bag_raw = attr_bag;
-    NS_ADDREF(attr_bag_raw);
     mAllowedTags.Put(&tag_key, attr_bag_raw);
   }
 
diff --git a/content/base/src/nsAttrAndChildArray.cpp b/content/base/src/nsAttrAndChildArray.cpp
--- a/content/base/src/nsAttrAndChildArray.cpp
+++ b/content/base/src/nsAttrAndChildArray.cpp
@@ -148,7 +148,6 @@ nsAttrAndChildArray::InsertChildAt(nsICo
       memmove(pos + 1, pos, (childCount - aPos) * sizeof(nsIContent*));
     }
     *pos = aChild;
-    NS_ADDREF(aChild);
 
     SetChildCount(childCount + 1);
 
@@ -166,7 +165,6 @@ nsAttrAndChildArray::InsertChildAt(nsICo
     newStart[aPos] = aChild;
     memmove(&newStart[aPos + 1], &oldStart[aPos],
             (childCount - aPos) * sizeof(nsIContent*));
-    NS_ADDREF(aChild);
 
     SetAttrSlotAndChildCount(attrCount, childCount + 1);
 
@@ -183,7 +181,6 @@ nsAttrAndChildArray::InsertChildAt(nsICo
     memmove(pos + 1, pos, (childCount - aPos) * sizeof(nsIContent*));
   }
   *pos = aChild;
-  NS_ADDREF(aChild);
 
   SetChildCount(childCount + 1);
   
@@ -672,7 +669,6 @@ nsAttrAndChildArray::GetModifiableMapped
     *aModifiable = mImpl->mMappedAttrs->Clone(aWillAddAttr);
     NS_ENSURE_TRUE(*aModifiable, NS_ERROR_OUT_OF_MEMORY);
 
-    NS_ADDREF(*aModifiable);
     
     return NS_OK;
   }
@@ -684,7 +680,6 @@ nsAttrAndChildArray::GetModifiableMapped
   *aModifiable = new nsMappedAttributes(aSheet, mapRuleFunc);
   NS_ENSURE_TRUE(*aModifiable, NS_ERROR_OUT_OF_MEMORY);
 
-  NS_ADDREF(*aModifiable);
 
   return NS_OK;
 }
diff --git a/content/base/src/nsAttrName.h b/content/base/src/nsAttrName.h
--- a/content/base/src/nsAttrName.h
+++ b/content/base/src/nsAttrName.h
@@ -65,7 +65,6 @@ public:
     : mBits(reinterpret_cast<PtrBits>(aAtom))
   {
     NS_ASSERTION(aAtom, "null atom-name in nsAttrName");
-    NS_ADDREF(aAtom);
   }
 
   explicit nsAttrName(nsINodeInfo* aNodeInfo)
@@ -73,12 +72,10 @@ public:
     NS_ASSERTION(aNodeInfo, "null nodeinfo-name in nsAttrName");
     if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
       mBits = reinterpret_cast<PtrBits>(aNodeInfo->NameAtom());
-      NS_ADDREF(aNodeInfo->NameAtom());
     }
     else {
       mBits = reinterpret_cast<PtrBits>(aNodeInfo) |
               NS_ATTRNAME_NODEINFO_BIT;
-      NS_ADDREF(aNodeInfo);
     }
   }
 
@@ -94,12 +91,10 @@ public:
     ReleaseInternalName();
     if (aNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
       mBits = reinterpret_cast<PtrBits>(aNodeInfo->NameAtom());
-      NS_ADDREF(aNodeInfo->NameAtom());
     }
     else {
       mBits = reinterpret_cast<PtrBits>(aNodeInfo) |
               NS_ATTRNAME_NODEINFO_BIT;
-      NS_ADDREF(aNodeInfo);
     }
   }
 
@@ -109,7 +104,6 @@ public:
 
     ReleaseInternalName();
     mBits = reinterpret_cast<PtrBits>(aAtom);
-    NS_ADDREF(aAtom);
   }
 
   PRBool IsAtom() const
@@ -223,7 +217,6 @@ private:
     nsISupports* name = reinterpret_cast<nsISupports *>
                                         (mBits & ~NS_ATTRNAME_NODEINFO_BIT);
 
-    NS_ADDREF(name);
   }
 
   void ReleaseInternalName()
diff --git a/content/base/src/nsAttrValue.cpp b/content/base/src/nsAttrValue.cpp
--- a/content/base/src/nsAttrValue.cpp
+++ b/content/base/src/nsAttrValue.cpp
@@ -190,7 +190,6 @@ nsAttrValue::SetTo(const nsAttrValue& aO
     {
       ResetIfSet();
       nsIAtom* atom = aOther.GetAtomValue();
-      NS_ADDREF(atom);
       SetPtrValueAndType(atom, eAtomBase);
       return;
     }
@@ -278,7 +277,7 @@ nsAttrValue::SetTo(nsICSSStyleRule* aVal
 {
   if (EnsureEmptyMiscContainer()) {
     MiscContainer* cont = GetMiscContainer();
-    NS_ADDREF(cont->mCSSStyleRule = aValue);
+    cont->mCSSStyleRule = aValue;
     cont->mType = eCSSStyleRule;
   }
 }
@@ -289,7 +288,7 @@ nsAttrValue::SetTo(nsISVGValue* aValue)
 {
   if (EnsureEmptyMiscContainer()) {
     MiscContainer* cont = GetMiscContainer();
-    NS_ADDREF(cont->mSVGValue = aValue);
+    cont->mSVGValue = aValue;
     cont->mType = eSVGValue;
   }
 }
diff --git a/content/base/src/nsCommentNode.cpp b/content/base/src/nsCommentNode.cpp
--- a/content/base/src/nsCommentNode.cpp
+++ b/content/base/src/nsCommentNode.cpp
@@ -94,7 +94,7 @@ NS_NewCommentNode(nsIContent** aInstance
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aInstancePtrResult = instance);
+  *aInstancePtrResult = instance;
 
   return NS_OK;
 }
diff --git a/content/base/src/nsContentAreaDragDrop.cpp b/content/base/src/nsContentAreaDragDrop.cpp
--- a/content/base/src/nsContentAreaDragDrop.cpp
+++ b/content/base/src/nsContentAreaDragDrop.cpp
@@ -687,7 +687,6 @@ nsContentAreaDragDrop::GetHookEnumerator
   NS_ENSURE_TRUE(enumerator, NS_ERROR_FAILURE);
 
   *outEnumerator = enumerator;
-  NS_ADDREF(*outEnumerator);
 
   return NS_OK;
 }
@@ -1505,7 +1504,6 @@ nsTransferableFactory::ConvertStringsToT
   }
 
   *outTrans = trans;
-  NS_IF_ADDREF(*outTrans);
 
   return NS_OK;
 }
@@ -1687,7 +1685,7 @@ void nsTransferableFactory::GetSelectedL
     nsIDOMNode* link2 = FindParentLinkNode(selectionEnd);
 
     if (link == link2) {
-      NS_IF_ADDREF(*outLinkNode = link);
+      *outLinkNode = link;
     }
   }
 
diff --git a/content/base/src/nsContentIterator.cpp b/content/base/src/nsContentIterator.cpp
--- a/content/base/src/nsContentIterator.cpp
+++ b/content/base/src/nsContentIterator.cpp
@@ -235,7 +235,7 @@ nsresult NS_NewContentIterator(nsIConten
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aInstancePtrResult = iter);
+  *aInstancePtrResult = iter;
 
   return NS_OK;
 }
@@ -248,7 +248,7 @@ nsresult NS_NewPreContentIterator(nsICon
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aInstancePtrResult = iter);
+  *aInstancePtrResult = iter;
 
   return NS_OK;
 }
@@ -1215,7 +1215,7 @@ nsresult NS_NewContentSubtreeIterator(ns
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aInstancePtrResult = iter);
+  *aInstancePtrResult = iter;
 
   return NS_OK;
 }
diff --git a/content/base/src/nsContentList.cpp b/content/base/src/nsContentList.cpp
--- a/content/base/src/nsContentList.cpp
+++ b/content/base/src/nsContentList.cpp
@@ -267,7 +267,6 @@ NS_GetContentList(nsINode* aRootNode, ns
     NS_ENSURE_TRUE(list, nsnull);
   }
 
-  NS_ADDREF(list);
 
   // Hold on to the last requested content list to avoid having it be
   // removed from the cache immediately when it's released. Avoid
@@ -278,7 +277,6 @@ NS_GetContentList(nsINode* aRootNode, ns
     NS_IF_RELEASE(gCachedContentList);
 
     gCachedContentList = list;
-    NS_ADDREF(gCachedContentList);
   }
 
   return list;
diff --git a/content/base/src/nsContentPolicy.cpp b/content/base/src/nsContentPolicy.cpp
--- a/content/base/src/nsContentPolicy.cpp
+++ b/content/base/src/nsContentPolicy.cpp
@@ -64,7 +64,6 @@ NS_NewContentPolicy(nsIContentPolicy **a
   *aResult = new nsContentPolicy;
   if (!*aResult)
       return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
diff --git a/content/base/src/nsDOMAttribute.cpp b/content/base/src/nsDOMAttribute.cpp
--- a/content/base/src/nsDOMAttribute.cpp
+++ b/content/base/src/nsDOMAttribute.cpp
@@ -264,10 +264,9 @@ nsDOMAttribute::GetChildNodes(nsIDOMNode
   if (!slots->mChildNodes) {
     slots->mChildNodes = new nsChildContentList(this);
     NS_ENSURE_TRUE(slots->mChildNodes, NS_ERROR_OUT_OF_MEMORY);
-    NS_ADDREF(slots->mChildNodes);
   }
 
-  NS_ADDREF(*aChildNodes = slots->mChildNodes);
+  *aChildNodes = slots->mChildNodes;
 
   return NS_OK;
 }
@@ -378,7 +377,6 @@ nsDOMAttribute::Clone(nsINodeInfo *aNode
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aResult);
 
   return NS_OK;
 }
diff --git a/content/base/src/nsDOMAttributeMap.cpp b/content/base/src/nsDOMAttributeMap.cpp
--- a/content/base/src/nsDOMAttributeMap.cpp
+++ b/content/base/src/nsDOMAttributeMap.cpp
@@ -237,7 +237,7 @@ nsDOMAttributeMap::SetNamedItemInternal(
 
       // setting a preexisting attribute is a no-op, just return the same
       // node.
-      NS_ADDREF(*aReturn = aNode);
+      *aReturn = aNode;
       
       return NS_OK;
     }
diff --git a/content/base/src/nsDOMBuilder.cpp b/content/base/src/nsDOMBuilder.cpp
--- a/content/base/src/nsDOMBuilder.cpp
+++ b/content/base/src/nsDOMBuilder.cpp
@@ -86,7 +86,6 @@ nsDOMBuilder::GetEntityResolver(nsIDOMDO
 nsDOMBuilder::GetEntityResolver(nsIDOMDOMEntityResolver** aEntityResolver)
 {
   *aEntityResolver = mEntityResolver;
-  NS_IF_ADDREF(*aEntityResolver);
   return NS_OK;
 }
 
@@ -101,7 +100,6 @@ nsDOMBuilder::GetErrorHandler(nsIDOMDOME
 nsDOMBuilder::GetErrorHandler(nsIDOMDOMErrorHandler** aErrorHandler)
 {
   *aErrorHandler = mErrorHandler;
-  NS_IF_ADDREF(*aErrorHandler);
   return NS_OK;
 }
 
@@ -116,7 +114,6 @@ nsDOMBuilder::GetFilter(nsIDOMDOMBuilder
 nsDOMBuilder::GetFilter(nsIDOMDOMBuilderFilter** aFilter)
 {
   *aFilter = mFilter;
-  NS_IF_ADDREF(*aFilter);
   return NS_OK;
 }
 
diff --git a/content/base/src/nsDOMDocumentType.cpp b/content/base/src/nsDOMDocumentType.cpp
--- a/content/base/src/nsDOMDocumentType.cpp
+++ b/content/base/src/nsDOMDocumentType.cpp
@@ -95,7 +95,6 @@ NS_NewDOMDocumentType(nsIDOMDocumentType
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aDocType);
 
   return NS_OK;
 }
@@ -162,7 +161,6 @@ nsDOMDocumentType::GetEntities(nsIDOMNam
 
   *aEntities = mEntities;
 
-  NS_IF_ADDREF(*aEntities);
 
   return NS_OK;
 }
@@ -174,7 +172,6 @@ nsDOMDocumentType::GetNotations(nsIDOMNa
 
   *aNotations = mNotations;
 
-  NS_IF_ADDREF(*aNotations);
 
   return NS_OK;
 }
diff --git a/content/base/src/nsDOMFile.cpp b/content/base/src/nsDOMFile.cpp
--- a/content/base/src/nsDOMFile.cpp
+++ b/content/base/src/nsDOMFile.cpp
@@ -386,7 +386,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsDOMFileList::Item(PRUint32 aIndex, nsIDOMFile **aFile)
 {
-  NS_IF_ADDREF(*aFile = mFiles.SafeObjectAt(aIndex));
+  *aFile = mFiles.SafeObjectAt(aIndex);
 
   return NS_OK;
 }
diff --git a/content/base/src/nsDOMParser.cpp b/content/base/src/nsDOMParser.cpp
--- a/content/base/src/nsDOMParser.cpp
+++ b/content/base/src/nsDOMParser.cpp
@@ -441,9 +441,9 @@ GetInitArgs(JSContext *cx, PRUint32 argc
     }
   }
 
-  NS_IF_ADDREF(*aPrincipal = prin);
-  NS_IF_ADDREF(*aDocumentURI = documentURI);
-  NS_IF_ADDREF(*aBaseURI = baseURI);
+  *aPrincipal = prin;
+  *aDocumentURI = documentURI;
+  *aBaseURI = baseURI;
   return NS_OK;
 }
 
diff --git a/content/base/src/nsDOMSerializer.cpp b/content/base/src/nsDOMSerializer.cpp
--- a/content/base/src/nsDOMSerializer.cpp
+++ b/content/base/src/nsDOMSerializer.cpp
@@ -116,7 +116,6 @@ SetUpEncoder(nsIDOMNode *aRoot, const ns
 
   if (NS_SUCCEEDED(rv)) {
     *aEncoder = encoder;
-    NS_ADDREF(*aEncoder);
   }
 
   return rv;
diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -314,7 +314,6 @@ nsIdentifierMapEntry::CreateNameContentL
 {
   mNameContentList = new nsBaseContentList();
   NS_ENSURE_TRUE(mNameContentList, NS_ERROR_OUT_OF_MEMORY);
-  NS_ADDREF(mNameContentList);
   return NS_OK;
 }
 
@@ -852,7 +851,6 @@ NS_NewDOMImplementation(nsIDOMDOMImpleme
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aInstancePtrResult);
 
   return NS_OK;
 }
@@ -1192,7 +1190,6 @@ nsDocument::Init()
   mNodeInfoManager = new nsNodeInfoManager();
   NS_ENSURE_TRUE(mNodeInfoManager, NS_ERROR_OUT_OF_MEMORY);
 
-  NS_ADDREF(mNodeInfoManager);
 
   nsresult  rv = mNodeInfoManager->Init(this);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -1898,7 +1895,6 @@ nsDocument::GetActiveElement(nsIDOMEleme
     htmlDoc->GetBody(&bodyElement);
     if (bodyElement) {
       *aElement = bodyElement;
-      NS_ADDREF(*aElement);
     }
     // Because of IE compatibility, return null when html document doesn't have
     // a body.
@@ -2006,7 +2002,6 @@ nsDocument::GetElementsByClassNameHelper
   }
 
   *aReturn = elements;
-  NS_ADDREF(*aReturn);
 
   return NS_OK;
 }
@@ -2328,7 +2323,6 @@ SubDocInitEntry(PLDHashTable *table, PLD
 
   e->mKey = const_cast<nsIContent *>
                       (static_cast<const nsIContent *>(key));
-  NS_ADDREF(e->mKey);
 
   e->mSubDocument = nsnull;
   return PR_TRUE;
@@ -2393,7 +2387,6 @@ nsDocument::SetSubDocumentFor(nsIContent
     }
 
     entry->mSubDocument = aSubDoc;
-    NS_ADDREF(entry->mSubDocument);
 
     aSubDoc->SetParentDocument(this);
   }
@@ -3315,7 +3308,6 @@ nsDocument::GetImplementation(nsIDOMDOMI
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aImplementation);
 
   return NS_OK;
 }
@@ -3625,7 +3617,6 @@ nsDocument::GetStyleSheets(nsIDOMStyleSh
   }
 
   *aStyleSheets = mDOMStyleSheets;
-  NS_ADDREF(*aStyleSheets);
 
   return NS_OK;
 }
@@ -3703,7 +3694,7 @@ nsDocument::GetStyleSheetSets(nsIDOMDOMS
     }
   }
 
-  NS_ADDREF(*aList = mStyleSheetSetList);
+  *aList = mStyleSheetSetList;
   return NS_OK;
 }
 
@@ -3903,7 +3894,7 @@ nsDocument::GetBindingParent(nsIDOMNode*
     return NS_ERROR_FAILURE;
 
   nsIDOMElement* elt(do_QueryInterface(content->GetBindingParent()));
-  NS_IF_ADDREF(*aResult = elt);
+  *aResult = elt;
   return NS_OK;
 }
 
@@ -4125,7 +4116,6 @@ nsDocument::GetBoxObjectFor(nsIDOMElemen
     // Want to use Get(content, aResult); but it's the wrong type
     *aResult = mBoxObjectTable->GetWeak(content);
     if (*aResult) {
-      NS_ADDREF(*aResult);
       return NS_OK;
     }
   }
@@ -4166,7 +4156,6 @@ nsDocument::GetBoxObjectFor(nsIDOMElemen
   }
 
   *aResult = boxObject;
-  NS_ADDREF(*aResult);
 
   return NS_OK;
 }
@@ -4402,10 +4391,9 @@ nsDocument::GetChildNodes(nsIDOMNodeList
   if (!slots->mChildNodes) {
     slots->mChildNodes = new nsChildContentList(this);
     NS_ENSURE_TRUE(slots->mChildNodes, NS_ERROR_OUT_OF_MEMORY);
-    NS_ADDREF(slots->mChildNodes);
-  }
-
-  NS_ADDREF(*aChildNodes = slots->mChildNodes);
+  }
+
+  *aChildNodes = slots->mChildNodes;
 
   return NS_OK;
 }
@@ -5058,7 +5046,6 @@ nsDocument::GetListenerManager(PRBool aC
 {
   if (mListenerManager) {
     *aInstancePtrResult = mListenerManager;
-    NS_ADDREF(*aInstancePtrResult);
 
     return NS_OK;
   }
@@ -5073,7 +5060,6 @@ nsDocument::GetListenerManager(PRBool aC
   mListenerManager->SetListenerTarget(static_cast<nsIDocument *>(this));
 
   *aInstancePtrResult = mListenerManager;
-  NS_ADDREF(*aInstancePtrResult);
 
   return NS_OK;
 }
@@ -5282,7 +5268,6 @@ nsDocument::CreateEventGroup(nsIDOMEvent
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aInstancePtrResult = group;
-  NS_ADDREF(*aInstancePtrResult);
 
   return NS_OK;
 }
@@ -5490,7 +5475,6 @@ nsDocument::GetCurrentRadioButton(const 
   GetRadioGroup(aName, &radioGroup);
   if (radioGroup) {
     *aRadio = radioGroup->mSelectedRadioButton;
-    NS_IF_ADDREF(*aRadio);
   }
 
   return NS_OK;
@@ -5575,7 +5559,7 @@ nsDocument::GetNextRadioButton(const nsA
     radio->GetDisabled(&disabled);
   } while (disabled && radio != currentRadio);
 
-  NS_IF_ADDREF(*aRadioOut = radio);
+  *aRadioOut = radio;
   return NS_OK;
 }
 
@@ -5997,7 +5981,7 @@ nsDocument::GetLayoutHistoryState() cons
 {
   nsILayoutHistoryState* state = nsnull;
   if (!mScriptGlobalObject) {
-    NS_IF_ADDREF(state = mLayoutHistoryState);
+    state = mLayoutHistoryState;
   } else {
     nsIDocShell* docShell(do_QueryReferent(mDocumentContainer));
     if (docShell) {
@@ -6128,7 +6112,6 @@ nsDocument::CheckAncestryAndGetFrame(nsI
     return nsnull;
   }
 
-  NS_ADDREF(frameElement);
   return frameElement;
 }
 
diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -196,7 +196,6 @@ class nsUint32ToContentHashEntry : publi
     /** Set the single element, adding a reference */
     nsresult SetContent(nsIContent* aVal)
     {
-      NS_IF_ADDREF(aVal);
       mValOrHash = (void*)(PtrBits(aVal) | 0x1);
       return NS_OK;
     }
diff --git a/content/base/src/nsDocumentEncoder.cpp b/content/base/src/nsDocumentEncoder.cpp
--- a/content/base/src/nsDocumentEncoder.cpp
+++ b/content/base/src/nsDocumentEncoder.cpp
@@ -550,7 +550,6 @@ static nsresult GetNextNode(nsIDOMNode* 
   } else if (aDirection == kDirectionIn) {
     aNextNode = aNode;
 
-    NS_ADDREF(aNextNode);
 
     aDirection = kDirectionOut;
   } else {
@@ -588,7 +587,6 @@ static nsresult GetNextNode(nsIDOMNode* 
 
       aNextNode = parent;
 
-      NS_ADDREF(aNextNode);
     }
   }
 
@@ -1020,7 +1018,6 @@ NS_NewTextEncoder(nsIDocumentEncoder** a
   *aResult = new nsDocumentEncoder;
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
- NS_ADDREF(*aResult);
  return NS_OK;
 }
 
@@ -1761,6 +1758,5 @@ NS_NewHTMLCopyTextEncoder(nsIDocumentEnc
   *aResult = new nsHTMLCopyEncoder;
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
- NS_ADDREF(*aResult);
  return NS_OK;
 }
diff --git a/content/base/src/nsDocumentFragment.cpp b/content/base/src/nsDocumentFragment.cpp
--- a/content/base/src/nsDocumentFragment.cpp
+++ b/content/base/src/nsDocumentFragment.cpp
@@ -177,7 +177,7 @@ NS_NewDocumentFragment(nsIDOMDocumentFra
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aInstancePtrResult = it);
+  *aInstancePtrResult = it;
 
   return NS_OK;
 }
diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp
--- a/content/base/src/nsFrameLoader.cpp
+++ b/content/base/src/nsFrameLoader.cpp
@@ -267,7 +267,6 @@ nsFrameLoader::GetDocShell(nsIDocShell *
   }
 
   *aDocShell = mDocShell;
-  NS_IF_ADDREF(*aDocShell);
 
   return NS_OK;
 }
diff --git a/content/base/src/nsGenConImageContent.cpp b/content/base/src/nsGenConImageContent.cpp
--- a/content/base/src/nsGenConImageContent.cpp
+++ b/content/base/src/nsGenConImageContent.cpp
@@ -84,7 +84,7 @@ NS_NewGenConImageContent(nsIContent** aR
   nsGenConImageContent *it = new nsGenConImageContent(aNodeInfo);
   if (!it)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*aResult = it);
+  *aResult = it;
   nsresult rv = it->Init(aImageRequest);
   if (NS_FAILED(rv))
     NS_RELEASE(*aResult);
diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp
--- a/content/base/src/nsGenericDOMDataNode.cpp
+++ b/content/base/src/nsGenericDOMDataNode.cpp
@@ -167,10 +167,9 @@ nsGenericDOMDataNode::GetChildNodes(nsID
   if (!slots->mChildNodes) {
     slots->mChildNodes = new nsChildContentList(this);
     NS_ENSURE_TRUE(slots->mChildNodes, NS_ERROR_OUT_OF_MEMORY);
-    NS_ADDREF(slots->mChildNodes);
   }
 
-  NS_ADDREF(*aChildNodes = slots->mChildNodes);
+  *aChildNodes = slots->mChildNodes;
   return NS_OK;
 }
 
@@ -848,7 +847,7 @@ nsGenericDOMDataNode::GetBaseURI() const
   nsIURI *uri;
   nsIDocument *doc = GetOwnerDoc();
   if (doc) {
-    NS_IF_ADDREF(uri = doc->GetBaseURI());
+    uri = doc->GetBaseURI();
   }
   else {
     uri = nsnull;
diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h
--- a/content/base/src/nsGenericDOMDataNode.h
+++ b/content/base/src/nsGenericDOMDataNode.h
@@ -258,7 +258,6 @@ public:
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    NS_ADDREF(*aResult);
 
     return NS_OK;
   }
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
@@ -374,7 +374,6 @@ nsImageLoadingContent::GetRequest(PRInt3
     return NS_ERROR_UNEXPECTED;
   }
   
-  NS_IF_ADDREF(*aRequest);
   return NS_OK;
 }
 
diff --git a/content/base/src/nsNameSpaceManager.cpp b/content/base/src/nsNameSpaceManager.cpp
--- a/content/base/src/nsNameSpaceManager.cpp
+++ b/content/base/src/nsNameSpaceManager.cpp
@@ -322,7 +322,6 @@ NS_GetNameSpaceManager(nsINameSpaceManag
   *aInstancePtrResult = sNameSpaceManager;
   NS_ENSURE_TRUE(sNameSpaceManager, NS_ERROR_OUT_OF_MEMORY);
 
-  NS_ADDREF(*aInstancePtrResult);
 
   return NS_OK;
 }
diff --git a/content/base/src/nsNodeInfo.cpp b/content/base/src/nsNodeInfo.cpp
--- a/content/base/src/nsNodeInfo.cpp
+++ b/content/base/src/nsNodeInfo.cpp
@@ -81,15 +81,12 @@ nsNodeInfo::Init(nsIAtom *aName, nsIAtom
   NS_ENSURE_ARG_POINTER(aOwnerManager);
 
   mInner.mName = aName;
-  NS_ADDREF(mInner.mName);
 
   mInner.mPrefix = aPrefix;
-  NS_IF_ADDREF(mInner.mPrefix);
 
   mInner.mNamespaceID = aNamespaceID;
 
   mOwnerManager = aOwnerManager;
-  NS_ADDREF(mOwnerManager);
 
   return NS_OK;
 }
diff --git a/content/base/src/nsNodeInfoManager.cpp b/content/base/src/nsNodeInfoManager.cpp
--- a/content/base/src/nsNodeInfoManager.cpp
+++ b/content/base/src/nsNodeInfoManager.cpp
@@ -150,7 +150,6 @@ nsNodeInfoManager::Init(nsIDocument *aDo
     mBindingManager = new nsBindingManager(aDocument);
     NS_ENSURE_TRUE(mBindingManager, NS_ERROR_OUT_OF_MEMORY);
 
-    NS_ADDREF(mBindingManager);
   }
 
   mDefaultPrincipal = mPrincipal;
@@ -192,7 +191,6 @@ nsNodeInfoManager::GetNodeInfo(nsIAtom *
   if (node) {
     *aNodeInfo = static_cast<nsINodeInfo *>(node);
 
-    NS_ADDREF(*aNodeInfo);
 
     return NS_OK;
   }
@@ -200,7 +198,6 @@ nsNodeInfoManager::GetNodeInfo(nsIAtom *
   nsNodeInfo *newNodeInfo = nsNodeInfo::Create();
   NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
-  NS_ADDREF(newNodeInfo);
 
   nsresult rv = newNodeInfo->Init(aName, aPrefix, aNamespaceID, this);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -275,7 +272,6 @@ nsNodeInfoManager::GetTextNodeInfo()
                 &mTextNodeInfo);
   }
   else {
-    NS_ADDREF(mTextNodeInfo);
   }
 
   return mTextNodeInfo;
@@ -289,7 +285,6 @@ nsNodeInfoManager::GetCommentNodeInfo()
                 &mCommentNodeInfo);
   }
   else {
-    NS_ADDREF(mCommentNodeInfo);
   }
 
   return mCommentNodeInfo;
@@ -303,7 +298,6 @@ nsNodeInfoManager::GetDocumentNodeInfo()
                 &mDocumentNodeInfo);
   }
   else {
-    NS_ADDREF(mDocumentNodeInfo);
   }
 
   return mDocumentNodeInfo;
@@ -319,7 +313,7 @@ nsNodeInfoManager::SetDocumentPrincipal(
 
   NS_ASSERTION(aPrincipal, "Must have principal by this point!");
   
-  NS_ADDREF(mPrincipal = aPrincipal);
+  mPrincipal = aPrincipal;
 }
 
 void
diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -666,7 +666,6 @@ nsObjectLoadingContent::GetFrameLoader(n
 nsObjectLoadingContent::GetFrameLoader(nsIFrameLoader** aFrameLoader)
 {
   *aFrameLoader = mFrameLoader;
-  NS_IF_ADDREF(*aFrameLoader);
   return NS_OK;
 }
 
@@ -837,7 +836,6 @@ nsObjectLoadingContent::GetInterface(con
   if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {
     nsIChannelEventSink* sink = this;
     *aResult = sink;
-    NS_ADDREF(sink);
     return NS_OK;
   }
 
diff --git a/content/base/src/nsRange.cpp b/content/base/src/nsRange.cpp
--- a/content/base/src/nsRange.cpp
+++ b/content/base/src/nsRange.cpp
@@ -895,9 +895,9 @@ RangeSubtreeIterator::GetCurrentNode()
   nsIDOMNode *node = nsnull;
 
   if (mIterState == eUseStartCData && mStartCData) {
-    NS_ADDREF(node = mStartCData);
+    node = mStartCData;
   } else if (mIterState == eUseEndCData && mEndCData)
-    NS_ADDREF(node = mEndCData);
+    node = mEndCData;
   else if (mIterState == eUseIterator && mIter)
   {
     nsIContent *content = mIter->GetCurrentNode();
@@ -1354,10 +1354,8 @@ CloneParentsBetween(nsIDOMNode *aAncesto
   }
 
   *aClosestAncestor  = firstParent;
-  NS_IF_ADDREF(*aClosestAncestor);
 
   *aFarthestAncestor = lastParent;
-  NS_IF_ADDREF(*aFarthestAncestor);
 
   return NS_OK;
 }
@@ -1404,7 +1402,6 @@ nsresult nsRange::CloneContents(nsIDOMDo
     // There's nothing to add to the doc frag, we must be done!
 
     *aReturn = clonedFrag;
-    NS_IF_ADDREF(*aReturn);
     return NS_OK;
   }
 
@@ -1544,7 +1541,6 @@ nsresult nsRange::CloneContents(nsIDOMDo
   }
 
   *aReturn = clonedFrag;
-  NS_IF_ADDREF(*aReturn);
 
   return NS_OK;
 }
@@ -1560,7 +1556,7 @@ nsresult nsRange::CloneRange(nsIDOMRange
   nsRange* range = new nsRange();
   NS_ENSURE_TRUE(range, NS_ERROR_OUT_OF_MEMORY);
 
-  NS_ADDREF(*aReturn = range);
+  *aReturn = range;
   
   range->SetMaySpanAnonymousSubtrees(mMaySpanAnonymousSubtrees);
 
diff --git a/content/base/src/nsScriptEventManager.cpp b/content/base/src/nsScriptEventManager.cpp
--- a/content/base/src/nsScriptEventManager.cpp
+++ b/content/base/src/nsScriptEventManager.cpp
@@ -123,7 +123,6 @@ nsScriptEventManager::FindEventHandler(c
 
     if (NS_SUCCEEDED(rv) && bFound) {
         *aScriptHandler = handler;
-        NS_ADDREF(*aScriptHandler);
 
         return NS_OK;
     }
diff --git a/content/base/src/nsStyleLinkElement.cpp b/content/base/src/nsStyleLinkElement.cpp
--- a/content/base/src/nsStyleLinkElement.cpp
+++ b/content/base/src/nsStyleLinkElement.cpp
@@ -104,7 +104,6 @@ nsStyleLinkElement::GetStyleSheet(nsISty
 nsStyleLinkElement::GetStyleSheet(nsIStyleSheet*& aStyleSheet)
 {
   aStyleSheet = mStyleSheet;
-  NS_IF_ADDREF(aStyleSheet);
 
   return NS_OK;
 }
diff --git a/content/base/src/nsStyledElement.cpp b/content/base/src/nsStyledElement.cpp
--- a/content/base/src/nsStyledElement.cpp
+++ b/content/base/src/nsStyledElement.cpp
@@ -199,7 +199,7 @@ nsStyledElement::GetStyle(nsIDOMCSSStyle
   }
 
   // Why bother with QI?
-  NS_ADDREF(*aStyle = slots->mStyle);
+  *aStyle = slots->mStyle;
   return NS_OK;
 }
 
diff --git a/content/base/src/nsTextNode.cpp b/content/base/src/nsTextNode.cpp
--- a/content/base/src/nsTextNode.cpp
+++ b/content/base/src/nsTextNode.cpp
@@ -161,7 +161,7 @@ NS_NewTextNode(nsIContent** aInstancePtr
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aInstancePtrResult = instance);
+  *aInstancePtrResult = instance;
 
   return NS_OK;
 }
@@ -288,7 +288,7 @@ NS_NewAttributeContent(nsNodeInfoManager
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aResult = textNode);
+  *aResult = textNode;
 
   return NS_OK;
 }
diff --git a/content/base/src/nsTreeWalker.cpp b/content/base/src/nsTreeWalker.cpp
--- a/content/base/src/nsTreeWalker.cpp
+++ b/content/base/src/nsTreeWalker.cpp
@@ -470,7 +470,6 @@ nsTreeWalker::NextInDocumentOrderOf(nsIN
                 }
             }
             *_retval = sibling;
-            NS_ADDREF(*_retval);
             return NS_OK;
         }
 
@@ -484,7 +483,6 @@ nsTreeWalker::NextInDocumentOrderOf(nsIN
                 mCurrentNode = parent;
                 mPossibleIndexesPos = aIndexPos;
                 *_retval = parent;
-                NS_ADDREF(*_retval);
                 return NS_OK;
             }
         }
@@ -542,7 +540,6 @@ nsTreeWalker::ChildOf(nsINode* aNode,
                 mCurrentNode = child;
                 mPossibleIndexesPos = aIndexPos;
                 *_retval = child;
-                NS_ADDREF(*_retval);
 
                 SetChildIndex(aIndexPos, i);
 
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
@@ -548,7 +548,7 @@ nsXMLHttpRequest::GetOnreadystatechange(
 {
   NS_ENSURE_ARG_POINTER(aOnreadystatechange);
 
-  NS_IF_ADDREF(*aOnreadystatechange = mOnReadystatechangeListener);
+  *aOnreadystatechange = mOnReadystatechangeListener;
 
   return NS_OK;
 }
@@ -567,7 +567,7 @@ nsXMLHttpRequest::GetOnload(nsIDOMEventL
 {
   NS_ENSURE_ARG_POINTER(aOnLoad);
 
-  NS_IF_ADDREF(*aOnLoad = mOnLoadListener);
+  *aOnLoad = mOnLoadListener;
 
   return NS_OK;
 }
@@ -585,7 +585,7 @@ nsXMLHttpRequest::GetOnerror(nsIDOMEvent
 {
   NS_ENSURE_ARG_POINTER(aOnerror);
 
-  NS_IF_ADDREF(*aOnerror = mOnErrorListener);
+  *aOnerror = mOnErrorListener;
 
   return NS_OK;
 }
@@ -603,7 +603,7 @@ nsXMLHttpRequest::GetOnprogress(nsIDOMEv
 {
   NS_ENSURE_ARG_POINTER(aOnprogress);  
 
-  NS_IF_ADDREF(*aOnprogress = mOnProgressListener);
+  *aOnprogress = mOnProgressListener;
 
   return NS_OK;
 }
@@ -621,7 +621,7 @@ nsXMLHttpRequest::GetOnuploadprogress(ns
 {
   NS_ENSURE_ARG_POINTER(aOnuploadprogress);  
 
-  NS_IF_ADDREF(*aOnuploadprogress = mOnUploadProgressListener);
+  *aOnuploadprogress = mOnUploadProgressListener;
 
   return NS_OK;
 }
@@ -638,7 +638,7 @@ nsXMLHttpRequest::GetChannel(nsIChannel 
 nsXMLHttpRequest::GetChannel(nsIChannel **aChannel)
 {
   NS_ENSURE_ARG_POINTER(aChannel);
-  NS_IF_ADDREF(*aChannel = mChannel);
+  *aChannel = mChannel;
 
   return NS_OK;
 }
@@ -651,7 +651,6 @@ nsXMLHttpRequest::GetResponseXML(nsIDOMD
   *aResponseXML = nsnull;
   if ((XML_HTTP_REQUEST_COMPLETED & mState) && mDocument) {
     *aResponseXML = mDocument;
-    NS_ADDREF(*aResponseXML);
   }
 
   return NS_OK;
@@ -882,7 +881,6 @@ nsXMLHttpRequest::GetAllResponseHeaders(
     NS_NEWXPCOM(visitor, nsHeaderVisitor);
     if (!visitor)
       return NS_ERROR_OUT_OF_MEMORY;
-    NS_ADDREF(visitor);
 
     nsresult rv = httpChannel->VisitResponseHeaders(visitor);
     if (NS_SUCCEEDED(rv))
@@ -2336,12 +2334,10 @@ nsXMLHttpRequest::GetInterface(const nsI
   if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {
     mChannelEventSink = do_GetInterface(mNotificationCallbacks);
     *aResult = static_cast<nsIChannelEventSink*>(this);
-    NS_ADDREF_THIS();
     return NS_OK;
   } else if (aIID.Equals(NS_GET_IID(nsIProgressEventSink))) {
     mProgressEventSink = do_GetInterface(mNotificationCallbacks);
     *aResult = static_cast<nsIProgressEventSink*>(this);
-    NS_ADDREF_THIS();
     return NS_OK;
   }
 
diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp
--- a/content/canvas/src/nsCanvasRenderingContext2D.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp
@@ -552,7 +552,7 @@ NS_NewCanvasRenderingContext2D(nsIDOMCan
     if (!ctx)
         return NS_ERROR_OUT_OF_MEMORY;
 
-    NS_ADDREF(*aResult = ctx);
+    *aResult = ctx;
     return NS_OK;
 }
 
@@ -1102,7 +1102,7 @@ nsCanvasRenderingContext2D::GetStrokeSty
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
-    NS_ADDREF(*aStyle = var);
+    *aStyle = var;
     return NS_OK;
 }
 
@@ -1137,7 +1137,7 @@ nsCanvasRenderingContext2D::GetFillStyle
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
-    NS_ADDREF(*aStyle = var);
+    *aStyle = var;
     return NS_OK;
 }
 
@@ -1159,7 +1159,7 @@ nsCanvasRenderingContext2D::CreateLinear
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    NS_ADDREF(*_retval = grad);
+    *_retval = grad;
     return NS_OK;
 }
 
@@ -1179,7 +1179,7 @@ nsCanvasRenderingContext2D::CreateRadial
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    NS_ADDREF(*_retval = grad);
+    *_retval = grad;
     return NS_OK;
 }
 
@@ -1228,7 +1228,7 @@ nsCanvasRenderingContext2D::CreatePatter
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    NS_ADDREF(*_retval = pat);
+    *_retval = pat;
     return NS_OK;
 }
 
@@ -2077,7 +2077,7 @@ nsCanvasRenderingContext2D::MeasureText(
     if (!textMetrics)
         return NS_ERROR_OUT_OF_MEMORY;
 
-    NS_ADDREF(*_retval = textMetrics);
+    *_retval = textMetrics;
     return NS_OK;
 }
 
@@ -2780,7 +2780,7 @@ nsCanvasRenderingContext2D::CairoSurface
             *widthOut = w;
             *heightOut = h;
 
-            NS_ADDREF(*prinOut = node->NodePrincipal());
+            *prinOut = node->NodePrincipal();
             *forceWriteOnlyOut = canvas->IsWriteOnly();
 
             return NS_OK;
diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -238,7 +238,6 @@ nsDOMEvent::GetExplicitOriginalTarget(ns
 {
   if (mExplicitOriginalTarget) {
     *aRealEventTarget = mExplicitOriginalTarget;
-    NS_ADDREF(*aRealEventTarget);
     return NS_OK;
   }
 
@@ -250,7 +249,6 @@ nsDOMEvent::GetTmpRealOriginalTarget(nsI
 {
   if (mTmpRealOriginalTarget) {
     *aRealEventTarget = mTmpRealOriginalTarget;
-    NS_ADDREF(*aRealEventTarget);
     return NS_OK;
   }
 
diff --git a/content/events/src/nsDOMEventGroup.cpp b/content/events/src/nsDOMEventGroup.cpp
--- a/content/events/src/nsDOMEventGroup.cpp
+++ b/content/events/src/nsDOMEventGroup.cpp
@@ -68,6 +68,5 @@ NS_NewDOMEventGroup(nsIDOMEventGroup** a
   *aInstancePtrResult = new nsDOMEventGroup;
   if (!*aInstancePtrResult)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*aInstancePtrResult);
   return NS_OK;
 }
diff --git a/content/events/src/nsDOMMessageEvent.cpp b/content/events/src/nsDOMMessageEvent.cpp
--- a/content/events/src/nsDOMMessageEvent.cpp
+++ b/content/events/src/nsDOMMessageEvent.cpp
@@ -81,7 +81,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsDOMMessageEvent::GetSource(nsIDOMWindow** aSource)
 {
-  NS_IF_ADDREF(*aSource = mSource);
+  *aSource = mSource;
   return NS_OK;
 }
 
diff --git a/content/events/src/nsDOMMutationEvent.cpp b/content/events/src/nsDOMMutationEvent.cpp
--- a/content/events/src/nsDOMMutationEvent.cpp
+++ b/content/events/src/nsDOMMutationEvent.cpp
@@ -73,7 +73,6 @@ nsDOMMutationEvent::GetRelatedNode(nsIDO
   *aRelatedNode = nsnull;
   nsMutationEvent* mutation = static_cast<nsMutationEvent*>(mEvent);
   *aRelatedNode = mutation->mRelatedNode;
-  NS_IF_ADDREF(*aRelatedNode);
   return NS_OK;
 }
 
diff --git a/content/events/src/nsDOMPopupBlockedEvent.cpp b/content/events/src/nsDOMPopupBlockedEvent.cpp
--- a/content/events/src/nsDOMPopupBlockedEvent.cpp
+++ b/content/events/src/nsDOMPopupBlockedEvent.cpp
@@ -96,7 +96,6 @@ nsDOMPopupBlockedEvent::InitPopupBlocked
        nsPopupBlockedEvent* event = static_cast<nsPopupBlockedEvent*>(mEvent);
        event->mRequestingWindow = do_GetWeakReference(aRequestingWindow);
        event->mPopupWindowURI = aPopupWindowURI;
-       NS_IF_ADDREF(event->mPopupWindowURI);
        event->mPopupWindowFeatures = aPopupWindowFeatures;
        event->mPopupWindowName = aPopupWindowName;
        break;
@@ -128,7 +127,6 @@ nsDOMPopupBlockedEvent::GetPopupWindowUR
   if (mEvent->eventStructType == NS_POPUPBLOCKED_EVENT) {
     nsPopupBlockedEvent* event = static_cast<nsPopupBlockedEvent*>(mEvent);
     *aPopupWindowURI = event->mPopupWindowURI;
-    NS_IF_ADDREF(*aPopupWindowURI);
     return NS_OK;
   }
   *aPopupWindowURI = 0;
diff --git a/content/events/src/nsDOMTextEvent.cpp b/content/events/src/nsDOMTextEvent.cpp
--- a/content/events/src/nsDOMTextEvent.cpp
+++ b/content/events/src/nsDOMTextEvent.cpp
@@ -102,7 +102,6 @@ NS_METHOD nsDOMTextEvent::GetInputRange(
   if (mEvent->message == NS_TEXT_TEXT)
   {
     *aInputRange = mTextRange;
-    NS_IF_ADDREF(*aInputRange);
     return NS_OK;
   }
   *aInputRange = nsnull;
diff --git a/content/events/src/nsDOMUIEvent.cpp b/content/events/src/nsDOMUIEvent.cpp
--- a/content/events/src/nsDOMUIEvent.cpp
+++ b/content/events/src/nsDOMUIEvent.cpp
@@ -170,7 +170,6 @@ nsDOMUIEvent::GetView(nsIDOMAbstractView
 nsDOMUIEvent::GetView(nsIDOMAbstractView** aView)
 {
   *aView = mView;
-  NS_IF_ADDREF(*aView);
   return NS_OK;
 }
 
diff --git a/content/events/src/nsDOMXULCommandEvent.cpp b/content/events/src/nsDOMXULCommandEvent.cpp
--- a/content/events/src/nsDOMXULCommandEvent.cpp
+++ b/content/events/src/nsDOMXULCommandEvent.cpp
@@ -106,7 +106,7 @@ nsDOMXULCommandEvent::GetSourceEvent(nsI
 nsDOMXULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
 {
   NS_ENSURE_ARG_POINTER(aSourceEvent);
-  NS_IF_ADDREF(*aSourceEvent = Event()->sourceEvent);
+  *aSourceEvent = Event()->sourceEvent;
   return NS_OK;
 }
 
diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -1218,11 +1218,9 @@ nsEventListenerManager::GetSystemEventGr
       return result;
 
     gSystemEventGroup = group;
-    NS_ADDREF(gSystemEventGroup);
   }
 
   *aGroup = gSystemEventGroup;
-  NS_ADDREF(*aGroup);
   return NS_OK;
 }
 
@@ -1236,11 +1234,9 @@ nsEventListenerManager::GetDOM2EventGrou
       return result;
 
     gDOM2EventGroup = group;
-    NS_ADDREF(gDOM2EventGroup);
   }
 
   *aGroup = gDOM2EventGroup;
-  NS_ADDREF(*aGroup);
   return NS_OK;
 }
 
diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -456,7 +456,6 @@ nsEventStateManager::nsEventStateManager
   if (sESMInstanceCount == 0) {
     gUserInteractionTimerCallback = new nsUITimerCallback();
     if (gUserInteractionTimerCallback) {
-      NS_ADDREF(gUserInteractionTimerCallback);
       CallCreateInstance("@mozilla.org/timer;1", &gUserInteractionTimer);
       if (gUserInteractionTimer) {
         gUserInteractionTimer->InitWithCallback(gUserInteractionTimerCallback,
@@ -943,7 +942,6 @@ nsEventStateManager::PreHandleEvent(nsPr
           SetFocusedContent(currentFocus); // we kept this reference above
           NS_IF_RELEASE(gLastFocusedContent);
           gLastFocusedContent = mCurrentFocus;
-          NS_IF_ADDREF(gLastFocusedContent);
         }
 
         // Try to keep the focus controllers and the globals in synch
@@ -966,7 +964,6 @@ nsEventStateManager::PreHandleEvent(nsPr
         NS_IF_RELEASE(gLastFocusedDocument);
         gLastFocusedDocument = mDocument;
         gLastFocusedPresContext = aPresContext;
-        NS_IF_ADDREF(gLastFocusedDocument);
       }
 
       ResetBrowseWithCaret();
@@ -1994,7 +1991,6 @@ nsEventStateManager::GetMarkupDocumentVi
   if(!mv) return NS_ERROR_FAILURE;
 
   *aMv = mv;
-  NS_IF_ADDREF(*aMv);
 
   return NS_OK;
 }
@@ -2256,7 +2252,7 @@ nsEventStateManager::GetParentScrollingV
   nsIFrame* frameFrame = pPresShell->GetPrimaryFrameFor(frameContent);
   if (!frameFrame) return NS_ERROR_FAILURE;
 
-  NS_IF_ADDREF(presCtxOuter = pPresShell->GetPresContext());
+  presCtxOuter = pPresShell->GetPresContext();
   targetOuterFrame = frameFrame;
 
   return NS_OK;
@@ -3852,13 +3848,13 @@ nsEventStateManager::GetNextTabbableCont
         // Special case for image maps: they don't get walked by nsIFrameTraversal
         nsIContent *areaContent = GetNextTabbableMapArea(forward, currentContent);
         if (areaContent) {
-          NS_ADDREF(*aResultNode = areaContent);
+          *aResultNode = areaContent;
           return NS_OK;
         }
       }
       else if ((aIgnoreTabIndex || mCurrentTabIndex == tabIndex) &&
           currentContent != aStartContent) {
-        NS_ADDREF(*aResultNode = currentContent);
+        *aResultNode = currentContent;
         return NS_OK;
       }
     }
@@ -3997,13 +3993,11 @@ nsEventStateManager::GetEventTargetConte
       (aEvent->message == NS_FOCUS_CONTENT ||
        aEvent->message == NS_BLUR_CONTENT)) {
     *aContent = mCurrentFocus;
-    NS_IF_ADDREF(*aContent);
     return NS_OK;
   }
 
   if (mCurrentTargetContent) {
     *aContent = mCurrentTargetContent;
-    NS_IF_ADDREF(*aContent);
     return NS_OK;
   }
 
@@ -4126,13 +4120,11 @@ nsEventStateManager::SetContentState(nsI
 
   if ((aState & NS_EVENT_STATE_DRAGOVER) && (aContent != mDragOverContent)) {
     notifyContent[3] = mDragOverContent; // notify dragover first, since more common case
-    NS_IF_ADDREF(notifyContent[3]);
     mDragOverContent = aContent;
   }
 
   if ((aState & NS_EVENT_STATE_URLTARGET) && (aContent != mURLTargetContent)) {
     notifyContent[4] = mURLTargetContent;
-    NS_IF_ADDREF(notifyContent[4]);
     mURLTargetContent = aContent;
   }
 
@@ -4175,7 +4167,6 @@ nsEventStateManager::SetContentState(nsI
       // I'm not setting it here. This is to catch an edge case.
       NS_IF_RELEASE(gLastFocusedContent);
       gLastFocusedContent = mCurrentFocus;
-      NS_IF_ADDREF(gLastFocusedContent);
       //If this notification was for focus alone then get rid of aContent
       //ref to avoid unnecessary notification.
       if (!(aState & ~NS_EVENT_STATE_FOCUS)) {
@@ -4190,7 +4181,6 @@ nsEventStateManager::SetContentState(nsI
           fc->GetActive(&fcActive);
       }
       notifyContent[2] = gLastFocusedContent;
-      NS_IF_ADDREF(gLastFocusedContent);
       // only raise window if the the focus controller is active
       SendFocusBlur(mPresContext, aContent, fcActive);
       if (mCurrentFocus != aContent) {
@@ -4227,7 +4217,6 @@ nsEventStateManager::SetContentState(nsI
   if (aContent && simpleStates != 0) {
     // notify about new content too
     notifyContent[0] = aContent;
-    NS_ADDREF(aContent);  // everything in notify array has a ref
   }
 
   // remove duplicates
@@ -4581,7 +4570,6 @@ nsEventStateManager::SendFocusBlur(nsPre
 
   NS_IF_RELEASE(gLastFocusedContent);
   gLastFocusedContent = aContent;
-  NS_IF_ADDREF(gLastFocusedContent);
   SetFocusedContent(aContent);
   EnsureFocusSynchronization();
 
@@ -4676,7 +4664,6 @@ nsEventStateManager::GetFocusedContent(n
 nsEventStateManager::GetFocusedContent(nsIContent** aContent)
 {
   *aContent = mCurrentFocus;
-  NS_IF_ADDREF(*aContent);
   return NS_OK;
 }
 
@@ -4720,7 +4707,6 @@ nsEventStateManager::GetLastFocusedConte
 nsEventStateManager::GetLastFocusedContent(nsIContent** aContent)
 {
   *aContent = mLastFocus;
-  NS_IF_ADDREF(*aContent);
   return NS_OK;
 }
 
@@ -5028,8 +5014,6 @@ nsEventStateManager::GetDocSelectionLoca
   *aStartFrame = startFrame;
   *aStartContent = startContent;
   *aEndContent = endContent;
-  NS_IF_ADDREF(*aStartContent);
-  NS_IF_ADDREF(*aEndContent);
 
   return rv;
 }
@@ -5585,7 +5569,6 @@ nsEventStateManager::GetLastChildDocShel
     curNode->GetChildCount(&childCount);
     if (!childCount) {
       *aResult = curItem;
-      NS_ADDREF(*aResult);
       return;
     }
 
@@ -5687,12 +5670,10 @@ nsEventStateManager::GetPrevDocShell(nsI
     }
 
     *aResult = curItem;
-    NS_ADDREF(*aResult);
     return;
   }
 
   *aResult = parentItem;
-  NS_ADDREF(*aResult);
   return;
 }
 
diff --git a/content/events/src/nsPrivateTextRange.cpp b/content/events/src/nsPrivateTextRange.cpp
--- a/content/events/src/nsPrivateTextRange.cpp
+++ b/content/events/src/nsPrivateTextRange.cpp
@@ -104,7 +104,6 @@ NS_METHOD nsPrivateTextRangeList::Item(P
 {
 	*aReturn = mList.ElementAt(aIndex);
 	if (*aReturn) {
-		NS_ADDREF(*aReturn);
 		return NS_OK;
 	}
 	return NS_ERROR_FAILURE;
diff --git a/content/events/src/nsXMLEventsElement.cpp b/content/events/src/nsXMLEventsElement.cpp
--- a/content/events/src/nsXMLEventsElement.cpp
+++ b/content/events/src/nsXMLEventsElement.cpp
@@ -91,7 +91,7 @@ NS_NewXMLEventsElement(nsIContent** aIns
   if (!it) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  NS_ADDREF(*aInstancePtrResult = it);
+  *aInstancePtrResult = it;
   return NS_OK;
 }
 
diff --git a/content/html/content/src/nsClientRect.cpp b/content/html/content/src/nsClientRect.cpp
--- a/content/html/content/src/nsClientRect.cpp
+++ b/content/html/content/src/nsClientRect.cpp
@@ -107,6 +107,6 @@ nsClientRectList::Item(PRUint32 aIndex, 
     return NS_OK;
   } 
   
-  NS_IF_ADDREF(*aReturn = mArray.ObjectAt(aIndex));
+  *aReturn = mArray.ObjectAt(aIndex);
   return NS_OK;
 }
diff --git a/content/html/content/src/nsFormSubmission.cpp b/content/html/content/src/nsFormSubmission.cpp
--- a/content/html/content/src/nsFormSubmission.cpp
+++ b/content/html/content/src/nsFormSubmission.cpp
@@ -519,7 +519,6 @@ nsFSURLEncoded::GetEncodedSubmission(nsI
       mimeStream->SetData(dataStream);
 
       *aPostDataStream = mimeStream;
-      NS_ADDREF(*aPostDataStream);
     }
 
   } else {
@@ -888,7 +887,6 @@ nsFSMultipartFormData::GetEncodedSubmiss
 
   *aPostDataStream = mimeStream;
 
-  NS_ADDREF(*aPostDataStream);
 
   return NS_OK;
 }
@@ -1173,7 +1171,6 @@ GetSubmissionFromForm(nsGenericHTMLEleme
                                           formProcessor, bidiOptions, method);
   }
   NS_ENSURE_TRUE(*aFormSubmission, NS_ERROR_OUT_OF_MEMORY);
-  NS_ADDREF(*aFormSubmission);
 
 
   // This ASSUMES that all encodings above inherit from nsFormSubmission, which
diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -284,14 +284,12 @@ nsGenericHTMLElement::CopyInnerTo(nsGene
     rv = aDst->SetProperty(nsGkAtoms::htmlBaseHref, prop,
                            nsPropertyTable::SupportsDtorFunc, PR_TRUE);
     if (NS_SUCCEEDED(rv)) {
-      NS_ADDREF(static_cast<nsIURI*>(prop));
     }
   }
   if ((prop = GetProperty(nsGkAtoms::htmlBaseTarget))) {
     rv = aDst->SetProperty(nsGkAtoms::htmlBaseTarget, prop,
                            nsPropertyTable::SupportsDtorFunc, PR_TRUE);
     if (NS_SUCCEEDED(rv)) {
-      NS_ADDREF(static_cast<nsIAtom*>(prop));
     }
   }
 
@@ -532,7 +530,6 @@ nsGenericHTMLElement::GetOffsetRect(nsRe
       // Stop at the first ancestor that is positioned.
       if (parent->GetStyleDisplay()->IsPositioned()) {
         *aOffsetParent = content;
-        NS_IF_ADDREF(*aOffsetParent);
         break;
       }
 
@@ -553,7 +550,6 @@ nsGenericHTMLElement::GetOffsetRect(nsRe
         // and this element is *not* positioned or if we found the body element.
         if (isOffsetParent || IsBody(content)) {
           *aOffsetParent = content;
-          NS_ADDREF(*aOffsetParent);
           break;
         }
       }
@@ -1372,7 +1368,7 @@ nsGenericHTMLElement::GetEventListenerMa
       rv = piTarget->GetListenerManager(PR_TRUE, aManager);
 
       if (NS_SUCCEEDED(rv)) {
-        NS_ADDREF(*aTarget = win);
+        *aTarget = win;
       }
       *aDefer = PR_FALSE;
     } else {
@@ -1448,7 +1444,6 @@ nsGenericHTMLElement::GetBaseURI() const
   void* prop;
   if (HasFlag(NODE_HAS_PROPERTIES) && (prop = GetProperty(nsGkAtoms::htmlBaseHref))) {
     nsIURI* uri = static_cast<nsIURI*>(prop);
-    NS_ADDREF(uri);
     
     return uri;
   }
@@ -1458,7 +1453,6 @@ nsGenericHTMLElement::GetBaseURI() const
   if (mNodeInfo->NamespaceEquals(kNameSpaceID_None)) {
     if (doc) {
       nsIURI *uri = doc->GetBaseURI();
-      NS_IF_ADDREF(uri);
 
       return uri;
     }
@@ -2998,7 +2992,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsGenericHTMLFrameElement::GetFrameLoader(nsIFrameLoader **aFrameLoader)
 {
-  NS_IF_ADDREF(*aFrameLoader = mFrameLoader);
+  *aFrameLoader = mFrameLoader;
   return NS_OK;
 }
 
diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h
--- a/content/html/content/src/nsGenericHTMLElement.h
+++ b/content/html/content/src/nsGenericHTMLElement.h
@@ -1168,7 +1168,6 @@ NS_NewHTML##_elementName##Element(nsINod
       return PostQueryInterface(aIID, aInstancePtr);                          \
     }                                                                         \
                                                                               \
-    NS_ADDREF(foundInterface);                                                \
                                                                               \
     *aInstancePtr = foundInterface;                                           \
                                                                               \
diff --git a/content/html/content/src/nsHTMLBodyElement.cpp b/content/html/content/src/nsHTMLBodyElement.cpp
--- a/content/html/content/src/nsHTMLBodyElement.cpp
+++ b/content/html/content/src/nsHTMLBodyElement.cpp
@@ -540,7 +540,6 @@ nsHTMLBodyElement::WalkContentStyleRules
     // XXXbz should this use GetOwnerDoc() or GetCurrentDoc()?
     // sXBL/XBL2 issue!
     mContentStyleRule = new BodyRule(this);
-    NS_IF_ADDREF(mContentStyleRule);
   }
   if (aRuleWalker && mContentStyleRule) {
     aRuleWalker->Forward(mContentStyleRule);
diff --git a/content/html/content/src/nsHTMLCanvasElement.cpp b/content/html/content/src/nsHTMLCanvasElement.cpp
--- a/content/html/content/src/nsHTMLCanvasElement.cpp
+++ b/content/html/content/src/nsHTMLCanvasElement.cpp
@@ -491,7 +491,7 @@ nsHTMLCanvasElement::GetContext(const ns
     return NS_ERROR_INVALID_ARG;
   }
 
-  NS_ADDREF (*aContext = mCurrentContext);
+  *aContext = mCurrentContext;
   return NS_OK;
 }
 
diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp
--- a/content/html/content/src/nsHTMLFormElement.cpp
+++ b/content/html/content/src/nsHTMLFormElement.cpp
@@ -557,7 +557,6 @@ nsHTMLFormElement::GetElements(nsIDOMHTM
 nsHTMLFormElement::GetElements(nsIDOMHTMLCollection** aElements)
 {
   *aElements = mControls;
-  NS_ADDREF(*aElements);
   return NS_OK;
 }
 
@@ -1219,7 +1218,6 @@ nsHTMLFormElement::GetElementAt(PRInt32 
     *aFormControl = nsnull;
   } else {
     *aFormControl = mControls->mElements[aIndex];
-    NS_ADDREF(*aFormControl);
   }
 
   return NS_OK;
@@ -1665,7 +1663,6 @@ nsHTMLFormElement::GetActionURL(nsIURI**
   // Assign to the output
   //
   *aActionURL = actionURL;
-  NS_ADDREF(*aActionURL);
 
   return rv;
 }
@@ -1924,7 +1921,7 @@ nsHTMLFormElement::GetNextRadioButton(co
     radio->GetDisabled(&disabled);
   } while (disabled && radio != currentRadio);
 
-  NS_IF_ADDREF(*aRadioOut = radio);
+  *aRadioOut = radio;
   return NS_OK;
 }
 
diff --git a/content/html/content/src/nsHTMLLabelElement.cpp b/content/html/content/src/nsHTMLLabelElement.cpp
--- a/content/html/content/src/nsHTMLLabelElement.cpp
+++ b/content/html/content/src/nsHTMLLabelElement.cpp
@@ -398,7 +398,6 @@ nsHTMLLabelElement::GetFirstFormControl(
     nsIContent *child = current->GetChildAt(i);
     if (child) {
       if (IsNonLabelFormControl(child)) {
-        NS_ADDREF(child);
         return child;
       }
 
diff --git a/content/html/content/src/nsHTMLMapElement.cpp b/content/html/content/src/nsHTMLMapElement.cpp
--- a/content/html/content/src/nsHTMLMapElement.cpp
+++ b/content/html/content/src/nsHTMLMapElement.cpp
@@ -160,7 +160,7 @@ nsHTMLMapElement::GetAreas(nsIDOMHTMLCol
     }
   }
 
-  NS_ADDREF(*aAreas = mAreas);
+  *aAreas = mAreas;
   return NS_OK;
 }
 
diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -97,7 +97,7 @@ NS_IMPL_FLOAT_ATTR_DEFAULT_VALUE(nsHTMLM
 /* readonly attribute nsIDOMHTMLMediaError error; */
 NS_IMETHODIMP nsHTMLMediaElement::GetError(nsIDOMHTMLMediaError * *aError)
 {
-  NS_IF_ADDREF(*aError = mError);
+  *aError = mError;
 
   return NS_OK;
 }
diff --git a/content/html/content/src/nsHTMLSelectElement.cpp b/content/html/content/src/nsHTMLSelectElement.cpp
--- a/content/html/content/src/nsHTMLSelectElement.cpp
+++ b/content/html/content/src/nsHTMLSelectElement.cpp
@@ -664,7 +664,6 @@ nsHTMLSelectElement::GetOptions(nsIDOMHT
 nsHTMLSelectElement::GetOptions(nsIDOMHTMLOptionsCollection** aValue)
 {
   *aValue = mOptions;
-  NS_IF_ADDREF(*aValue);
 
   return NS_OK;
 }
@@ -1957,7 +1956,7 @@ nsHTMLOptionCollection::Item(PRUint32 aI
 {
   nsIDOMHTMLOptionElement *option = mElements.SafeObjectAt(aIndex);
 
-  NS_IF_ADDREF(*aReturn = option);
+  *aReturn = option;
 
   return NS_OK;
 }
@@ -1992,6 +1991,6 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsHTMLOptionCollection::GetSelect(nsIDOMHTMLSelectElement **aReturn)
 {
-  NS_IF_ADDREF(*aReturn = mSelect);
+  *aReturn = mSelect;
   return NS_OK;
 }
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
@@ -400,7 +400,6 @@ nsHTMLTableElement::GetCaption(nsIDOMHTM
 
     if (caption) {
       *aValue = caption;
-      NS_ADDREF(*aValue);
 
       break;
     }
@@ -441,7 +440,6 @@ nsHTMLTableElement::GetSection(nsIAtom *
 
     if (section && child->NodeInfo()->Equals(aTag)) {
       nsIDOMHTMLTableSectionElement *result = section;
-      NS_ADDREF(result);
 
       return result;
     }
@@ -532,7 +530,6 @@ nsHTMLTableElement::GetRows(nsIDOMHTMLCo
   }
 
   *aValue = mRows;
-  NS_ADDREF(*aValue);
 
   return NS_OK;
 }
@@ -550,7 +547,7 @@ nsHTMLTableElement::GetTBodies(nsIDOMHTM
     NS_ENSURE_TRUE(mTBodies, NS_ERROR_OUT_OF_MEMORY);
   }
 
-  NS_ADDREF(*aValue = mTBodies);
+  *aValue = mTBodies;
   return NS_OK;
 }
 
diff --git a/content/html/content/src/nsHTMLTableRowElement.cpp b/content/html/content/src/nsHTMLTableRowElement.cpp
--- a/content/html/content/src/nsHTMLTableRowElement.cpp
+++ b/content/html/content/src/nsHTMLTableRowElement.cpp
@@ -256,7 +256,7 @@ nsHTMLTableRowElement::GetCells(nsIDOMHT
     NS_ENSURE_TRUE(mCells, NS_ERROR_OUT_OF_MEMORY);
   }
 
-  NS_ADDREF(*aValue = mCells);
+  *aValue = mCells;
   return NS_OK;
 }
 
diff --git a/content/html/content/src/nsHTMLTableSectionElement.cpp b/content/html/content/src/nsHTMLTableSectionElement.cpp
--- a/content/html/content/src/nsHTMLTableSectionElement.cpp
+++ b/content/html/content/src/nsHTMLTableSectionElement.cpp
@@ -138,7 +138,7 @@ nsHTMLTableSectionElement::GetRows(nsIDO
     NS_ENSURE_TRUE(mRows, NS_ERROR_OUT_OF_MEMORY);
   }
 
-  NS_ADDREF(*aValue = mRows);
+  *aValue = mRows;
   return NS_OK;
 }
 
diff --git a/content/html/content/src/nsHTMLTextAreaElement.cpp b/content/html/content/src/nsHTMLTextAreaElement.cpp
--- a/content/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/content/html/content/src/nsHTMLTextAreaElement.cpp
@@ -743,7 +743,6 @@ nsHTMLTextAreaElement::GetControllers(ns
   }
 
   *aResult = mControllers;
-  NS_IF_ADDREF(*aResult);
 
   return NS_OK;
 }
diff --git a/content/html/content/src/nsImageMapUtils.cpp b/content/html/content/src/nsImageMapUtils.cpp
--- a/content/html/content/src/nsImageMapUtils.cpp
+++ b/content/html/content/src/nsImageMapUtils.cpp
@@ -82,7 +82,6 @@ nsImageMapUtils::FindImageMap(nsIDocumen
   nsIHTMLDocument* htmlDoc(do_QueryInterface(aDocument));
   if (htmlDoc) {
     nsIDOMHTMLMapElement* map = htmlDoc->GetImageMap(usemap);
-    NS_IF_ADDREF(map);
     return map;
   } else {
     // For XHTML elements embedded in non-XHTML documents we get the
diff --git a/content/html/content/src/nsTextRectangle.cpp b/content/html/content/src/nsTextRectangle.cpp
--- a/content/html/content/src/nsTextRectangle.cpp
+++ b/content/html/content/src/nsTextRectangle.cpp
@@ -107,6 +107,6 @@ nsTextRectangleList::Item(PRUint32 aInde
     return NS_OK;
   } 
   
-  NS_IF_ADDREF(*aReturn = mArray.ObjectAt(aIndex));
+  *aReturn = mArray.ObjectAt(aIndex);
   return NS_OK;
 }
diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp
--- a/content/html/document/src/nsHTMLContentSink.cpp
+++ b/content/html/document/src/nsHTMLContentSink.cpp
@@ -557,7 +557,7 @@ HTMLContentSink::CreateContentObject(con
 
     mNodeInfoManager->GetNodeInfo(name, nsnull, kNameSpaceID_None,
                                   &nodeInfo);
-    NS_IF_ADDREF(mNodeInfoCache[aNodeType] = nodeInfo);
+    mNodeInfoCache[aNodeType] = nodeInfo;
   }
 
   NS_ENSURE_TRUE(nodeInfo, nsnull);
@@ -608,7 +608,6 @@ CreateHTMLElement(PRUint32 aNodeType, ns
                "Don't know how to construct tag element!");
 
   nsGenericHTMLElement* result = cb(aNodeInfo, aFromParser);
-  NS_IF_ADDREF(result);
 
   return result;
 }
@@ -660,7 +659,6 @@ SinkContext::Begin(nsHTMLTag aNodeType,
   mStack[0].mContent = aRoot;
   mStack[0].mNumFlushed = aNumFlushed;
   mStack[0].mInsertionPoint = aInsertionPoint;
-  NS_ADDREF(aRoot);
   mStackPos = 1;
   mTextLength = 0;
 
@@ -1552,7 +1550,6 @@ NS_NewHTMLContentSink(nsIHTMLContentSink
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aResult = it;
-  NS_ADDREF(*aResult);
 
   return NS_OK;
 }
@@ -1723,7 +1720,7 @@ HTMLContentSink::Init(nsIDocument* aDoc,
     // If the document already has a root we'll use it. This will
     // happen when we do document.open()/.write()/.close()...
 
-    NS_ADDREF(mRoot = static_cast<nsGenericHTMLElement*>(doc_root));
+    mRoot = static_cast<nsGenericHTMLElement*>(doc_root);
   } else {
     mRoot = NS_NewHTMLHtmlElement(nodeInfo);
     if (!mRoot) {
@@ -1731,7 +1728,6 @@ HTMLContentSink::Init(nsIDocument* aDoc,
       MOZ_TIMER_STOP(mWatch);
       return NS_ERROR_OUT_OF_MEMORY;
     }
-    NS_ADDREF(mRoot);
 
     NS_ASSERTION(mDocument->GetChildCount() == 0,
                  "Document should have no kids here!");
@@ -1751,7 +1747,6 @@ HTMLContentSink::Init(nsIDocument* aDoc,
     MOZ_TIMER_STOP(mWatch);
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  NS_ADDREF(mHead);
 
   mRoot->AppendChildTo(mHead, PR_FALSE);
 
@@ -1926,7 +1921,6 @@ HTMLContentSink::BeginContext(PRInt32 aP
             content,
             mCurrentContext->mStack[aPosition].mNumFlushed,
             insertionPoint);
-  NS_ADDREF(sc->mSink);
 
   mContextStack.AppendElement(mCurrentContext);
   mCurrentContext = sc;
@@ -2064,7 +2058,6 @@ HTMLContentSink::OpenBody(const nsIParse
 
   mBody = mCurrentContext->mStack[mCurrentContext->mStackPos - 1].mContent;
 
-  NS_ADDREF(mBody);
 
   MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::OpenBody()\n"));
   MOZ_TIMER_STOP(mWatch);
@@ -2813,7 +2806,6 @@ HTMLContentSink::AddBaseTagInfo(nsIConte
                                nsPropertyTable::SupportsDtorFunc, PR_TRUE);
     if (NS_SUCCEEDED(rv)) {
       // circumvent nsDerivedSafe
-      NS_ADDREF(static_cast<nsIURI*>(mBaseHref));
     }
   }
   if (mBaseTarget) {
@@ -2821,7 +2813,6 @@ HTMLContentSink::AddBaseTagInfo(nsIConte
                                nsPropertyTable::SupportsDtorFunc, PR_TRUE);
     if (NS_SUCCEEDED(rv)) {
       // circumvent nsDerivedSafe
-      NS_ADDREF(static_cast<nsIAtom*>(mBaseTarget));
     }
   }
 }
diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -207,7 +207,6 @@ NS_NewHTMLDocument(nsIDocument** aInstan
   nsHTMLDocument* doc = new nsHTMLDocument();
   NS_ENSURE_TRUE(doc, NS_ERROR_OUT_OF_MEMORY);
 
-  NS_ADDREF(doc);
   nsresult rv = doc->Init();
 
   if (NS_FAILED(rv)) {
@@ -1573,7 +1572,6 @@ nsHTMLDocument::GetImages(nsIDOMHTMLColl
   }
 
   *aImages = mImages;
-  NS_ADDREF(*aImages);
 
   return NS_OK;
 }
@@ -1590,7 +1588,6 @@ nsHTMLDocument::GetApplets(nsIDOMHTMLCol
   }
 
   *aApplets = mApplets;
-  NS_ADDREF(*aApplets);
 
   return NS_OK;
 }
@@ -1639,7 +1636,6 @@ nsHTMLDocument::GetLinks(nsIDOMHTMLColle
   }
 
   *aLinks = mLinks;
-  NS_ADDREF(*aLinks);
 
   return NS_OK;
 }
@@ -1680,7 +1676,6 @@ nsHTMLDocument::GetAnchors(nsIDOMHTMLCol
   }
 
   *aAnchors = mAnchors;
-  NS_ADDREF(*aAnchors);
 
   return NS_OK;
 }
@@ -2333,7 +2328,6 @@ nsHTMLDocument::GetElementsByName(const 
   NS_ENSURE_TRUE(elements, NS_ERROR_OUT_OF_MEMORY);
 
   *aReturn = elements;
-  NS_ADDREF(*aReturn);
 
   return NS_OK;
 }
@@ -2614,7 +2608,6 @@ nsHTMLDocument::GetEmbeds(nsIDOMHTMLColl
   }
 
   *aEmbeds = mEmbeds;
-  NS_ADDREF(*aEmbeds);
 
   return NS_OK;
 }
@@ -2827,7 +2820,6 @@ nsHTMLDocument::ResolveName(const nsAStr
       }
 
       *aResult = node;
-      NS_IF_ADDREF(*aResult);
 
       return NS_OK;
     }
@@ -2855,7 +2847,7 @@ nsHTMLDocument::ResolveName(const nsAStr
 
         fc_list->Item(0, &node);
 
-        NS_IF_ADDREF(*aResult = node);
+        *aResult = node;
 
         delete fc_list;
 
@@ -2883,7 +2875,7 @@ nsHTMLDocument::ResolveName(const nsAStr
          tag == nsGkAtoms::object ||
          tag == nsGkAtoms::applet) &&
         (!aForm || nsContentUtils::BelongsInForm(aForm, e))) {
-      NS_ADDREF(*aResult = e);
+      *aResult = e;
     }
   }
 
@@ -2960,7 +2952,7 @@ nsHTMLDocument::GetForms(nsIDOMHTMLColle
   if (!forms)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aForms = forms);
+  *aForms = forms;
   return NS_OK;
 }
 
@@ -3231,12 +3223,12 @@ nsHTMLDocument::GetDocumentAllResult(con
 
   nsIContent* cont = docAllList->Item(1, PR_TRUE);
   if (cont) {
-    NS_ADDREF(*aResult = static_cast<nsIDOMNodeList*>(docAllList));
+    *aResult = static_cast<nsIDOMNodeList*>(docAllList);
     return NS_OK;
   }
 
   // There's only 0 or 1 items. Return the first one or null.
-  NS_IF_ADDREF(*aResult = docAllList->Item(0, PR_TRUE));
+  *aResult = docAllList->Item(0, PR_TRUE);
 
   return NS_OK;
 }
@@ -3501,7 +3493,7 @@ nsHTMLDocument::GetMidasCommandManager(n
 
   // check if we have it cached
   if (mMidasCommandManager) {
-    NS_ADDREF(*aCmdMgr = mMidasCommandManager);
+    *aCmdMgr = mMidasCommandManager;
     return NS_OK;
   }
 
@@ -3519,7 +3511,7 @@ nsHTMLDocument::GetMidasCommandManager(n
   if (!mMidasCommandManager)
     return NS_ERROR_FAILURE;
 
-  NS_ADDREF(*aCmdMgr = mMidasCommandManager);
+  *aCmdMgr = mMidasCommandManager;
 
   return NS_OK;
 }
diff --git a/content/html/document/src/nsHTMLFragmentContentSink.cpp b/content/html/document/src/nsHTMLFragmentContentSink.cpp
--- a/content/html/document/src/nsHTMLFragmentContentSink.cpp
+++ b/content/html/document/src/nsHTMLFragmentContentSink.cpp
@@ -178,7 +178,7 @@ NewHTMLFragmentContentSinkHelper(PRBool 
     return NS_ERROR_OUT_OF_MEMORY;
   }
   
-  NS_ADDREF(*aResult = it);
+  *aResult = it;
   
   return NS_OK;
 }
@@ -351,7 +351,6 @@ nsHTMLFragmentContentSink::AddBaseTagInf
                                nsPropertyTable::SupportsDtorFunc, PR_TRUE);
     if (NS_SUCCEEDED(rv)) {
       // circumvent nsDerivedSafe
-      NS_ADDREF(static_cast<nsIURI*>(mBaseHref));
     }
   }
   if (mBaseTarget) {
@@ -359,7 +358,6 @@ nsHTMLFragmentContentSink::AddBaseTagInf
                                nsPropertyTable::SupportsDtorFunc, PR_TRUE);
     if (NS_SUCCEEDED(rv)) {
       // circumvent nsDerivedSafe
-      NS_ADDREF(static_cast<nsIAtom*>(mBaseTarget));
     }
   }
 }
@@ -417,7 +415,7 @@ nsHTMLFragmentContentSink::OpenContainer
                                              &nodeInfo);
       NS_ENSURE_SUCCESS(result, result);
 
-      NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo);
+      mNodeInfoCache[nodeType] = nodeInfo;
     }
 
     content = CreateHTMLElement(nodeType, nodeInfo, PR_FALSE);
@@ -517,7 +515,7 @@ nsHTMLFragmentContentSink::AddLeaf(const
                                                  kNameSpaceID_None,
                                                  &nodeInfo);
           NS_ENSURE_SUCCESS(result, result);
-          NS_ADDREF(mNodeInfoCache[nodeType] = nodeInfo);
+          mNodeInfoCache[nodeType] = nodeInfo;
         }
 
         content = CreateHTMLElement(nodeType, nodeInfo, PR_FALSE);
@@ -955,7 +953,7 @@ NS_NewHTMLParanoidFragmentSink(nsIFragme
   }
   nsresult rv = nsHTMLParanoidFragmentSink::Init();
   NS_ENSURE_SUCCESS(rv, rv);
-  NS_ADDREF(*aResult = it);
+  *aResult = it;
   
   return NS_OK;
 }
@@ -977,7 +975,7 @@ nsHTMLParanoidFragmentSink::NameFromType
   if (!parserService) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  NS_IF_ADDREF(*aResult = parserService->HTMLIdToAtomTag(aTag));
+  *aResult = parserService->HTMLIdToAtomTag(aTag);
   
   return NS_OK;
 }
@@ -997,7 +995,7 @@ nsHTMLParanoidFragmentSink::NameFromNode
                                     kNameSpaceID_None,
                                     &nodeInfo);
     NS_ENSURE_SUCCESS(rv, rv);
-    NS_IF_ADDREF(*aResult = nodeInfo->NameAtom());
+    *aResult = nodeInfo->NameAtom();
   } else {
     rv = NameFromType(type, aResult);
   }
diff --git a/content/html/document/src/nsImageDocument.cpp b/content/html/document/src/nsImageDocument.cpp
--- a/content/html/document/src/nsImageDocument.cpp
+++ b/content/html/document/src/nsImageDocument.cpp
@@ -321,7 +321,6 @@ nsImageDocument::StartDocumentLoad(const
   *aDocListener = new ImageListener(this);
   if (!*aDocListener)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*aDocListener);
 
   return NS_OK;
 }
@@ -799,7 +798,6 @@ NS_NewImageDocument(nsIDocument** aResul
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(doc);
   nsresult rv = doc->Init();
 
   if (NS_FAILED(rv)) {
diff --git a/content/html/document/src/nsPluginDocument.cpp b/content/html/document/src/nsPluginDocument.cpp
--- a/content/html/document/src/nsPluginDocument.cpp
+++ b/content/html/document/src/nsPluginDocument.cpp
@@ -204,7 +204,7 @@ nsPluginDocument::StartDocumentLoad(cons
     return NS_ERROR_OUT_OF_MEMORY;
   }
   NS_ASSERTION(aDocListener, "null aDocListener");
-  NS_ADDREF(*aDocListener = mStreamListener);
+  *aDocListener = mStreamListener;
 
   return rv;
 }
@@ -333,7 +333,6 @@ NS_NewPluginDocument(nsIDocument** aResu
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(doc);
   nsresult rv = doc->Init();
 
   if (NS_FAILED(rv)) {
diff --git a/content/html/document/src/nsWyciwygChannel.cpp b/content/html/document/src/nsWyciwygChannel.cpp
--- a/content/html/document/src/nsWyciwygChannel.cpp
+++ b/content/html/document/src/nsWyciwygChannel.cpp
@@ -143,7 +143,6 @@ nsWyciwygChannel::GetLoadGroup(nsILoadGr
 nsWyciwygChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
 {
   *aLoadGroup = mLoadGroup;
-  NS_IF_ADDREF(*aLoadGroup);
   return NS_OK;
 }
 
@@ -180,7 +179,6 @@ nsWyciwygChannel::GetOriginalURI(nsIURI*
   NS_ASSERTION(mOriginalURI, "nsWyciwygChannel::GetOriginalURI - mOriginalURI not set!\n");
 
   *aURI = mOriginalURI ? mOriginalURI : mURI;
-  NS_IF_ADDREF(*aURI);
   return NS_OK;
 }
 
@@ -195,7 +193,6 @@ nsWyciwygChannel::GetURI(nsIURI* *aURI)
 nsWyciwygChannel::GetURI(nsIURI* *aURI)
 {
   *aURI = mURI;
-  NS_IF_ADDREF(*aURI);
   return NS_OK;
 }
 
@@ -205,7 +202,7 @@ nsWyciwygChannel::GetOwner(nsISupports *
   NS_PRECONDITION(mOwner, "Must have a principal!");
   NS_ENSURE_STATE(mOwner);
 
-  NS_ADDREF(*aOwner = mOwner);
+  *aOwner = mOwner;
   return NS_OK;
 }
 
@@ -220,7 +217,6 @@ nsWyciwygChannel::GetNotificationCallbac
 nsWyciwygChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aCallbacks)
 {
   *aCallbacks = mCallbacks.get();
-  NS_IF_ADDREF(*aCallbacks);
   return NS_OK;
 }
 
@@ -235,7 +231,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP 
 nsWyciwygChannel::GetSecurityInfo(nsISupports * *aSecurityInfo)
 {
-  NS_IF_ADDREF(*aSecurityInfo = mSecurityInfo);
+  *aSecurityInfo = mSecurityInfo;
 
   return NS_OK;
 }
diff --git a/content/html/document/src/nsWyciwygProtocolHandler.cpp b/content/html/document/src/nsWyciwygProtocolHandler.cpp
--- a/content/html/document/src/nsWyciwygProtocolHandler.cpp
+++ b/content/html/document/src/nsWyciwygProtocolHandler.cpp
@@ -99,7 +99,6 @@ nsWyciwygProtocolHandler::NewURI(const n
   NS_ENSURE_SUCCESS(rv, rv);
 
   *result = url;
-  NS_ADDREF(*result);
 
   return rv;
 }
@@ -113,7 +112,6 @@ nsWyciwygProtocolHandler::NewChannel(nsI
   nsWyciwygChannel* channel = new nsWyciwygChannel();
   if (!channel)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(channel);
   rv = channel->Init(url);
   if (NS_FAILED(rv)) {
     NS_RELEASE(channel);
diff --git a/content/mathml/content/src/nsMathMLElement.cpp b/content/mathml/content/src/nsMathMLElement.cpp
--- a/content/mathml/content/src/nsMathMLElement.cpp
+++ b/content/mathml/content/src/nsMathMLElement.cpp
@@ -79,7 +79,6 @@ nsMathMLElement::QueryInterface(REFNSIID
     return PostQueryInterface(aIID, aInstancePtr);
   }
 
-  NS_ADDREF(inst);
 
   *aInstancePtr = inst;
 
diff --git a/content/mathml/content/src/nsMathMLElementFactory.cpp b/content/mathml/content/src/nsMathMLElementFactory.cpp
--- a/content/mathml/content/src/nsMathMLElementFactory.cpp
+++ b/content/mathml/content/src/nsMathMLElementFactory.cpp
@@ -50,6 +50,6 @@ NS_NewMathMLElement(nsIContent** aResult
   nsMathMLElement* it = new nsMathMLElement(aNodeInfo);
   NS_ENSURE_TRUE(it, NS_ERROR_OUT_OF_MEMORY);
 
-  NS_ADDREF(*aResult = it);
+  *aResult = it;
   return NS_OK;
 }
diff --git a/content/svg/content/src/nsDOMSVGZoomEvent.cpp b/content/svg/content/src/nsDOMSVGZoomEvent.cpp
--- a/content/svg/content/src/nsDOMSVGZoomEvent.cpp
+++ b/content/svg/content/src/nsDOMSVGZoomEvent.cpp
@@ -154,7 +154,6 @@ nsDOMSVGZoomEvent::GetPreviousTranslate(
 nsDOMSVGZoomEvent::GetPreviousTranslate(nsIDOMSVGPoint **aPreviousTranslate)
 {
   *aPreviousTranslate = mPreviousTranslate;
-  NS_IF_ADDREF(*aPreviousTranslate);
   return NS_OK;
 }
 
@@ -170,7 +169,6 @@ nsDOMSVGZoomEvent::GetNewTranslate(nsIDO
 nsDOMSVGZoomEvent::GetNewTranslate(nsIDOMSVGPoint **aNewTranslate)
 {
   *aNewTranslate = mNewTranslate;
-  NS_IF_ADDREF(*aNewTranslate);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGAngle.cpp b/content/svg/content/src/nsSVGAngle.cpp
--- a/content/svg/content/src/nsSVGAngle.cpp
+++ b/content/svg/content/src/nsSVGAngle.cpp
@@ -272,7 +272,6 @@ nsSVGAngle::ToDOMBaseVal(nsIDOMSVGAngle 
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -283,7 +282,6 @@ nsSVGAngle::ToDOMAnimVal(nsIDOMSVGAngle 
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -340,7 +338,6 @@ nsSVGAngle::ToDOMAnimatedAngle(nsIDOMSVG
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -351,6 +348,5 @@ NS_NewDOMSVGAngle(nsIDOMSVGAngle** aResu
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
diff --git a/content/svg/content/src/nsSVGAnimatedLengthList.cpp b/content/svg/content/src/nsSVGAnimatedLengthList.cpp
--- a/content/svg/content/src/nsSVGAnimatedLengthList.cpp
+++ b/content/svg/content/src/nsSVGAnimatedLengthList.cpp
@@ -150,7 +150,6 @@ nsSVGAnimatedLengthList::GetBaseVal(nsID
 nsSVGAnimatedLengthList::GetBaseVal(nsIDOMSVGLengthList * *aBaseVal)
 {
   *aBaseVal = mBaseVal;
-  NS_ADDREF(*aBaseVal);
   return NS_OK;
 }
 
@@ -159,7 +158,6 @@ nsSVGAnimatedLengthList::GetAnimVal(nsID
 nsSVGAnimatedLengthList::GetAnimVal(nsIDOMSVGLengthList * *aAnimVal)
 {
   *aAnimVal = mBaseVal;
-  NS_ADDREF(*aAnimVal);
   return NS_OK;
 }
 
@@ -194,7 +192,6 @@ NS_NewSVGAnimatedLengthList(nsIDOMSVGAni
   
   nsSVGAnimatedLengthList* animatedLengthList = new nsSVGAnimatedLengthList();
   if(!animatedLengthList) return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(animatedLengthList);
 
   animatedLengthList->Init(baseVal);
   
diff --git a/content/svg/content/src/nsSVGAnimatedNumberList.cpp b/content/svg/content/src/nsSVGAnimatedNumberList.cpp
--- a/content/svg/content/src/nsSVGAnimatedNumberList.cpp
+++ b/content/svg/content/src/nsSVGAnimatedNumberList.cpp
@@ -152,7 +152,6 @@ nsSVGAnimatedNumberList::GetBaseVal(nsID
 nsSVGAnimatedNumberList::GetBaseVal(nsIDOMSVGNumberList * *aBaseVal)
 {
   *aBaseVal = mBaseVal;
-  NS_ADDREF(*aBaseVal);
   return NS_OK;
 }
 
@@ -161,7 +160,6 @@ nsSVGAnimatedNumberList::GetAnimVal(nsID
 nsSVGAnimatedNumberList::GetAnimVal(nsIDOMSVGNumberList * *aAnimVal)
 {
   *aAnimVal = mBaseVal;
-  NS_ADDREF(*aAnimVal);
   return NS_OK;
 }
 
@@ -196,7 +194,6 @@ NS_NewSVGAnimatedNumberList(nsIDOMSVGAni
   
   nsSVGAnimatedNumberList* animatedNumberList = new nsSVGAnimatedNumberList();
   if (!animatedNumberList) return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(animatedNumberList);
 
   if (NS_FAILED(animatedNumberList->Init(aBaseVal))) {
     NS_RELEASE(animatedNumberList);
diff --git a/content/svg/content/src/nsSVGAnimatedPreserveAspectRatio.cpp b/content/svg/content/src/nsSVGAnimatedPreserveAspectRatio.cpp
--- a/content/svg/content/src/nsSVGAnimatedPreserveAspectRatio.cpp
+++ b/content/svg/content/src/nsSVGAnimatedPreserveAspectRatio.cpp
@@ -150,7 +150,6 @@ nsSVGAnimatedPreserveAspectRatio::GetBas
 nsSVGAnimatedPreserveAspectRatio::GetBaseVal(nsIDOMSVGPreserveAspectRatio** aBaseVal)
 {
   *aBaseVal = mBaseVal;
-  NS_ADDREF(*aBaseVal);
   return NS_OK;
 }
 
@@ -159,7 +158,6 @@ nsSVGAnimatedPreserveAspectRatio::GetAni
 nsSVGAnimatedPreserveAspectRatio::GetAnimVal(nsIDOMSVGPreserveAspectRatio** aAnimVal)
 {
   *aAnimVal = mBaseVal;
-  NS_ADDREF(*aAnimVal);
   return NS_OK;
 }
 
@@ -200,7 +198,6 @@ NS_NewSVGAnimatedPreserveAspectRatio(nsI
   if (!animatedPreserveAspectRatio)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(animatedPreserveAspectRatio);
   animatedPreserveAspectRatio->Init(baseVal);
   *result = (nsIDOMSVGAnimatedPreserveAspectRatio*) animatedPreserveAspectRatio;
 
diff --git a/content/svg/content/src/nsSVGAnimatedRect.cpp b/content/svg/content/src/nsSVGAnimatedRect.cpp
--- a/content/svg/content/src/nsSVGAnimatedRect.cpp
+++ b/content/svg/content/src/nsSVGAnimatedRect.cpp
@@ -148,7 +148,6 @@ nsSVGAnimatedRect::GetBaseVal(nsIDOMSVGR
 nsSVGAnimatedRect::GetBaseVal(nsIDOMSVGRect * *aBaseVal)
 {
   *aBaseVal = mBaseVal;
-  NS_ADDREF(*aBaseVal);
   return NS_OK;
 }
 
@@ -157,7 +156,6 @@ nsSVGAnimatedRect::GetAnimVal(nsIDOMSVGR
 nsSVGAnimatedRect::GetAnimVal(nsIDOMSVGRect * *aAnimVal)
 {
   *aAnimVal = mBaseVal;
-  NS_ADDREF(*aAnimVal);
   return NS_OK;
 }
 
@@ -192,7 +190,6 @@ NS_NewSVGAnimatedRect(nsIDOMSVGAnimatedR
   
   nsSVGAnimatedRect* animatedRect = new nsSVGAnimatedRect();
   if(!animatedRect) return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(animatedRect);
 
   animatedRect->Init(baseVal);
   
diff --git a/content/svg/content/src/nsSVGAnimatedTransformList.cpp b/content/svg/content/src/nsSVGAnimatedTransformList.cpp
--- a/content/svg/content/src/nsSVGAnimatedTransformList.cpp
+++ b/content/svg/content/src/nsSVGAnimatedTransformList.cpp
@@ -150,7 +150,6 @@ nsSVGAnimatedTransformList::GetBaseVal(n
 nsSVGAnimatedTransformList::GetBaseVal(nsIDOMSVGTransformList * *aBaseVal)
 {
   *aBaseVal = mBaseVal;
-  NS_ADDREF(*aBaseVal);
   return NS_OK;
 }
 
@@ -159,7 +158,6 @@ nsSVGAnimatedTransformList::GetAnimVal(n
 nsSVGAnimatedTransformList::GetAnimVal(nsIDOMSVGTransformList * *aAnimVal)
 {
   *aAnimVal = mBaseVal;
-  NS_ADDREF(*aAnimVal);
   return NS_OK;
 }
 
@@ -194,7 +192,6 @@ NS_NewSVGAnimatedTransformList(nsIDOMSVG
   
   nsSVGAnimatedTransformList* animatedTransformList = new nsSVGAnimatedTransformList();
   if(!animatedTransformList) return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(animatedTransformList);
 
   animatedTransformList->Init(baseVal);
   
diff --git a/content/svg/content/src/nsSVGBoolean.cpp b/content/svg/content/src/nsSVGBoolean.cpp
--- a/content/svg/content/src/nsSVGBoolean.cpp
+++ b/content/svg/content/src/nsSVGBoolean.cpp
@@ -91,7 +91,6 @@ nsSVGBoolean::ToDOMAnimatedBoolean(nsIDO
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGElement.cpp b/content/svg/content/src/nsSVGElement.cpp
--- a/content/svg/content/src/nsSVGElement.cpp
+++ b/content/svg/content/src/nsSVGElement.cpp
@@ -847,7 +847,6 @@ nsSVGElement::GetOwnerSVGElement(nsIDOMS
     }
     if (tag == nsGkAtoms::svg) {
       *aOwnerSVGElement = static_cast<nsSVGSVGElement*>(parent);
-      NS_ADDREF(*aOwnerSVGElement);
       return NS_OK;
     }
     nsIContent* next = nsnull;
@@ -886,7 +885,6 @@ nsSVGElement::GetViewportElement(nsIDOMS
   if (SVGSVGElement) {
     nsIDOMSVGElement* SVGElement = do_QueryInterface(SVGSVGElement);
     *aViewportElement = SVGElement;
-    NS_IF_ADDREF(*aViewportElement);
   }
   return NS_OK;
 }
diff --git a/content/svg/content/src/nsSVGElement.h b/content/svg/content/src/nsSVGElement.h
--- a/content/svg/content/src/nsSVGElement.h
+++ b/content/svg/content/src/nsSVGElement.h
@@ -346,7 +346,6 @@ NS_NewSVG##_elementName##Element(nsICont
   if (!it)                                                                   \
     return NS_ERROR_OUT_OF_MEMORY;                                           \
                                                                              \
-  NS_ADDREF(it);                                                             \
                                                                              \
   nsresult rv = it->Init();                                                  \
                                                                              \
diff --git a/content/svg/content/src/nsSVGEnum.cpp b/content/svg/content/src/nsSVGEnum.cpp
--- a/content/svg/content/src/nsSVGEnum.cpp
+++ b/content/svg/content/src/nsSVGEnum.cpp
@@ -121,6 +121,5 @@ nsSVGEnum::ToDOMAnimatedEnum(nsIDOMSVGAn
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
diff --git a/content/svg/content/src/nsSVGFilters.cpp b/content/svg/content/src/nsSVGFilters.cpp
--- a/content/svg/content/src/nsSVGFilters.cpp
+++ b/content/svg/content/src/nsSVGFilters.cpp
@@ -1223,7 +1223,6 @@ NS_IMETHODIMP nsSVGFEColorMatrixElement:
 NS_IMETHODIMP nsSVGFEColorMatrixElement::GetValues(nsIDOMSVGAnimatedNumberList * *aValues)
 {
   *aValues = mValues;
-  NS_IF_ADDREF(*aValues);
   return NS_OK;
 }
 
@@ -1995,7 +1994,6 @@ NS_IMETHODIMP nsSVGComponentTransferFunc
 NS_IMETHODIMP nsSVGComponentTransferFunctionElement::GetTableValues(nsIDOMSVGAnimatedNumberList * *aTableValues)
 {
   *aTableValues = mTableValues;
-  NS_IF_ADDREF(*aTableValues);
   return NS_OK;
 }
 
@@ -4060,7 +4058,6 @@ NS_IMETHODIMP nsSVGFEConvolveMatrixEleme
 NS_IMETHODIMP nsSVGFEConvolveMatrixElement::GetKernelMatrix(nsIDOMSVGAnimatedNumberList * *aKernelMatrix)
 {
   *aKernelMatrix = mKernelMatrix;
-  NS_IF_ADDREF(*aKernelMatrix);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGGradientElement.cpp b/content/svg/content/src/nsSVGGradientElement.cpp
--- a/content/svg/content/src/nsSVGGradientElement.cpp
+++ b/content/svg/content/src/nsSVGGradientElement.cpp
@@ -144,7 +144,6 @@ NS_IMETHODIMP nsSVGGradientElement::GetG
 NS_IMETHODIMP nsSVGGradientElement::GetGradientTransform(nsIDOMSVGAnimatedTransformList * *aGradientTransform)
 {
   *aGradientTransform = mGradientTransform;
-  NS_IF_ADDREF(*aGradientTransform);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGGraphicElement.cpp b/content/svg/content/src/nsSVGGraphicElement.cpp
--- a/content/svg/content/src/nsSVGGraphicElement.cpp
+++ b/content/svg/content/src/nsSVGGraphicElement.cpp
@@ -117,7 +117,6 @@ nsSVGGraphicElement::AppendLocalTransfor
 {
   if (!mTransforms) {
     *_retval = aCTM;
-    NS_ADDREF(*_retval);
     return NS_OK;
   }
 
@@ -129,7 +128,6 @@ nsSVGGraphicElement::AppendLocalTransfor
     nsSVGTransformList::GetConsolidationMatrix(transforms);
   if (!matrix) {
     *_retval = aCTM;
-    NS_ADDREF(*_retval);
     return NS_OK;
   }
   return aCTM->Multiply(matrix, _retval);  // addrefs, so we don't
@@ -265,7 +263,6 @@ NS_IMETHODIMP nsSVGGraphicElement::GetTr
     return NS_ERROR_OUT_OF_MEMORY;
       
   *aTransform = mTransforms;
-  NS_ADDREF(*aTransform);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGImageElement.cpp b/content/svg/content/src/nsSVGImageElement.cpp
--- a/content/svg/content/src/nsSVGImageElement.cpp
+++ b/content/svg/content/src/nsSVGImageElement.cpp
@@ -226,7 +226,6 @@ nsSVGImageElement::GetPreserveAspectRati
                                           **aPreserveAspectRatio)
 {
   *aPreserveAspectRatio = mPreserveAspectRatio;
-  NS_IF_ADDREF(*aPreserveAspectRatio);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGInteger.cpp b/content/svg/content/src/nsSVGInteger.cpp
--- a/content/svg/content/src/nsSVGInteger.cpp
+++ b/content/svg/content/src/nsSVGInteger.cpp
@@ -93,7 +93,6 @@ nsSVGInteger::ToDOMAnimatedInteger(nsIDO
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGLength.cpp b/content/svg/content/src/nsSVGLength.cpp
--- a/content/svg/content/src/nsSVGLength.cpp
+++ b/content/svg/content/src/nsSVGLength.cpp
@@ -126,7 +126,6 @@ NS_NewSVGLength(nsISVGLength** result,
   *result = new nsSVGLength(value, unit);
   if (!*result)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*result);
   return NS_OK;
 }
 
@@ -138,7 +137,6 @@ NS_NewSVGLength(nsISVGLength** result,
   nsSVGLength *pl = new nsSVGLength();
   if (!pl)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(pl);
   nsresult rv = pl->SetValueAsString(value);
   if (NS_FAILED(rv)) {
     NS_RELEASE(pl);
diff --git a/content/svg/content/src/nsSVGLength2.cpp b/content/svg/content/src/nsSVGLength2.cpp
--- a/content/svg/content/src/nsSVGLength2.cpp
+++ b/content/svg/content/src/nsSVGLength2.cpp
@@ -280,7 +280,6 @@ nsSVGLength2::ToDOMBaseVal(nsIDOMSVGLeng
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -291,7 +290,6 @@ nsSVGLength2::ToDOMAnimVal(nsIDOMSVGLeng
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -344,6 +342,5 @@ nsSVGLength2::ToDOMAnimatedLength(nsIDOM
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
diff --git a/content/svg/content/src/nsSVGLengthList.cpp b/content/svg/content/src/nsSVGLengthList.cpp
--- a/content/svg/content/src/nsSVGLengthList.cpp
+++ b/content/svg/content/src/nsSVGLengthList.cpp
@@ -232,7 +232,6 @@ NS_IMETHODIMP nsSVGLengthList::GetItem(P
   }
 
   *_retval  = ElementAt(index);
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -273,7 +272,6 @@ NS_IMETHODIMP nsSVGLengthList::RemoveIte
   }
 
   *_retval = ElementAt(index);
-  NS_ADDREF(*_retval);
   WillModify();
   RemoveElementAt(index);
   DidModify();
@@ -292,7 +290,6 @@ nsSVGLengthList::AppendItem(nsIDOMSVGLen
   AppendElement(length);
 
   *_retval = newItem;
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -343,7 +340,6 @@ nsSVGLengthList::AppendElement(nsISVGLen
 nsSVGLengthList::AppendElement(nsISVGLength* aElement)
 {
   WillModify();
-  NS_ADDREF(aElement);
   
   // The SVG specs state that 'if newItem is already in a list, it
   // is removed from its previous list before it is inserted into this
@@ -372,7 +368,6 @@ nsSVGLengthList::InsertElementAt(nsISVGL
 nsSVGLengthList::InsertElementAt(nsISVGLength* aElement, PRInt32 index)
 {
   WillModify();
-  NS_ADDREF(aElement);
 
   // The SVG specs state that 'if newItem is already in a list, it
   // is removed from its previous list before it is inserted into this
@@ -397,7 +392,6 @@ NS_NewSVGLengthList(nsIDOMSVGLengthList*
   
   nsSVGLengthList* lengthList = new nsSVGLengthList(aContext, aCtxType);
   if (!lengthList) return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(lengthList);
 
   *result = lengthList;
   
diff --git a/content/svg/content/src/nsSVGMarkerElement.cpp b/content/svg/content/src/nsSVGMarkerElement.cpp
--- a/content/svg/content/src/nsSVGMarkerElement.cpp
+++ b/content/svg/content/src/nsSVGMarkerElement.cpp
@@ -127,7 +127,6 @@ nsSVGOrientType::ToDOMAnimatedEnum(nsIDO
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -184,7 +183,6 @@ NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGMar
   NS_IMETHODIMP nsSVGMarkerElement::GetViewBox(nsIDOMSVGAnimatedRect * *aViewBox)
 {
   *aViewBox = mViewBox;
-  NS_ADDREF(*aViewBox);
   return NS_OK;
 }
 
@@ -193,7 +191,6 @@ nsSVGMarkerElement::GetPreserveAspectRat
 nsSVGMarkerElement::GetPreserveAspectRatio(nsIDOMSVGAnimatedPreserveAspectRatio * *aPreserveAspectRatio)
 {
   *aPreserveAspectRatio = mPreserveAspectRatio;
-  NS_ADDREF(*aPreserveAspectRatio);
   return NS_OK;
 }
 
@@ -427,7 +424,6 @@ nsSVGMarkerElement::GetMarkerTransform(f
                   aX,                    aY);
     
   *_retval = matrix;
-  NS_IF_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -478,7 +474,6 @@ nsSVGMarkerElement::GetViewboxToViewport
   }
 
   *_retval = mViewBoxToViewportTransform;
-  NS_IF_ADDREF(*_retval);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGMatrix.cpp b/content/svg/content/src/nsSVGMatrix.cpp
--- a/content/svg/content/src/nsSVGMatrix.cpp
+++ b/content/svg/content/src/nsSVGMatrix.cpp
@@ -79,7 +79,6 @@ NS_NewSVGMatrix(nsIDOMSVGMatrix** result
   *result = new nsSVGMatrix(a, b, c, d, e, f);
   if (!*result)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*result);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGNumber.cpp b/content/svg/content/src/nsSVGNumber.cpp
--- a/content/svg/content/src/nsSVGNumber.cpp
+++ b/content/svg/content/src/nsSVGNumber.cpp
@@ -78,7 +78,6 @@ NS_NewSVGNumber(nsIDOMSVGNumber** result
 {
   *result = new nsSVGNumber(val);
   if (!*result) return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*result);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGNumber2.cpp b/content/svg/content/src/nsSVGNumber2.cpp
--- a/content/svg/content/src/nsSVGNumber2.cpp
+++ b/content/svg/content/src/nsSVGNumber2.cpp
@@ -95,7 +95,6 @@ nsSVGNumber2::ToDOMAnimatedNumber(nsIDOM
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGNumberList.cpp b/content/svg/content/src/nsSVGNumberList.cpp
--- a/content/svg/content/src/nsSVGNumberList.cpp
+++ b/content/svg/content/src/nsSVGNumberList.cpp
@@ -229,7 +229,6 @@ NS_IMETHODIMP nsSVGNumberList::GetItem(P
   }
 
   *_retval  = ElementAt(index);
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -253,7 +252,6 @@ nsSVGNumberList::InsertItemBefore(nsIDOM
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -284,7 +282,6 @@ NS_IMETHODIMP nsSVGNumberList::RemoveIte
   }
 
   *_retval = ElementAt(index);
-  NS_ADDREF(*_retval);
   WillModify();
   RemoveElementAt(index);
   DidModify();
@@ -299,7 +296,6 @@ nsSVGNumberList::AppendItem(nsIDOMSVGNum
   if (!newItem)
     return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR;
   AppendElement(newItem);
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -349,7 +345,6 @@ nsSVGNumberList::AppendElement(nsIDOMSVG
 nsSVGNumberList::AppendElement(nsIDOMSVGNumber* aElement)
 {
   WillModify();
-  NS_ADDREF(aElement);
   
   // The SVG specs state that 'if newItem is already in a list, it
   // is removed from its previous list before it is inserted into this
@@ -378,7 +373,6 @@ nsSVGNumberList::InsertElementAt(nsIDOMS
 {
   nsresult rv;
   WillModify();
-  NS_ADDREF(aElement);
 
   // The SVG specs state that 'if newItem is already in a list, it
   // is removed from its previous list before it is inserted into this
@@ -402,7 +396,6 @@ NS_NewSVGNumberList(nsIDOMSVGNumberList*
   
   nsSVGNumberList* numberList = new nsSVGNumberList();
   if (!numberList) return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(numberList);
 
   *result = numberList;
   
diff --git a/content/svg/content/src/nsSVGPathElement.cpp b/content/svg/content/src/nsSVGPathElement.cpp
--- a/content/svg/content/src/nsSVGPathElement.cpp
+++ b/content/svg/content/src/nsSVGPathElement.cpp
@@ -407,7 +407,6 @@ NS_IMETHODIMP nsSVGPathElement::GetPathS
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aPathSegList = mSegments;
-  NS_ADDREF(*aPathSegList);
   return NS_OK;
 }
 
@@ -424,7 +423,6 @@ NS_IMETHODIMP nsSVGPathElement::GetAnima
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aAnimatedPathSegList = mSegments;
-  NS_ADDREF(*aAnimatedPathSegList);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGPathSegList.cpp b/content/svg/content/src/nsSVGPathSegList.cpp
--- a/content/svg/content/src/nsSVGPathSegList.cpp
+++ b/content/svg/content/src/nsSVGPathSegList.cpp
@@ -216,7 +216,6 @@ NS_IMETHODIMP nsSVGPathSegList::GetItem(
   }
 
   *_retval  = mSegments.ObjectAt(index);
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -232,7 +231,7 @@ NS_IMETHODIMP nsSVGPathSegList::InsertIt
   }
 
   InsertElementAt(static_cast<nsSVGPathSeg*>(newItem), index);
-  NS_ADDREF(*_retval = newItem);
+  *_retval = newItem;
 
   return NS_OK;
 }
@@ -250,7 +249,7 @@ NS_IMETHODIMP nsSVGPathSegList::ReplaceI
 
   InsertElementAt(static_cast<nsSVGPathSeg*>(newItem), index);
   RemoveElementAt(index+1);
-  NS_ADDREF(*_retval = newItem);
+  *_retval = newItem;
 
   return NS_OK;
 }
@@ -264,7 +263,6 @@ NS_IMETHODIMP nsSVGPathSegList::RemoveIt
   }
 
   *_retval = mSegments.ObjectAt(index);
-  NS_ADDREF(*_retval);
   WillModify();
   RemoveElementAt(index);
   DidModify();
@@ -276,7 +274,7 @@ NS_IMETHODIMP nsSVGPathSegList::AppendIt
                                            nsIDOMSVGPathSeg **_retval)
 {
   NS_ENSURE_NATIVE_PATH_SEG(newItem, _retval);
-  NS_ADDREF(*_retval = newItem);
+  *_retval = newItem;
   AppendElement(static_cast<nsSVGPathSeg*>(newItem));
   return NS_OK;
 }
@@ -387,7 +385,6 @@ NS_NewSVGPathSegList(nsIDOMSVGPathSegLis
   
   nsSVGPathSegList* pathSegList = new nsSVGPathSegList();
   if (!pathSegList) return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(pathSegList);
 
   // pathSegList->Init();
 
diff --git a/content/svg/content/src/nsSVGPatternElement.cpp b/content/svg/content/src/nsSVGPatternElement.cpp
--- a/content/svg/content/src/nsSVGPatternElement.cpp
+++ b/content/svg/content/src/nsSVGPatternElement.cpp
@@ -167,7 +167,6 @@ NS_IMETHODIMP nsSVGPatternElement::GetVi
 NS_IMETHODIMP nsSVGPatternElement::GetViewBox(nsIDOMSVGAnimatedRect * *aViewBox)
 {
   *aViewBox = mViewBox;
-  NS_ADDREF(*aViewBox);
   return NS_OK;
 }
 
@@ -176,7 +175,6 @@ nsSVGPatternElement::GetPreserveAspectRa
 nsSVGPatternElement::GetPreserveAspectRatio(nsIDOMSVGAnimatedPreserveAspectRatio * *aPreserveAspectRatio)
 {
   *aPreserveAspectRatio = mPreserveAspectRatio;
-  NS_ADDREF(*aPreserveAspectRatio);
   return NS_OK;
 }
 
@@ -199,7 +197,6 @@ NS_IMETHODIMP nsSVGPatternElement::GetPa
 NS_IMETHODIMP nsSVGPatternElement::GetPatternTransform(nsIDOMSVGAnimatedTransformList * *aPatternTransform)
 {
   *aPatternTransform = mPatternTransform;
-  NS_IF_ADDREF(*aPatternTransform);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGPoint.cpp b/content/svg/content/src/nsSVGPoint.cpp
--- a/content/svg/content/src/nsSVGPoint.cpp
+++ b/content/svg/content/src/nsSVGPoint.cpp
@@ -75,7 +75,6 @@ NS_NewSVGPoint(nsIDOMSVGPoint** result, 
   *result = new nsSVGPoint(x, y);
   if (!*result)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*result);
   return NS_OK;
 }
 
@@ -202,7 +201,6 @@ NS_NewSVGReadonlyPoint(nsIDOMSVGPoint** 
   *result = new nsSVGReadonlyPoint(x, y);
   if (!*result)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*result);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGPointList.cpp b/content/svg/content/src/nsSVGPointList.cpp
--- a/content/svg/content/src/nsSVGPointList.cpp
+++ b/content/svg/content/src/nsSVGPointList.cpp
@@ -53,7 +53,6 @@ nsSVGPointList::Create(const nsAString& 
   *aResult = (nsISVGValue*) new nsSVGPointList();
   if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
   
-  NS_ADDREF(*aResult);
 
   (*aResult)->SetValueString(aValue);  
   return NS_OK;
@@ -65,7 +64,6 @@ nsSVGPointList::Create(nsIDOMSVGPointLis
   *aResult = (nsIDOMSVGPointList*) new nsSVGPointList();
   if(!*aResult) return NS_ERROR_OUT_OF_MEMORY;
   
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -104,7 +102,6 @@ nsSVGPointList::AppendElement(nsIDOMSVGP
 nsSVGPointList::AppendElement(nsIDOMSVGPoint* aElement)
 {
   WillModify();
-  NS_ADDREF(aElement);
   mPoints.AppendElement((void*)aElement);
   nsISVGValue* val = do_QueryInterface(aElement);
   if (val)
@@ -130,7 +127,6 @@ nsSVGPointList::InsertElementAt(nsIDOMSV
 nsSVGPointList::InsertElementAt(nsIDOMSVGPoint* aElement, PRInt32 index)
 {
   WillModify();
-  NS_ADDREF(aElement);
   mPoints.InsertElementAt((void*)aElement, index);
   nsISVGValue* val = do_QueryInterface(aElement);
   if (val)
@@ -283,7 +279,6 @@ NS_IMETHODIMP nsSVGPointList::GetItem(PR
   }
 
   *_retval  = ElementAt(index);
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -322,7 +317,6 @@ NS_IMETHODIMP nsSVGPointList::RemoveItem
   }
 
   *_retval = ElementAt(index);
-  NS_ADDREF(*_retval);
   WillModify();
   RemoveElementAt(index);
   DidModify();
@@ -341,7 +335,6 @@ NS_IMETHODIMP nsSVGPointList::AppendItem
   if (!newItem)
     return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR;
   AppendElement(newItem);
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGPolyElement.cpp b/content/svg/content/src/nsSVGPolyElement.cpp
--- a/content/svg/content/src/nsSVGPolyElement.cpp
+++ b/content/svg/content/src/nsSVGPolyElement.cpp
@@ -81,7 +81,6 @@ nsSVGPolyElement::GetPoints(nsIDOMSVGPoi
 nsSVGPolyElement::GetPoints(nsIDOMSVGPointList * *aPoints)
 {
   *aPoints = mPoints;
-  NS_ADDREF(*aPoints);
   return NS_OK;
 }
 
@@ -90,7 +89,6 @@ nsSVGPolyElement::GetAnimatedPoints(nsID
 nsSVGPolyElement::GetAnimatedPoints(nsIDOMSVGPointList * *aAnimatedPoints)
 {
   *aAnimatedPoints = mPoints;
-  NS_ADDREF(*aAnimatedPoints);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGPreserveAspectRatio.cpp b/content/svg/content/src/nsSVGPreserveAspectRatio.cpp
--- a/content/svg/content/src/nsSVGPreserveAspectRatio.cpp
+++ b/content/svg/content/src/nsSVGPreserveAspectRatio.cpp
@@ -287,6 +287,5 @@ NS_NewSVGPreserveAspectRatio(nsIDOMSVGPr
   *result = (nsIDOMSVGPreserveAspectRatio*) new nsSVGPreserveAspectRatio(aAlign, aMeetOrSlice);
   if (!*result) return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*result);
   return NS_OK;
 }
diff --git a/content/svg/content/src/nsSVGRect.cpp b/content/svg/content/src/nsSVGRect.cpp
--- a/content/svg/content/src/nsSVGRect.cpp
+++ b/content/svg/content/src/nsSVGRect.cpp
@@ -225,7 +225,6 @@ NS_NewSVGRect(nsIDOMSVGRect** result, fl
 {
   *result = new nsSVGRect(x, y, width, height);
   if (!*result) return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*result);
   return NS_OK;
 }
 
@@ -243,7 +242,6 @@ NS_NewSVGReadonlyRect(nsIDOMSVGRect** re
 {
   *result = new nsSVGReadonlyRect(x, y, width, height);
   if (!*result) return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*result);
   return NS_OK;
 }
 
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
@@ -362,7 +362,6 @@ nsSVGSVGElement::GetCurrentTranslate(nsI
 nsSVGSVGElement::GetCurrentTranslate(nsIDOMSVGPoint * *aCurrentTranslate)
 {
   *aCurrentTranslate = mCurrentTranslate;
-  NS_ADDREF(*aCurrentTranslate);
   return NS_OK;
 }
 
@@ -639,7 +638,6 @@ nsSVGSVGElement::GetViewBox(nsIDOMSVGAni
 nsSVGSVGElement::GetViewBox(nsIDOMSVGAnimatedRect * *aViewBox)
 {
   *aViewBox = mViewBox;
-  NS_ADDREF(*aViewBox);
   return NS_OK;
 }
 
@@ -648,7 +646,6 @@ nsSVGSVGElement::GetPreserveAspectRatio(
 nsSVGSVGElement::GetPreserveAspectRatio(nsIDOMSVGAnimatedPreserveAspectRatio * *aPreserveAspectRatio)
 {
   *aPreserveAspectRatio = mPreserveAspectRatio;
-  NS_ADDREF(*aPreserveAspectRatio);
   return NS_OK;
 }
 
@@ -993,7 +990,6 @@ nsSVGSVGElement::GetCurrentScaleNumber(n
 nsSVGSVGElement::GetCurrentScaleNumber(nsIDOMSVGNumber **aResult)
 {
   *aResult = mCurrentScale;
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGString.cpp b/content/svg/content/src/nsSVGString.cpp
--- a/content/svg/content/src/nsSVGString.cpp
+++ b/content/svg/content/src/nsSVGString.cpp
@@ -64,6 +64,5 @@ nsSVGString::ToDOMAnimatedString(nsIDOMS
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
diff --git a/content/svg/content/src/nsSVGStringProxyValue.cpp b/content/svg/content/src/nsSVGStringProxyValue.cpp
--- a/content/svg/content/src/nsSVGStringProxyValue.cpp
+++ b/content/svg/content/src/nsSVGStringProxyValue.cpp
@@ -100,7 +100,6 @@ NS_CreateSVGStringProxyValue(nsISVGValue
   
   nsSVGStringProxyValue *sp = new nsSVGStringProxyValue();
   if(!sp) return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(sp);
   if (!sp->Init(proxiedValue)) {
     NS_RELEASE(sp);
     return NS_ERROR_FAILURE;
diff --git a/content/svg/content/src/nsSVGStylableElement.cpp b/content/svg/content/src/nsSVGStylableElement.cpp
--- a/content/svg/content/src/nsSVGStylableElement.cpp
+++ b/content/svg/content/src/nsSVGStylableElement.cpp
@@ -100,7 +100,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsSVGStylableElement::GetClassName(nsIDOMSVGAnimatedString** aClassName)
 {
-  NS_ADDREF(*aClassName = mClassName);
+  *aClassName = mClassName;
 
   return NS_OK;
 }
diff --git a/content/svg/content/src/nsSVGSymbolElement.cpp b/content/svg/content/src/nsSVGSymbolElement.cpp
--- a/content/svg/content/src/nsSVGSymbolElement.cpp
+++ b/content/svg/content/src/nsSVGSymbolElement.cpp
@@ -154,7 +154,6 @@ NS_IMETHODIMP nsSVGSymbolElement::GetVie
 NS_IMETHODIMP nsSVGSymbolElement::GetViewBox(nsIDOMSVGAnimatedRect * *aViewBox)
 {
   *aViewBox = mViewBox;
-  NS_ADDREF(*aViewBox);
   return NS_OK;
 }
 
@@ -163,7 +162,6 @@ nsSVGSymbolElement::GetPreserveAspectRat
 nsSVGSymbolElement::GetPreserveAspectRatio(nsIDOMSVGAnimatedPreserveAspectRatio * *aPreserveAspectRatio)
 {
   *aPreserveAspectRatio = mPreserveAspectRatio;
-  NS_ADDREF(*aPreserveAspectRatio);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGTSpanElement.cpp b/content/svg/content/src/nsSVGTSpanElement.cpp
--- a/content/svg/content/src/nsSVGTSpanElement.cpp
+++ b/content/svg/content/src/nsSVGTSpanElement.cpp
@@ -202,7 +202,6 @@ NS_IMETHODIMP nsSVGTSpanElement::GetX(ns
 NS_IMETHODIMP nsSVGTSpanElement::GetX(nsIDOMSVGAnimatedLengthList * *aX)
 {
   *aX = mX;
-  NS_IF_ADDREF(*aX);
   return NS_OK;
 }
 
@@ -210,7 +209,6 @@ NS_IMETHODIMP nsSVGTSpanElement::GetY(ns
 NS_IMETHODIMP nsSVGTSpanElement::GetY(nsIDOMSVGAnimatedLengthList * *aY)
 {
   *aY = mY;
-  NS_IF_ADDREF(*aY);
   return NS_OK;
 }
 
@@ -218,7 +216,6 @@ NS_IMETHODIMP nsSVGTSpanElement::GetDx(n
 NS_IMETHODIMP nsSVGTSpanElement::GetDx(nsIDOMSVGAnimatedLengthList * *aDx)
 {
   *aDx = mdX;
-  NS_IF_ADDREF(*aDx);
   return NS_OK;
 }
 
@@ -226,7 +223,6 @@ NS_IMETHODIMP nsSVGTSpanElement::GetDy(n
 NS_IMETHODIMP nsSVGTSpanElement::GetDy(nsIDOMSVGAnimatedLengthList * *aDy)
 {
   *aDy = mdY;
-  NS_IF_ADDREF(*aDy);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGTextElement.cpp b/content/svg/content/src/nsSVGTextElement.cpp
--- a/content/svg/content/src/nsSVGTextElement.cpp
+++ b/content/svg/content/src/nsSVGTextElement.cpp
@@ -199,7 +199,6 @@ NS_IMETHODIMP nsSVGTextElement::GetX(nsI
 NS_IMETHODIMP nsSVGTextElement::GetX(nsIDOMSVGAnimatedLengthList * *aX)
 {
   *aX = mX;
-  NS_IF_ADDREF(*aX);
   return NS_OK;
 }
 
@@ -207,7 +206,6 @@ NS_IMETHODIMP nsSVGTextElement::GetY(nsI
 NS_IMETHODIMP nsSVGTextElement::GetY(nsIDOMSVGAnimatedLengthList * *aY)
 {
   *aY = mY;
-  NS_IF_ADDREF(*aY);
   return NS_OK;
 }
 
@@ -215,7 +213,6 @@ NS_IMETHODIMP nsSVGTextElement::GetDx(ns
 NS_IMETHODIMP nsSVGTextElement::GetDx(nsIDOMSVGAnimatedLengthList * *aDx)
 {
   *aDx = mdX;
-  NS_IF_ADDREF(*aDx);
   return NS_OK;
 }
 
@@ -223,7 +220,6 @@ NS_IMETHODIMP nsSVGTextElement::GetDy(ns
 NS_IMETHODIMP nsSVGTextElement::GetDy(nsIDOMSVGAnimatedLengthList * *aDy)
 {
   *aDy = mdY;
-  NS_IF_ADDREF(*aDy);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGTransform.cpp b/content/svg/content/src/nsSVGTransform.cpp
--- a/content/svg/content/src/nsSVGTransform.cpp
+++ b/content/svg/content/src/nsSVGTransform.cpp
@@ -96,7 +96,6 @@ nsSVGTransform::Create(nsIDOMSVGTransfor
 {
   nsSVGTransform *pl = new nsSVGTransform();
   NS_ENSURE_TRUE(pl, NS_ERROR_OUT_OF_MEMORY);
-  NS_ADDREF(pl);
   if (NS_FAILED(pl->Init())) {
     NS_RELEASE(pl);
     *aResult = nsnull;
@@ -266,7 +265,6 @@ NS_IMETHODIMP nsSVGTransform::GetMatrix(
   // XXX should we make a copy here? is the matrix supposed to be live
   // or not?
   *aMatrix = mMatrix;
-  NS_IF_ADDREF(*aMatrix);
   return NS_OK;
 }
 
diff --git a/content/svg/content/src/nsSVGTransformList.cpp b/content/svg/content/src/nsSVGTransformList.cpp
--- a/content/svg/content/src/nsSVGTransformList.cpp
+++ b/content/svg/content/src/nsSVGTransformList.cpp
@@ -55,7 +55,6 @@ nsSVGTransformList::Create(nsIDOMSVGTran
   *aResult = new nsSVGTransformList();
   if (!*aResult) return NS_ERROR_OUT_OF_MEMORY;
   
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -93,7 +92,6 @@ nsSVGTransformList::AppendElement(nsIDOM
 {
   PRBool rv = mTransforms.AppendElement((void*)aElement);
   if (rv) {
-    NS_ADDREF(aElement);
     nsISVGValue* val = do_QueryInterface(aElement);
     if (val)
       val->AddObserver(this);
@@ -256,7 +254,6 @@ NS_IMETHODIMP nsSVGTransformList::Initia
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -269,7 +266,6 @@ NS_IMETHODIMP nsSVGTransformList::GetIte
   }
 
   *_retval  = ElementAt(index);
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -291,12 +287,10 @@ NS_IMETHODIMP nsSVGTransformList::Insert
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(newItem);
   nsISVGValue* val = do_QueryInterface(newItem);
   if (val)
     val->AddObserver(this);
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -329,10 +323,8 @@ NS_IMETHODIMP nsSVGTransformList::Replac
   val = do_QueryInterface(newItem);
   if (val)
     val->AddObserver(this);
-  NS_ADDREF(newItem);
 
   *_retval = newItem;
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -377,7 +369,6 @@ NS_IMETHODIMP nsSVGTransformList::Append
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -408,7 +399,6 @@ NS_IMETHODIMP nsSVGTransformList::Consol
   if (count==0) return NS_OK;
   if (count==1) {
     *_retval = ElementAt(0);
-    NS_ADDREF(*_retval);
     return NS_OK;
   }
 
@@ -427,7 +417,6 @@ NS_IMETHODIMP nsSVGTransformList::Consol
     return NS_ERROR_OUT_OF_MEMORY;
 
   *_retval = consolidation;
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
diff --git a/content/svg/document/src/nsSVGDocument.cpp b/content/svg/document/src/nsSVGDocument.cpp
--- a/content/svg/document/src/nsSVGDocument.cpp
+++ b/content/svg/document/src/nsSVGDocument.cpp
@@ -141,7 +141,6 @@ NS_NewSVGDocument(nsIDocument** aInstanc
   if (!doc)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(doc);
   nsresult rv = doc->Init();
 
   if (NS_FAILED(rv)) {
diff --git a/content/xbl/src/nsBindingManager.cpp b/content/xbl/src/nsBindingManager.cpp
--- a/content/xbl/src/nsBindingManager.cpp
+++ b/content/xbl/src/nsBindingManager.cpp
@@ -577,7 +577,6 @@ nsBindingManager::GetContentListFor(nsIC
   if (mContentListTable.ops) {
     *aResult = static_cast<nsIDOMNodeList*>
                           (LookupObject(mContentListTable, aContent));
-    NS_IF_ADDREF(*aResult);
   }
   
   if (!*aResult) {
@@ -624,7 +623,6 @@ nsBindingManager::GetAnonymousNodesInter
   if (mAnonymousNodesTable.ops) {
     *aResult = static_cast<nsIDOMNodeList*>
                           (LookupObject(mAnonymousNodesTable, aContent));
-    NS_IF_ADDREF(*aResult);
   }
 
   if (!*aResult) {
diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp
--- a/content/xbl/src/nsXBLBinding.cpp
+++ b/content/xbl/src/nsXBLBinding.cpp
@@ -276,7 +276,6 @@ nsXBLBinding::nsXBLBinding(nsXBLPrototyp
 {
   NS_ASSERTION(mPrototypeBinding, "Must have a prototype binding!");
   // Grab a ref to the document info so the prototype binding won't die
-  NS_ADDREF(mPrototypeBinding->XBLDocumentInfo());
 }
 
 
@@ -1276,7 +1275,6 @@ nsXBLBinding::DoInitJSClass(JSContext *c
     // we can guarantee that in XBLFinalize this will be non-null.
     nsIXBLDocumentInfo* docInfo = aProtoBinding->XBLDocumentInfo();
     ::JS_SetPrivate(cx, proto, docInfo);
-    NS_ADDREF(docInfo);
 
     if (!::JS_SetReservedSlot(cx, proto, 0, PRIVATE_TO_JSVAL(aProtoBinding))) {
       (nsXBLService::gClassTable)->Remove(&key);
diff --git a/content/xbl/src/nsXBLDocumentInfo.cpp b/content/xbl/src/nsXBLDocumentInfo.cpp
--- a/content/xbl/src/nsXBLDocumentInfo.cpp
+++ b/content/xbl/src/nsXBLDocumentInfo.cpp
@@ -333,7 +333,6 @@ nsXBLDocGlobalObject::EnsureScriptEnviro
   // Add an owning reference from JS back to us. This'll be
   // released when the JSObject is finalized.
   ::JS_SetPrivate(cx, mJSObject, this);
-  NS_ADDREF(this);
   return NS_OK;
 }
 
@@ -579,6 +578,5 @@ nsresult NS_NewXBLDocumentInfo(nsIDocume
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
diff --git a/content/xbl/src/nsXBLEventHandler.cpp b/content/xbl/src/nsXBLEventHandler.cpp
--- a/content/xbl/src/nsXBLEventHandler.cpp
+++ b/content/xbl/src/nsXBLEventHandler.cpp
@@ -212,7 +212,6 @@ NS_NewXBLEventHandler(nsXBLPrototypeHand
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
 
   return NS_OK;
 }
@@ -226,7 +225,6 @@ NS_NewXBLKeyEventHandler(nsIAtom* aEvent
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
 
   return NS_OK;
 }
diff --git a/content/xbl/src/nsXBLInsertionPoint.cpp b/content/xbl/src/nsXBLInsertionPoint.cpp
--- a/content/xbl/src/nsXBLInsertionPoint.cpp
+++ b/content/xbl/src/nsXBLInsertionPoint.cpp
@@ -68,7 +68,6 @@ nsIContent*
 nsIContent*
 nsXBLInsertionPoint::GetInsertionParent()
 {
-  NS_IF_ADDREF(mParentElement);
   return mParentElement;
 }
 
@@ -76,7 +75,6 @@ nsXBLInsertionPoint::GetDefaultContent()
 nsXBLInsertionPoint::GetDefaultContent()
 {
   nsIContent* defaultContent = mDefaultContent;
-  NS_IF_ADDREF(defaultContent);
   return defaultContent;
 }
 
@@ -84,7 +82,6 @@ nsXBLInsertionPoint::GetDefaultContentTe
 nsXBLInsertionPoint::GetDefaultContentTemplate()
 {
   nsIContent* defaultContent = mDefaultContentTemplate;
-  NS_IF_ADDREF(defaultContent);
   return defaultContent;
 }
 
@@ -92,7 +89,6 @@ nsXBLInsertionPoint::ChildAt(PRUint32 aI
 nsXBLInsertionPoint::ChildAt(PRUint32 aIndex)
 {
   nsIContent* result = mElements.ObjectAt(aIndex);
-  NS_IF_ADDREF(result);
   return result;
 }
 
diff --git a/content/xbl/src/nsXBLPrototypeBinding.cpp b/content/xbl/src/nsXBLPrototypeBinding.cpp
--- a/content/xbl/src/nsXBLPrototypeBinding.cpp
+++ b/content/xbl/src/nsXBLPrototypeBinding.cpp
@@ -295,7 +295,6 @@ nsXBLPrototypeBinding::GetBindingElement
 nsXBLPrototypeBinding::GetBindingElement()
 {
   nsIContent* result = mBinding;
-  NS_IF_ADDREF(result);
   return result;
 }
 
diff --git a/content/xbl/src/nsXBLPrototypeHandler.cpp b/content/xbl/src/nsXBLPrototypeHandler.cpp
--- a/content/xbl/src/nsXBLPrototypeHandler.cpp
+++ b/content/xbl/src/nsXBLPrototypeHandler.cpp
@@ -550,7 +550,6 @@ nsXBLPrototypeHandler::GetEventName()
 nsXBLPrototypeHandler::GetEventName()
 {
   nsIAtom* eventName = mEventName;
-  NS_IF_ADDREF(eventName);
   return eventName;
 }
 
diff --git a/content/xbl/src/nsXBLPrototypeResources.cpp b/content/xbl/src/nsXBLPrototypeResources.cpp
--- a/content/xbl/src/nsXBLPrototypeResources.cpp
+++ b/content/xbl/src/nsXBLPrototypeResources.cpp
@@ -58,7 +58,6 @@ nsXBLPrototypeResources::nsXBLPrototypeR
   MOZ_COUNT_CTOR(nsXBLPrototypeResources);
 
   mLoader = new nsXBLResourceLoader(aBinding, this);
-  NS_IF_ADDREF(mLoader);
 }
 
 nsXBLPrototypeResources::~nsXBLPrototypeResources()
diff --git a/content/xbl/src/nsXBLService.cpp b/content/xbl/src/nsXBLService.cpp
--- a/content/xbl/src/nsXBLService.cpp
+++ b/content/xbl/src/nsXBLService.cpp
@@ -617,11 +617,10 @@ nsXBLService::ResolveTag(nsIContent* aCo
   nsIDocument* document = aContent->GetOwnerDoc();
   if (document) {
     *aResult = document->BindingManager()->ResolveTag(aContent, aNameSpaceID);
-    NS_IF_ADDREF(*aResult);
   }
   else {
     *aNameSpaceID = aContent->GetNameSpaceID();
-    NS_ADDREF(*aResult = aContent->Tag());
+    *aResult = aContent->Tag();
   }
 
   return NS_OK;
@@ -931,7 +930,7 @@ nsXBLService::GetBinding(nsIContent* aBo
     if (baseBinding)
       newBinding->SetBaseBinding(baseBinding);
 
-    NS_ADDREF(*aResult = newBinding);
+    *aResult = newBinding;
   }
 
   return NS_OK;
@@ -1072,7 +1071,6 @@ nsXBLService::LoadBindingDocumentInfo(ns
     return NS_OK;
  
   *aResult = info;
-  NS_IF_ADDREF(*aResult);
 
   return NS_OK;
 }
@@ -1219,7 +1217,7 @@ NS_NewXBLService(nsIXBLService** aResult
   if (! result)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult = result);
+  *aResult = result;
 
   // Register the first (and only) nsXBLService as a memory pressure observer
   // so it can flush the LRU list in low-memory situations.
diff --git a/content/xbl/src/nsXBLWindowKeyHandler.cpp b/content/xbl/src/nsXBLWindowKeyHandler.cpp
--- a/content/xbl/src/nsXBLWindowKeyHandler.cpp
+++ b/content/xbl/src/nsXBLWindowKeyHandler.cpp
@@ -606,6 +606,5 @@ NS_NewXBLWindowKeyHandler(nsIDOMElement*
   *aResult = new nsXBLWindowKeyHandler(aElement, aTarget);
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
diff --git a/content/xml/content/src/nsXMLCDATASection.cpp b/content/xml/content/src/nsXMLCDATASection.cpp
--- a/content/xml/content/src/nsXMLCDATASection.cpp
+++ b/content/xml/content/src/nsXMLCDATASection.cpp
@@ -93,7 +93,7 @@ NS_NewXMLCDATASection(nsIContent** aInst
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aInstancePtrResult = instance);
+  *aInstancePtrResult = instance;
 
   return NS_OK;
 }
diff --git a/content/xml/content/src/nsXMLElement.cpp b/content/xml/content/src/nsXMLElement.cpp
--- a/content/xml/content/src/nsXMLElement.cpp
+++ b/content/xml/content/src/nsXMLElement.cpp
@@ -52,7 +52,7 @@ NS_NewXMLElement(nsIContent** aInstanceP
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aInstancePtrResult = it);
+  *aInstancePtrResult = it;
 
   return NS_OK;
 }
@@ -87,7 +87,6 @@ nsXMLElement::QueryInterface(REFNSIID aI
     return PostQueryInterface(aIID, aInstancePtr);
   }
 
-  NS_ADDREF(inst);
 
   *aInstancePtr = inst;
 
diff --git a/content/xml/content/src/nsXMLProcessingInstruction.cpp b/content/xml/content/src/nsXMLProcessingInstruction.cpp
--- a/content/xml/content/src/nsXMLProcessingInstruction.cpp
+++ b/content/xml/content/src/nsXMLProcessingInstruction.cpp
@@ -70,7 +70,7 @@ NS_NewXMLProcessingInstruction(nsIConten
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aInstancePtrResult = instance);
+  *aInstancePtrResult = instance;
 
   return NS_OK;
 }
diff --git a/content/xml/content/src/nsXMLStylesheetPI.cpp b/content/xml/content/src/nsXMLStylesheetPI.cpp
--- a/content/xml/content/src/nsXMLStylesheetPI.cpp
+++ b/content/xml/content/src/nsXMLStylesheetPI.cpp
@@ -270,7 +270,7 @@ NS_NewXMLStylesheetProcessingInstruction
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aInstancePtrResult = instance);
+  *aInstancePtrResult = instance;
 
   return NS_OK;
 }
diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp
--- a/content/xml/document/src/nsXMLContentSink.cpp
+++ b/content/xml/document/src/nsXMLContentSink.cpp
@@ -957,7 +957,6 @@ nsXMLContentSink::SetDocElement(PRInt32 
   }
 
   mDocElement = aContent;
-  NS_ADDREF(mDocElement);
   nsresult rv = mDocument->AppendChildTo(mDocElement, PR_TRUE);
   if (NS_FAILED(rv)) {
     // If we return PR_FALSE here, the caller will bail out because it won't
diff --git a/content/xml/document/src/nsXMLDocument.cpp b/content/xml/document/src/nsXMLDocument.cpp
--- a/content/xml/document/src/nsXMLDocument.cpp
+++ b/content/xml/document/src/nsXMLDocument.cpp
@@ -152,7 +152,6 @@ NS_NewDOMDocument(nsIDOMDocument** aInst
   }
 
   *aInstancePtrResult = doc;
-  NS_ADDREF(*aInstancePtrResult);
 
   return NS_OK;
 }
@@ -164,7 +163,6 @@ NS_NewXMLDocument(nsIDocument** aInstanc
   nsXMLDocument* doc = new nsXMLDocument();
   NS_ENSURE_TRUE(doc, NS_ERROR_OUT_OF_MEMORY);
 
-  NS_ADDREF(doc);
   nsresult rv = doc->Init();
 
   if (NS_FAILED(rv)) {
diff --git a/content/xml/document/src/nsXMLFragmentContentSink.cpp b/content/xml/document/src/nsXMLFragmentContentSink.cpp
--- a/content/xml/document/src/nsXMLFragmentContentSink.cpp
+++ b/content/xml/document/src/nsXMLFragmentContentSink.cpp
@@ -145,7 +145,7 @@ NewXMLFragmentContentSinkHelper(PRBool a
     return NS_ERROR_OUT_OF_MEMORY;
   }
   
-  NS_ADDREF(*aResult = it);
+  *aResult = it;
   
   return NS_OK;
 }
@@ -570,7 +570,7 @@ NS_NewXHTMLParanoidFragmentSink(nsIFragm
   }
   nsresult rv = nsXHTMLParanoidFragmentSink::Init();
   NS_ENSURE_SUCCESS(rv, rv);
-  NS_ADDREF(*aResult = it);
+  *aResult = it;
   
   return NS_OK;
 }
diff --git a/content/xml/document/src/nsXMLPrettyPrinter.cpp b/content/xml/document/src/nsXMLPrettyPrinter.cpp
--- a/content/xml/document/src/nsXMLPrettyPrinter.cpp
+++ b/content/xml/document/src/nsXMLPrettyPrinter.cpp
@@ -183,7 +183,6 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocum
     aDocument->AddObserver(this);
     mDocument = aDocument;
 
-    NS_ADDREF_THIS();
 
     return NS_OK;
 }
@@ -282,6 +281,5 @@ nsresult NS_NewXMLPrettyPrinter(nsXMLPre
 {
     *aPrinter = new nsXMLPrettyPrinter;
     NS_ENSURE_TRUE(*aPrinter, NS_ERROR_OUT_OF_MEMORY);
-    NS_ADDREF(*aPrinter);
     return NS_OK;
 }
diff --git a/content/xslt/src/main/testXalan.cpp b/content/xslt/src/main/testXalan.cpp
--- a/content/xslt/src/main/testXalan.cpp
+++ b/content/xslt/src/main/testXalan.cpp
@@ -185,11 +185,8 @@ setupXalan(const char* aPath, nsIFile** 
     }
     // got conf and conf-gold subdirectories
     *aConf = conf;
-    NS_ADDREF(*aConf);
     *aConfGold = gold;
-    NS_ADDREF(*aConfGold);
     *aTemp = tmpFile;
-    NS_ADDREF(*aTemp);
     return NS_OK;
 }
 
diff --git a/content/xslt/src/xml/txAttr.cpp b/content/xslt/src/xml/txAttr.cpp
--- a/content/xslt/src/xml/txAttr.cpp
+++ b/content/xslt/src/xml/txAttr.cpp
@@ -90,7 +90,6 @@ MBool Attr::getLocalName(nsIAtom** aLoca
   if (!aLocalName)
     return MB_FALSE;
   *aLocalName = mLocalName;
-  NS_ADDREF(*aLocalName);
   return MB_TRUE;
 }
 
diff --git a/content/xslt/src/xml/txElement.cpp b/content/xslt/src/xml/txElement.cpp
--- a/content/xslt/src/xml/txElement.cpp
+++ b/content/xslt/src/xml/txElement.cpp
@@ -103,7 +103,6 @@ MBool Element::getLocalName(nsIAtom** aL
   if (!aLocalName)
     return MB_FALSE;
   *aLocalName = mLocalName;
-  NS_ADDREF(*aLocalName);
   return MB_TRUE;
 }
 
diff --git a/content/xslt/src/xml/txProcessingInstruction.cpp b/content/xslt/src/xml/txProcessingInstruction.cpp
--- a/content/xslt/src/xml/txProcessingInstruction.cpp
+++ b/content/xslt/src/xml/txProcessingInstruction.cpp
@@ -68,6 +68,5 @@ MBool ProcessingInstruction::getLocalNam
   if (!aLocalName)
     return MB_FALSE;
   *aLocalName = mLocalName;
-  NS_ADDREF(*aLocalName);
   return MB_TRUE;
 }
diff --git a/content/xslt/src/xpath/nsXPath1Scheme.cpp b/content/xslt/src/xpath/nsXPath1Scheme.cpp
--- a/content/xslt/src/xpath/nsXPath1Scheme.cpp
+++ b/content/xslt/src/xpath/nsXPath1Scheme.cpp
@@ -219,7 +219,6 @@ nsXPath1SchemeProcessor::Evaluate(nsIDOM
   xpointerResult->GetLength(&count);
   if (NS_SUCCEEDED(rv) && (count > 0)) {
     *aResult = xpointerResult;
-    NS_ADDREF(*aResult);
   }
 
   return rv;
diff --git a/content/xslt/src/xpath/nsXPathEvaluator.cpp b/content/xslt/src/xpath/nsXPathEvaluator.cpp
--- a/content/xslt/src/xpath/nsXPathEvaluator.cpp
+++ b/content/xslt/src/xpath/nsXPathEvaluator.cpp
@@ -139,7 +139,6 @@ nsXPathEvaluator::CreateNSResolver(nsIDO
     *aResult = new nsXPathNSResolver(aNodeResolver);
     NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
 
-    NS_ADDREF(*aResult);
     return NS_OK;
 }
 
@@ -244,7 +243,6 @@ nsXPathEvaluator::CreateExpression(const
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    NS_ADDREF(*aResult);
     return NS_OK;
 }
 
diff --git a/content/xslt/src/xpath/nsXPathResult.cpp b/content/xslt/src/xpath/nsXPathResult.cpp
--- a/content/xslt/src/xpath/nsXPathResult.cpp
+++ b/content/xslt/src/xpath/nsXPathResult.cpp
@@ -147,7 +147,7 @@ nsXPathResult::GetSingleNodeValue(nsIDOM
     }
 
     if (mResultNodes.Count() > 0) {
-        NS_ADDREF(*aSingleNodeValue = mResultNodes[0]);
+        *aSingleNodeValue = mResultNodes[0];
     }
     else {
         *aSingleNodeValue = nsnull;
@@ -192,7 +192,7 @@ nsXPathResult::IterateNext(nsIDOMNode **
     }
 
     if (mCurrentPos < (PRUint32)mResultNodes.Count()) {
-        NS_ADDREF(*aResult = mResultNodes[mCurrentPos++]);
+        *aResult = mResultNodes[mCurrentPos++];
     }
     else {
         *aResult = nsnull;
@@ -208,7 +208,7 @@ nsXPathResult::SnapshotItem(PRUint32 aIn
         return NS_ERROR_DOM_TYPE_ERR;
     }
 
-    NS_IF_ADDREF(*aResult = mResultNodes.SafeObjectAt(aIndex));
+    *aResult = mResultNodes.SafeObjectAt(aIndex);
 
     return NS_OK;
 }
@@ -380,7 +380,7 @@ nsXPathResult::GetExprResult(txAExprResu
     }
 
     if (mResult) {
-        NS_ADDREF(*aExprResult = mResult);
+        *aExprResult = mResult;
 
         return NS_OK;
     }
@@ -404,7 +404,7 @@ nsXPathResult::GetExprResult(txAExprResu
         nodeSet->append(*node);
     }
 
-    NS_ADDREF(*aExprResult = nodeSet);
+    *aExprResult = nodeSet;
 
     return NS_OK;
 }
diff --git a/content/xslt/src/xpath/txCoreFunctionCall.cpp b/content/xslt/src/xpath/txCoreFunctionCall.cpp
--- a/content/xslt/src/xpath/txCoreFunctionCall.cpp
+++ b/content/xslt/src/xpath/txCoreFunctionCall.cpp
@@ -163,7 +163,6 @@ txCoreFunctionCall::evaluate(txIEvalCont
             }
 
             *aResult = resultSet;
-            NS_ADDREF(*aResult);
 
             return NS_OK;
         }
@@ -260,7 +259,7 @@ txCoreFunctionCall::evaluate(txIEvalCont
                 NS_ENSURE_SUCCESS(rv, rv);
             }
 
-            NS_ADDREF(*aResult = strRes);
+            *aResult = strRes;
 
             return NS_OK;
         }
@@ -320,7 +319,6 @@ txCoreFunctionCall::evaluate(txIEvalCont
                 }
             }
             *aResult = strRes;
-            NS_ADDREF(*aResult);
 
             return NS_OK;
         }
@@ -361,7 +359,7 @@ txCoreFunctionCall::evaluate(txIEvalCont
                                                   strRes->mValue);
             }
 
-            NS_ADDREF(*aResult = strRes);
+            *aResult = strRes;
 
             return NS_OK;
         }
@@ -521,7 +519,7 @@ txCoreFunctionCall::evaluate(txIEvalCont
                 }
             }
 
-            NS_ADDREF(*aResult = strRes);
+            *aResult = strRes;
 
             return NS_OK;
         }
@@ -756,7 +754,7 @@ nsresult
 nsresult
 txCoreFunctionCall::getNameAtom(nsIAtom** aAtom)
 {
-    NS_ADDREF(*aAtom = *descriptTable[mType].mName);
+    *aAtom = *descriptTable[mType].mName;
     return NS_OK;
 }
 #endif
diff --git a/content/xslt/src/xpath/txFilterExpr.cpp b/content/xslt/src/xpath/txFilterExpr.cpp
--- a/content/xslt/src/xpath/txFilterExpr.cpp
+++ b/content/xslt/src/xpath/txFilterExpr.cpp
@@ -81,7 +81,6 @@ FilterExpr::evaluate(txIEvalContext* aCo
     NS_ENSURE_SUCCESS(rv, rv);
 
     *aResult = nonShared;
-    NS_ADDREF(*aResult);
 
     return NS_OK;
 } //-- evaluate
diff --git a/content/xslt/src/xpath/txFunctionCall.cpp b/content/xslt/src/xpath/txFunctionCall.cpp
--- a/content/xslt/src/xpath/txFunctionCall.cpp
+++ b/content/xslt/src/xpath/txFunctionCall.cpp
@@ -85,7 +85,6 @@ FunctionCall::evaluateToNodeSet(Expr* aE
 
     *aResult =
         static_cast<txNodeSet*>(static_cast<txAExprResult*>(exprRes));
-    NS_ADDREF(*aResult);
 
     return NS_OK;
 }
diff --git a/content/xslt/src/xpath/txLiteralExpr.cpp b/content/xslt/src/xpath/txLiteralExpr.cpp
--- a/content/xslt/src/xpath/txLiteralExpr.cpp
+++ b/content/xslt/src/xpath/txLiteralExpr.cpp
@@ -44,7 +44,6 @@ txLiteralExpr::evaluate(txIEvalContext* 
     NS_ENSURE_TRUE(mValue, NS_ERROR_OUT_OF_MEMORY);
 
     *aResult = mValue;
-    NS_ADDREF(*aResult);
 
     return NS_OK;
 }
diff --git a/content/xslt/src/xpath/txLocationStep.cpp b/content/xslt/src/xpath/txLocationStep.cpp
--- a/content/xslt/src/xpath/txLocationStep.cpp
+++ b/content/xslt/src/xpath/txLocationStep.cpp
@@ -234,7 +234,7 @@ LocationStep::evaluate(txIEvalContext* a
 
     nodes->unsetReverse();
 
-    NS_ADDREF(*aResult = nodes);
+    *aResult = nodes;
 
     return NS_OK;
 }
diff --git a/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp b/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp
--- a/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp
+++ b/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp
@@ -347,7 +347,6 @@ txXPathNode::txXPathNode(const txXPathNo
 {
     MOZ_COUNT_CTOR(txXPathNode);
     if (mRefCountRoot) {
-        NS_ADDREF(Root());
     }
 }
 
@@ -374,7 +373,6 @@ txXPathNodeUtils::getLocalName(const txX
     if (aNode.isContent()) {
         if (aNode.mNode->IsNodeOfType(nsINode::eELEMENT)) {
             nsIAtom* localName = aNode.Content()->Tag();
-            NS_ADDREF(localName);
 
             return localName;
         }
@@ -392,7 +390,6 @@ txXPathNodeUtils::getLocalName(const txX
 
     nsIAtom* localName = aNode.Content()->
         GetAttrNameAt(aNode.mIndex)->LocalName();
-    NS_ADDREF(localName);
 
     return localName;
 }
diff --git a/content/xslt/src/xpath/txNamedAttributeStep.cpp b/content/xslt/src/xpath/txNamedAttributeStep.cpp
--- a/content/xslt/src/xpath/txNamedAttributeStep.cpp
+++ b/content/xslt/src/xpath/txNamedAttributeStep.cpp
@@ -66,7 +66,7 @@ txNamedAttributeStep::evaluate(txIEvalCo
         rv = nodes->append(walker.getCurrentPosition());
         NS_ENSURE_SUCCESS(rv, rv);
     }
-    NS_ADDREF(*aResult = nodes);
+    *aResult = nodes;
 
     return NS_OK;
 }
diff --git a/content/xslt/src/xpath/txPathExpr.cpp b/content/xslt/src/xpath/txPathExpr.cpp
--- a/content/xslt/src/xpath/txPathExpr.cpp
+++ b/content/xslt/src/xpath/txPathExpr.cpp
@@ -161,7 +161,6 @@ PathExpr::evaluate(txIEvalContext* aCont
     }
 
     *aResult = nodes;
-    NS_ADDREF(*aResult);
     
     return NS_OK;
 } //-- evaluate
diff --git a/content/xslt/src/xpath/txUnionExpr.cpp b/content/xslt/src/xpath/txUnionExpr.cpp
--- a/content/xslt/src/xpath/txUnionExpr.cpp
+++ b/content/xslt/src/xpath/txUnionExpr.cpp
@@ -87,7 +87,6 @@ UnionExpr::evaluate(txIEvalContext* aCon
     }
 
     *aResult = nodes;
-    NS_ADDREF(*aResult);
 
     return NS_OK;
 } //-- evaluate
diff --git a/content/xslt/src/xpath/txXPCOMExtensionFunction.cpp b/content/xslt/src/xpath/txXPCOMExtensionFunction.cpp
--- a/content/xslt/src/xpath/txXPCOMExtensionFunction.cpp
+++ b/content/xslt/src/xpath/txXPCOMExtensionFunction.cpp
@@ -108,7 +108,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 txFunctionEvaluationContext::GetState(nsISupports **aState)
 {
-    NS_IF_ADDREF(*aState = mState);
+    *aState = mState;
 
     return NS_OK;
 }
@@ -411,7 +411,7 @@ txXPCOMExtensionFunctionCall::evaluate(t
         nsXPTCVariant &invokeParam = invokeParams[0];
         invokeParam.type = paramInfo.GetType();
         invokeParam.SetValIsInterface();
-        NS_ADDREF((txIFunctionEvaluationContext*&)invokeParam.val.p = context);
+        (txIFunctionEvaluationContext*&)invokeParam.val.p = context;
 
         // Skip first argument, since it's the context.
         paramStart = 1;
@@ -535,7 +535,7 @@ txXPCOMExtensionFunctionCall::evaluate(t
             txINodeSet *nodeSet = static_cast<txINodeSet*>
                                              (returnParam.val.p);
 
-            NS_ADDREF(*aResult = nodeSet->GetTxNodeSet());
+            *aResult = nodeSet->GetTxNodeSet();
 
             return NS_OK;
         }
@@ -584,7 +584,7 @@ nsresult
 nsresult
 txXPCOMExtensionFunctionCall::getNameAtom(nsIAtom** aAtom)
 {
-    NS_ADDREF(*aAtom = mName);
+    *aAtom = mName;
 
     return NS_OK;
 }
diff --git a/content/xslt/src/xpath/txXPathNode.h b/content/xslt/src/xpath/txXPathNode.h
--- a/content/xslt/src/xpath/txXPathNode.h
+++ b/content/xslt/src/xpath/txXPathNode.h
@@ -99,7 +99,6 @@ private:
     {
         MOZ_COUNT_CTOR(txXPathNode);
         if (aRoot) {
-            NS_ADDREF(aRoot);
         }
     }
 
diff --git a/content/xslt/src/xpath/txXPathTreeWalker.h b/content/xslt/src/xpath/txXPathTreeWalker.h
--- a/content/xslt/src/xpath/txXPathTreeWalker.h
+++ b/content/xslt/src/xpath/txXPathTreeWalker.h
@@ -169,7 +169,6 @@ public:
     static nsIDocument* getDocument(const txXPathNode& aNode);
     static void addRef(const txXPathNode& aNode)
     {
-        NS_ADDREF(aNode.mNode);
     }
     static void release(const txXPathNode& aNode)
     {
@@ -229,7 +228,6 @@ txXPathTreeWalker::moveTo(const txXPathT
         newRoot = mPosition.Root();
     }
     if (root != newRoot) {
-        NS_IF_ADDREF(newRoot);
         NS_IF_RELEASE(root);
     }
 
diff --git a/content/xslt/src/xslt/txCurrentFunctionCall.cpp b/content/xslt/src/xslt/txCurrentFunctionCall.cpp
--- a/content/xslt/src/xslt/txCurrentFunctionCall.cpp
+++ b/content/xslt/src/xslt/txCurrentFunctionCall.cpp
@@ -55,7 +55,6 @@ CurrentFunctionCall::getNameAtom(nsIAtom
 CurrentFunctionCall::getNameAtom(nsIAtom** aAtom)
 {
     *aAtom = txXSLTAtoms::current;
-    NS_ADDREF(*aAtom);
     return NS_OK;
 }
 #endif
diff --git a/content/xslt/src/xslt/txDocumentFunctionCall.cpp b/content/xslt/src/xslt/txDocumentFunctionCall.cpp
--- a/content/xslt/src/xslt/txDocumentFunctionCall.cpp
+++ b/content/xslt/src/xslt/txDocumentFunctionCall.cpp
@@ -159,7 +159,7 @@ DocumentFunctionCall::evaluate(txIEvalCo
             retrieveNode(es, uriStr, baseURI, nodeSet);
         }
         
-        NS_ADDREF(*aResult = nodeSet);
+        *aResult = nodeSet;
         
         return NS_OK;
     }
@@ -170,7 +170,7 @@ DocumentFunctionCall::evaluate(txIEvalCo
     const nsAString* base = baseURISet ? &baseURI : &mBaseURI;
     retrieveNode(es, uriStr, *base, nodeSet);
 
-    NS_ADDREF(*aResult = nodeSet);
+    *aResult = nodeSet;
 
     return NS_OK;
 }
@@ -192,7 +192,6 @@ DocumentFunctionCall::getNameAtom(nsIAto
 DocumentFunctionCall::getNameAtom(nsIAtom** aAtom)
 {
     *aAtom = txXSLTAtoms::document;
-    NS_ADDREF(*aAtom);
     return NS_OK;
 }
 #endif
diff --git a/content/xslt/src/xslt/txEXSLTFunctions.cpp b/content/xslt/src/xslt/txEXSLTFunctions.cpp
--- a/content/xslt/src/xslt/txEXSLTFunctions.cpp
+++ b/content/xslt/src/xslt/txEXSLTFunctions.cpp
@@ -340,7 +340,7 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
                     resultSet->append(*node);
                 }
 
-                NS_ADDREF(*aResult = resultSet);
+                *aResult = resultSet;
             }
 
             return NS_OK;
@@ -359,7 +359,7 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
             AppendASCIItoUTF16(sTypes[exprResult->getResultType()],
                                strRes->mValue);
 
-            NS_ADDREF(*aResult = strRes);
+            *aResult = strRes;
 
             return NS_OK;
         }
@@ -397,7 +397,7 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
                 }
             }
 
-            NS_ADDREF(*aResult = resultSet);
+            *aResult = resultSet;
 
             return NS_OK;
         }
@@ -431,7 +431,7 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
                 }
             }
 
-            NS_ADDREF(*aResult = resultSet);
+            *aResult = resultSet;
 
             return NS_OK;
         }
@@ -475,7 +475,6 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
 
             if (nodes2->isEmpty()) {
                 *aResult = nodes1;
-                NS_ADDREF(*aResult);
 
                 return NS_OK;
             }
@@ -497,7 +496,7 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
                 }
             }
 
-            NS_ADDREF(*aResult = resultSet);
+            *aResult = resultSet;
 
             return NS_OK;
         }
@@ -604,7 +603,7 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
                 NS_ENSURE_SUCCESS(rv, rv);
             }
 
-            NS_ADDREF(*aResult = resultSet);
+            *aResult = resultSet;
 
             return NS_OK;
         }
@@ -651,7 +650,7 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
             NS_ENSURE_SUCCESS(rv, rv);
 
             if (nodes->isEmpty()) {
-                NS_ADDREF(*aResult = nodes);
+                *aResult = nodes;
 
                 return NS_OK;
             }
@@ -684,7 +683,7 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
                 }
             }
 
-            NS_ADDREF(*aResult = resultSet);
+            *aResult = resultSet;
 
             return NS_OK;
         }
@@ -714,7 +713,7 @@ nsresult
 nsresult
 txEXSLTFunctionCall::getNameAtom(nsIAtom **aAtom)
 {
-    NS_ADDREF(*aAtom = *descriptTable[mType].mName);
+    *aAtom = *descriptTable[mType].mName;
     return NS_OK;
 }
 #endif
diff --git a/content/xslt/src/xslt/txExecutionState.cpp b/content/xslt/src/xslt/txExecutionState.cpp
--- a/content/xslt/src/xslt/txExecutionState.cpp
+++ b/content/xslt/src/xslt/txExecutionState.cpp
@@ -422,7 +422,6 @@ txExecutionState::pushTemplateRule(txSty
     mTemplateRules[mTemplateRuleCount].mModeNsId = aMode.mNamespaceID;
     mTemplateRules[mTemplateRuleCount].mModeLocalName = aMode.mLocalName;
     mTemplateRules[mTemplateRuleCount].mParams = aParams;
-    NS_IF_ADDREF(mTemplateRules[mTemplateRuleCount].mModeLocalName);
     ++mTemplateRuleCount;
     
     return NS_OK;
diff --git a/content/xslt/src/xslt/txFormatNumberFunctionCall.cpp b/content/xslt/src/xslt/txFormatNumberFunctionCall.cpp
--- a/content/xslt/src/xslt/txFormatNumberFunctionCall.cpp
+++ b/content/xslt/src/xslt/txFormatNumberFunctionCall.cpp
@@ -424,7 +424,6 @@ txFormatNumberFunctionCall::getNameAtom(
 txFormatNumberFunctionCall::getNameAtom(nsIAtom** aAtom)
 {
     *aAtom = txXSLTAtoms::formatNumber;
-    NS_ADDREF(*aAtom);
     return NS_OK;
 }
 #endif
diff --git a/content/xslt/src/xslt/txGenerateIdFunctionCall.cpp b/content/xslt/src/xslt/txGenerateIdFunctionCall.cpp
--- a/content/xslt/src/xslt/txGenerateIdFunctionCall.cpp
+++ b/content/xslt/src/xslt/txGenerateIdFunctionCall.cpp
@@ -125,7 +125,6 @@ GenerateIdFunctionCall::getNameAtom(nsIA
 GenerateIdFunctionCall::getNameAtom(nsIAtom** aAtom)
 {
     *aAtom = txXSLTAtoms::generateId;
-    NS_ADDREF(*aAtom);
     return NS_OK;
 }
 #endif
diff --git a/content/xslt/src/xslt/txKeyFunctionCall.cpp b/content/xslt/src/xslt/txKeyFunctionCall.cpp
--- a/content/xslt/src/xslt/txKeyFunctionCall.cpp
+++ b/content/xslt/src/xslt/txKeyFunctionCall.cpp
@@ -121,7 +121,6 @@ txKeyFunctionCall::evaluate(txIEvalConte
     }
 
     *aResult = res;
-    NS_ADDREF(*aResult);
 
     return NS_OK;
 }
@@ -143,7 +142,6 @@ txKeyFunctionCall::getNameAtom(nsIAtom**
 txKeyFunctionCall::getNameAtom(nsIAtom** aAtom)
 {
     *aAtom = txXSLTAtoms::key;
-    NS_ADDREF(*aAtom);
     return NS_OK;
 }
 #endif
@@ -222,7 +220,6 @@ txKeyHash::getKeyNodes(const txExpandedN
     txKeyValueHashEntry* valueEntry = mKeyValues.GetEntry(valueKey);
     if (valueEntry) {
         *aResult = valueEntry->mNodeSet;
-        NS_ADDREF(*aResult);
 
         return NS_OK;
     }
@@ -235,7 +232,6 @@ txKeyHash::getKeyNodes(const txExpandedN
         // If aIndexIfNotFound is set then the caller knows this key is
         // indexed, so don't bother investigating.
         *aResult = mEmptyNodeSet;
-        NS_ADDREF(*aResult);
 
         return NS_OK;
     }
@@ -248,7 +244,6 @@ txKeyHash::getKeyNodes(const txExpandedN
         // The key was indexed and apparently didn't contain this value so
         // return the empty nodeset.
         *aResult = mEmptyNodeSet;
-        NS_ADDREF(*aResult);
 
         return NS_OK;
     }
@@ -269,11 +264,9 @@ txKeyHash::getKeyNodes(const txExpandedN
     valueEntry = mKeyValues.GetEntry(valueKey);
     if (valueEntry) {
         *aResult = valueEntry->mNodeSet;
-        NS_ADDREF(*aResult);
     }
     else {
         *aResult = mEmptyNodeSet;
-        NS_ADDREF(*aResult);
     }
 
     return NS_OK;
diff --git a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
--- a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
+++ b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp
@@ -774,7 +774,6 @@ TX_CompileStylesheet(nsINode* aNode, txM
     NS_ENSURE_SUCCESS(rv, rv);
     
     *aStylesheet = compiler->getStylesheet();
-    NS_ADDREF(*aStylesheet);
 
     return NS_OK;
 }
diff --git a/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp b/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
--- a/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
+++ b/content/xslt/src/xslt/txMozillaXSLTProcessor.cpp
@@ -254,14 +254,12 @@ public:
         }
 
         *aValue = mTxValue;
-        NS_ADDREF(*aValue);
 
         return NS_OK;
     }
     nsresult getValue(nsIVariant** aValue)
     {
         *aValue = mValue;
-        NS_ADDREF(*aValue);
         return NS_OK;
     }
     nsIVariant* getValue()
@@ -1324,7 +1322,6 @@ txVariable::Convert(nsIVariant *aValue, 
             *aResult = new NumberResult(value);
             NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
 
-            NS_ADDREF(*aResult);
 
             return NS_OK;
         }
@@ -1339,7 +1336,6 @@ txVariable::Convert(nsIVariant *aValue, 
             *aResult = new BooleanResult(value);
             NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
 
-            NS_ADDREF(*aResult);
 
             return NS_OK;
         }
@@ -1363,7 +1359,6 @@ txVariable::Convert(nsIVariant *aValue, 
             *aResult = new StringResult(value);
             NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
 
-            NS_ADDREF(*aResult);
 
             return NS_OK;
         }
@@ -1388,7 +1383,6 @@ txVariable::Convert(nsIVariant *aValue, 
                     return NS_ERROR_OUT_OF_MEMORY;
                 }
 
-                NS_ADDREF(*aResult);
 
                 return NS_OK;
             }
@@ -1422,7 +1416,7 @@ txVariable::Convert(nsIVariant *aValue, 
                     nodeSet->add(*xpathNode);
                 }
 
-                NS_ADDREF(*aResult = nodeSet);
+                *aResult = nodeSet;
 
                 return NS_OK;
             }
@@ -1460,7 +1454,6 @@ txVariable::Convert(nsIVariant *aValue, 
                     return NS_ERROR_OUT_OF_MEMORY;
                 }
 
-                NS_ADDREF(*aResult);
 
                 return NS_OK;
             }
@@ -1515,7 +1508,7 @@ txVariable::Convert(nsIVariant *aValue, 
 
             nsMemory::Free(array);
 
-            NS_ADDREF(*aResult = nodeSet);
+            *aResult = nodeSet;
 
             return NS_OK;
         }
diff --git a/content/xslt/src/xslt/txNodeSorter.cpp b/content/xslt/src/xslt/txNodeSorter.cpp
--- a/content/xslt/src/xslt/txNodeSorter.cpp
+++ b/content/xslt/src/xslt/txNodeSorter.cpp
@@ -159,7 +159,7 @@ txNodeSorter::sortNodeSet(txNodeSet* aNo
                           txNodeSet** aResult)
 {
     if (mNKeys == 0 || aNodes->isEmpty()) {
-        NS_ADDREF(*aResult = aNodes);
+        *aResult = aNodes;
 
         return NS_OK;
     }
@@ -224,7 +224,7 @@ txNodeSorter::sortNodeSet(txNodeSet* aNo
     PR_Free(mem);
     delete aEs->popEvalContext();
 
-    NS_ADDREF(*aResult = sortedNodes);
+    *aResult = sortedNodes;
 
     return NS_OK;
 }
diff --git a/content/xslt/src/xslt/txRtfHandler.cpp b/content/xslt/src/xslt/txRtfHandler.cpp
--- a/content/xslt/src/xslt/txRtfHandler.cpp
+++ b/content/xslt/src/xslt/txRtfHandler.cpp
@@ -94,7 +94,6 @@ txRtfHandler::getAsRTF(txAExprResult** a
     *aResult = new txResultTreeFragment(mBuffer);
     NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
 
-    NS_ADDREF(*aResult);
 
     return NS_OK;
 }
diff --git a/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp b/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp
--- a/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp
+++ b/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp
@@ -108,7 +108,6 @@ TX_CompileStylesheetPath(const txParsedU
         return rv;
     };
     *aResult = driver->mCompiler->getStylesheet();
-    NS_ADDREF(*aResult);
     return NS_OK;
 }
 
diff --git a/content/xslt/src/xslt/txStylesheetCompiler.cpp b/content/xslt/src/xslt/txStylesheetCompiler.cpp
--- a/content/xslt/src/xslt/txStylesheetCompiler.cpp
+++ b/content/xslt/src/xslt/txStylesheetCompiler.cpp
@@ -918,7 +918,7 @@ nsresult
 nsresult
 txErrorFunctionCall::getNameAtom(nsIAtom** aAtom)
 {
-    NS_IF_ADDREF(*aAtom = mName);
+    *aAtom = mName;
 
     return NS_OK;
 }
diff --git a/content/xslt/src/xslt/txVariableMap.h b/content/xslt/src/xslt/txVariableMap.h
--- a/content/xslt/src/xslt/txVariableMap.h
+++ b/content/xslt/src/xslt/txVariableMap.h
@@ -75,7 +75,6 @@ txVariableMap::bindVariable(const txExpa
     NS_ASSERTION(aValue, "can't add null-variables to a txVariableMap");
     nsresult rv = mMap.add(aName, aValue);
     if (NS_SUCCEEDED(rv)) {
-        NS_ADDREF(aValue);
     }
     else if (rv == NS_ERROR_XSLT_ALREADY_SET) {
         rv = NS_ERROR_XSLT_VAR_ALREADY_SET;
@@ -88,7 +87,6 @@ txVariableMap::getVariable(const txExpan
 {
     *aResult = mMap.get(aName);
     if (*aResult) {
-        NS_ADDREF(*aResult);
     }
 }
 
diff --git a/content/xslt/src/xslt/txXSLTEnvironmentFunctionCall.cpp b/content/xslt/src/xslt/txXSLTEnvironmentFunctionCall.cpp
--- a/content/xslt/src/xslt/txXSLTEnvironmentFunctionCall.cpp
+++ b/content/xslt/src/xslt/txXSLTEnvironmentFunctionCall.cpp
@@ -164,7 +164,6 @@ txXSLTEnvironmentFunctionCall::getNameAt
     *aAtom = mType == SYSTEM_PROPERTY ? txXSLTAtoms::systemProperty :
              mType == ELEMENT_AVAILABLE ? txXSLTAtoms::elementAvailable :
              txXSLTAtoms::functionAvailable;
-    NS_ADDREF(*aAtom);
 
     return NS_OK;
 }
diff --git a/content/xtf/src/nsXMLContentBuilder.cpp b/content/xtf/src/nsXMLContentBuilder.cpp
--- a/content/xtf/src/nsXMLContentBuilder.cpp
+++ b/content/xtf/src/nsXMLContentBuilder.cpp
@@ -105,7 +105,6 @@ NS_NewXMLContentBuilder(nsIXMLContentBui
   if (! result)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(result);
   *aResult = result;
   return NS_OK;
 }
diff --git a/content/xtf/src/nsXTFElementWrapper.cpp b/content/xtf/src/nsXTFElementWrapper.cpp
--- a/content/xtf/src/nsXTFElementWrapper.cpp
+++ b/content/xtf/src/nsXTFElementWrapper.cpp
@@ -122,12 +122,10 @@ nsXTFElementWrapper::QueryInterface(REFN
 
   if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
     *aInstancePtr = static_cast<nsIClassInfo*>(this);
-    NS_ADDREF_THIS();
     return NS_OK;
   }
   if (aIID.Equals(NS_GET_IID(nsIXTFElementWrapper))) {
     *aInstancePtr = static_cast<nsIXTFElementWrapper*>(this);
-    NS_ADDREF_THIS();
     return NS_OK;
   }
 
@@ -600,7 +598,7 @@ nsXTFElementWrapper::Clone(nsINodeInfo *
         }
       }
     }
-    NS_ADDREF(*aResult = it);
+    *aResult = it;
   }
 
   // XXX CloneState should take |const nIDOMElement*|
@@ -809,7 +807,6 @@ nsXTFElementWrapper::GetElementNode(nsID
 nsXTFElementWrapper::GetElementNode(nsIDOMElement * *aElementNode)
 {
   *aElementNode = (nsIDOMElement*)this;
-  NS_ADDREF(*aElementNode);
   return NS_OK;
 }
 
@@ -835,7 +832,6 @@ nsXTFElementWrapper::GetDocumentFrameEle
     return NS_ERROR_FAILURE;
   }
   *aDocumentFrameElement = pidomwin->GetFrameElementInternal();
-  NS_IF_ADDREF(*aDocumentFrameElement);
   return NS_OK;
 }
 
@@ -1009,7 +1005,6 @@ NS_NewXTFElementWrapper(nsIXTFElement* a
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(result);
 
   nsresult rv = result->Init();
   if (NS_FAILED(rv)) {
diff --git a/content/xtf/src/nsXTFInterfaceAggregator.cpp b/content/xtf/src/nsXTFInterfaceAggregator.cpp
--- a/content/xtf/src/nsXTFInterfaceAggregator.cpp
+++ b/content/xtf/src/nsXTFInterfaceAggregator.cpp
@@ -140,7 +140,6 @@ nsXTFInterfaceAggregator::QueryInterface
 
   if (aIID.Equals(mIID)) {
     *aInstancePtr = mXPTCStub;
-    NS_ADDREF_THIS();
     return NS_OK;
   }
 
diff --git a/content/xtf/src/nsXTFService.cpp b/content/xtf/src/nsXTFService.cpp
--- a/content/xtf/src/nsXTFService.cpp
+++ b/content/xtf/src/nsXTFService.cpp
@@ -86,7 +86,6 @@ NS_NewXTFService(nsIXTFService** aResult
   if (! result)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(result);
   *aResult = result;
   return NS_OK;
 }
diff --git a/content/xtf/src/nsXTFWeakTearoff.cpp b/content/xtf/src/nsXTFWeakTearoff.cpp
--- a/content/xtf/src/nsXTFWeakTearoff.cpp
+++ b/content/xtf/src/nsXTFWeakTearoff.cpp
@@ -123,7 +123,6 @@ nsXTFWeakTearoff::QueryInterface(REFNSII
 
   if (aIID.Equals(mIID) || aIID.Equals(NS_GET_IID(nsISupports))) {
     *aInstancePtr = mXPTCStub;
-    NS_ADDREF_THIS();
     return NS_OK;
   }
   // we can't map QI onto the obj, because the xpcom wrapper otherwise
diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -285,7 +285,6 @@ nsXULElement::Create(nsXULPrototypeEleme
 {
     nsXULElement *element = new nsXULElement(aNodeInfo);
     if (element) {
-        NS_ADDREF(element);
 
         element->mPrototype = aPrototype;
         if (aPrototype->mHasIdAttribute) {
@@ -351,7 +350,7 @@ nsXULElement::Create(nsXULPrototypeEleme
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    NS_ADDREF(*aResult = element);
+    *aResult = element;
 
     return NS_OK;
 }
@@ -367,7 +366,7 @@ NS_NewXULElement(nsIContent** aResult, n
     nsXULElement* element = new nsXULElement(aNodeInfo);
     NS_ENSURE_TRUE(element, NS_ERROR_OUT_OF_MEMORY);
 
-    NS_ADDREF(*aResult = element);
+    *aResult = element;
 
     return NS_OK;
 }
@@ -420,7 +419,6 @@ nsXULElement::QueryInterface(REFNSIID aI
         return PostQueryInterface(aIID, aInstancePtr);
     }
 
-    NS_ADDREF(inst);
  
     *aInstancePtr = inst;
     return NS_OK;
@@ -463,7 +461,7 @@ nsXULElement::Clone(nsINodeInfo *aNodeIn
 
     nsresult rv = CopyInnerTo(element);
     if (NS_SUCCEEDED(rv)) {
-        NS_ADDREF(*aResult = element);
+        *aResult = element;
     }
 
     return rv;
@@ -490,7 +488,7 @@ nsXULElement::GetElementsByAttribute(con
                           kNameSpaceID_Unknown);
     NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
 
-    NS_ADDREF(*aReturn = list);
+    *aReturn = list;
     return NS_OK;
 }
 
@@ -524,7 +522,7 @@ nsXULElement::GetElementsByAttributeNS(c
                           nameSpaceId);
     NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
 
-    NS_ADDREF(*aReturn = list);
+    *aReturn = list;
     return NS_OK;
 }
 
@@ -551,7 +549,7 @@ nsXULElement::GetEventListenerManagerFor
 
         nsresult rv = piTarget->GetListenerManager(PR_TRUE, aManager);
         if (NS_SUCCEEDED(rv)) {
-            NS_ADDREF(*aTarget = window);
+            *aTarget = window;
         }
         *aDefer = PR_FALSE;
         return rv;
@@ -1924,7 +1922,6 @@ nsXULElement::GetControllers(nsIControll
     }
 
     *aResult = Controllers();
-    NS_IF_ADDREF(*aResult);
     return NS_OK;
 }
 
@@ -2045,7 +2042,7 @@ nsXULElement::GetStyle(nsIDOMCSSStyleDec
         SetFlags(NODE_MAY_HAVE_STYLE);
     }
 
-    NS_IF_ADDREF(*aStyle = slots->mStyle);
+    *aStyle = slots->mStyle;
 
     return NS_OK;
 }
@@ -2083,7 +2080,7 @@ nsXULElement::GetFrameLoader(nsIFrameLoa
     *aFrameLoader = nsnull;
     nsXULSlots* slots = static_cast<nsXULSlots*>(GetExistingSlots());
     if (slots) {
-        NS_IF_ADDREF(*aFrameLoader = slots->mFrameLoader);
+        *aFrameLoader = slots->mFrameLoader;
     }
     return NS_OK;
 }
diff --git a/content/xul/content/src/nsXULPopupListener.cpp b/content/xul/content/src/nsXULPopupListener.cpp
--- a/content/xul/content/src/nsXULPopupListener.cpp
+++ b/content/xul/content/src/nsXULPopupListener.cpp
@@ -339,7 +339,6 @@ GetImmediateChild(nsIContent* aContent, 
     nsIContent *child = aContent->GetChildAt(i);
     if (child->Tag() == aTag) {
       *aResult = child;
-      NS_ADDREF(*aResult);
       return;
     }
   }
@@ -486,6 +485,5 @@ NS_NewXULPopupListener(nsIDOMElement* aE
       return NS_ERROR_OUT_OF_MEMORY;
 
     *aListener = static_cast<nsIDOMMouseListener *>(pl);
-    NS_ADDREF(*aListener);
     return NS_OK;
 }
diff --git a/content/xul/document/src/nsXULContentSink.cpp b/content/xul/document/src/nsXULContentSink.cpp
--- a/content/xul/document/src/nsXULContentSink.cpp
+++ b/content/xul/document/src/nsXULContentSink.cpp
@@ -317,7 +317,6 @@ XULContentSinkImpl::SetParser(nsIParser*
 {
     NS_IF_RELEASE(mParser);
     mParser = aParser;
-    NS_IF_ADDREF(mParser);
     return NS_OK;
 }
 
diff --git a/content/xul/document/src/nsXULControllers.cpp b/content/xul/document/src/nsXULControllers.cpp
--- a/content/xul/document/src/nsXULControllers.cpp
+++ b/content/xul/document/src/nsXULControllers.cpp
@@ -91,7 +91,6 @@ NS_NewXULControllers(nsISupports* aOuter
     return NS_ERROR_OUT_OF_MEMORY;
   
   nsresult rv;
-  NS_ADDREF(controllers);
   rv = controllers->QueryInterface(aIID, aResult);
   NS_RELEASE(controllers);
   return rv;
@@ -129,7 +128,6 @@ nsXULControllers::GetControllerForComman
         controller->SupportsCommand(aCommand, &supportsCommand);
         if (supportsCommand) {
           *_retval = controller;
-          NS_ADDREF(*_retval);
           return NS_OK;
         }
       }
diff --git a/content/xul/document/src/nsXULControllers.h b/content/xul/document/src/nsXULControllers.h
--- a/content/xul/document/src/nsXULControllers.h
+++ b/content/xul/document/src/nsXULControllers.h
@@ -68,7 +68,7 @@ public:
 
     nsresult                GetController(nsIController **outController)
                             {
-                              NS_IF_ADDREF(*outController = mController);
+                              *outController = mController;
                               return NS_OK;
                             }
     
diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/nsXULDocument.cpp
@@ -295,7 +295,6 @@ NS_NewXULDocument(nsIXULDocument** resul
     if (! doc)
         return NS_ERROR_OUT_OF_MEMORY;
 
-    NS_ADDREF(doc);
 
     nsresult rv;
     if (NS_FAILED(rv = doc->Init())) {
@@ -477,7 +476,6 @@ nsXULDocument::StartDocumentLoad(const c
         }
     }
 
-    NS_IF_ADDREF(*aDocListener);
     return NS_OK;
 }
 
@@ -1131,7 +1129,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsXULDocument::GetScriptGlobalObjectOwner(nsIScriptGlobalObjectOwner** aGlobalOwner)
 {
-    NS_IF_ADDREF(*aGlobalOwner = mMasterPrototype);
+    *aGlobalOwner = mMasterPrototype;
     return NS_OK;
 }
 
@@ -1158,7 +1156,7 @@ nsXULDocument::GetElementsByAttribute(co
                                             kNameSpaceID_Unknown);
     NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
     
-    NS_ADDREF(*aReturn = list);
+    *aReturn = list;
     return NS_OK;
 }
 
@@ -1190,7 +1188,7 @@ nsXULDocument::GetElementsByAttributeNS(
                                             nameSpaceId);
     NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
 
-    NS_ADDREF(*aReturn = list);
+    *aReturn = list;
     return NS_OK;
 }
 
@@ -1499,14 +1497,13 @@ nsXULDocument::GetTooltipNode(nsIDOMNode
         return NS_ERROR_DOM_SECURITY_ERR;
     }
     *aNode = mTooltipNode;
-    NS_IF_ADDREF(*aNode);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXULDocument::TrustedGetTooltipNode(nsIDOMNode** aNode)
 {
-    NS_IF_ADDREF(*aNode = mTooltipNode);
+    *aNode = mTooltipNode;
     return NS_OK;
 }
 
@@ -1522,7 +1519,6 @@ nsXULDocument::GetCommandDispatcher(nsID
 nsXULDocument::GetCommandDispatcher(nsIDOMXULCommandDispatcher** aTracker)
 {
     *aTracker = mCommandDispatcher;
-    NS_IF_ADDREF(*aTracker);
     return NS_OK;
 }
 
@@ -2043,7 +2039,6 @@ nsXULDocument::PrepareToLoadPrototype(ns
     parser->SetContentSink(sink); // grabs a reference to the parser
 
     *aResult = parser;
-    NS_ADDREF(*aResult);
     return NS_OK;
 }
 
@@ -2212,7 +2207,6 @@ nsXULDocument::ContextStack::Push(nsXULP
 
     entry->mPrototype = aPrototype;
     entry->mElement   = aElement;
-    NS_IF_ADDREF(entry->mElement);
     entry->mIndex     = 0;
 
     entry->mNext = mTop;
@@ -2247,7 +2241,6 @@ nsXULDocument::ContextStack::Peek(nsXULP
 
     *aPrototype = mTop->mPrototype;
     *aElement   = mTop->mElement;
-    NS_IF_ADDREF(*aElement);
     *aIndex     = mTop->mIndex;
 
     return NS_OK;
@@ -2680,7 +2673,6 @@ nsXULDocument::LoadOverlayInternal(nsIUR
         if (! parserObserver)
             return NS_ERROR_OUT_OF_MEMORY;
 
-        NS_ADDREF(parserObserver);
         parser->Parse(aURI, parserObserver);
         NS_RELEASE(parserObserver);
 
@@ -3246,7 +3238,6 @@ nsXULDocument::LoadScript(nsXULPrototype
         // Remember to ResumeWalk this document when the load completes.
         mNextSrcLoadWaiter = aScriptProto->mSrcLoadWaiters;
         aScriptProto->mSrcLoadWaiters = this;
-        NS_ADDREF_THIS();
     }
     else {
         nsILoadGroup* group = do_QueryReferent(mDocumentLoadGroup);
@@ -3559,7 +3550,7 @@ nsXULDocument::CreateOverlayElement(nsXU
     rv = AddForwardReference(fwdref);
     if (NS_FAILED(rv)) return rv;
 
-    NS_ADDREF(*aResult = element);
+    *aResult = element;
     return NS_OK;
 }
 
@@ -4315,7 +4306,6 @@ nsXULDocument::CachedChromeStreamListene
     : mDocument(aDocument),
       mProtoLoaded(aProtoLoaded)
 {
-    NS_ADDREF(mDocument);
 }
 
 
@@ -4435,7 +4425,7 @@ nsXULDocument::GetFocusController(nsIFoc
     nsIInterfaceRequestor* ir = do_QueryReferent(mDocumentContainer);
     nsPIDOMWindow* windowPrivate = do_GetInterface(ir);
     if (windowPrivate) {
-        NS_IF_ADDREF(*aFocusController = windowPrivate->GetRootFocusController());
+        *aFocusController = windowPrivate->GetRootFocusController();
     } else
         *aFocusController = nsnull;
 }
diff --git a/content/xul/document/src/nsXULPrototypeCache.cpp b/content/xul/document/src/nsXULPrototypeCache.cpp
--- a/content/xul/document/src/nsXULPrototypeCache.cpp
+++ b/content/xul/document/src/nsXULPrototypeCache.cpp
@@ -643,7 +643,7 @@ nsXULFastLoadFileIO::GetInputStream(nsII
         if (NS_FAILED(rv)) return rv;
     }
 
-    NS_ADDREF(*aResult = mInputStream);
+    *aResult = mInputStream;
     return NS_OK;
 }
 
@@ -668,7 +668,7 @@ nsXULFastLoadFileIO::GetOutputStream(nsI
         if (NS_FAILED(rv)) return rv;
     }
 
-    NS_ADDREF(*aResult = mOutputStream);
+    *aResult = mOutputStream;
     return NS_OK;
 }
 
@@ -888,8 +888,8 @@ nsXULPrototypeCache::StartFastLoad(nsIUR
     // and commit locals to globals.
     mFastLoadURITable.Put(aURI, 1);
 
-    NS_ADDREF(gFastLoadService = fastLoadService);
-    NS_ADDREF(gFastLoadFile = file);
+    gFastLoadService = fastLoadService;
+    gFastLoadFile = file;
     return NS_OK;
 }
 
diff --git a/content/xul/document/src/nsXULPrototypeDocument.cpp b/content/xul/document/src/nsXULPrototypeDocument.cpp
--- a/content/xul/document/src/nsXULPrototypeDocument.cpp
+++ b/content/xul/document/src/nsXULPrototypeDocument.cpp
@@ -218,7 +218,6 @@ NS_NewXULPrototypeDocument(nsXULPrototyp
         return rv;
     }
 
-    NS_ADDREF(*aResult);
     return rv;
 }
 
@@ -240,7 +239,6 @@ nsXULPrototypeDocument::NewXULPDGlobalOb
             gSystemGlobal = new nsXULPDGlobalObject(nsnull);
             if (! gSystemGlobal)
                 return nsnull;
-            NS_ADDREF(gSystemGlobal);
         }
         global = gSystemGlobal;
     } else {
@@ -704,7 +702,6 @@ nsXULPDGlobalObject::EnsureScriptEnviron
       // Add an owning reference from JS back to us. This'll be
       // released when the JSObject is finalized.
       ::JS_SetPrivate(cx, newGlob, this);
-      NS_ADDREF(this);
     }
 
     NS_ENSURE_SUCCESS(rv, nsnull);
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
@@ -268,7 +268,6 @@ nsBindingValues::GetAssignmentFor(nsXULT
         if (idx >= 0) {
             *aValue = mValues[idx];
             if (*aValue) {
-                NS_ADDREF(*aValue);
             }
             else {
                 nsXULTemplateQueryProcessorRDF* processor = aResult->GetProcessor();
diff --git a/content/xul/templates/src/nsRDFQuery.cpp b/content/xul/templates/src/nsRDFQuery.cpp
--- a/content/xul/templates/src/nsRDFQuery.cpp
+++ b/content/xul/templates/src/nsRDFQuery.cpp
@@ -75,7 +75,6 @@ nsRDFQuery::UseCachedResults(nsISimpleEn
 nsRDFQuery::UseCachedResults(nsISimpleEnumerator** aResults)
 {
     *aResults = mCachedResults;
-    NS_IF_ADDREF(*aResults);
 
     mCachedResults = nsnull;
 }
diff --git a/content/xul/templates/src/nsRDFQuery.h b/content/xul/templates/src/nsRDFQuery.h
--- a/content/xul/templates/src/nsRDFQuery.h
+++ b/content/xul/templates/src/nsRDFQuery.h
@@ -94,7 +94,6 @@ public:
     void GetQueryNode(nsIDOMNode** aQueryNode)
     {
        *aQueryNode = mQueryNode;
-       NS_IF_ADDREF(*aQueryNode);
     }
 
     void SetQueryNode(nsIDOMNode* aQueryNode)
diff --git a/content/xul/templates/src/nsResourceSet.cpp b/content/xul/templates/src/nsResourceSet.cpp
--- a/content/xul/templates/src/nsResourceSet.cpp
+++ b/content/xul/templates/src/nsResourceSet.cpp
@@ -102,7 +102,6 @@ nsResourceSet::Add(nsIRDFResource* aReso
     }
 
     mResources[mCount++] = aResource;
-    NS_ADDREF(aResource);
     return NS_OK;
 }
 
diff --git a/content/xul/templates/src/nsRuleNetwork.cpp b/content/xul/templates/src/nsRuleNetwork.cpp
--- a/content/xul/templates/src/nsRuleNetwork.cpp
+++ b/content/xul/templates/src/nsRuleNetwork.cpp
@@ -154,7 +154,6 @@ nsAssignmentSet::GetAssignmentFor(nsIAto
     for (ConstIterator assignment = First(); assignment != Last(); ++assignment) {
         if (assignment->mVariable == aVariable) {
             *aValue = assignment->mValue;
-            NS_IF_ADDREF(*aValue);
             return PR_TRUE;
         }
     }
diff --git a/content/xul/templates/src/nsRuleNetwork.h b/content/xul/templates/src/nsRuleNetwork.h
--- a/content/xul/templates/src/nsRuleNetwork.h
+++ b/content/xul/templates/src/nsRuleNetwork.h
@@ -142,7 +142,6 @@ public:
     MemoryElementSet& operator=(const MemoryElementSet& aSet) {
         NS_IF_RELEASE(mElements);
         mElements = aSet.mElements;
-        NS_IF_ADDREF(mElements);
         return *this; }
         
     
@@ -160,7 +159,6 @@ public:
         ConstIterator& operator=(const ConstIterator& aConstIterator) {
             NS_IF_RELEASE(mCurrent);
             mCurrent = aConstIterator.mCurrent;
-            NS_IF_ADDREF(mCurrent);
             return *this; }
 
         ~ConstIterator() { NS_IF_RELEASE(mCurrent); }
@@ -169,7 +167,6 @@ public:
             List* next = mCurrent->mNext;
             NS_RELEASE(mCurrent);
             mCurrent = next;
-            NS_IF_ADDREF(mCurrent);
             return *this; }
 
         ConstIterator operator++(int) {
@@ -177,7 +174,6 @@ public:
             List* next = mCurrent->mNext;
             NS_RELEASE(mCurrent);
             mCurrent = next;
-            NS_IF_ADDREF(mCurrent);
             return result; }
 
         const MemoryElement& operator*() const {
@@ -282,7 +278,6 @@ public:
     nsAssignmentSet& operator=(const nsAssignmentSet& aSet) {
         NS_IF_RELEASE(mAssignments);
         mAssignments = aSet.mAssignments;
-        NS_IF_ADDREF(mAssignments);
         return *this; }
 
     
@@ -300,7 +295,6 @@ public:
         ConstIterator& operator=(const ConstIterator& aConstIterator) {
             NS_IF_RELEASE(mCurrent);
             mCurrent = aConstIterator.mCurrent;
-            NS_IF_ADDREF(mCurrent);
             return *this; }
 
         ~ConstIterator() { NS_IF_RELEASE(mCurrent); }
@@ -309,7 +303,6 @@ public:
             List* next = mCurrent->mNext;
             NS_RELEASE(mCurrent);
             mCurrent = next;
-            NS_IF_ADDREF(mCurrent);
             return *this; }
 
         ConstIterator operator++(int) {
@@ -317,7 +310,6 @@ public:
             List* next = mCurrent->mNext;
             NS_RELEASE(mCurrent);
             mCurrent = next;
-            NS_IF_ADDREF(mCurrent);
             return result; }
 
         const nsAssignment& operator*() const {
diff --git a/content/xul/templates/src/nsTemplateMap.h b/content/xul/templates/src/nsTemplateMap.h
--- a/content/xul/templates/src/nsTemplateMap.h
+++ b/content/xul/templates/src/nsTemplateMap.h
@@ -110,7 +110,7 @@ public:
             reinterpret_cast<Entry*>(PL_DHashTableOperate(&mTable, aContent, PL_DHASH_LOOKUP));
 
         if (PL_DHASH_ENTRY_IS_BUSY(&entry->mHdr))
-            NS_IF_ADDREF(*aResult = entry->mTemplate);
+            *aResult = entry->mTemplate;
         else
             *aResult = nsnull;
     }
diff --git a/content/xul/templates/src/nsTemplateRule.cpp b/content/xul/templates/src/nsTemplateRule.cpp
--- a/content/xul/templates/src/nsTemplateRule.cpp
+++ b/content/xul/templates/src/nsTemplateRule.cpp
@@ -303,7 +303,6 @@ nsTemplateRule::GetAction(nsIContent** a
 nsTemplateRule::GetAction(nsIContent** aAction) const
 {
     *aAction = mAction;
-    NS_IF_ADDREF(*aAction);
     return NS_OK;
 }
 
@@ -311,7 +310,6 @@ nsTemplateRule::GetRuleNode(nsIDOMNode**
 nsTemplateRule::GetRuleNode(nsIDOMNode** aRuleNode) const
 {
     *aRuleNode = mRuleNode;
-    NS_IF_ADDREF(*aRuleNode);
     return NS_OK;
 }
 
diff --git a/content/xul/templates/src/nsXMLBinding.cpp b/content/xul/templates/src/nsXMLBinding.cpp
--- a/content/xul/templates/src/nsXMLBinding.cpp
+++ b/content/xul/templates/src/nsXMLBinding.cpp
@@ -115,7 +115,6 @@ nsXMLBindingValues::GetAssignmentFor(nsX
     }
   }
 
-  NS_IF_ADDREF(*aValue);
 }
 
 void
diff --git a/content/xul/templates/src/nsXULContentBuilder.cpp b/content/xul/templates/src/nsXULContentBuilder.cpp
--- a/content/xul/templates/src/nsXULContentBuilder.cpp
+++ b/content/xul/templates/src/nsXULContentBuilder.cpp
@@ -459,7 +459,6 @@ NS_NewXULContentBuilder(nsISupports* aOu
     if (!result)
         return NS_ERROR_OUT_OF_MEMORY;
 
-    NS_ADDREF(result); // stabilize
 
     rv = result->InitGlobals();
 
@@ -681,7 +680,6 @@ nsXULContentBuilder::BuildContentFromTem
                 // this -before- we recurse!
                 if (aContainer && !*aContainer) {
                     *aContainer = aRealNode;
-                    NS_ADDREF(*aContainer);
 
                     PRUint32 indx = aRealNode->GetChildCount();
 
@@ -794,7 +792,6 @@ nsXULContentBuilder::BuildContentFromTem
             // first element that we've generated.
             if (aContainer && !*aContainer) {
                 *aContainer = aRealNode;
-                NS_ADDREF(*aContainer);
 
                 PRUint32 indx = aRealNode->GetChildCount();
 
@@ -1485,7 +1482,6 @@ nsXULContentBuilder::EnsureElementHasGen
             return rv;
 
         *result = element;
-        NS_ADDREF(*result);
         return NS_ELEMENT_GOT_CREATED;
     }
     else {
@@ -1631,7 +1627,6 @@ nsXULContentBuilder::CreateElement(PRInt
         return rv;
 
     *aResult = result;
-    NS_ADDREF(*aResult);
     return NS_OK;
 }
 
@@ -1778,7 +1773,6 @@ nsXULContentBuilder::GetResultForContent
             *aResult = nsnull;
     }
 
-    NS_IF_ADDREF(*aResult);
     return NS_OK;
 }
 
diff --git a/content/xul/templates/src/nsXULContentUtils.cpp b/content/xul/templates/src/nsXULContentUtils.cpp
--- a/content/xul/templates/src/nsXULContentUtils.cpp
+++ b/content/xul/templates/src/nsXULContentUtils.cpp
@@ -207,7 +207,7 @@ nsXULContentUtils::FindChildByTag(nsICon
         nsIContent *kid = aElement->GetChildAt(i);
 
         if (kid->NodeInfo()->Equals(aTag, aNameSpaceID)) {
-            NS_ADDREF(*aResult = kid);
+            *aResult = kid;
 
             return NS_OK;
         }
diff --git a/content/xul/templates/src/nsXULSortService.cpp b/content/xul/templates/src/nsXULSortService.cpp
--- a/content/xul/templates/src/nsXULSortService.cpp
+++ b/content/xul/templates/src/nsXULSortService.cpp
@@ -512,6 +512,5 @@ NS_NewXULSortService(nsIXULSortService**
   if (!*sortService)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*sortService);
   return NS_OK;
 }
diff --git a/content/xul/templates/src/nsXULTemplateBuilder.cpp b/content/xul/templates/src/nsXULTemplateBuilder.cpp
--- a/content/xul/templates/src/nsXULTemplateBuilder.cpp
+++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp
@@ -284,9 +284,9 @@ nsXULTemplateBuilder::GetDatasource(nsIS
 nsXULTemplateBuilder::GetDatasource(nsISupports** aResult)
 {
     if (mCompDB)
-        NS_ADDREF(*aResult = mCompDB);
+        *aResult = mCompDB;
     else
-        NS_IF_ADDREF(*aResult = mDataSource);
+        *aResult = mDataSource;
     return NS_OK;
 }
 
@@ -302,14 +302,14 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsXULTemplateBuilder::GetDatabase(nsIRDFCompositeDataSource** aResult)
 {
-    NS_IF_ADDREF(*aResult = mCompDB);
+    *aResult = mCompDB;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXULTemplateBuilder::GetQueryProcessor(nsIXULTemplateQueryProcessor** aResult)
 {
-    NS_IF_ADDREF(*aResult = mQueryProcessor.get());
+    *aResult = mQueryProcessor.get();
     return NS_OK;
 }
 
@@ -970,7 +970,6 @@ nsXULTemplateBuilder::GetRootResult(nsIX
 nsXULTemplateBuilder::GetRootResult(nsIXULTemplateResult** aResult)
 {
   *aResult = mRootResult;
-  NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -992,7 +991,6 @@ nsXULTemplateBuilder::GetResultForId(con
         while (match) {
             if (match->IsActive()) {
                 *aResult = match->mResult;
-                NS_IF_ADDREF(*aResult);
                 break;
             }
             match = match->mNext;
@@ -1655,7 +1653,7 @@ nsXULTemplateBuilder::GetTemplateRoot(ns
             nsIContent *child = mRoot->GetChildAt(i);
 
             if (IsTemplateElement(child)) {
-                NS_ADDREF(*aResult = child);
+                *aResult = child;
                 return NS_OK;
             }
         }
@@ -1684,7 +1682,7 @@ nsXULTemplateBuilder::GetTemplateRoot(ns
             nsIContent* child = do_QueryInterface(node);
 
             if (IsTemplateElement(child)) {
-                NS_ADDREF(*aResult = child);
+                *aResult = child;
                 return NS_OK;
             }
         }
@@ -2075,7 +2073,6 @@ nsXULTemplateBuilder::DetermineMemberVar
 
     if (mMemberVariable) {
         *aMemberVariable = mMemberVariable;
-        NS_IF_ADDREF(*aMemberVariable);
     }
     else {
         *aMemberVariable = nsnull;
diff --git a/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp b/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp
--- a/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp
+++ b/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp
@@ -421,7 +421,6 @@ nsXULTemplateQueryProcessorRDF::CompileQ
         return rv;
 
     *_retval = query;
-    NS_ADDREF(*_retval);
 
     return NS_OK;
 }
@@ -585,7 +584,6 @@ nsXULTemplateQueryProcessorRDF::Translat
         return NS_ERROR_OUT_OF_MEMORY;
 
     *aRef = refresult;
-    NS_ADDREF(*aRef);
 
     return NS_OK;
 }
@@ -1915,6 +1913,5 @@ nsXULTemplateQueryProcessorRDF::GetSortV
     }
 
     *aResultNode = value;
-    NS_IF_ADDREF(*aResultNode);
     return NS_OK;
 }
diff --git a/content/xul/templates/src/nsXULTemplateQueryProcessorStorage.cpp b/content/xul/templates/src/nsXULTemplateQueryProcessorStorage.cpp
--- a/content/xul/templates/src/nsXULTemplateQueryProcessorStorage.cpp
+++ b/content/xul/templates/src/nsXULTemplateQueryProcessorStorage.cpp
@@ -112,7 +112,6 @@ nsXULTemplateResultSetStorage::GetNext(n
         return NS_ERROR_OUT_OF_MEMORY;
 
     *aResult = result;
-    NS_ADDREF(result);
     return NS_OK;
 }
 
@@ -260,7 +259,7 @@ nsXULTemplateQueryProcessorStorage::GetD
     rv = storage->OpenDatabase(databaseFile, &connection);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    NS_ADDREF(*aReturn = connection);
+    *aReturn = connection;
     return NS_OK;
 }
 
@@ -387,7 +386,6 @@ nsXULTemplateQueryProcessorStorage::Comp
     }
 
     *aReturn = statement;
-    NS_IF_ADDREF(*aReturn);
 
     return NS_OK;
 }
@@ -411,7 +409,6 @@ nsXULTemplateQueryProcessorStorage::Gene
         return NS_ERROR_OUT_OF_MEMORY;
 
     *aResults = results;
-    NS_ADDREF(*aResults);
 
     return NS_OK;
 }
@@ -436,7 +433,6 @@ nsXULTemplateQueryProcessorStorage::Tran
         return NS_ERROR_OUT_OF_MEMORY;
 
     *aRef = result;
-    NS_ADDREF(*aRef);
     return NS_OK;
 }
 
diff --git a/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp b/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp
--- a/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp
+++ b/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp
@@ -97,7 +97,6 @@ nsXULTemplateResultSetXML::GetNext(nsISu
 
     ++mPosition;
     *aResult = result;
-    NS_ADDREF(result);
     return NS_OK;
 }
 
@@ -310,7 +309,6 @@ nsXULTemplateQueryProcessorXML::CompileQ
     }
 
     *_retval = query;
-    NS_ADDREF(*_retval);
 
     return rv;
 }
@@ -356,7 +354,6 @@ nsXULTemplateQueryProcessorXML::Generate
     NS_ENSURE_TRUE(results, NS_ERROR_OUT_OF_MEMORY);
 
     *aResults = results;
-    NS_ADDREF(*aResults);
 
     return NS_OK;
 }
@@ -410,7 +407,6 @@ nsXULTemplateQueryProcessorXML::Translat
     NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY);
 
     *aRef = result;
-    NS_ADDREF(*aRef);
 
     return NS_OK;
 }
diff --git a/content/xul/templates/src/nsXULTemplateResultRDF.cpp b/content/xul/templates/src/nsXULTemplateResultRDF.cpp
--- a/content/xul/templates/src/nsXULTemplateResultRDF.cpp
+++ b/content/xul/templates/src/nsXULTemplateResultRDF.cpp
@@ -123,7 +123,6 @@ nsXULTemplateResultRDF::GetResource(nsIR
 nsXULTemplateResultRDF::GetResource(nsIRDFResource** aResource)
 {
     *aResource = mNode;
-    NS_IF_ADDREF(*aResource);
     return NS_OK;
 }
 
diff --git a/content/xul/templates/src/nsXULTemplateResultSetRDF.cpp b/content/xul/templates/src/nsXULTemplateResultSetRDF.cpp
--- a/content/xul/templates/src/nsXULTemplateResultSetRDF.cpp
+++ b/content/xul/templates/src/nsXULTemplateResultSetRDF.cpp
@@ -108,7 +108,6 @@ nsXULTemplateResultSetRDF::GetNext(nsISu
     mCheckedNext = PR_FALSE;
 
     *aResult = nextresult;
-    NS_ADDREF(*aResult);
 
     return NS_OK;
 }
diff --git a/content/xul/templates/src/nsXULTemplateResultStorage.cpp b/content/xul/templates/src/nsXULTemplateResultStorage.cpp
--- a/content/xul/templates/src/nsXULTemplateResultStorage.cpp
+++ b/content/xul/templates/src/nsXULTemplateResultStorage.cpp
@@ -91,7 +91,6 @@ nsXULTemplateResultStorage::GetResource(
 nsXULTemplateResultStorage::GetResource(nsIRDFResource** aResource)
 {
     *aResource = mNode;
-    NS_IF_ADDREF(*aResource);
     return NS_OK;
 }
 
@@ -134,7 +133,6 @@ nsXULTemplateResultStorage::GetBindingOb
         PRInt32 idx = mResultSet->GetColumnIndex(aVar);
         if (idx >= 0) {
             *aValue = mValues[idx];
-            NS_IF_ADDREF(*aValue);
             return NS_OK;
         }
     }
diff --git a/content/xul/templates/src/nsXULTemplateResultXML.cpp b/content/xul/templates/src/nsXULTemplateResultXML.cpp
--- a/content/xul/templates/src/nsXULTemplateResultXML.cpp
+++ b/content/xul/templates/src/nsXULTemplateResultXML.cpp
@@ -179,7 +179,6 @@ nsXULTemplateResultXML::GetBindingObject
     }
 
     *aValue = node;
-    NS_IF_ADDREF(*aValue);
     return NS_OK;
 }
 
@@ -210,5 +209,4 @@ nsXULTemplateResultXML::GetNode(nsIDOMNo
 nsXULTemplateResultXML::GetNode(nsIDOMNode** aNode)
 {
     *aNode = mNode;
-    NS_IF_ADDREF(*aNode);
 }
diff --git a/content/xul/templates/src/nsXULTreeBuilder.cpp b/content/xul/templates/src/nsXULTreeBuilder.cpp
--- a/content/xul/templates/src/nsXULTreeBuilder.cpp
+++ b/content/xul/templates/src/nsXULTreeBuilder.cpp
@@ -285,7 +285,6 @@ NS_NewXULTreeBuilder(nsISupports* aOuter
     if (! result)
         return NS_ERROR_OUT_OF_MEMORY;
 
-    NS_ADDREF(result); // stabilize
 
     rv = result->InitGlobals();
 
@@ -434,7 +433,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsXULTreeBuilder::GetSelection(nsITreeSelection** aSelection)
 {
-    NS_IF_ADDREF(*aSelection = mSelection.get());
+    *aSelection = mSelection.get();
     return NS_OK;
 }
 
@@ -1471,7 +1470,6 @@ nsXULTreeBuilder::GetTemplateActionCellF
             }
         }
     }
-    NS_IF_ADDREF(*aResult);
 
     return NS_OK;
 }
diff --git a/docshell/base/nsAboutRedirector.cpp b/docshell/base/nsAboutRedirector.cpp
--- a/docshell/base/nsAboutRedirector.cpp
+++ b/docshell/base/nsAboutRedirector.cpp
@@ -140,7 +140,7 @@ nsAboutRedirector::NewChannel(nsIURI *aU
                     return rv;
             }
 
-            NS_ADDREF(*result = tempChannel);
+            *result = tempChannel;
             return rv;
         }
     }
@@ -177,7 +177,6 @@ nsAboutRedirector::Create(nsISupports *a
     nsAboutRedirector* about = new nsAboutRedirector();
     if (about == nsnull)
         return NS_ERROR_OUT_OF_MEMORY;
-    NS_ADDREF(about);
     nsresult rv = about->QueryInterface(aIID, aResult);
     NS_RELEASE(about);
     return rv;
diff --git a/docshell/base/nsDSURIContentListener.cpp b/docshell/base/nsDSURIContentListener.cpp
--- a/docshell/base/nsDSURIContentListener.cpp
+++ b/docshell/base/nsDSURIContentListener.cpp
@@ -212,7 +212,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsDSURIContentListener::GetLoadCookie(nsISupports ** aLoadCookie)
 {
-    NS_IF_ADDREF(*aLoadCookie = nsDocShell::GetAsSupports(mDocShell));
+    *aLoadCookie = nsDocShell::GetAsSupports(mDocShell);
     return NS_OK;
 }
 
@@ -237,11 +237,9 @@ nsDSURIContentListener::GetParentContent
         nsIURIContentListener* tempListener =
             do_QueryReferent(mWeakParentContentListener);
         *aParentListener = tempListener;
-        NS_IF_ADDREF(*aParentListener);
     }
     else {
         *aParentListener = mParentContentListener;
-        NS_IF_ADDREF(*aParentListener);
     }
     return NS_OK;
 }
diff --git a/docshell/base/nsDefaultURIFixup.cpp b/docshell/base/nsDefaultURIFixup.cpp
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -86,7 +86,6 @@ nsDefaultURIFixup::CreateExposableURI(ns
     if (!isWyciwyg && userPass.IsEmpty())
     {
         *aReturn = aURI;
-        NS_ADDREF(*aReturn);
         return NS_OK;
     }
 
@@ -140,7 +139,6 @@ nsDefaultURIFixup::CreateExposableURI(ns
 
     // return the fixed-up URI
     *aReturn = uri;
-    NS_ADDREF(*aReturn);
     return NS_OK;
 }
 
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -491,7 +491,6 @@ NS_IMETHODIMP nsDocShell::GetInterface(c
             GetSessionHistory(&shistory);
         if (NS_SUCCEEDED(rv) && shistory) {
             *aSink = shistory;
-            NS_ADDREF((nsISupports *) * aSink);
             return NS_OK;
         }
         return NS_NOINTERFACE;
@@ -501,7 +500,6 @@ NS_IMETHODIMP nsDocShell::GetInterface(c
         if (NS_FAILED(rv)) return rv;
 
         *aSink = mFind;
-        NS_ADDREF((nsISupports*)*aSink);
         return NS_OK;
     }
     else if (aIID.Equals(NS_GET_IID(nsIEditingSession)) && NS_SUCCEEDED(EnsureEditorData())) {
@@ -510,7 +508,6 @@ NS_IMETHODIMP nsDocShell::GetInterface(c
       if (editingSession)
       {
         *aSink = editingSession;
-        NS_ADDREF((nsISupports *)*aSink);
         return NS_OK;
       }  
 
@@ -519,7 +516,6 @@ NS_IMETHODIMP nsDocShell::GetInterface(c
     else if (aIID.Equals(NS_GET_IID(nsIClipboardDragDropHookList)) 
             && NS_SUCCEEDED(EnsureTransferableHookData())) {
         *aSink = mTransferableHookData;
-        NS_ADDREF((nsISupports *)*aSink);
         return NS_OK;
     }
     else if (aIID.Equals(NS_GET_IID(nsISelectionDisplay))) {
@@ -538,7 +534,6 @@ NS_IMETHODIMP nsDocShell::GetInterface(c
         return nsDocLoader::GetInterface(aIID, aSink);
     }
 
-    NS_IF_ADDREF(((nsISupports *) * aSink));
     return *aSink ? NS_OK : NS_NOINTERFACE;
 }
 
@@ -970,7 +965,6 @@ nsDocShell::CreateLoadInfo(nsIDocShellLo
     nsIDocShellLoadInfo* localRef(loadInfo);
 
     *aLoadInfo = localRef;
-    NS_ADDREF(*aLoadInfo);
     return NS_OK;
 }
 
@@ -1148,7 +1142,7 @@ nsDocShell::GetPresShell(nsIPresShell **
     (void) GetPresContext(&presContext);
 
     if (presContext) {
-        NS_IF_ADDREF(*aPresShell = presContext->GetPresShell());
+        *aPresShell = presContext->GetPresShell();
     }
 
     return rv;
@@ -1166,7 +1160,7 @@ nsDocShell::GetEldestPresShell(nsIPresSh
     (void) GetEldestPresContext(&presContext);
 
     if (presContext) {
-        NS_IF_ADDREF(*aPresShell = presContext->GetPresShell());
+        *aPresShell = presContext->GetPresShell();
     }
 
     return rv;
@@ -1178,7 +1172,6 @@ nsDocShell::GetContentViewer(nsIContentV
     NS_ENSURE_ARG_POINTER(aContentViewer);
 
     *aContentViewer = mContentViewer;
-    NS_IF_ADDREF(*aContentViewer);
     return NS_OK;
 }
 
@@ -1327,7 +1320,6 @@ nsDocShell::GetDocumentCharsetInfo(nsIDo
     }
 
     *aDocumentCharsetInfo = mDocumentCharsetInfo;
-    NS_IF_ADDREF(*aDocumentCharsetInfo);
     return NS_OK;
 }
 
@@ -1583,7 +1575,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsDocShell::GetSecurityUI(nsISecureBrowserUI **aSecurityUI)
 {
-    NS_IF_ADDREF(*aSecurityUI = mSecurityUI);
+    *aSecurityUI = mSecurityUI;
     return NS_OK;
 }
 
@@ -1694,7 +1686,6 @@ nsDocShell::GetSessionStorageForURI(nsIU
             return NS_ERROR_OUT_OF_MEMORY;
 		
         *aStorage = newstorage;
-        NS_ADDREF(*aStorage);
     }
 
     return NS_OK;
@@ -1743,7 +1734,6 @@ nsDocShell::GetCurrentDocumentChannel(ns
     nsIDocument* doc(do_QueryInterface(domDoc));
     if (doc) {
       *aResult = doc->GetChannel();
-      NS_IF_ADDREF(*aResult);
     }
   
     return NS_OK;
@@ -1895,7 +1885,6 @@ nsDocShell::GetRootTreeItem(nsIDocShellT
         NS_ENSURE_SUCCESS((*aRootTreeItem)->GetParent(&parent),
                           NS_ERROR_FAILURE);
     }
-    NS_ADDREF(*aRootTreeItem);
     return NS_OK;
 }
 
@@ -1914,7 +1903,6 @@ nsDocShell::GetSameTypeRootTreeItem(nsID
             GetSameTypeParent(&parent);
         NS_ENSURE_SUCCESS(res, NS_ERROR_FAILURE);
     }
-    NS_ADDREF(*aRootTreeItem);
     return NS_OK;
 }
 
@@ -2118,7 +2106,7 @@ nsDocShell::FindItemWithName(const PRUni
     // First we check our name.
     if (mName.Equals(aName) && ItemIsActive(this) &&
         CanAccessItem(this, aOriginalRequestor)) {
-        NS_ADDREF(*_retval = this);
+        *_retval = this;
         return NS_OK;
     }
 
@@ -2182,7 +2170,6 @@ nsDocShell::GetTreeOwner(nsIDocShellTree
     NS_ENSURE_ARG_POINTER(aTreeOwner);
 
     *aTreeOwner = mTreeOwner;
-    NS_IF_ADDREF(*aTreeOwner);
     return NS_OK;
 }
 
@@ -3458,7 +3445,6 @@ nsDocShell::GetReferringURI(nsIURI ** aU
     NS_ENSURE_ARG_POINTER(aURI);
 
     *aURI = mReferrerURI;
-    NS_IF_ADDREF(*aURI);
 
     return NS_OK;
 }
@@ -3496,7 +3482,6 @@ nsDocShell::GetSessionHistory(nsISHistor
 {
     NS_ENSURE_ARG_POINTER(aSessionHistory);
     *aSessionHistory = mSessionHistory;
-    NS_IF_ADDREF(*aSessionHistory);
     return NS_OK;
 }
 
@@ -3849,7 +3834,6 @@ nsDocShell::GetParentWidget(nsIWidget **
     NS_ENSURE_ARG_POINTER(parentWidget);
 
     *parentWidget = mParentWidget;
-    NS_IF_ADDREF(*parentWidget);
 
     return NS_OK;
 }
@@ -7208,7 +7192,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
                    (aFlags & INTERNAL_LOAD_FLAGS_FIRST_LOAD) != 0,
                    (aFlags & INTERNAL_LOAD_FLAGS_BYPASS_CLASSIFIER) != 0);
     if (req && aRequest)
-        NS_ADDREF(*aRequest = req);
+        *aRequest = req;
 
     if (NS_FAILED(rv)) {
         nsIChannel* chan(do_QueryInterface(req));
@@ -7325,7 +7309,7 @@ nsDocShell::DoURILoad(nsIURI * aURI,
     // Make sure to give the caller a channel if we managed to create one
     // This is important for correct error page/session history interaction
     if (aRequest)
-        NS_ADDREF(*aRequest = channel);
+        *aRequest = channel;
 
     channel->SetOriginalURI(aURI);
     if (aTypeHint && *aTypeHint) {
@@ -7490,7 +7474,6 @@ nsDocShell::DoURILoad(nsIURI * aURI,
     if (NS_SUCCEEDED(rv)) {
         if (aDocShell) {
           *aDocShell = this;
-          NS_ADDREF(*aDocShell);
         }
     }
 
@@ -8266,7 +8249,6 @@ nsDocShell::AddToSessionHistory(nsIURI *
         *aNewEntry = nsnull;
         if (NS_SUCCEEDED(rv)) {
             *aNewEntry = entry;
-            NS_ADDREF(*aNewEntry);
         }
     }
 
@@ -8684,7 +8666,6 @@ nsDocShell::GetHttpChannel(nsIChannel * 
         multiPartChannel->GetBaseChannel(&baseChannel);
         nsIHttpChannel*  httpChannel(do_QueryInterface(baseChannel));
         *aReturn = httpChannel;
-        NS_IF_ADDREF(*aReturn);
     }
     return NS_OK;
 }
diff --git a/docshell/base/nsDocShellEditorData.cpp b/docshell/base/nsDocShellEditorData.cpp
--- a/docshell/base/nsDocShellEditorData.cpp
+++ b/docshell/base/nsDocShellEditorData.cpp
@@ -151,7 +151,7 @@ nsDocShellEditorData::GetEditingSession(
   nsresult rv = EnsureEditingSession();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  NS_ADDREF(*outEditingSession = mEditingSession);
+  *outEditingSession = mEditingSession;
 
   return NS_OK;
 }
@@ -166,7 +166,7 @@ nsDocShellEditorData::GetEditor(nsIEdito
 nsDocShellEditorData::GetEditor(nsIEditor **outEditor)
 {
   NS_ENSURE_ARG_POINTER(outEditor);
-  NS_IF_ADDREF(*outEditor = mEditor);
+  *outEditor = mEditor;
   return NS_OK;
 }
 
diff --git a/docshell/base/nsDocShellEnumerator.cpp b/docshell/base/nsDocShellEnumerator.cpp
--- a/docshell/base/nsDocShellEnumerator.cpp
+++ b/docshell/base/nsDocShellEnumerator.cpp
@@ -99,7 +99,6 @@ nsresult nsDocShellEnumerator::GetEnumer
 {
   NS_ENSURE_ARG_POINTER(aEnumerationRootItem);
   *aEnumerationRootItem = mRootItem;
-  NS_IF_ADDREF(*aEnumerationRootItem);
   return NS_OK;
 }
 
diff --git a/docshell/base/nsDocShellLoadInfo.cpp b/docshell/base/nsDocShellLoadInfo.cpp
--- a/docshell/base/nsDocShellLoadInfo.cpp
+++ b/docshell/base/nsDocShellLoadInfo.cpp
@@ -79,7 +79,6 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetRef
    NS_ENSURE_ARG_POINTER(aReferrer);
 
    *aReferrer = mReferrer;
-   NS_IF_ADDREF(*aReferrer);
    return NS_OK;
 }
 
@@ -94,7 +93,6 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetOwn
    NS_ENSURE_ARG_POINTER(aOwner);
 
    *aOwner = mOwner;
-   NS_IF_ADDREF(*aOwner);
    return NS_OK;
 }
 
@@ -137,7 +135,6 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetSHE
    NS_ENSURE_ARG_POINTER(aSHEntry);
 
    *aSHEntry = mSHEntry;
-   NS_IF_ADDREF(*aSHEntry);
    return NS_OK;
 }
  
@@ -170,7 +167,6 @@ nsDocShellLoadInfo::GetPostDataStream(ns
 
   *aResult = mPostDataStream;
 
-  NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -187,7 +183,6 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetHea
 {
   NS_ENSURE_ARG_POINTER(aHeadersStream);
   *aHeadersStream = mHeadersStream;
-  NS_IF_ADDREF(*aHeadersStream);
   return NS_OK;
 }
 NS_IMETHODIMP nsDocShellLoadInfo::SetHeadersStream(nsIInputStream * aHeadersStream)
diff --git a/docshell/base/nsGlobalHistory2Adapter.cpp b/docshell/base/nsGlobalHistory2Adapter.cpp
--- a/docshell/base/nsGlobalHistory2Adapter.cpp
+++ b/docshell/base/nsGlobalHistory2Adapter.cpp
@@ -66,7 +66,6 @@ nsGlobalHistory2Adapter::Create(nsISuppo
     return rv;
   }
 
-  NS_ADDREF(adapter);
   rv = adapter->Init();
   if (NS_SUCCEEDED(rv)) {
     rv = adapter->QueryInterface(aIID, aResult);
diff --git a/docshell/base/nsGlobalHistoryAdapter.cpp b/docshell/base/nsGlobalHistoryAdapter.cpp
--- a/docshell/base/nsGlobalHistoryAdapter.cpp
+++ b/docshell/base/nsGlobalHistoryAdapter.cpp
@@ -62,7 +62,6 @@ nsGlobalHistoryAdapter::Create(nsISuppor
     return rv;
   }
 
-  NS_ADDREF(adapter);
   rv = adapter->Init();
   if (NS_SUCCEEDED(rv)) {
     rv = adapter->QueryInterface(aIID, aResult);
diff --git a/docshell/base/nsWebShell.cpp b/docshell/base/nsWebShell.cpp
--- a/docshell/base/nsWebShell.cpp
+++ b/docshell/base/nsWebShell.cpp
@@ -370,7 +370,6 @@ nsPingListener::GetInterface(const nsIID
 nsPingListener::GetInterface(const nsIID &iid, void **result)
 {
   if (iid.Equals(NS_GET_IID(nsIChannelEventSink))) {
-    NS_ADDREF_THIS();
     *result = (nsIChannelEventSink *) this;
     return NS_OK;
   }
@@ -625,7 +624,6 @@ nsWebShell::GetInterface(const nsIID &aI
       {
       NS_ENSURE_SUCCESS(EnsureCommandHandler(), NS_ERROR_FAILURE);
       *aInstancePtr = mCommandManager;
-      NS_ADDREF((nsISupports*) *aInstancePtr);
       return NS_OK;
       }
 
diff --git a/docshell/shistory/src/nsSHEntry.cpp b/docshell/shistory/src/nsSHEntry.cpp
--- a/docshell/shistory/src/nsSHEntry.cpp
+++ b/docshell/shistory/src/nsSHEntry.cpp
@@ -203,7 +203,6 @@ NS_IMETHODIMP nsSHEntry::GetURI(nsIURI**
 NS_IMETHODIMP nsSHEntry::GetURI(nsIURI** aURI)
 {
   *aURI = mURI;
-  NS_IF_ADDREF(*aURI);
   return NS_OK;
 }
 
@@ -216,7 +215,6 @@ NS_IMETHODIMP nsSHEntry::GetReferrerURI(
 NS_IMETHODIMP nsSHEntry::GetReferrerURI(nsIURI **aReferrerURI)
 {
   *aReferrerURI = mReferrerURI;
-  NS_IF_ADDREF(*aReferrerURI);
   return NS_OK;
 }
 
@@ -258,7 +256,6 @@ nsSHEntry::GetContentViewer(nsIContentVi
 nsSHEntry::GetContentViewer(nsIContentViewer **aResult)
 {
   *aResult = mContentViewer;
-  NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -275,7 +272,6 @@ nsSHEntry::GetAnyContentViewer(nsISHEntr
     printf("Found content viewer\n");
 #endif
     *aOwnerEntry = this;
-    NS_ADDREF(*aOwnerEntry);
     return NS_OK;
   }
   // The root SHEntry doesn't have a ContentViewer, so check child nodes
@@ -331,7 +327,6 @@ NS_IMETHODIMP nsSHEntry::GetPostData(nsI
 NS_IMETHODIMP nsSHEntry::GetPostData(nsIInputStream** aResult)
 {
   *aResult = mPostData;
-  NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -344,7 +339,6 @@ NS_IMETHODIMP nsSHEntry::GetLayoutHistor
 NS_IMETHODIMP nsSHEntry::GetLayoutHistoryState(nsILayoutHistoryState** aResult)
 {
   *aResult = mLayoutHistoryState;
-  NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -406,7 +400,6 @@ NS_IMETHODIMP nsSHEntry::GetCacheKey(nsI
 NS_IMETHODIMP nsSHEntry::GetCacheKey(nsISupports** aResult)
 {
   *aResult = mCacheKey;
-  NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -496,7 +489,6 @@ nsSHEntry::Clone(nsISHEntry ** aResult)
   *aResult = new nsSHEntry(*this);
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -505,7 +497,6 @@ nsSHEntry::GetParent(nsISHEntry ** aResu
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = mParent;
-  NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -531,7 +522,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsSHEntry::GetWindowState(nsISupports **aState)
 {
-  NS_IF_ADDREF(*aState = mWindowState);
+  *aState = mWindowState;
   return NS_OK;
 }
 
@@ -552,7 +543,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsSHEntry::GetOwner(nsISupports **aOwner)
 {
-  NS_IF_ADDREF(*aOwner = mOwner);
+  *aOwner = mOwner;
   return NS_OK;
 }
 
@@ -624,7 +615,6 @@ nsSHEntry::GetChildAt(PRInt32 aIndex, ns
     *aResult = mChildren[aIndex];
     // yes, mChildren can have holes in it.  AddChild's offset parameter makes
     // that possible.
-    NS_IF_ADDREF(*aResult);
   } else {
     *aResult = nsnull;
   }
@@ -642,7 +632,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsSHEntry::ChildShellAt(PRInt32 aIndex, nsIDocShellTreeItem **aShell)
 {
-  NS_IF_ADDREF(*aShell = mChildShells.SafeObjectAt(aIndex));
+  *aShell = mChildShells.SafeObjectAt(aIndex);
   return NS_OK;
 }
 
@@ -656,7 +646,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsSHEntry::GetRefreshURIList(nsISupportsArray **aList)
 {
-  NS_IF_ADDREF(*aList = mRefreshURIList);
+  *aList = mRefreshURIList;
   return NS_OK;
 }
 
diff --git a/docshell/shistory/src/nsSHTransaction.cpp b/docshell/shistory/src/nsSHTransaction.cpp
--- a/docshell/shistory/src/nsSHTransaction.cpp
+++ b/docshell/shistory/src/nsSHTransaction.cpp
@@ -85,7 +85,6 @@ nsSHTransaction::GetSHEntry(nsISHEntry *
 {
    NS_ENSURE_ARG_POINTER(aResult);
 	*aResult = mSHEntry;
-	NS_IF_ADDREF(*aResult);
 	return NS_OK;
 }
 
@@ -103,7 +102,6 @@ nsSHTransaction::GetNext(nsISHTransactio
 {
    NS_ENSURE_ARG_POINTER(aResult);
    *aResult = mNext;
-   NS_IF_ADDREF(*aResult);
    return NS_OK;
 }
 
@@ -130,7 +128,6 @@ nsSHTransaction::GetPrev(nsISHTransactio
 {
    NS_ENSURE_ARG_POINTER(aResult);
    *aResult  = mPrev;
-   NS_IF_ADDREF(*aResult);
    return NS_OK;
 }
 
diff --git a/docshell/shistory/src/nsSHistory.cpp b/docshell/shistory/src/nsSHistory.cpp
--- a/docshell/shistory/src/nsSHistory.cpp
+++ b/docshell/shistory/src/nsSHistory.cpp
@@ -421,7 +421,6 @@ nsSHistory::GetTransactionAtIndex(PRInt3
   if (aIndex == 0)
   {
     *aResult = mListRoot;
-    NS_ADDREF(*aResult);
     return NS_OK;
   } 
   PRInt32   cnt=0;
@@ -438,7 +437,6 @@ nsSHistory::GetTransactionAtIndex(PRInt3
       cnt++;
       if (cnt == aIndex) {
         *aResult = ptr;
-        NS_ADDREF(*aResult);
         break;
       }
       else {
@@ -518,7 +516,6 @@ nsSHistory::GetRootTransaction(nsISHTran
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult=mListRoot;
-  NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
diff --git a/dom/public/nsIBaseDOMException.h b/dom/public/nsIBaseDOMException.h
--- a/dom/public/nsIBaseDOMException.h
+++ b/dom/public/nsIBaseDOMException.h
@@ -118,7 +118,6 @@ NS_New##domname(nsresult aNSResult, nsIE
   nsCOMPtr<nsIException> inner = do_QueryInterface(baseException);           \
   *aException = new classname(inner);                                        \
   NS_ENSURE_TRUE(*aException, NS_ERROR_OUT_OF_MEMORY);                       \
-  NS_ADDREF(*aException);                                                    \
   return NS_OK;                                                              \
 }
 
diff --git a/dom/src/base/nsDOMClassInfo.cpp b/dom/src/base/nsDOMClassInfo.cpp
--- a/dom/src/base/nsDOMClassInfo.cpp
+++ b/dom/src/base/nsDOMClassInfo.cpp
@@ -1890,7 +1890,6 @@ nsDOMClassInfo::Init()
   NS_ENSURE_SUCCESS(rv, rv);
 
   sSecMan = sm;
-  NS_ADDREF(sSecMan);
 
   nsIThreadJSContextStack* stack =
     do_GetService("@mozilla.org/js/xpc/ContextStack;1", &rv);
@@ -3566,7 +3565,6 @@ nsDOMClassInfo::GetHelperForLanguage(PRU
   if (language == nsIProgrammingLanguage::JAVASCRIPT) {
     *_retval = static_cast<nsIXPCScriptable *>(this);
 
-    NS_ADDREF(*_retval);
   } else {
     *_retval = nsnull;
   }
@@ -4008,7 +4006,6 @@ NS_GetDOMClassInfoInstance(nsDOMClassInf
     data.mCachedClassInfo = data.u.mConstructorFptr(&data);
     NS_ENSURE_TRUE(data.mCachedClassInfo, nsnull);
 
-    NS_ADDREF(data.mCachedClassInfo);
   }
 
   NS_ASSERTION(!IS_EXTERNAL(sClassInfoData[aID].mCachedClassInfo),
@@ -4034,7 +4031,6 @@ nsDOMClassInfo::GetClassInfoInstance(nsD
     }
     NS_ENSURE_TRUE(aData->mCachedClassInfo, nsnull);
 
-    NS_ADDREF(aData->mCachedClassInfo);
     aData->mCachedClassInfo = MARK_EXTERNAL(aData->mCachedClassInfo);
   }
 
@@ -4433,7 +4429,6 @@ nsWindowSH::InstallGlobalScopePolluter(J
 
   // The global scope polluter will release doc on destruction (or
   // invalidation).
-  NS_ADDREF(doc);
 
   return NS_OK;
 }
@@ -5088,7 +5083,6 @@ nsDOMConstructor::Create(const PRUnichar
   }
   *aResult = new nsDOMConstructor(aName, aNameStruct, currentInner);
   NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -8156,7 +8150,6 @@ nsHTMLDocumentSH::DocumentAllNewResolve(
     }
 
     // The "tags" JSObject now also owns doc.
-    NS_ADDREF(doc);
 
     v = OBJECT_TO_JSVAL(tags);
   } else {
@@ -10188,7 +10181,6 @@ nsEventListenerThisTranslator::Translate
   event->GetCurrentTarget(&target);
 
   *_retval = target;
-  NS_IF_ADDREF(*_retval);
 
   return NS_OK;
 }
diff --git a/dom/src/base/nsDOMException.cpp b/dom/src/base/nsDOMException.cpp
--- a/dom/src/base/nsDOMException.cpp
+++ b/dom/src/base/nsDOMException.cpp
@@ -96,7 +96,6 @@ NS_New##domname(nsresult aNSResult, nsIE
   NS_ENSURE_TRUE(inst, NS_ERROR_OUT_OF_MEMORY);                              \
   inst->Init(aNSResult, name, message, aDefaultException);                   \
   *aException = inst;                                                        \
-  NS_ADDREF(*aException);                                                    \
   return NS_OK;                                                              \
 }
 
diff --git a/dom/src/base/nsDOMScriptObjectFactory.cpp b/dom/src/base/nsDOMScriptObjectFactory.cpp
--- a/dom/src/base/nsDOMScriptObjectFactory.cpp
+++ b/dom/src/base/nsDOMScriptObjectFactory.cpp
@@ -161,7 +161,6 @@ nsDOMScriptObjectFactory::GetScriptRunti
                  "Got a different language for this ID???");
   }
   *aLanguage = lang;
-  NS_IF_ADDREF(*aLanguage);
   return NS_OK;
 }
 
@@ -192,7 +191,6 @@ nsDOMScriptObjectFactory::GetScriptRunti
     mLanguageArray[NS_STID_INDEX(aLanguageID)] = lang;
     *aLanguage = lang;
   }
-  NS_IF_ADDREF(*aLanguage);
   return NS_OK;
 }
 
@@ -329,7 +327,7 @@ CreateXPConnectException(nsresult aResul
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  NS_ADDREF(*_retval = exception);
+  *_retval = exception;
   return NS_OK;
 }
 
diff --git a/dom/src/base/nsFocusController.cpp b/dom/src/base/nsFocusController.cpp
--- a/dom/src/base/nsFocusController.cpp
+++ b/dom/src/base/nsFocusController.cpp
@@ -116,7 +116,6 @@ nsFocusController::Create(nsIFocusContro
     return NS_ERROR_OUT_OF_MEMORY;
 
   *aResult = controller;
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -128,7 +127,6 @@ nsFocusController::GetFocusedElement(nsI
 nsFocusController::GetFocusedElement(nsIDOMElement** aElement)
 {
   *aElement = mCurrentElement;
-  NS_IF_ADDREF(*aElement);
   return NS_OK;
 }
 
@@ -136,7 +134,6 @@ nsFocusController::GetFocusedWindow(nsID
 nsFocusController::GetFocusedWindow(nsIDOMWindowInternal** aWindow)
 {
   *aWindow = mCurrentWindow;
-  NS_IF_ADDREF(*aWindow);
   return NS_OK;
 }
 
@@ -601,7 +598,6 @@ nsFocusController::GetPopupNode(nsIDOMNo
 #endif
 
   *aNode = mPopupNode;
-  NS_IF_ADDREF(*aNode);
   return NS_OK;
 }
 
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
@@ -453,7 +453,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsDummyJavaPluginOwner::GetInstance(nsIPluginInstance *&aInstance)
 {
-  NS_IF_ADDREF(aInstance = mInstance);
+  aInstance = mInstance;
 
   return NS_OK;
 }
@@ -505,7 +505,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsDummyJavaPluginOwner::GetDocument(nsIDocument **aDocument)
 {
-  NS_IF_ADDREF(*aDocument = mDocument);
+  *aDocument = mDocument;
 
   return NS_OK;
 }
@@ -613,7 +613,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalW
 
     mObserver = new nsGlobalWindowObserver(this);
     if (mObserver) {
-      NS_ADDREF(mObserver);
       nsIObserverService* os =
         do_GetService("@mozilla.org/observer-service;1");
       if (os) {
@@ -2304,7 +2303,7 @@ nsGlobalWindow::GetDocument(nsIDOMDocume
   if (!mDocument && (docShell = GetDocShell()))
     nsIDOMDocument* domdoc(do_GetInterface(docShell));
 
-  NS_IF_ADDREF(*aDocument = mDocument);
+  *aDocument = mDocument;
 
   return NS_OK;
 }
@@ -2319,7 +2318,6 @@ nsGlobalWindow::GetWindow(nsIDOMWindowIn
   FORWARD_TO_OUTER(GetWindow, (aWindow), NS_ERROR_NOT_INITIALIZED);
 
   *aWindow = static_cast<nsIDOMWindowInternal *>(this);
-  NS_ADDREF(*aWindow);
   return NS_OK;
 }
 
@@ -2329,7 +2327,6 @@ nsGlobalWindow::GetSelf(nsIDOMWindowInte
   FORWARD_TO_OUTER(GetSelf, (aWindow), NS_ERROR_NOT_INITIALIZED);
 
   *aWindow = static_cast<nsIDOMWindowInternal *>(this);
-  NS_ADDREF(*aWindow);
   return NS_OK;
 }
 
@@ -2347,7 +2344,7 @@ nsGlobalWindow::GetNavigator(nsIDOMNavig
     }
   }
 
-  NS_ADDREF(*aNavigator = mNavigator);
+  *aNavigator = mNavigator;
 
   return NS_OK;
 }
@@ -2366,7 +2363,7 @@ nsGlobalWindow::GetScreen(nsIDOMScreen**
     }
   }
 
-  NS_IF_ADDREF(*aScreen = mScreen);
+  *aScreen = mScreen;
 
   return NS_OK;
 }
@@ -2385,7 +2382,7 @@ nsGlobalWindow::GetHistory(nsIDOMHistory
     }
   }
 
-  NS_IF_ADDREF(*aHistory = mHistory);
+  *aHistory = mHistory;
   return NS_OK;
 }
 
@@ -2411,7 +2408,6 @@ nsGlobalWindow::GetParent(nsIDOMWindow**
   }
   else {
     *aParent = static_cast<nsIDOMWindowInternal *>(this);
-    NS_ADDREF(*aParent);
   }
   return NS_OK;
 }
@@ -2475,7 +2471,7 @@ nsGlobalWindow::GetContent(nsIDOMWindow*
   }
 
   nsIDOMWindowInternal* domWindow(do_GetInterface(primaryContent));
-  NS_IF_ADDREF(*aContent = domWindow);
+  *aContent = domWindow;
 
   return NS_OK;
 }
@@ -2491,7 +2487,7 @@ nsGlobalWindow::GetPrompter(nsIPrompt** 
   nsIPrompt* prompter(do_GetInterface(mDocShell));
   NS_ENSURE_TRUE(prompter, NS_ERROR_NO_INTERFACE);
 
-  NS_ADDREF(*aPrompt = prompter);
+  *aPrompt = prompter;
   return NS_OK;
 }
 
@@ -2514,7 +2510,7 @@ nsGlobalWindow::GetMenubar(nsIDOMBarProp
     mMenubar->SetWebBrowserChrome(browserChrome);
   }
 
-  NS_ADDREF(*aMenubar = mMenubar);
+  *aMenubar = mMenubar;
 
   return NS_OK;
 }
@@ -2538,7 +2534,7 @@ nsGlobalWindow::GetToolbar(nsIDOMBarProp
     mToolbar->SetWebBrowserChrome(browserChrome);
   }
 
-  NS_ADDREF(*aToolbar = mToolbar);
+  *aToolbar = mToolbar;
 
   return NS_OK;
 }
@@ -2562,7 +2558,7 @@ nsGlobalWindow::GetLocationbar(nsIDOMBar
     mLocationbar->SetWebBrowserChrome(browserChrome);
   }
 
-  NS_ADDREF(*aLocationbar = mLocationbar);
+  *aLocationbar = mLocationbar;
 
   return NS_OK;
 }
@@ -2586,7 +2582,7 @@ nsGlobalWindow::GetPersonalbar(nsIDOMBar
     mPersonalbar->SetWebBrowserChrome(browserChrome);
   }
 
-  NS_ADDREF(*aPersonalbar = mPersonalbar);
+  *aPersonalbar = mPersonalbar;
 
   return NS_OK;
 }
@@ -2610,7 +2606,7 @@ nsGlobalWindow::GetStatusbar(nsIDOMBarPr
     mStatusbar->SetWebBrowserChrome(browserChrome);
   }
 
-  NS_ADDREF(*aStatusbar = mStatusbar);
+  *aStatusbar = mStatusbar;
 
   return NS_OK;
 }
@@ -2634,7 +2630,7 @@ nsGlobalWindow::GetScrollbars(nsIDOMBarP
     mScrollbars->SetWebBrowserChrome(browserChrome);
   }
 
-  NS_ADDREF(*aScrollbars = mScrollbars);
+  *aScrollbars = mScrollbars;
 
   return NS_OK;
 }
@@ -2672,7 +2668,6 @@ nsGlobalWindow::GetFrames(nsIDOMWindowCo
   }
 
   *aFrames = static_cast<nsIDOMWindowCollection *>(mFrames);
-  NS_IF_ADDREF(*aFrames);
   return NS_OK;
 }
 
@@ -2711,7 +2706,7 @@ nsGlobalWindow::GetApplicationCache(nsID
     mApplicationCache = applicationCache;
   }
 
-  NS_IF_ADDREF(*aApplicationCache = mApplicationCache);
+  *aApplicationCache = mApplicationCache;
 
   return NS_OK;
 }
@@ -2725,7 +2720,7 @@ nsGlobalWindow::GetCrypto(nsIDOMCrypto**
     mCrypto = do_CreateInstance(kCryptoContractID);
   }
 
-  NS_IF_ADDREF(*aCrypto = mCrypto);
+  *aCrypto = mCrypto;
 
   return NS_OK;
 }
@@ -2739,7 +2734,7 @@ nsGlobalWindow::GetPkcs11(nsIDOMPkcs11**
     mPkcs11 = do_CreateInstance(kPkcs11ContractID);
   }
 
-  NS_IF_ADDREF(*aPkcs11 = mPkcs11);
+  *aPkcs11 = mPkcs11;
 
   return NS_OK;
 }
@@ -2767,7 +2762,6 @@ nsGlobalWindow::GetControllers(nsIContro
   }
 
   *aResult = mControllers;
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -2785,7 +2779,7 @@ nsGlobalWindow::GetOpener(nsIDOMWindowIn
 
   // First, check if we were called from a privileged chrome script
   if (nsContentUtils::IsCallerTrustedForRead()) {
-    NS_ADDREF(*aOpener = opener);
+    *aOpener = opener;
     return NS_OK;
   }
 
@@ -2810,7 +2804,6 @@ nsGlobalWindow::GetOpener(nsIDOMWindowIn
       }
     }
   }
-  NS_IF_ADDREF(*aOpener);
   return NS_OK;
 }
 
@@ -4977,7 +4970,6 @@ nsGlobalWindow::GetFrames(nsIDOMWindow**
   FORWARD_TO_OUTER(GetFrames, (aFrames), NS_ERROR_NOT_INITIALIZED);
 
   *aFrames = this;
-  NS_ADDREF(*aFrames);
 
   FlushPendingNotifications(Flush_ContentAndNotify);
 
@@ -5720,7 +5712,6 @@ nsGlobalWindow::GetFrameElement(nsIDOMEl
   }
 
   *aFrameElement = mFrameElement;
-  NS_IF_ADDREF(*aFrameElement);
 
   return NS_OK;
 }
@@ -6000,7 +5991,6 @@ nsGlobalWindow::GetSelection(nsISelectio
     
   *aSelection = presShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL);
   
-  NS_IF_ADDREF(*aSelection);
 
   return NS_OK;
 }
@@ -6454,7 +6444,7 @@ nsGlobalWindow::GetListenerManager(PRBoo
       static_cast<nsPIDOMEventTarget*>(this));
   }
 
-  NS_ADDREF(*aResult = mListenerManager);
+  *aResult = mListenerManager;
 
   return NS_OK;
 }
@@ -6557,7 +6547,7 @@ nsGlobalWindow::GetLocation(nsIDOMLocati
     }
   }
 
-  NS_IF_ADDREF(*aLocation = mLocation);
+  *aLocation = mLocation;
 
   return NS_OK;
 }
@@ -6754,7 +6744,6 @@ nsGlobalWindow::GetGlobalStorage(nsIDOMS
   }
 
   *aGlobalStorage = gGlobalStorageList;
-  NS_IF_ADDREF(*aGlobalStorage);
 
   return NS_OK;
 #else
@@ -6779,7 +6768,6 @@ nsGlobalWindow::GetInterface(const nsIID
       nsIDocCharset* docCharset(do_QueryInterface(mDocShell));
       if (docCharset) {
         *aSink = docCharset;
-        NS_ADDREF(((nsISupports *) *aSink));
       }
     }
   }
@@ -6790,7 +6778,6 @@ nsGlobalWindow::GetInterface(const nsIID
       nsIWebNavigation* webNav(do_QueryInterface(mDocShell));
       if (webNav) {
         *aSink = webNav;
-        NS_ADDREF(((nsISupports *) *aSink));
       }
     }
   }
@@ -6805,7 +6792,6 @@ nsGlobalWindow::GetInterface(const nsIID
         nsIWebBrowserPrint* webBrowserPrint(do_QueryInterface(viewer));
         if (webBrowserPrint) {
           *aSink = webBrowserPrint;
-          NS_ADDREF(((nsISupports *) *aSink));
         }
       }
     }
@@ -6816,7 +6802,6 @@ nsGlobalWindow::GetInterface(const nsIID
       nsIScriptEventManager* mgr = mDoc->GetScriptEventManager();
       if (mgr) {
         *aSink = mgr;
-        NS_ADDREF(((nsISupports *) *aSink));
       }
     }
   }
@@ -6826,7 +6811,6 @@ nsGlobalWindow::GetInterface(const nsIID
     nsISupports* utils(do_QueryReferent(mWindowUtils));
     if (utils) {
       *aSink = utils;
-      NS_ADDREF(((nsISupports *) *aSink));
     } else {
       nsDOMWindowUtils *utilObj = new nsDOMWindowUtils(this);
       nsISupports* utilsIfc =
@@ -6834,7 +6818,6 @@ nsGlobalWindow::GetInterface(const nsIID
       if (utilsIfc) {
         mWindowUtils = do_GetWeakReference(utilsIfc);
         *aSink = utilsIfc;
-        NS_ADDREF(((nsISupports *) *aSink));
       }
     }
   }
@@ -8098,7 +8081,7 @@ nsGlobalWindow::GetWebBrowserChrome(nsIW
   GetTreeOwner(&treeOwner);
 
   nsIWebBrowserChrome* browserChrome(do_GetInterface(treeOwner));
-  NS_IF_ADDREF(*aBrowserChrome = browserChrome);
+  *aBrowserChrome = browserChrome;
 
   return NS_OK;
 }
@@ -8709,7 +8692,6 @@ nsGlobalChromeWindow::GetBrowserDOMWindo
   NS_ENSURE_ARG_POINTER(aBrowserWindow);
 
   *aBrowserWindow = mBrowserDOMWindow;
-  NS_IF_ADDREF(*aBrowserWindow);
   return NS_OK;
 }
 
@@ -8763,7 +8745,7 @@ nsGlobalModalWindow::GetReturnValue(nsIV
 {
   FORWARD_TO_OUTER_MODAL_CONTENT_WINDOW(GetReturnValue, (aRetVal), NS_OK);
 
-  NS_IF_ADDREF(*aRetVal = mReturnValue);
+  *aRetVal = mReturnValue;
 
   return NS_OK;
 }
@@ -8800,7 +8782,7 @@ NS_NewScriptGlobalObject(PRBool aIsChrom
 
   NS_ENSURE_TRUE(global, NS_ERROR_OUT_OF_MEMORY);
 
-  NS_ADDREF(*aResult = global);
+  *aResult = global;
 
   return NS_OK;
 }
@@ -9118,7 +9100,7 @@ nsNavigator::GetMimeTypes(nsIDOMMimeType
     }
   }
 
-  NS_ADDREF(*aMimeTypes = mMimeTypes);
+  *aMimeTypes = mMimeTypes;
 
   return NS_OK;
 }
@@ -9133,7 +9115,7 @@ nsNavigator::GetPlugins(nsIDOMPluginArra
     }
   }
 
-  NS_ADDREF(*aPlugins = mPlugins);
+  *aPlugins = mPlugins;
 
   return NS_OK;
 }
diff --git a/dom/src/base/nsGlobalWindowCommands.cpp b/dom/src/base/nsGlobalWindowCommands.cpp
--- a/dom/src/base/nsGlobalWindowCommands.cpp
+++ b/dom/src/base/nsGlobalWindowCommands.cpp
@@ -237,7 +237,7 @@ nsSelectionCommandsBase::GetEventStateMa
   {
     nsPresContext *presContext = presShell->GetPresContext();
     if (presContext) {
-      NS_ADDREF(*aEventStateManager = presContext->EventStateManager());
+      *aEventStateManager = presContext->EventStateManager();
       return NS_OK;
     }
   }
@@ -498,7 +498,6 @@ nsClipboardBaseCommand::GetContentViewer
   NS_ENSURE_TRUE(edit, NS_ERROR_FAILURE);
 
   *aEditInterface = edit;
-  NS_ADDREF(*aEditInterface);
   return NS_OK;
 }
 
diff --git a/dom/src/base/nsJSEnvironment.cpp b/dom/src/base/nsJSEnvironment.cpp
--- a/dom/src/base/nsJSEnvironment.cpp
+++ b/dom/src/base/nsJSEnvironment.cpp
@@ -2248,7 +2248,6 @@ nsJSContext::CreateNativeGlobalForInner(
     return rv;
   jsholder->GetJSObject(reinterpret_cast<JSObject **>(aNativeGlobal));
   *aHolder = jsholder;
-  NS_ADDREF(*aHolder);
   return NS_OK;
 }
 
@@ -3493,7 +3492,6 @@ nsJSRuntime::CreateContext(nsIScriptCont
 
   *aContext = new nsJSContext(sRuntime);
   NS_ENSURE_TRUE(*aContext, NS_ERROR_OUT_OF_MEMORY);
-  NS_ADDREF(*aContext);
   return NS_OK;
 }
 
@@ -3769,7 +3767,6 @@ nsresult NS_CreateJSRuntime(nsIScriptRun
   *aRuntime = new nsJSRuntime();
   if (*aRuntime == nsnull)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_IF_ADDREF(*aRuntime);
   return NS_OK;
 }
 
diff --git a/dom/src/base/nsJSTimeoutHandler.cpp b/dom/src/base/nsJSTimeoutHandler.cpp
--- a/dom/src/base/nsJSTimeoutHandler.cpp
+++ b/dom/src/base/nsJSTimeoutHandler.cpp
@@ -318,7 +318,7 @@ nsresult NS_CreateJSTimeoutHandler(nsGlo
     return rv;
   }
 
-  NS_ADDREF(*aRet = handler);
+  *aRet = handler;
 
   return NS_OK;
 }
diff --git a/dom/src/base/nsLocation.cpp b/dom/src/base/nsLocation.cpp
--- a/dom/src/base/nsLocation.cpp
+++ b/dom/src/base/nsLocation.cpp
@@ -277,7 +277,6 @@ nsLocation::FindUsableBaseURI(nsIURI * a
     protocolHandler->GetProtocolFlags(&pFlags);
     if (!(pFlags & nsIProtocolHandler::URI_NORELATIVE)) {
       *aUsableURI = baseURI;
-      NS_ADDREF(*aUsableURI);
       return NS_OK;
     }
 
@@ -1020,7 +1019,7 @@ nsLocation::GetSourceBaseURL(JSContext* 
   nsIDocument* doc = nsnull;
   nsresult rv = GetSourceDocument(cx, &doc);
   if (doc) {
-    NS_IF_ADDREF(*sourceURL = doc->GetBaseURI());
+    *sourceURL = doc->GetBaseURI();
   } else {
     *sourceURL = nsnull;
   }
diff --git a/dom/src/base/nsMimeTypeArray.cpp b/dom/src/base/nsMimeTypeArray.cpp
--- a/dom/src/base/nsMimeTypeArray.cpp
+++ b/dom/src/base/nsMimeTypeArray.cpp
@@ -95,7 +95,6 @@ nsMimeTypeArray::Item(PRUint32 aIndex, n
   }
   if (aIndex < mMimeTypeCount) {
     *aReturn = mMimeTypeArray[aIndex];
-    NS_IF_ADDREF(*aReturn);
     return NS_OK;
   }
   return NS_ERROR_FAILURE;
@@ -123,7 +122,6 @@ nsMimeTypeArray::NamedItem(const nsAStri
     if (type.Equals(aName)) {
       *aReturn = mtype;
 
-      NS_ADDREF(*aReturn);
 
       return NS_OK;
     }
@@ -284,7 +282,6 @@ nsMimeType::GetEnabledPlugin(nsIDOMPlugi
 
   *aEnabledPlugin = disabled ? nsnull : mPlugin;
 
-  NS_IF_ADDREF(*aEnabledPlugin);
 
   return NS_OK;
 }
diff --git a/dom/src/base/nsPluginArray.cpp b/dom/src/base/nsPluginArray.cpp
--- a/dom/src/base/nsPluginArray.cpp
+++ b/dom/src/base/nsPluginArray.cpp
@@ -123,7 +123,6 @@ nsPluginArray::Item(PRUint32 aIndex, nsI
 
   if (aIndex < mPluginCount) {
     *aReturn = mPluginArray[aIndex];
-    NS_IF_ADDREF(*aReturn);
   }
 
   return NS_OK;
@@ -150,7 +149,6 @@ nsPluginArray::NamedItem(const nsAString
     if (plugin->GetName(pluginName) == NS_OK) {
       if (pluginName.Equals(aName)) {
         *aReturn = plugin;
-        NS_IF_ADDREF(plugin);
         break;
       }
     }
@@ -175,7 +173,6 @@ nsPluginArray::GetPluginHost(nsIPluginHo
   }
 
   *aPluginHost = mPluginHost;
-  NS_IF_ADDREF(*aPluginHost);
 
   return rv;
 }
@@ -295,7 +292,6 @@ nsPluginArray::GetPlugins()
       // is scriptable.
       for (PRUint32 i = 0; i < mPluginCount; i++) {
         nsIDOMPlugin* wrapper = new nsPluginElement(mPluginArray[i]);
-        NS_IF_ADDREF(wrapper);
         mPluginArray[i] = wrapper;
       }
     } else {
@@ -376,7 +372,6 @@ nsPluginElement::Item(PRUint32 aIndex, n
   }
   if (aIndex < mMimeTypeCount) {
     nsIDOMMimeType* mimeType = mMimeTypeArray[aIndex];
-    NS_IF_ADDREF(mimeType);
     *aReturn = mimeType;
     return NS_OK;
   }
@@ -399,7 +394,6 @@ nsPluginElement::NamedItem(const nsAStri
     if (mimeType->GetType(type) == NS_OK) {
       if (type.Equals(aName)) {
         *aReturn = mimeType;
-        NS_ADDREF(mimeType);
         break;
       }
     }
@@ -422,7 +416,7 @@ nsPluginElement::GetMimeTypes()
       if (rv != NS_OK)
         break;
       mimeType = new nsMimeType(this, mimeType);
-      NS_IF_ADDREF(mMimeTypeArray[i] = mimeType);
+      mMimeTypeArray[i] = mimeType;
     }
   }
   return rv;
diff --git a/dom/src/base/nsWindowRoot.cpp b/dom/src/base/nsWindowRoot.cpp
--- a/dom/src/base/nsWindowRoot.cpp
+++ b/dom/src/base/nsWindowRoot.cpp
@@ -222,7 +222,6 @@ nsWindowRoot::GetListenerManager(PRBool 
   }
 
   *aResult = mListenerManager;
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -258,7 +257,6 @@ nsWindowRoot::GetFocusController(nsIFocu
 nsWindowRoot::GetFocusController(nsIFocusController** aResult)
 {
   *aResult = mFocusController;
-  NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -290,6 +288,5 @@ NS_NewWindowRoot(nsIDOMWindow* aWindow, 
   *aResult = new nsWindowRoot(aWindow);
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
diff --git a/dom/src/events/nsJSEventListener.cpp b/dom/src/events/nsJSEventListener.cpp
--- a/dom/src/events/nsJSEventListener.cpp
+++ b/dom/src/events/nsJSEventListener.cpp
@@ -272,7 +272,7 @@ NS_NewJSEventListener(nsIScriptContext *
   if (!it) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  NS_ADDREF(*aReturn = it);
+  *aReturn = it;
 
   return NS_OK;
 }
diff --git a/dom/src/json/nsJSON.cpp b/dom/src/json/nsJSON.cpp
--- a/dom/src/json/nsJSON.cpp
+++ b/dom/src/json/nsJSON.cpp
@@ -721,7 +721,6 @@ NS_NewJSON(nsISupports* aOuter, REFNSIID
   if (!json)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(json);
   *aResult = json;
 
   return NS_OK;
diff --git a/dom/src/jsurl/nsJSProtocolHandler.cpp b/dom/src/jsurl/nsJSProtocolHandler.cpp
--- a/dom/src/jsurl/nsJSProtocolHandler.cpp
+++ b/dom/src/jsurl/nsJSProtocolHandler.cpp
@@ -1081,7 +1081,6 @@ nsJSProtocolHandler::Create(nsISupports 
     nsJSProtocolHandler* ph = new nsJSProtocolHandler();
     if (!ph)
         return NS_ERROR_OUT_OF_MEMORY;
-    NS_ADDREF(ph);
     nsresult rv = ph->Init();
     if (NS_SUCCEEDED(rv)) {
         rv = ph->QueryInterface(aIID, aResult);
@@ -1189,12 +1188,10 @@ nsJSProtocolHandler::NewChannel(nsIURI* 
     if (!channel) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
-    NS_ADDREF(channel);
 
     rv = channel->Init(uri);
     if (NS_SUCCEEDED(rv)) {
         *result = channel;
-        NS_ADDREF(*result);
     }
     NS_RELEASE(channel);
     return rv;
diff --git a/dom/src/offline/nsDOMOfflineLoadStatusList.cpp b/dom/src/offline/nsDOMOfflineLoadStatusList.cpp
--- a/dom/src/offline/nsDOMOfflineLoadStatusList.cpp
+++ b/dom/src/offline/nsDOMOfflineLoadStatusList.cpp
@@ -324,7 +324,7 @@ nsDOMOfflineLoadStatusList::Item(PRUint3
 
   if ((PRInt32)aItem >= mItems.Count()) return NS_ERROR_DOM_INDEX_SIZE_ERR;
 
-  NS_ADDREF(*aStatus = mItems[aItem]);
+  *aStatus = mItems[aItem];
 
   return NS_OK;
 }
@@ -571,7 +571,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsDOMLoadStatusEvent::GetStatus(nsIDOMLoadStatus **aStatus)
 {
-  NS_ADDREF(*aStatus = mStatus);
+  *aStatus = mStatus;
 
   return NS_OK;
 }
diff --git a/dom/src/offline/nsDOMOfflineResourceList.cpp b/dom/src/offline/nsDOMOfflineResourceList.cpp
--- a/dom/src/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/src/offline/nsDOMOfflineResourceList.cpp
@@ -408,7 +408,7 @@ nsDOMOfflineResourceList::GetOnchecking(
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ENSURE_ARG_POINTER(aOnchecking);
-  NS_IF_ADDREF(*aOnchecking = mOnCheckingListener);
+  *aOnchecking = mOnCheckingListener;
   return NS_OK;
 }
 
@@ -429,7 +429,7 @@ nsDOMOfflineResourceList::GetOnerror(nsI
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ENSURE_ARG_POINTER(aOnerror);
-  NS_IF_ADDREF(*aOnerror = mOnErrorListener);
+  *aOnerror = mOnErrorListener;
   return NS_OK;
 }
 
@@ -450,7 +450,7 @@ nsDOMOfflineResourceList::GetOnnoupdate(
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ENSURE_ARG_POINTER(aOnnoupdate);
-  NS_IF_ADDREF(*aOnnoupdate = mOnNoUpdateListener);
+  *aOnnoupdate = mOnNoUpdateListener;
   return NS_OK;
 }
 
@@ -471,7 +471,7 @@ nsDOMOfflineResourceList::GetOndownloadi
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ENSURE_ARG_POINTER(aOndownloading);
-  NS_IF_ADDREF(*aOndownloading = mOnDownloadingListener);
+  *aOndownloading = mOnDownloadingListener;
   return NS_OK;
 }
 
@@ -492,7 +492,7 @@ nsDOMOfflineResourceList::GetOnprogress(
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ENSURE_ARG_POINTER(aOnprogress);
-  NS_IF_ADDREF(*aOnprogress = mOnProgressListener);
+  *aOnprogress = mOnProgressListener;
   return NS_OK;
 }
 
@@ -514,7 +514,7 @@ nsDOMOfflineResourceList::GetOnupdaterea
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ENSURE_ARG_POINTER(aOnupdateready);
-  NS_IF_ADDREF(*aOnupdateready = mOnUpdateReadyListener);
+  *aOnupdateready = mOnUpdateReadyListener;
   return NS_OK;
 }
 
@@ -535,7 +535,7 @@ nsDOMOfflineResourceList::GetOncached(ns
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ENSURE_ARG_POINTER(aOncached);
-  NS_IF_ADDREF(*aOncached = mOnCachedListener);
+  *aOncached = mOnCachedListener;
   return NS_OK;
 }
 
diff --git a/dom/src/storage/nsDOMStorage.cpp b/dom/src/storage/nsDOMStorage.cpp
--- a/dom/src/storage/nsDOMStorage.cpp
+++ b/dom/src/storage/nsDOMStorage.cpp
@@ -195,7 +195,6 @@ nsDOMStorageManager::Initialize()
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(gStorageManager);
 
   nsIObserverService* os = do_GetService("@mozilla.org/observer-service;1");
   if (os) {
@@ -212,7 +211,6 @@ nsDOMStorageManager::GetInstance()
 {
   NS_ASSERTION(gStorageManager,
                "nsDOMStorageManager::GetInstance() called before Initialize()");
-  NS_IF_ADDREF(gStorageManager);
   return gStorageManager;
 }
 
@@ -382,7 +380,6 @@ NS_NewDOMStorage(nsISupports* aOuter, RE
   if (!storage)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(storage);
   *aResult = storage;
 
   return NS_OK;
@@ -602,7 +599,7 @@ nsDOMStorage::GetItem(const nsAString& a
     if (!IsCallerSecure() && entry->mItem->IsSecure()) {
       return NS_OK;
     }
-    NS_ADDREF(*aItem = entry->mItem);
+    *aItem = entry->mItem;
   }
   else if (UseDB()) {
     PRBool secure;
@@ -623,7 +620,7 @@ nsDOMStorage::GetItem(const nsAString& a
     NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY);
 
     entry->mItem = newitem;
-    NS_ADDREF(*aItem = newitem);
+    *aItem = newitem;
   }
 
   return NS_OK;
@@ -952,7 +949,6 @@ nsDOMStorage::Clone(nsIURI* aURI)
 
   mItems.EnumerateEntries(CopyStorageItems, storage);
 
-  NS_ADDREF(storage);
 
   return storage;
 }
@@ -1182,7 +1178,6 @@ NS_NewDOMStorageList(nsIDOMStorageList**
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
diff --git a/editor/composer/src/nsComposerDocumentCommands.cpp b/editor/composer/src/nsComposerDocumentCommands.cpp
--- a/editor/composer/src/nsComposerDocumentCommands.cpp
+++ b/editor/composer/src/nsComposerDocumentCommands.cpp
@@ -82,7 +82,7 @@ GetPresContextFromEditor(nsIEditor *aEdi
   nsIPresShell* presShell = do_QueryInterface(selCon);
   if (!presShell) return NS_ERROR_FAILURE;
 
-  NS_IF_ADDREF(*aResult = presShell->GetPresContext());
+  *aResult = presShell->GetPresContext();
   return NS_OK;
 }
 
diff --git a/editor/composer/src/nsComposerRegistration.cpp b/editor/composer/src/nsComposerRegistration.cpp
--- a/editor/composer/src/nsComposerRegistration.cpp
+++ b/editor/composer/src/nsComposerRegistration.cpp
@@ -90,7 +90,6 @@ nsComposeTxtSrvFilterConstructor(nsISupp
     {
         return NS_ERROR_OUT_OF_MEMORY;
     }
-    NS_ADDREF(inst);
 	  inst->Init(aIsForMail);
     nsresult rv = inst->QueryInterface(aIID, aResult);
     NS_RELEASE(inst);
@@ -141,7 +140,6 @@ CreateControllerWithSingletonCommandTabl
   if (NS_FAILED(rv)) return rv;
   
   *aResult = controller;
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
diff --git a/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp b/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
--- a/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
+++ b/editor/libeditor/base/ChangeCSSInlineStyleTxn.cpp
@@ -144,7 +144,6 @@ NS_IMETHODIMP ChangeCSSInlineStyleTxn::I
   mEditor = aEditor;
   mElement = do_QueryInterface(aElement);
   mProperty = aProperty;
-  NS_ADDREF(mProperty);
   mValue.Assign(aValue);
   mRemoveProperty = aRemoveProperty;
   mUndoAttributeWasSet = PR_FALSE;
diff --git a/editor/libeditor/base/CreateElementTxn.cpp b/editor/libeditor/base/CreateElementTxn.cpp
--- a/editor/libeditor/base/CreateElementTxn.cpp
+++ b/editor/libeditor/base/CreateElementTxn.cpp
@@ -210,6 +210,5 @@ NS_IMETHODIMP CreateElementTxn::GetNewNo
   if (!mNewNode)
     return NS_ERROR_NOT_INITIALIZED;
   *aNewNode = mNewNode;
-  NS_ADDREF(*aNewNode);
   return NS_OK;
 }
diff --git a/editor/libeditor/base/EditAggregateTxn.cpp b/editor/libeditor/base/EditAggregateTxn.cpp
--- a/editor/libeditor/base/EditAggregateTxn.cpp
+++ b/editor/libeditor/base/EditAggregateTxn.cpp
@@ -205,7 +205,6 @@ NS_IMETHODIMP EditAggregateTxn::GetName(
   if (aName && mName)
   {
     *aName = mName;
-    NS_ADDREF(*aName);
     return NS_OK;
   }
   return NS_ERROR_NULL_POINTER;
@@ -217,7 +216,6 @@ NS_IMETHODIMP EditAggregateTxn::QueryInt
  
   if (aIID.Equals(EditAggregateTxn::GetCID())) {
     *aInstancePtr = static_cast<EditAggregateTxn*>(this);
-    NS_ADDREF_THIS();
     return NS_OK;
   }
   return EditTxn::QueryInterface(aIID, aInstancePtr);
diff --git a/editor/libeditor/base/IMETextTxn.cpp b/editor/libeditor/base/IMETextTxn.cpp
--- a/editor/libeditor/base/IMETextTxn.cpp
+++ b/editor/libeditor/base/IMETextTxn.cpp
@@ -186,7 +186,6 @@ IMETextTxn::QueryInterface(REFNSIID aIID
   }
   if (aIID.Equals(IMETextTxn::GetCID())) {
     *aInstancePtr = (void*)(IMETextTxn*)this;
-    NS_ADDREF_THIS();
     return NS_OK;
   }
   return (EditTxn::QueryInterface(aIID, aInstancePtr));
diff --git a/editor/libeditor/base/InsertTextTxn.cpp b/editor/libeditor/base/InsertTextTxn.cpp
--- a/editor/libeditor/base/InsertTextTxn.cpp
+++ b/editor/libeditor/base/InsertTextTxn.cpp
@@ -164,7 +164,6 @@ InsertTextTxn::QueryInterface(REFNSIID a
   }
   if (aIID.Equals(InsertTextTxn::GetCID())) {
     *aInstancePtr = (void*)(InsertTextTxn*)this;
-    NS_ADDREF_THIS();
     return NS_OK;
   }
   return (EditTxn::QueryInterface(aIID, aInstancePtr));
diff --git a/editor/libeditor/base/SplitElementTxn.cpp b/editor/libeditor/base/SplitElementTxn.cpp
--- a/editor/libeditor/base/SplitElementTxn.cpp
+++ b/editor/libeditor/base/SplitElementTxn.cpp
@@ -222,6 +222,5 @@ NS_IMETHODIMP SplitElementTxn::GetNewNod
   if (!mNewLeftNode)
     return NS_ERROR_NOT_INITIALIZED;
   *aNewNode = mNewLeftNode;
-  NS_ADDREF(*aNewNode);
   return NS_OK;
 }
diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -206,7 +206,6 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsI
 
   mViewManager = ps->GetViewManager();
   if (!mViewManager) {return NS_ERROR_NULL_POINTER;}
-  NS_ADDREF(mViewManager);
 
   mUpdateCount=0;
 
@@ -526,7 +525,7 @@ nsEditor::GetDocument(nsIDOMDocument **a
   NS_PRECONDITION(mDocWeak, "bad state, mDocWeak weak pointer not initialized");
   nsIDOMDocument* doc = do_QueryReferent(mDocWeak);
   if (!doc) return NS_ERROR_NOT_INITIALIZED;
-  NS_ADDREF(*aDoc = doc);
+  *aDoc = doc;
   return NS_OK;
 }
 
@@ -540,7 +539,7 @@ nsEditor::GetPresShell(nsIPresShell **aP
   NS_PRECONDITION(mPresShellWeak, "bad state, null mPresShellWeak");
   nsIPresShell* ps = do_QueryReferent(mPresShellWeak);
   if (!ps) return NS_ERROR_NOT_INITIALIZED;
-  NS_ADDREF(*aPS = ps);
+  *aPS = ps;
   return NS_OK;
 }
 
@@ -570,7 +569,7 @@ nsEditor::GetSelectionController(nsISele
   NS_PRECONDITION(mSelConWeak, "bad state, null mSelConWeak");
   nsISelectionController* selCon = do_QueryReferent(mSelConWeak);
   if (!selCon) return NS_ERROR_NOT_INITIALIZED;
-  NS_ADDREF(*aSel = selCon);
+  *aSel = selCon;
   return NS_OK;
 }
 
@@ -737,7 +736,7 @@ nsEditor::GetTransactionManager(nsITrans
   if (!mTxnMgr)
     return NS_ERROR_FAILURE;
 
-  NS_ADDREF(*aTxnManager = mTxnMgr);
+  *aTxnManager = mTxnMgr;
   return NS_OK;
 }
 
@@ -1312,7 +1311,7 @@ NS_IMETHODIMP nsEditor::GetInlineSpellCh
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  NS_IF_ADDREF(*aInlineSpellChecker = mInlineSpellChecker);
+  *aInlineSpellChecker = mInlineSpellChecker;
 
   return NS_OK;
 }
@@ -2077,7 +2076,6 @@ GetEditorContentWindow(nsIPresShell *aPr
   if (!*aResult)
     return NS_ERROR_FAILURE;
 
-  NS_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -2105,7 +2103,7 @@ nsEditor::GetKBStateControl(nsIKBStateCo
   if (!kb)
     return NS_ERROR_NOT_INITIALIZED;
 
-  NS_ADDREF(*aKBSC = kb);
+  *aKBSC = kb;
 
   return NS_OK;
 }
@@ -2301,7 +2299,6 @@ nsEditor::GetRootElement(nsIDOMElement *
   {
     // if we have cached the body element, use that
     *aRootElement = mRootElement;
-    NS_ADDREF(*aRootElement);
     return NS_OK;
   }
 
@@ -2324,7 +2321,6 @@ nsEditor::GetRootElement(nsIDOMElement *
 
   mRootElement = bodyElement;
   *aRootElement = bodyElement;
-  NS_ADDREF(*aRootElement);
 
   return NS_OK;
 }
@@ -4469,7 +4465,6 @@ nsEditor::DeleteSelectionAndCreateNode(c
                       &newNode);
   // XXX: ERROR_HANDLING  check result, and make sure aNewNode is set correctly in success/failure cases
   *aNewNode = newNode;
-  NS_IF_ADDREF(*aNewNode);
 
   // we want the selection to be just after the new node
   nsISelection* selection = nsnull;
@@ -4968,7 +4963,7 @@ nsEditor::CreateTxnForDeleteInsertionPoi
                                                ePrevious, &txn);
           if (NS_SUCCEEDED(result)) {
             aTxn->AppendChild(txn);
-            NS_ADDREF(*aNode = priorNode);
+            *aNode = priorNode;
             *aOffset = txn->GetOffset();
             *aLength = txn->GetNumCharsToDelete();
             NS_RELEASE(txn);
@@ -4987,7 +4982,7 @@ nsEditor::CreateTxnForDeleteInsertionPoi
         if (NS_SUCCEEDED(result)) {
           aTxn->AppendChild(txn);
           NS_RELEASE(txn);
-          NS_ADDREF(*aNode = priorNode);
+          *aNode = priorNode;
         }
       }
     }
@@ -5010,7 +5005,7 @@ nsEditor::CreateTxnForDeleteInsertionPoi
           result = CreateTxnForDeleteCharacter(nextNodeAsText, 0, eNext, &txn);
           if (NS_SUCCEEDED(result)) {
             aTxn->AppendChild(txn);
-            NS_ADDREF(*aNode = nextNode);
+            *aNode = nextNode;
             *aOffset = txn->GetOffset();
             *aLength = txn->GetNumCharsToDelete();
             NS_RELEASE(txn);
@@ -5029,7 +5024,7 @@ nsEditor::CreateTxnForDeleteInsertionPoi
         if (NS_SUCCEEDED(result)) {
           aTxn->AppendChild(txn);
           NS_RELEASE(txn);
-          NS_ADDREF(*aNode = nextNode);
+          *aNode = nextNode;
         }
       }
     }
@@ -5043,7 +5038,7 @@ nsEditor::CreateTxnForDeleteInsertionPoi
                                            &txn);
       if (NS_SUCCEEDED(result)) {
         aTxn->AppendChild(txn);
-        NS_ADDREF(*aNode = node);
+        *aNode = node;
         *aOffset = txn->GetOffset();
         *aLength = txn->GetNumCharsToDelete();
       }
@@ -5078,7 +5073,7 @@ nsEditor::CreateTxnForDeleteInsertionPoi
           if (NS_FAILED(result))  { return result; }
           if (!delTextTxn) { return NS_ERROR_NULL_POINTER; }
           aTxn->AppendChild(delTextTxn);
-          NS_ADDREF(*aNode = selectedNode);
+          *aNode = selectedNode;
           *aOffset = delTextTxn->GetOffset();
           *aLength = delTextTxn->GetNumCharsToDelete();
         }
@@ -5090,7 +5085,7 @@ nsEditor::CreateTxnForDeleteInsertionPoi
           if (NS_FAILED(result))  { return result; }
           if (!delElementTxn) { return NS_ERROR_NULL_POINTER; }
           aTxn->AppendChild(delElementTxn);
-          NS_ADDREF(*aNode = selectedNode);
+          *aNode = selectedNode;
         }
       }
     }
@@ -5233,7 +5228,6 @@ nsEditor::GetPIDOMEventTarget()
   nsPIDOMEventTarget* piTarget = mEventTarget;
   if (piTarget)
   {
-    NS_ADDREF(piTarget);
     return piTarget;
   }
 
@@ -5248,7 +5242,6 @@ nsEditor::GetPIDOMEventTarget()
   {
     mEventTarget = do_QueryInterface(content->GetParent());
     piTarget = mEventTarget;
-    NS_IF_ADDREF(piTarget);
   }
   else
   {
diff --git a/editor/libeditor/html/nsHTMLAbsPosition.cpp b/editor/libeditor/html/nsHTMLAbsPosition.cpp
--- a/editor/libeditor/html/nsHTMLAbsPosition.cpp
+++ b/editor/libeditor/html/nsHTMLAbsPosition.cpp
@@ -122,7 +122,6 @@ nsHTMLEditor::GetAbsolutelyPositionedSel
 
   element = do_QueryInterface(resultNode ); 
   *_retval = element;
-  NS_IF_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -651,7 +650,6 @@ nsHTMLEditor::GetPositionedElement(nsIDO
 nsHTMLEditor::GetPositionedElement(nsIDOMElement ** aReturn)
 {
   *aReturn = mAbsolutelyPositionedObject;
-  NS_IF_ADDREF(*aReturn);
   return NS_OK;
 }
 
diff --git a/editor/libeditor/html/nsHTMLAnonymousUtils.cpp b/editor/libeditor/html/nsHTMLAnonymousUtils.cpp
--- a/editor/libeditor/html/nsHTMLAnonymousUtils.cpp
+++ b/editor/libeditor/html/nsHTMLAnonymousUtils.cpp
@@ -201,7 +201,6 @@ nsHTMLEditor::CreateAnonymousElement(con
     newContent->UnbindFromTree();
     return NS_ERROR_OUT_OF_MEMORY;
   }
-  NS_ADDREF(observer); // NodeWillBeDestroyed releases.
   parentContent->AddMutationObserver(observer);
   newContent->AddMutationObserver(observer);
 
@@ -209,7 +208,6 @@ nsHTMLEditor::CreateAnonymousElement(con
   ps->RecreateFramesFor(newContent);
 
   *aReturn = newElement;
-  NS_IF_ADDREF(*aReturn);
   return NS_OK;
 }
 
diff --git a/editor/libeditor/html/nsHTMLCSSUtils.cpp b/editor/libeditor/html/nsHTMLCSSUtils.cpp
--- a/editor/libeditor/html/nsHTMLCSSUtils.cpp
+++ b/editor/libeditor/html/nsHTMLCSSUtils.cpp
@@ -1422,7 +1422,6 @@ nsHTMLCSSUtils::GetElementContainerOrSel
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
   nsIDOMElement* element = do_QueryInterface(node);
   (*aElement) = element;
-  NS_IF_ADDREF(*aElement);
   return NS_OK;
 }
 
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
@@ -1789,7 +1789,6 @@ nsHTMLEditor::PutDragDataInTransferable(
   }
 
   *aTransferable = trans; 
-  NS_ADDREF(*aTransferable);
   return NS_OK;
 }
 
@@ -2287,7 +2286,6 @@ nsHTMLEditor::InsertAsPlaintextQuotation
       if (aNodeInserted && NS_SUCCEEDED(rv))
       {
         *aNodeInserted = preNode;
-        NS_IF_ADDREF(*aNodeInserted);
       }
     }
   }
@@ -2378,7 +2376,6 @@ nsHTMLEditor::InsertAsCitedQuotation(con
         if (NS_SUCCEEDED(res))
         {
           *aNodeInserted = newNode;
-          NS_IF_ADDREF(*aNodeInserted);
         }
       }
     }
diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -314,7 +314,6 @@ nsHTMLEditor::Init(nsIDOMDocument *aDoc,
     // init the type-in state
     mTypeInState = new TypeInState();
     if (!mTypeInState) {return NS_ERROR_NULL_POINTER;}
-    NS_ADDREF(mTypeInState);
 
     // init the selection listener for image resizing
     mSelectionListenerP = new ResizerSelectionListener(this);
@@ -812,7 +811,6 @@ nsHTMLEditor::GetBlockSection(nsIDOMNode
     *aLeftNode = sibling;
     result = (*aLeftNode)->GetPreviousSibling(&sibling); 
   }
-  NS_ADDREF((*aLeftNode));
   // now do the right side
   result = aChild->GetNextSibling(&sibling);
   while ((NS_SUCCEEDED(result)) && sibling)
@@ -829,7 +827,6 @@ nsHTMLEditor::GetBlockSection(nsIDOMNode
     *aRightNode = sibling;
     result = (*aRightNode)->GetNextSibling(&sibling); 
   }
-  NS_ADDREF((*aRightNode));
 
   return result;
 }
@@ -2990,7 +2987,6 @@ NODE_FOUND:
     {
       *aReturn = currentElement;
       // Getters must addref
-      NS_ADDREF(*aReturn);
     }
   }
   else res = NS_EDITOR_ELEMENT_NOT_FOUND;
@@ -3124,7 +3120,6 @@ nsHTMLEditor::GetSelectedElement(const n
           if (bNodeFound) {
             // GetElementOrParentByTagName addref'd this, so we don't need to do it here
             *aReturn = parentLinkOfAnchor;
-            NS_IF_ADDREF(*aReturn);
             return NS_OK;
           }
         }
@@ -3225,7 +3220,6 @@ nsHTMLEditor::GetSelectedElement(const n
     if (selectedElement)
     {  
       // Getters must addref
-      NS_ADDREF(*aReturn);
     }
   } 
   else res = NS_EDITOR_ELEMENT_NOT_FOUND;
@@ -3298,7 +3292,6 @@ nsHTMLEditor::CreateElementWithDefaults(
   {
     *aReturn = newElement;
     // Getters must addref
-    NS_ADDREF(*aReturn);
   }
 
   return res;
@@ -3766,7 +3759,6 @@ nsHTMLEditor::GetStyleSheetForURL(const 
   if (!*aStyleSheet)
     return NS_ERROR_FAILURE;
 
-  NS_ADDREF(*aStyleSheet);
 
   return NS_OK;
 }
@@ -3803,7 +3795,7 @@ nsHTMLEditor::GetCSSLoader(const nsAStri
   nsIDocument *document = ps->GetDocument();
   if (!document)     return NS_ERROR_NULL_POINTER;
 
-  NS_ADDREF(*aCSSLoader = document->CSSLoader());
+  *aCSSLoader = document->CSSLoader();
 
   return NS_OK;
 }
@@ -4653,7 +4645,6 @@ nsHTMLEditor::GetNextElementByTagName(ns
       if (!element) return NS_ERROR_NULL_POINTER;
 
       *aReturn = element;
-      NS_ADDREF(*aReturn);
       done = PR_TRUE;
       return NS_OK;
     }
@@ -5776,7 +5767,6 @@ nsHTMLEditor::CopyLastEditableChildStyle
     if (NS_FAILED(res)) return res;
     // Getters must addref
     *aOutBrNode = outBRNode;
-    NS_ADDREF(*aOutBrNode);
   }
   return NS_OK;
 }
@@ -5919,7 +5909,6 @@ nsHTMLEditor::GetSelectionContainer(nsID
 
   nsIDOMElement* focusElement = do_QueryInterface(focusNode);
   *aReturn = focusElement;
-  NS_IF_ADDREF(*aReturn);
 
   return NS_OK;
 }
diff --git a/editor/libeditor/html/nsHTMLEditorLog.cpp b/editor/libeditor/html/nsHTMLEditorLog.cpp
--- a/editor/libeditor/html/nsHTMLEditorLog.cpp
+++ b/editor/libeditor/html/nsHTMLEditorLog.cpp
@@ -853,7 +853,6 @@ nsHTMLEditorLog::StartLogging(nsIFile *a
 
     if (mEditorTxnLog)
     {
-      NS_ADDREF(mEditorTxnLog);
       mTxnMgr->AddListener(mEditorTxnLog);
     }
     else
diff --git a/editor/libeditor/html/nsHTMLObjectResizer.cpp b/editor/libeditor/html/nsHTMLObjectResizer.cpp
--- a/editor/libeditor/html/nsHTMLObjectResizer.cpp
+++ b/editor/libeditor/html/nsHTMLObjectResizer.cpp
@@ -1075,7 +1075,6 @@ nsHTMLEditor::GetResizedObject(nsIDOMEle
 nsHTMLEditor::GetResizedObject(nsIDOMElement * *aResizedObject)
 {
   *aResizedObject = mResizedObject;
-  NS_IF_ADDREF(*aResizedObject);
   return NS_OK;
 }
 
diff --git a/editor/libeditor/html/nsHTMLURIRefObject.cpp b/editor/libeditor/html/nsHTMLURIRefObject.cpp
--- a/editor/libeditor/html/nsHTMLURIRefObject.cpp
+++ b/editor/libeditor/html/nsHTMLURIRefObject.cpp
@@ -295,7 +295,6 @@ nsHTMLURIRefObject::GetNode(nsIDOMNode**
   if (!aNode)
     return NS_ERROR_NULL_POINTER;
   *aNode = mNode.get();
-  NS_ADDREF(*aNode);
   return NS_OK;
 }
 
diff --git a/editor/libeditor/html/nsTableEditor.cpp b/editor/libeditor/html/nsTableEditor.cpp
--- a/editor/libeditor/html/nsTableEditor.cpp
+++ b/editor/libeditor/html/nsTableEditor.cpp
@@ -149,7 +149,6 @@ nsHTMLEditor::InsertCell(nsIDOMElement *
   if (aNewCell)
   {
     *aNewCell = newCell;
-    NS_ADDREF(*aNewCell);
   }
 
   if( aRowSpan > 1)
@@ -269,7 +268,6 @@ nsHTMLEditor::GetFirstRow(nsIDOMElement*
       {
         // Found a row directly under <table>
         *aRowNode = tableChild;
-        NS_ADDREF(*aRowNode);
         return NS_OK;
       }
       // Look for row in one of the row container elements      
@@ -293,7 +291,6 @@ nsHTMLEditor::GetFirstRow(nsIDOMElement*
         if(rowNode)
         {
           *aRowNode = rowNode;
-          NS_ADDREF(*aRowNode);
           return NS_OK;
         }
       }
@@ -341,7 +338,6 @@ nsHTMLEditor::GetNextRow(nsIDOMNode* aCu
   if(nextRow)
   {
     *aRowNode = nextRow;
-    NS_ADDREF(*aRowNode);
     return NS_OK;
   }
 
@@ -371,7 +367,6 @@ nsHTMLEditor::GetNextRow(nsIDOMNode* aCu
     if(nextRow)
     {
       *aRowNode = nextRow;
-      NS_ADDREF(*aRowNode);
       return NS_OK;
     }
 #ifdef DEBUG_cmanske
@@ -414,7 +409,6 @@ nsHTMLEditor::GetFirstCellInRow(nsIDOMNo
   if (rowChild)
   {
     *aCellNode = rowChild;
-    NS_ADDREF(*aCellNode);
     return NS_OK;
   }
   // If here, cell was not found
@@ -446,7 +440,6 @@ nsHTMLEditor::GetNextCellInRow(nsIDOMNod
   if (nextCell)
   {
     *aCellNode = nextCell;
-    NS_ADDREF(*aCellNode);
     return NS_OK;
   }
   // If here, cell was not found
@@ -478,7 +471,6 @@ nsHTMLEditor::GetLastCellInRow(nsIDOMNod
   if (rowChild)
   {
     *aCellNode = rowChild;
-    NS_ADDREF(*aCellNode);
     return NS_OK;
   }
   // If here, cell was not found
@@ -1917,7 +1909,6 @@ nsHTMLEditor::SplitCellIntoColumns(nsIDO
     if (aNewCell)
     {
       *aNewCell = newCell;
-      NS_ADDREF(*aNewCell);
     }
     res = CopyCellBackgroundColor(newCell, cell);
   }
@@ -2031,7 +2022,6 @@ nsHTMLEditor::SplitCellIntoRows(nsIDOMEl
     if (aNewCell)
     {
       *aNewCell = newCell;
-      NS_ADDREF(*aNewCell);
     }
     res = CopyCellBackgroundColor(newCell, cell2);
   }
@@ -2073,7 +2063,6 @@ nsHTMLEditor::SwitchTableCellHeaderType(
   {
     nsIDOMElement* newElement = do_QueryInterface(newNode);
     *aNewCell = newElement;
-    NS_ADDREF(*aNewCell);
   }
 
   return NS_OK;
@@ -2863,7 +2852,6 @@ nsHTMLEditor::GetCellDataAt(nsIDOMElemen
   if (cell)
   {
     *aCell = cell;
-    NS_ADDREF(*aCell);
   }
   // Convert to editor's generic "not found" return value
   if (res == NS_TABLELAYOUT_CELL_NOT_FOUND) res = NS_EDITOR_ELEMENT_NOT_FOUND;
@@ -2918,7 +2906,6 @@ nsHTMLEditor::GetCellContext(nsISelectio
   if (aSelection)
   {
     *aSelection = selection;
-    NS_ADDREF(*aSelection);
   }
   nsIDOMElement* table = nsnull;
   nsIDOMElement* cell = nsnull;
@@ -2945,7 +2932,6 @@ nsHTMLEditor::GetCellContext(nsISelectio
       if (aTable)
       {
         *aTable = cellOrTableElement;
-        NS_ADDREF(*aTable);
       }
       return NS_OK;
     }
@@ -2958,7 +2944,6 @@ nsHTMLEditor::GetCellContext(nsISelectio
   if (aCell)
   {
     *aCell = cell;
-    NS_ADDREF(*aCell);
   }
 
   // Get containing table
@@ -2969,7 +2954,6 @@ nsHTMLEditor::GetCellContext(nsISelectio
   if (aTable)
   {
     *aTable = table;
-    NS_ADDREF(*aTable);
   }
 
   // Get the rest of the related data only if requested
@@ -2992,7 +2976,6 @@ nsHTMLEditor::GetCellContext(nsISelectio
     if (!cellParent) return NS_ERROR_FAILURE;
 
     *aCellParent = cellParent;
-    NS_ADDREF(*aCellParent);
 
     if (aCellOffset)
       res = GetChildOffset(cell, cellParent, *aCellOffset);
@@ -3043,7 +3026,6 @@ nsHTMLEditor::GetCellFromRange(nsIDOMRan
     // (Let's not for now -- more efficient)
     nsIDOMElement* cellElement = do_QueryInterface(childNode);
     *aCell = cellElement;
-    NS_ADDREF(*aCell);
     return NS_OK;
   }
   return NS_EDITOR_ELEMENT_NOT_FOUND;
@@ -3078,7 +3060,6 @@ nsHTMLEditor::GetFirstSelectedCell(nsIDO
   if (aRange)
   {
     *aRange = range;
-    NS_ADDREF(*aRange);
   }
 
   // Setup for next cell
@@ -3134,7 +3115,6 @@ nsHTMLEditor::GetNextSelectedCell(nsIDOM
   if (aRange)
   {
     *aRange = range;
-    NS_ADDREF(*aRange);
   }
 
   // Setup for next cell
@@ -3159,7 +3139,6 @@ nsHTMLEditor::GetFirstSelectedCellInTabl
   if (!cell) return NS_EDITOR_ELEMENT_NOT_FOUND;
 
   *aCell = cell;
-  NS_ADDREF(*aCell);
 
   // Also return the row and/or column if requested
   if (aRowIndex || aColIndex)
@@ -3364,7 +3343,6 @@ nsHTMLEditor::GetSelectedOrParentTableEl
   if (tableOrCellElement)
   {
     *aTableElement = tableOrCellElement;
-    NS_ADDREF(*aTableElement);
   }
   return res;
 }
diff --git a/editor/libeditor/text/nsEditorEventListeners.cpp b/editor/libeditor/text/nsEditorEventListeners.cpp
--- a/editor/libeditor/text/nsEditorEventListeners.cpp
+++ b/editor/libeditor/text/nsEditorEventListeners.cpp
@@ -1071,7 +1071,7 @@ FindSelectionRoot(nsIEditor *aEditor, ns
 
   nsIContent *root;
   if (document->HasFlag(NODE_IS_EDITABLE)) {
-    NS_IF_ADDREF(root = document->GetRootContent());
+    root = document->GetRootContent();
 
     return root;
   }
@@ -1084,7 +1084,7 @@ FindSelectionRoot(nsIEditor *aEditor, ns
     CallQueryInterface(rootElement, &root);
 
     if (!root && document) {
-      NS_IF_ADDREF(root = document->GetRootContent());
+      root = document->GetRootContent();
     }
 
     return root;
@@ -1101,7 +1101,6 @@ FindSelectionRoot(nsIEditor *aEditor, ns
     content = parent;
   }
 
-  NS_IF_ADDREF(content);
 
   return content;
 }
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
@@ -533,7 +533,6 @@ nsPlaintextEditor::SetupDocEncoder(nsIDo
   if (NS_FAILED(rv)) return rv;
 
   *aDocEncoder = encoder;
-  NS_ADDREF(*aDocEncoder);
   return NS_OK;
 }
 
@@ -597,6 +596,5 @@ nsPlaintextEditor::PutDragDataInTransfer
   if (NS_FAILED(rv)) return rv;
 
   *aTransferable = trans;
-  NS_ADDREF(*aTransferable);
   return NS_OK;
 }
diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -1315,7 +1315,7 @@ nsPlaintextEditor::GetAndInitDocEncoder(
     }
   }
 
-  NS_ADDREF(*encoder = docEncoder);
+  *encoder = docEncoder;
   return rv;
 }
 
diff --git a/editor/txmgr/src/nsTransactionList.cpp b/editor/txmgr/src/nsTransactionList.cpp
--- a/editor/txmgr/src/nsTransactionList.cpp
+++ b/editor/txmgr/src/nsTransactionList.cpp
@@ -151,7 +151,6 @@ NS_IMETHODIMP nsTransactionList::GetItem
   if (NS_FAILED(result))
     return result;
 
-  NS_IF_ADDREF(*aItem);
 
   return NS_OK;
 }
@@ -220,7 +219,6 @@ NS_IMETHODIMP nsTransactionList::GetChil
   if (!*aTxnList)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(*aTxnList);
 
   return NS_OK;
 }
diff --git a/editor/txmgr/src/nsTransactionManager.cpp b/editor/txmgr/src/nsTransactionManager.cpp
--- a/editor/txmgr/src/nsTransactionManager.cpp
+++ b/editor/txmgr/src/nsTransactionManager.cpp
@@ -595,7 +595,6 @@ nsTransactionManager::PeekUndoStack(nsIT
 
   UNLOCK_TX_MANAGER(this);
 
-  NS_IF_ADDREF(*aTransaction);
 
   return result;
 }
@@ -624,7 +623,6 @@ nsTransactionManager::PeekRedoStack(nsIT
 
   UNLOCK_TX_MANAGER(this);
 
-  NS_IF_ADDREF(*aTransaction);
 
   return result;
 }
@@ -637,7 +635,6 @@ nsTransactionManager::GetUndoList(nsITra
 
   *aTransactionList = (nsITransactionList *)new nsTransactionList(this, &mUndoStack);
 
-  NS_IF_ADDREF(*aTransactionList);
 
   return (! *aTransactionList) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
 }
@@ -650,7 +647,6 @@ nsTransactionManager::GetRedoList(nsITra
 
   *aTransactionList = (nsITransactionList *)new nsTransactionList(this, &mRedoStack);
 
-  NS_IF_ADDREF(*aTransactionList);
 
   return (! *aTransactionList) ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
 }
@@ -677,7 +673,6 @@ nsTransactionManager::AddListener(nsITra
     return NS_ERROR_FAILURE;
   }
 
-  NS_ADDREF(aListener);
 
   UNLOCK_TX_MANAGER(this);
 
@@ -1050,7 +1045,6 @@ nsTransactionManager::BeginTransaction(n
   // No need for LOCK/UNLOCK_TX_MANAGER() calls since the calling routine
   // should have done this already!
 
-  NS_IF_ADDREF(aTransaction);
 
   // XXX: POSSIBLE OPTIMIZATION
   //      We could use a factory that pre-allocates/recycles transaction items.
diff --git a/editor/txtsvc/src/nsFilteredContentIterator.cpp b/editor/txtsvc/src/nsFilteredContentIterator.cpp
--- a/editor/txtsvc/src/nsFilteredContentIterator.cpp
+++ b/editor/txtsvc/src/nsFilteredContentIterator.cpp
@@ -296,7 +296,6 @@ nsFilteredContentIterator::AdvanceNode(n
     PRBool intersects = ContentIsInTraversalRange(mRange, nextNode, aDir == eForward);
     if (intersects) {
       aNewNode = nextNode;
-      NS_ADDREF(aNewNode);
       return NS_OK;
     }
   } else {
diff --git a/editor/txtsvc/src/nsTextServicesDocument.cpp b/editor/txtsvc/src/nsTextServicesDocument.cpp
--- a/editor/txtsvc/src/nsTextServicesDocument.cpp
+++ b/editor/txtsvc/src/nsTextServicesDocument.cpp
@@ -284,7 +284,6 @@ nsTextServicesDocument::GetDocument(nsID
     return NS_ERROR_NOT_INITIALIZED;
 
   *aDoc = mDOMDocument;
-  NS_ADDREF(*aDoc);
 
   return NS_OK;
 }
@@ -2702,7 +2701,6 @@ nsTextServicesDocument::CreateContentIte
   nsFilteredContentIterator* filter = new nsFilteredContentIterator(mTxtSvcFilter);
   *aIterator = static_cast<nsIContentIterator *>(filter);
   if (*aIterator) {
-    NS_IF_ADDREF(*aIterator);
     result = filter ? NS_OK : NS_ERROR_FAILURE;
   } else {
     delete filter;
@@ -4270,7 +4268,7 @@ nsTextServicesDocument::GetFirstTextNode
 
   if (!mIterator->IsDone())
   {
-    NS_ADDREF(*aContent = mIterator->GetCurrentNode());
+    *aContent = mIterator->GetCurrentNode();
   }
 
   // Restore the iterator:
@@ -4304,7 +4302,7 @@ nsTextServicesDocument::GetFirstTextNode
 
   if (!mIterator->IsDone())
   {
-    NS_ADDREF(*aContent = mIterator->GetCurrentNode());
+    *aContent = mIterator->GetCurrentNode();
   }
 
   // Restore the iterator:
@@ -4684,7 +4682,6 @@ nsTextServicesDocument::FindWordBounds(n
       if (aWordStartNode)
       {
         *aWordStartNode = entry->mNode;
-        NS_IF_ADDREF(*aWordStartNode);
       }
 
       if (aWordStartOffset)
@@ -4715,7 +4712,6 @@ nsTextServicesDocument::FindWordBounds(n
       if (aWordEndNode)
       {
         *aWordEndNode = entry->mNode;
-        NS_IF_ADDREF(*aWordEndNode);
       }
 
       if (aWordEndOffset)
diff --git a/embedding/browser/activex/src/control/HelperAppDlg.cpp b/embedding/browser/activex/src/control/HelperAppDlg.cpp
--- a/embedding/browser/activex/src/control/HelperAppDlg.cpp
+++ b/embedding/browser/activex/src/control/HelperAppDlg.cpp
@@ -550,7 +550,6 @@ nsresult NS_NewHelperAppLauncherDlgFacto
     if (!result)
         return NS_ERROR_OUT_OF_MEMORY;
 
-    NS_ADDREF(result);
     *aFactory = result;
 
     return NS_OK;
diff --git a/embedding/browser/activex/src/control/MozillaBrowser.cpp b/embedding/browser/activex/src/control/MozillaBrowser.cpp
--- a/embedding/browser/activex/src/control/MozillaBrowser.cpp
+++ b/embedding/browser/activex/src/control/MozillaBrowser.cpp
@@ -1726,7 +1726,6 @@ HRESULT STDMETHODCALLTYPE CMozillaBrowse
     if (mWebBrowser)
     {
         nsIWebBrowser *browser = mWebBrowser.get();
-        NS_ADDREF(browser);
         *aBrowser = (void *) browser;
     }
     return S_OK;
@@ -1753,7 +1752,6 @@ nsresult CMozillaBrowser::GetPrefs(nsIPr
 {
     if (mPrefBranch)
         *aPrefBranch = mPrefBranch;
-    NS_IF_ADDREF(*aPrefBranch);
     return (*aPrefBranch) ? NS_OK : NS_ERROR_FAILURE;
 }
 
diff --git a/embedding/browser/activex/src/control/PromptService.cpp b/embedding/browser/activex/src/control/PromptService.cpp
--- a/embedding/browser/activex/src/control/PromptService.cpp
+++ b/embedding/browser/activex/src/control/PromptService.cpp
@@ -892,7 +892,6 @@ nsresult NS_NewPromptServiceFactory(nsIF
     if (!result)
         return NS_ERROR_OUT_OF_MEMORY;
 
-    NS_ADDREF(result);
     *aFactory = result;
 
     return NS_OK;
diff --git a/embedding/browser/activex/src/plugin/XPCBrowser.cpp b/embedding/browser/activex/src/plugin/XPCBrowser.cpp
--- a/embedding/browser/activex/src/plugin/XPCBrowser.cpp
+++ b/embedding/browser/activex/src/plugin/XPCBrowser.cpp
@@ -78,7 +78,6 @@ nsresult IEBrowser::GetWebNavigation(nsI
 {
     NS_ENSURE_ARG_POINTER(aWebNav);
     *aWebNav = mWebNavigation;
-    NS_IF_ADDREF(*aWebNav);
     return (*aWebNav) ? NS_OK : NS_ERROR_FAILURE;
 }
 
@@ -87,7 +86,6 @@ nsresult IEBrowser::GetDOMWindow(nsIDOMW
 {
     NS_ENSURE_ARG_POINTER(aDOMWindow);
     *aDOMWindow = mDOMWindow;
-    NS_IF_ADDREF(*aDOMWindow);
     return (*aDOMWindow) ? NS_OK : NS_ERROR_FAILURE;
 }
 
diff --git a/embedding/browser/activex/src/plugin/XPCDocument.cpp b/embedding/browser/activex/src/plugin/XPCDocument.cpp
--- a/embedding/browser/activex/src/plugin/XPCDocument.cpp
+++ b/embedding/browser/activex/src/plugin/XPCDocument.cpp
@@ -188,7 +188,6 @@ END_COM_MAP()
     virtual nsresult GetDOMLocation(nsIDOMLocation **aLocation)
     {
         *aLocation = mDOMLocation;
-        NS_IF_ADDREF(*aLocation);
         return NS_OK;
     }
 };
diff --git a/embedding/browser/activex/src/plugin/XPConnect.cpp b/embedding/browser/activex/src/plugin/XPConnect.cpp
--- a/embedding/browser/activex/src/plugin/XPConnect.cpp
+++ b/embedding/browser/activex/src/plugin/XPConnect.cpp
@@ -119,7 +119,6 @@ nsScriptablePeer::QueryInterface(const n
         return E_FAIL;
     }
 
-    NS_IF_ADDREF(foundInterface);
     *aInstancePtr = foundInterface;
     return (*aInstancePtr) ? NS_OK : NS_NOINTERFACE;
 }
@@ -434,7 +433,6 @@ nsScriptablePeer::ConvertVariants(VARIAN
     }
 
     *aOut = v;
-    NS_ADDREF(*aOut);
 
     return NS_OK;
 } 
@@ -587,7 +585,6 @@ nsScriptablePeer::GetProperty(const char
     nsCOMPtr<nsIVariant> propertyValue;
     ConvertVariants(&vResult, getter_AddRefs(propertyValue));
     *_retval = propertyValue;
-    NS_IF_ADDREF(*_retval);
 
     return NS_OK;
 }
diff --git a/embedding/browser/gtk/src/EmbedDownloadMgr.cpp b/embedding/browser/gtk/src/EmbedDownloadMgr.cpp
--- a/embedding/browser/gtk/src/EmbedDownloadMgr.cpp
+++ b/embedding/browser/gtk/src/EmbedDownloadMgr.cpp
@@ -237,7 +237,7 @@ NS_IMETHODIMP EmbedDownloadMgr::PromptFo
   if (NS_FAILED(rv))
     return NS_ERROR_FAILURE;
 
-  NS_ADDREF(*_retval = destFile);
+  *_retval = destFile;
   return NS_OK;
 }
 
diff --git a/embedding/browser/gtk/src/EmbedFilePicker.cpp b/embedding/browser/gtk/src/EmbedFilePicker.cpp
--- a/embedding/browser/gtk/src/EmbedFilePicker.cpp
+++ b/embedding/browser/gtk/src/EmbedFilePicker.cpp
@@ -148,7 +148,7 @@ NS_IMETHODIMP EmbedFilePicker::GetFile(n
   localfile = do_QueryInterface(file, &rv);
 
   if (NS_SUCCEEDED(rv)) {
-    NS_ADDREF(*aFile = localfile);
+    *aFile = localfile;
     return NS_OK;
   }
 
diff --git a/embedding/browser/gtk/src/EmbedGlobalHistory.cpp b/embedding/browser/gtk/src/EmbedGlobalHistory.cpp
--- a/embedding/browser/gtk/src/EmbedGlobalHistory.cpp
+++ b/embedding/browser/gtk/src/EmbedGlobalHistory.cpp
@@ -280,7 +280,6 @@ EmbedGlobalHistory::GetInstance()
     sEmbedGlobalHistory = new EmbedGlobalHistory();
     if (!sEmbedGlobalHistory)
       return nsnull;
-    NS_ADDREF(sEmbedGlobalHistory);   // addref the global
     if (NS_FAILED(sEmbedGlobalHistory->Init()))
     {
       NS_RELEASE(sEmbedGlobalHistory);
diff --git a/embedding/browser/gtk/src/EmbedPasswordMgr.cpp b/embedding/browser/gtk/src/EmbedPasswordMgr.cpp
--- a/embedding/browser/gtk/src/EmbedPasswordMgr.cpp
+++ b/embedding/browser/gtk/src/EmbedPasswordMgr.cpp
@@ -255,13 +255,11 @@ EmbedPasswordMgr::GetInstance()
     sPasswordManager = new EmbedPasswordMgr();
     if (!sPasswordManager)
       return nsnull;
-    NS_ADDREF(sPasswordManager);   // addref the global
     if (NS_FAILED(sPasswordManager->Init())) {
       NS_RELEASE(sPasswordManager);
       return nsnull;
     }
   }
-  NS_ADDREF(sPasswordManager);   // addref the return result
   return sPasswordManager;
 }
 
@@ -1404,7 +1402,6 @@ EmbedPasswordMgr::GetPrompt(nsIDOMWindow
   if (!wrapper)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(wrapper);
   *_retval = static_cast<nsIAuthPrompt2*>(wrapper);
   return NS_OK;
 }
diff --git a/embedding/browser/gtk/src/EmbedPrivate.cpp b/embedding/browser/gtk/src/EmbedPrivate.cpp
--- a/embedding/browser/gtk/src/EmbedPrivate.cpp
+++ b/embedding/browser/gtk/src/EmbedPrivate.cpp
@@ -639,7 +639,6 @@ EmbedPrivate::SetDirectoryServiceProvide
 
   if (appFileLocProvider) {
     sAppFileLocProvider = appFileLocProvider;
-    NS_ADDREF(sAppFileLocProvider);
   }
 }
 
@@ -911,7 +910,6 @@ EmbedPrivate::GetPIDOMWindow(nsPIDOMWind
   *aPIWin = domWindowPrivate->GetPrivateRoot();
 
   if (*aPIWin) {
-    NS_ADDREF(*aPIWin);
     return NS_OK;
   }
 
diff --git a/embedding/browser/gtk/src/EmbedWindow.cpp b/embedding/browser/gtk/src/EmbedWindow.cpp
--- a/embedding/browser/gtk/src/EmbedWindow.cpp
+++ b/embedding/browser/gtk/src/EmbedWindow.cpp
@@ -159,7 +159,6 @@ EmbedWindow::GetWebBrowser(nsIWebBrowser
 EmbedWindow::GetWebBrowser(nsIWebBrowser **aWebBrowser)
 {
   *aWebBrowser = mWebBrowser;
-  NS_IF_ADDREF(*aWebBrowser);
   return NS_OK;
 }
 
diff --git a/embedding/browser/gtk/src/EmbedWindowCreator.cpp b/embedding/browser/gtk/src/EmbedWindowCreator.cpp
--- a/embedding/browser/gtk/src/EmbedWindowCreator.cpp
+++ b/embedding/browser/gtk/src/EmbedWindowCreator.cpp
@@ -98,7 +98,6 @@ EmbedWindowCreator::CreateChromeWindow(n
   *_retval = static_cast<nsIWebBrowserChrome *>(newEmbedPrivate->mWindow);
   
   if (*_retval) {
-    NS_ADDREF(*_retval);
     return NS_OK;
   }
 
diff --git a/embedding/browser/photon/src/EmbedPrivate.cpp b/embedding/browser/photon/src/EmbedPrivate.cpp
--- a/embedding/browser/photon/src/EmbedPrivate.cpp
+++ b/embedding/browser/photon/src/EmbedPrivate.cpp
@@ -215,7 +215,6 @@ EmbedPrivate::Init(PtWidget_t *aOwningWi
 		if (pref)
 		{
 			sPrefs = pref.get();
-			NS_ADDREF( sPrefs );
 			extern int sProfileDirCreated;
 			if( sProfileDirCreated ) mozilla_set_default_pref( pref );
 			sPrefs->ReadUserPrefs( nsnull );
@@ -948,7 +947,6 @@ EmbedPrivate::GetPIDOMWindow(nsPIDOMWind
 	*aPIWin = domWindowPrivate->GetPrivateRoot();
   
   if (*aPIWin) {
-    NS_ADDREF(*aPIWin);
     return NS_OK;
   }
 
diff --git a/embedding/browser/photon/src/EmbedWindow.cpp b/embedding/browser/photon/src/EmbedWindow.cpp
--- a/embedding/browser/photon/src/EmbedWindow.cpp
+++ b/embedding/browser/photon/src/EmbedWindow.cpp
@@ -227,7 +227,6 @@ EmbedWindow::GetWebBrowser(nsIWebBrowser
 EmbedWindow::GetWebBrowser(nsIWebBrowser **aWebBrowser)
 {
   *aWebBrowser = mWebBrowser;
-  NS_IF_ADDREF(*aWebBrowser);
   return NS_OK;
 }
 
diff --git a/embedding/browser/photon/src/EmbedWindowCreator.cpp b/embedding/browser/photon/src/EmbedWindowCreator.cpp
--- a/embedding/browser/photon/src/EmbedWindowCreator.cpp
+++ b/embedding/browser/photon/src/EmbedWindowCreator.cpp
@@ -96,7 +96,6 @@ EmbedWindowCreator::CreateChromeWindow(n
 
 		if (*_retval) 
 		{
-			NS_ADDREF(*_retval);
 			return NS_OK;
 		}
 	}
diff --git a/embedding/browser/photon/src/PromptService.cpp b/embedding/browser/photon/src/PromptService.cpp
--- a/embedding/browser/photon/src/PromptService.cpp
+++ b/embedding/browser/photon/src/PromptService.cpp
@@ -451,7 +451,6 @@ nsresult NS_NewPromptServiceFactory(nsIF
   if (!result)
     return NS_ERROR_OUT_OF_MEMORY;
     
-  NS_ADDREF(result);
   *aFactory = result;
   
   return NS_OK;
diff --git a/embedding/browser/photon/src/PtMozilla.cpp b/embedding/browser/photon/src/PtMozilla.cpp
--- a/embedding/browser/photon/src/PtMozilla.cpp
+++ b/embedding/browser/photon/src/PtMozilla.cpp
@@ -1055,7 +1055,6 @@ static int StartupEmbedding()
     	return (-1);
     	}
   nsIAppShell * sAppShell = appShell.get();
-  NS_ADDREF(sAppShell);
   sAppShell->Create(0, nsnull);
   sAppShell->Spinup();
 	return 0;
diff --git a/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp b/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp
--- a/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp
+++ b/embedding/browser/photon/src/nsUnknownContentTypeHandler.cpp
@@ -129,7 +129,6 @@ NS_IMETHODIMP nsUnknownContentTypeHandle
 	if( !file ) return NS_ERROR_FAILURE;
 
 	*_retval = file;
-	NS_ADDREF( *_retval );
 
 	/* add this download to our list */
 	EmbedDownload *download = new EmbedDownload( moz, moz->moz_unknown_ctrl->download_ticket, url );
@@ -190,11 +189,9 @@ NS_IMETHODIMP className::QueryInterface(
 		*anInstancePtr = 0; 
 		if ( anIID.Equals( NS_GET_IID(nsIHelperAppLauncherDialog) ) ) { 
 			*anInstancePtr = (void*) (nsIHelperAppLauncherDialog*)this; 
-			NS_ADDREF_THIS();
 			}
 		else if ( anIID.Equals( NS_GET_IID(nsISupports) ) ) { 
 			*anInstancePtr = (void*) ( (nsISupports*) (interfaceName*)this ); 
-			NS_ADDREF_THIS();
 			}
 		else rv = NS_NOINTERFACE;
 		} 
diff --git a/embedding/browser/webBrowser/nsContextMenuInfo.cpp b/embedding/browser/webBrowser/nsContextMenuInfo.cpp
--- a/embedding/browser/webBrowser/nsContextMenuInfo.cpp
+++ b/embedding/browser/webBrowser/nsContextMenuInfo.cpp
@@ -79,7 +79,7 @@ nsContextMenuInfo::GetMouseEvent(nsIDOME
 nsContextMenuInfo::GetMouseEvent(nsIDOMEvent **aEvent)
 {
   NS_ENSURE_ARG_POINTER(aEvent);
-  NS_IF_ADDREF(*aEvent = mMouseEvent);
+  *aEvent = mMouseEvent;
   return NS_OK;
 }
 
@@ -88,7 +88,7 @@ nsContextMenuInfo::GetTargetNode(nsIDOMN
 nsContextMenuInfo::GetTargetNode(nsIDOMNode **aNode)
 {
   NS_ENSURE_ARG_POINTER(aNode);
-  NS_IF_ADDREF(*aNode = mDOMNode);
+  *aNode = mDOMNode;
   return NS_OK;
 }
 
diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
--- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
+++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
@@ -121,7 +121,6 @@ GetPIDOMEventTarget( nsWebBrowser* inBro
     do_QueryInterface(rootWindow->GetChromeEventHandler());
   NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE);
   *aTarget = piTarget;
-  NS_IF_ADDREF(*aTarget);
   
   return NS_OK;
 }
@@ -188,7 +187,6 @@ nsDocShellTreeOwner::GetInterface(const 
     EnsurePrompter();
     prompt = mPrompter;
     if (prompt) {
-      NS_ADDREF(prompt);
       *aSink = prompt;
       return NS_OK;
     }
@@ -200,7 +198,6 @@ nsDocShellTreeOwner::GetInterface(const 
     EnsureAuthPrompter();
     prompt = mAuthPrompter;
     if (prompt) {
-      NS_ADDREF(prompt);
       *aSink = prompt;
       return NS_OK;
     }
@@ -243,7 +240,6 @@ nsDocShellTreeOwner::FindItemWithName(co
   // see bug 217886 for details
   if(name.LowerCaseEqualsLiteral("_content") || name.EqualsLiteral("_main")) {
     *aFoundItem = mWebBrowser->mDocShellAsItem;
-    NS_IF_ADDREF(*aFoundItem);
     return NS_OK;
   }
 
@@ -256,7 +252,6 @@ nsDocShellTreeOwner::FindItemWithName(co
       domWindow->GetName(ourName);
       if (name.Equals(ourName, nsCaseInsensitiveStringComparator())) {
         *aFoundItem = mWebBrowser->mDocShellAsItem;
-        NS_IF_ADDREF(*aFoundItem);
         return NS_OK;
       }
     }
@@ -436,7 +431,6 @@ nsDocShellTreeOwner::GetPrimaryContentSh
        return mTreeOwner->GetPrimaryContentShell(aShell);
 
    *aShell = (mPrimaryContentShell ? mPrimaryContentShell : mWebBrowser->mDocShellAsItem.get());
-   NS_IF_ADDREF(*aShell);
 
    return NS_OK;
 }
@@ -889,7 +883,6 @@ nsDocShellTreeOwner::AddChromeListeners(
       mChromeTooltipListener = new ChromeTooltipListener(mWebBrowser,
                                                          webBrowserChrome);
       if ( mChromeTooltipListener ) {
-        NS_ADDREF(mChromeTooltipListener);
         rv = mChromeTooltipListener->AddChromeListeners();
       }
       else
@@ -907,7 +900,6 @@ nsDocShellTreeOwner::AddChromeListeners(
       mChromeContextMenuListener =
                    new ChromeContextMenuListener(mWebBrowser, webBrowserChrome);
       if ( mChromeContextMenuListener ) {
-        NS_ADDREF(mChromeContextMenuListener);
         rv = mChromeContextMenuListener->AddChromeListeners();
       }
       else
@@ -959,7 +951,6 @@ nsDocShellTreeOwner::GetWebBrowserChrome
                                       reinterpret_cast<void**>(&chrome));
   } else if (mWebBrowserChrome) {
     chrome = mWebBrowserChrome;
-    NS_ADDREF(mWebBrowserChrome);
   }
 
   return chrome;
@@ -975,7 +966,6 @@ nsDocShellTreeOwner::GetOwnerWin()
                                       reinterpret_cast<void**>(&win));
   } else if (mOwnerWin) {
     win = mOwnerWin;
-    NS_ADDREF(mOwnerWin);
   }
 
   return win;
@@ -991,7 +981,6 @@ nsDocShellTreeOwner::GetOwnerRequestor()
                                       reinterpret_cast<void**>(&req));
   } else if (mOwnerRequestor) {
     req = mOwnerRequestor;
-    NS_ADDREF(mOwnerRequestor);
   }
 
   return req;
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
@@ -206,7 +206,6 @@ NS_IMETHODIMP nsWebBrowser::GetInterface
            nsIWebBrowserPrint* webBrowserPrint(do_QueryInterface(viewer));
            nsIWebBrowserPrint* print = (nsIWebBrowserPrint*)webBrowserPrint;
            NS_ASSERTION(print, "This MUST support this interface!");
-           NS_ADDREF(print);
            *aSink = print;
            return NS_OK;
        }
@@ -412,7 +411,6 @@ NS_IMETHODIMP nsWebBrowser::GetContentDO
     if (NS_FAILED(rv)) return rv;
 
     *_retval = retval;
-    NS_ADDREF(*_retval);
     return rv;
 }
 
@@ -505,7 +503,6 @@ NS_IMETHODIMP nsWebBrowser::GetRootTreeI
       *aRootTreeItem = parent;
       NS_ENSURE_SUCCESS((*aRootTreeItem)->GetParent(&parent), NS_ERROR_FAILURE);
       }
-   NS_ADDREF(*aRootTreeItem);
    return NS_OK;
 }
 
@@ -522,7 +519,6 @@ NS_IMETHODIMP nsWebBrowser::GetSameTypeR
       NS_ENSURE_SUCCESS((*aRootTreeItem)->GetSameTypeParent(&parent), 
          NS_ERROR_FAILURE);
       }
-   NS_ADDREF(*aRootTreeItem);
    return NS_OK;
 }
 
@@ -553,7 +549,6 @@ NS_IMETHODIMP nsWebBrowser::GetTreeOwner
             *aTreeOwner = mDocShellTreeOwner;
         }
     }
-    NS_IF_ADDREF(*aTreeOwner);
     return NS_OK;
 }
 
@@ -703,7 +698,6 @@ NS_IMETHODIMP nsWebBrowser::GetSessionHi
    else
       *aSessionHistory = mInitInfo->sessionHistory;
 
-   NS_IF_ADDREF(*aSessionHistory);
 
    return NS_OK;
 }
@@ -914,7 +908,6 @@ NS_IMETHODIMP nsWebBrowser::GetProgressL
 {
     NS_ENSURE_ARG_POINTER(aProgressListener);
     *aProgressListener = mProgressListener;
-    NS_IF_ADDREF(*aProgressListener);
     return NS_OK;
 }
   
@@ -1345,7 +1338,6 @@ NS_IMETHODIMP nsWebBrowser::GetParentWid
 
    *aParentWidget = mParentWidget;
 
-   NS_IF_ADDREF(*aParentWidget);
 
    return NS_OK;
 }
@@ -1444,7 +1436,6 @@ NS_IMETHODIMP nsWebBrowser::GetMainWidge
    else
       *mainWidget = mParentWidget;
 
-   NS_IF_ADDREF(*mainWidget);
 
    return NS_OK;
 }
@@ -1637,7 +1628,6 @@ NS_IMETHODIMP nsWebBrowser::EnsureDocShe
    mDocShellTreeOwner = new nsDocShellTreeOwner();
    NS_ENSURE_TRUE(mDocShellTreeOwner, NS_ERROR_OUT_OF_MEMORY);
 
-   NS_ADDREF(mDocShellTreeOwner);
    mDocShellTreeOwner->WebBrowser(this);
    
    return NS_OK;
@@ -1722,7 +1712,6 @@ NS_IMETHODIMP nsWebBrowser::GetPrimaryCo
   NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
 
   *aDOMWindow = domWindow;
-  NS_ADDREF(*aDOMWindow);
   return NS_OK;
   
 }
@@ -1853,7 +1842,6 @@ NS_IMETHODIMP nsWebBrowser::GetFocusedWi
       rv = focusController->GetFocusedWindow(&focusedWindow);
     
     *aFocusedWindow = focusedWindow;
-    NS_IF_ADDREF(*aFocusedWindow);
     
     return *aFocusedWindow ? NS_OK : NS_ERROR_FAILURE;
 }
@@ -1882,7 +1870,6 @@ NS_IMETHODIMP nsWebBrowser::GetFocusedEl
   rv = focusController->GetFocusedElement(&focusedElement);
 
   *aFocusedElement = focusedElement;
-  NS_IF_ADDREF(*aFocusedElement);
   return *aFocusedElement ? NS_OK : NS_ERROR_FAILURE;
 }
 
diff --git a/embedding/components/commandhandler/src/nsCommandParams.cpp b/embedding/components/commandhandler/src/nsCommandParams.cpp
--- a/embedding/components/commandhandler/src/nsCommandParams.cpp
+++ b/embedding/components/commandhandler/src/nsCommandParams.cpp
@@ -183,7 +183,7 @@ NS_IMETHODIMP nsCommandParams::GetISuppo
   HashEntry*  foundEntry = GetNamedEntry(name);
   if (foundEntry && foundEntry->mEntryType == eISupportsType)
   {
-    NS_IF_ADDREF(*_retval = foundEntry->mISupports.get());
+    *_retval = foundEntry->mISupports.get();
     return NS_OK;
   }
   
diff --git a/embedding/components/commandhandler/src/nsControllerCommandTable.cpp b/embedding/components/commandhandler/src/nsControllerCommandTable.cpp
--- a/embedding/components/commandhandler/src/nsControllerCommandTable.cpp
+++ b/embedding/components/commandhandler/src/nsControllerCommandTable.cpp
@@ -238,7 +238,6 @@ NS_NewControllerCommandTable(nsIControll
   if (! newCommandTable)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(newCommandTable);
   *aResult = newCommandTable;
   return NS_OK;
 }
diff --git a/embedding/components/find/src/nsFind.cpp b/embedding/components/find/src/nsFind.cpp
--- a/embedding/components/find/src/nsFind.cpp
+++ b/embedding/components/find/src/nsFind.cpp
@@ -610,7 +610,6 @@ nsFind::GetWordBreaker(nsIWordBreaker** 
 nsFind::GetWordBreaker(nsIWordBreaker** aWordBreaker)
 {
   *aWordBreaker = mWordBreaker;
-  NS_IF_ADDREF(*aWordBreaker);
   return NS_OK;
 }
 
@@ -903,7 +902,6 @@ nsresult nsFind::GetBlockParent(nsIDOMNo
     if (content && IsBlockNode(content))
     {
       *aParent = parent;
-      NS_ADDREF(*aParent);
       return NS_OK;
     }
     aNode = parent;
@@ -1246,7 +1244,6 @@ nsFind::Find(const PRUnichar *aPatText, 
             range->SetStart(startParent, matchStartOffset);
             range->SetEnd(endParent, matchEndOffset);
             *aRangeRet = range;
-            NS_ADDREF(*aRangeRet);
           }
           else {
             startParent = nsnull; // This match is no good -- invisible or bad range
diff --git a/embedding/components/find/src/nsWebBrowserFind.cpp b/embedding/components/find/src/nsWebBrowserFind.cpp
--- a/embedding/components/find/src/nsWebBrowserFind.cpp
+++ b/embedding/components/find/src/nsWebBrowserFind.cpp
@@ -679,7 +679,7 @@ NS_IMETHODIMP nsWebBrowserFind::GetCurre
 {
     NS_ENSURE_ARG_POINTER(aCurrentSearchFrame);
     nsIDOMWindow* searchFrame = do_QueryReferent(mCurrentSearchFrame);
-    NS_IF_ADDREF(*aCurrentSearchFrame = searchFrame);
+    *aCurrentSearchFrame = searchFrame;
     return (*aCurrentSearchFrame) ? NS_OK : NS_ERROR_NOT_INITIALIZED;
 }
 
@@ -696,7 +696,7 @@ NS_IMETHODIMP nsWebBrowserFind::GetRootS
 {
     NS_ENSURE_ARG_POINTER(aRootSearchFrame);
     nsIDOMWindow* searchFrame = do_QueryReferent(mRootSearchFrame);
-    NS_IF_ADDREF(*aRootSearchFrame = searchFrame);
+    *aRootSearchFrame = searchFrame;
     return (*aRootSearchFrame) ? NS_OK : NS_ERROR_NOT_INITIALIZED;
 }
 
diff --git a/embedding/components/printingui/src/os2/nsPrintingPromptService.cpp b/embedding/components/printingui/src/os2/nsPrintingPromptService.cpp
--- a/embedding/components/printingui/src/os2/nsPrintingPromptService.cpp
+++ b/embedding/components/printingui/src/os2/nsPrintingPromptService.cpp
@@ -171,7 +171,6 @@ nsPrintingPromptService::ShowProgress(ns
     }
 
     *webProgressListener = static_cast<nsIWebProgressListener*>(this);
-    NS_ADDREF(*webProgressListener);
 
     return rv;
 }
diff --git a/embedding/components/printingui/src/unixshared/nsPrintingPromptService.cpp b/embedding/components/printingui/src/unixshared/nsPrintingPromptService.cpp
--- a/embedding/components/printingui/src/unixshared/nsPrintingPromptService.cpp
+++ b/embedding/components/printingui/src/unixshared/nsPrintingPromptService.cpp
@@ -174,7 +174,6 @@ nsPrintingPromptService::ShowProgress(ns
     }
 
     *webProgressListener = static_cast<nsIWebProgressListener*>(this);
-    NS_ADDREF(*webProgressListener);
 
     return rv;
 }
diff --git a/embedding/components/printingui/src/win/nsPrintingPromptService.cpp b/embedding/components/printingui/src/win/nsPrintingPromptService.cpp
--- a/embedding/components/printingui/src/win/nsPrintingPromptService.cpp
+++ b/embedding/components/printingui/src/win/nsPrintingPromptService.cpp
@@ -247,7 +247,6 @@ nsPrintingPromptService::ShowProgress(ns
     }
 
     *webProgressListener = static_cast<nsIWebProgressListener*>(this);
-    NS_ADDREF(*webProgressListener);
 
     return rv;
 }
diff --git a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
+++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
@@ -350,7 +350,6 @@ NS_IMETHODIMP nsWebBrowserPersist::GetPr
 {
     NS_ENSURE_ARG_POINTER(aProgressListener);
     *aProgressListener = mProgressListener;
-    NS_IF_ADDREF(*aProgressListener);
     return NS_OK;
 }
 
@@ -1141,7 +1140,6 @@ nsresult nsWebBrowserPersist::GetValidUR
     if (objAsURI)
     {
         *aURI = objAsURI;
-        NS_ADDREF(*aURI);
         return NS_OK;
     }
 
@@ -2349,7 +2347,6 @@ public:
     nsresult GetISupports(nsISupports **ret)
     {
         *ret = mKey;
-        NS_IF_ADDREF(mKey);
         return NS_OK;
     }
 };
@@ -2950,7 +2947,7 @@ nsWebBrowserPersist::GetNodeToFixup(nsID
     }
     else
     {
-        NS_ADDREF(*aNodeOut = aNodeIn);
+        *aNodeOut = aNodeIn;
     }
     nsIDOMHTMLElement* element(do_QueryInterface(*aNodeOut));
     if (element) {
diff --git a/embedding/components/windowwatcher/src/nsDialogParamBlock.cpp b/embedding/components/windowwatcher/src/nsDialogParamBlock.cpp
--- a/embedding/components/windowwatcher/src/nsDialogParamBlock.cpp
+++ b/embedding/components/windowwatcher/src/nsDialogParamBlock.cpp
@@ -106,7 +106,7 @@ nsDialogParamBlock::GetObjects(nsIMutabl
 nsDialogParamBlock::GetObjects(nsIMutableArray * *aObjects)
 {
   NS_ENSURE_ARG_POINTER(aObjects);
-  NS_IF_ADDREF(*aObjects = mObjects);
+  *aObjects = mObjects;
   return NS_OK;
 }
 
diff --git a/embedding/components/windowwatcher/src/nsPrompt.cpp b/embedding/components/windowwatcher/src/nsPrompt.cpp
--- a/embedding/components/windowwatcher/src/nsPrompt.cpp
+++ b/embedding/components/windowwatcher/src/nsPrompt.cpp
@@ -69,7 +69,6 @@ NS_NewPrompter(nsIPrompt **result, nsIDO
   if (!prompter)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(prompter);
   rv = prompter->Init();
   if (NS_FAILED(rv)) {
     NS_RELEASE(prompter);
@@ -104,7 +103,6 @@ NS_NewAuthPrompter(nsIAuthPrompt **resul
   if (!prompter)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(prompter);
   rv = prompter->Init();
   if (NS_FAILED(rv)) {
     NS_RELEASE(prompter);
@@ -122,7 +120,6 @@ NS_NewAuthPrompter(nsIAuthPrompt **resul
     if (NS_SUCCEEDED(rv)) {
       *result = siPrompt;
       NS_RELEASE(prompter); // siPrompt is a strong owner
-      NS_ADDREF(*result);
     }
   }
   return NS_OK;
@@ -151,7 +148,6 @@ NS_NewAuthPrompter2(nsIAuthPrompt2 **res
   if (!prompter)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(prompter);
   rv = prompter->Init();
   if (NS_FAILED(rv)) {
     NS_RELEASE(prompter);
diff --git a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
--- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp
@@ -232,7 +232,6 @@ nsWatcherWindowEnumerator::GetNext(nsISu
     } else // window is gone!
       mWindowWatcher->RemoveWindow(mCurrentPosition);
   }
-  NS_IF_ADDREF(*retval);
 #else
   if (mCurrentPosition) {
     CallQueryInterface(mCurrentPosition->mWindow, retval);
@@ -1048,7 +1047,6 @@ nsWindowWatcher::CreateAdapter(nsIAuthPr
   *_retval = new AuthPromptWrapper(aPrompt);
   if (!*_retval)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -1066,7 +1064,6 @@ nsWindowWatcher::GetActiveWindow(nsIDOMW
     return NS_ERROR_INVALID_ARG;
 
   *aActiveWindow = mActiveWindow;
-  NS_IF_ADDREF(mActiveWindow);
   return NS_OK;
 }
 
@@ -1260,7 +1257,6 @@ nsWindowWatcher::GetChromeForWindow(nsID
                                           reinterpret_cast<void**>(_retval));
     }
     *_retval = info->mChrome;
-    NS_IF_ADDREF(*_retval);
   }
   return NS_OK;
 }
@@ -1696,7 +1692,7 @@ nsWindowWatcher::GetCallerTreeItem(nsIDo
   }
 
   if (!callerItem) {
-    NS_IF_ADDREF(callerItem = aParentItem);
+    callerItem = aParentItem;
   }
 
   return callerItem;
diff --git a/embedding/minimo/chromelite/nsSimpleChromeHandler.cpp b/embedding/minimo/chromelite/nsSimpleChromeHandler.cpp
--- a/embedding/minimo/chromelite/nsSimpleChromeHandler.cpp
+++ b/embedding/minimo/chromelite/nsSimpleChromeHandler.cpp
@@ -120,7 +120,7 @@ nsSimpleChromeURL::GetFile(nsIFile **res
     nsCOMPtr<nsIFile> newFile;
     mChromeDir->Clone(getter_AddRefs(newFile));
     nsresult rv = newFile->AppendNative(fileName);
-    NS_IF_ADDREF(*result = newFile);
+    *result = newFile;
     return rv;
 }
 
@@ -183,7 +183,6 @@ nsSimpleChromeHandler::NewURI(const nsAC
     if (!chromeURL)
         return NS_ERROR_OUT_OF_MEMORY;
 
-    NS_ADDREF(chromeURL);
 
     rv = chromeURL->Init(nsIStandardURL::URLTYPE_STANDARD, -1, aSpec, aCharset, aBaseURI);
     if (NS_SUCCEEDED(rv))
diff --git a/embedding/qa/mozembed/src/mozEmbed.cpp b/embedding/qa/mozembed/src/mozEmbed.cpp
--- a/embedding/qa/mozembed/src/mozEmbed.cpp
+++ b/embedding/qa/mozembed/src/mozEmbed.cpp
@@ -1091,7 +1091,6 @@ nsQABrowserUIGlue::CreateNewBrowserWindo
   // now an extra addref; the window owns itself (to be released by
   // nsQABrowserUIGlue::Destroy) 
   *aNewWindow = webBrowserChrome.get();
-  NS_ADDREF(*aNewWindow);
  
     // Set the chrome flags on the chrome. This may not be necessary.
   webBrowserChrome->SetChromeFlags(aChromeFlags);
diff --git a/embedding/qa/mozembed/src/nsQABrowserChrome.cpp b/embedding/qa/mozembed/src/nsQABrowserChrome.cpp
--- a/embedding/qa/mozembed/src/nsQABrowserChrome.cpp
+++ b/embedding/qa/mozembed/src/nsQABrowserChrome.cpp
@@ -138,7 +138,6 @@ NS_IMETHODIMP nsQABrowserChrome::GetWebB
 {
     NS_ENSURE_ARG_POINTER(aWebBrowser);
     *aWebBrowser = mWebBrowser;
-    NS_IF_ADDREF(*aWebBrowser);
     return NS_OK;
 }
 
diff --git a/embedding/qa/mozembed/src/nsQABrowserView.cpp b/embedding/qa/mozembed/src/nsQABrowserView.cpp
--- a/embedding/qa/mozembed/src/nsQABrowserView.cpp
+++ b/embedding/qa/mozembed/src/nsQABrowserView.cpp
@@ -166,7 +166,6 @@ nsQABrowserView::GetWebBrowser(nsIWebBro
     return NS_ERROR_FAILURE;
   
   *aWebBrowser = mWebBrowser;
-  NS_ADDREF(*aWebBrowser);
   return NS_OK;
 }
  
diff --git a/embedding/qa/testembed/BrowserFrameGlue.cpp b/embedding/qa/testembed/BrowserFrameGlue.cpp
--- a/embedding/qa/testembed/BrowserFrameGlue.cpp
+++ b/embedding/qa/testembed/BrowserFrameGlue.cpp
@@ -318,7 +318,7 @@ PRBool CBrowserFrame::BrowserFrameGlueOb
 	// embedded browser gets created and how it's mWebBrowser member
 	// gets initialized)
 
-	NS_IF_ADDREF(*aWebBrowser = pFrm->m_wndBrowserView.mWebBrowser);
+	*aWebBrowser = pFrm->m_wndBrowserView.mWebBrowser;
 
 	return PR_TRUE;
 }
diff --git a/embedding/qa/testembed/BrowserImpl.cpp b/embedding/qa/testembed/BrowserImpl.cpp
--- a/embedding/qa/testembed/BrowserImpl.cpp
+++ b/embedding/qa/testembed/BrowserImpl.cpp
@@ -188,7 +188,6 @@ NS_IMETHODIMP CBrowserImpl::GetWebBrowse
    if (!aWebBrowser)
       QAOutput("aWebBrowser is null", 1);
 
-   NS_IF_ADDREF(*aWebBrowser);
 
    return NS_OK;
 }
@@ -697,7 +696,6 @@ NS_IMETHODIMP CBrowserImpl::GetLoadCooki
 	if (!aLoadCookie)
 		QAOutput("aLoadCookie object is null",1);
 	*aLoadCookie = mLoadCookie;
-	NS_IF_ADDREF(*aLoadCookie);
 
 	return NS_OK;
 }
@@ -720,7 +718,6 @@ NS_IMETHODIMP CBrowserImpl::GetParentCon
 	if (!aParentContentListener)
 		QAOutput("aParentContentListener object is null",1);
 	*aParentContentListener = mParentContentListener;
-	NS_IF_ADDREF(*aParentContentListener);
 
 //	QueryInterface(NS_GET_IID(nsIURIContentListener), (void **) aParentContentListener);
 
diff --git a/embedding/qa/testembed/TestEmbed.cpp b/embedding/qa/testembed/TestEmbed.cpp
--- a/embedding/qa/testembed/TestEmbed.cpp
+++ b/embedding/qa/testembed/TestEmbed.cpp
@@ -662,7 +662,6 @@ NS_IMETHODIMP CTestEmbedApp::CreateChrom
   CBrowserFrame *pBrowserFrame = CreateNewBrowserFrame(chromeFlags);
   if(pBrowserFrame) {
     *_retval = static_cast<nsIWebBrowserChrome *>(pBrowserFrame->GetBrowserImpl());
-    NS_ADDREF(*_retval);
   }
   return NS_OK;
 }
diff --git a/embedding/qa/testembed/components/PromptService.cpp b/embedding/qa/testembed/components/PromptService.cpp
--- a/embedding/qa/testembed/components/PromptService.cpp
+++ b/embedding/qa/testembed/components/PromptService.cpp
@@ -465,7 +465,6 @@ nsresult NS_NewPromptServiceFactory(nsIF
   if (!result)
     return NS_ERROR_OUT_OF_MEMORY;
     
-  NS_ADDREF(result);
   *aFactory = result;
   
   return NS_OK;
diff --git a/embedding/qa/testembed/nsICmdParams.cpp b/embedding/qa/testembed/nsICmdParams.cpp
--- a/embedding/qa/testembed/nsICmdParams.cpp
+++ b/embedding/qa/testembed/nsICmdParams.cpp
@@ -42,7 +42,6 @@ nsICommandParams * CnsICmdParams::GetCom
 		return nsnull;
 	}
 	nsICommandParams *retVal = cmdParamsObj;
-	NS_ADDREF(retVal);
 	return retVal;
 }
 
diff --git a/embedding/qa/testembed/winEmbedFileLocProvider.cpp b/embedding/qa/testembed/winEmbedFileLocProvider.cpp
--- a/embedding/qa/testembed/winEmbedFileLocProvider.cpp
+++ b/embedding/qa/testembed/winEmbedFileLocProvider.cpp
@@ -258,7 +258,6 @@ NS_METHOD winEmbedFileLocProvider::GetGr
         if (tempLocal)
         {
            *aLocalFile = tempLocal;
-           NS_ADDREF(*aLocalFile);
            rv = NS_OK;
         }
 
@@ -302,7 +301,7 @@ NS_METHOD winEmbedFileLocProvider::Clone
     if (!lfile)
         return NS_ERROR_FAILURE;
     
-    NS_IF_ADDREF(*aLocalFile = lfile);
+    *aLocalFile = lfile;
     return NS_OK;
 }
 
@@ -342,7 +341,6 @@ NS_METHOD winEmbedFileLocProvider::GetPr
     if (NS_FAILED(rv)) return rv;
 
     *aLocalFile = localDir;
-    NS_ADDREF(*aLocalFile);
 
    return rv; 
 }
@@ -373,7 +371,6 @@ NS_METHOD winEmbedFileLocProvider::GetDe
     if (NS_FAILED(rv)) return rv;
 
     *aLocalFile = localDir;
-    NS_ADDREF(*aLocalFile);
 
    return rv; 
 }
diff --git a/embedding/tests/os2Embed/WebBrowserChrome.cpp b/embedding/tests/os2Embed/WebBrowserChrome.cpp
--- a/embedding/tests/os2Embed/WebBrowserChrome.cpp
+++ b/embedding/tests/os2Embed/WebBrowserChrome.cpp
@@ -104,7 +104,6 @@ nsresult WebBrowserChrome::CreateBrowser
     if (mWebBrowser)
     {
       *aBrowser = mWebBrowser;
-      NS_ADDREF(*aBrowser);
       return NS_OK;
     }
     return NS_ERROR_FAILURE;
@@ -164,7 +163,6 @@ NS_IMETHODIMP WebBrowserChrome::GetWebBr
 {
     NS_ENSURE_ARG_POINTER(aWebBrowser);
     *aWebBrowser = mWebBrowser;
-    NS_IF_ADDREF(*aWebBrowser);
     return NS_OK;
 }
 
diff --git a/embedding/tests/os2Embed/os2Embed.cpp b/embedding/tests/os2Embed/os2Embed.cpp
--- a/embedding/tests/os2Embed/os2Embed.cpp
+++ b/embedding/tests/os2Embed/os2Embed.cpp
@@ -1413,7 +1413,6 @@ nsresult CreateBrowserWindow(PRUint32 aC
   CallQueryInterface(static_cast<nsIWebBrowserChrome*>(chrome), aNewWindow);
   // now an extra addref; the window owns itself (to be released by
   // WebBrowserChromeUI::Destroy)
-  NS_ADDREF(*aNewWindow);
 
   chrome->SetChromeFlags(aChromeFlags);
   chrome->SetParent(aParent);
diff --git a/embedding/tests/winEmbed/WebBrowserChrome.cpp b/embedding/tests/winEmbed/WebBrowserChrome.cpp
--- a/embedding/tests/winEmbed/WebBrowserChrome.cpp
+++ b/embedding/tests/winEmbed/WebBrowserChrome.cpp
@@ -102,7 +102,6 @@ nsresult WebBrowserChrome::CreateBrowser
     if (mWebBrowser)
     {
       *aBrowser = mWebBrowser;
-      NS_ADDREF(*aBrowser);
       return NS_OK;
     }
     return NS_ERROR_FAILURE;
@@ -162,7 +161,6 @@ NS_IMETHODIMP WebBrowserChrome::GetWebBr
 {
     NS_ENSURE_ARG_POINTER(aWebBrowser);
     *aWebBrowser = mWebBrowser;
-    NS_IF_ADDREF(*aWebBrowser);
     return NS_OK;
 }
 
diff --git a/embedding/tests/winEmbed/winEmbed.cpp b/embedding/tests/winEmbed/winEmbed.cpp
--- a/embedding/tests/winEmbed/winEmbed.cpp
+++ b/embedding/tests/winEmbed/winEmbed.cpp
@@ -1102,7 +1102,6 @@ nsresult AppCallbacks::CreateBrowserWind
   CallQueryInterface(static_cast<nsIWebBrowserChrome*>(chrome), aNewWindow);
   // now an extra addref; the window owns itself (to be released by
   // WebBrowserChromeUI::Destroy)
-  NS_ADDREF(*aNewWindow);
 
   chrome->SetChromeFlags(aChromeFlags);
   chrome->SetParent(aParent);
diff --git a/embedding/tests/wxEmbed/EditorFrame.cpp b/embedding/tests/wxEmbed/EditorFrame.cpp
--- a/embedding/tests/wxEmbed/EditorFrame.cpp
+++ b/embedding/tests/wxEmbed/EditorFrame.cpp
@@ -134,7 +134,6 @@ nsresult MakeCommandParams(nsICommandPar
     if (!params)
         return NS_ERROR_FAILURE;
     *aParams = params;
-    NS_ADDREF(*aParams);
     return rv;
 }
 
diff --git a/embedding/tests/wxEmbed/GeckoContainer.cpp b/embedding/tests/wxEmbed/GeckoContainer.cpp
--- a/embedding/tests/wxEmbed/GeckoContainer.cpp
+++ b/embedding/tests/wxEmbed/GeckoContainer.cpp
@@ -111,7 +111,6 @@ nsresult GeckoContainer::CreateBrowser(P
     if (mWebBrowser)
     {
       *aBrowser = mWebBrowser;
-      NS_ADDREF(*aBrowser);
       return NS_OK;
     }
     return NS_ERROR_FAILURE;
@@ -206,7 +205,6 @@ NS_IMETHODIMP GeckoContainer::GetWebBrow
 {
     NS_ENSURE_ARG_POINTER(aWebBrowser);
     *aWebBrowser = mWebBrowser;
-    NS_IF_ADDREF(*aWebBrowser);
     return NS_OK;
 }
 
diff --git a/embedding/tests/wxEmbed/GeckoProtocolHandler.cpp b/embedding/tests/wxEmbed/GeckoProtocolHandler.cpp
--- a/embedding/tests/wxEmbed/GeckoProtocolHandler.cpp
+++ b/embedding/tests/wxEmbed/GeckoProtocolHandler.cpp
@@ -329,7 +329,6 @@ GeckoProtocolChannel::GetOriginalURI(nsI
 GeckoProtocolChannel::GetOriginalURI(nsIURI* *aURI)
 {
     *aURI = mOriginalURI ? mOriginalURI : mURI;
-    NS_ADDREF(*aURI);
     return NS_OK;
 }
 
@@ -344,7 +343,6 @@ GeckoProtocolChannel::GetURI(nsIURI* *aU
 GeckoProtocolChannel::GetURI(nsIURI* *aURI)
 {
     *aURI = mURI;
-    NS_IF_ADDREF(*aURI);
     return NS_OK;
 }
 
@@ -463,7 +461,6 @@ GeckoProtocolChannel::GetLoadGroup(nsILo
 GeckoProtocolChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
 {
     *aLoadGroup = mLoadGroup;
-    NS_IF_ADDREF(*aLoadGroup);
     return NS_OK;
 }
 
@@ -478,7 +475,6 @@ GeckoProtocolChannel::GetOwner(nsISuppor
 GeckoProtocolChannel::GetOwner(nsISupports* *aOwner)
 {
     *aOwner = mOwner.get();
-    NS_IF_ADDREF(*aOwner);
     return NS_OK;
 }
 
@@ -493,7 +489,6 @@ GeckoProtocolChannel::GetNotificationCal
 GeckoProtocolChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks)
 {
     *aNotificationCallbacks = mCallbacks.get();
-    NS_IF_ADDREF(*aNotificationCallbacks);
     return NS_OK;
 }
 
diff --git a/embedding/tests/wxEmbed/GeckoWindow.cpp b/embedding/tests/wxEmbed/GeckoWindow.cpp
--- a/embedding/tests/wxEmbed/GeckoWindow.cpp
+++ b/embedding/tests/wxEmbed/GeckoWindow.cpp
@@ -51,7 +51,6 @@ void GeckoWindow::SetGeckoContainer(Geck
     {
         NS_IF_RELEASE(mGeckoContainer);
         mGeckoContainer = aGeckoContainer;
-        NS_IF_ADDREF(mGeckoContainer);
     }
 }
 
diff --git a/embedding/wrappers/DotNETEmbed/DotNETEmbed.cpp b/embedding/wrappers/DotNETEmbed/DotNETEmbed.cpp
--- a/embedding/wrappers/DotNETEmbed/DotNETEmbed.cpp
+++ b/embedding/wrappers/DotNETEmbed/DotNETEmbed.cpp
@@ -229,7 +229,6 @@ WebBrowserChrome::GetWebBrowser(nsIWebBr
 {
   NS_ENSURE_ARG_POINTER(aWebBrowser);
   *aWebBrowser = mWebBrowser;
-  NS_IF_ADDREF(*aWebBrowser);
   return NS_OK;
 }
 
@@ -298,7 +297,6 @@ WebBrowserChrome::CreateBrowser(HWND hWn
   if (mWebBrowser)
   {
     *aBrowser = mWebBrowser;
-    NS_ADDREF(*aBrowser);
     return NS_OK;
   }
 
@@ -392,12 +390,10 @@ Gecko::CreateBrowserWindow(PRUint32 aChr
   }
 
   mChrome = chrome;
-  NS_ADDREF(mChrome);
 
   // XXX: Is this really needed?
   // now an extra addref; the window owns itself (to be released by
   // WebBrowserChromeUI::Destroy)
-  NS_ADDREF(mChrome);
 
   chrome->SetChromeFlags(aChromeFlags);
 
diff --git a/embedding/wrappers/DotNETEmbed/DotNETNetworking.cpp b/embedding/wrappers/DotNETEmbed/DotNETNetworking.cpp
--- a/embedding/wrappers/DotNETEmbed/DotNETNetworking.cpp
+++ b/embedding/wrappers/DotNETEmbed/DotNETNetworking.cpp
@@ -50,7 +50,6 @@ URI::URI(nsIURI *aURI)
 URI::URI(nsIURI *aURI)
   : mURI(aURI)
 {
-  NS_IF_ADDREF(mURI);
 }
 
 URI::URI(String *aSpec)
@@ -64,7 +63,6 @@ URI::URI(String *aSpec)
   ThrowIfFailed(rv);
 
   mURI = uri.get();
-  NS_IF_ADDREF(mURI);
 }
 
 URI::~URI()
diff --git a/embedding/wrappers/DotNETEmbed/DotNETProfileManager.cpp b/embedding/wrappers/DotNETEmbed/DotNETProfileManager.cpp
--- a/embedding/wrappers/DotNETEmbed/DotNETProfileManager.cpp
+++ b/embedding/wrappers/DotNETEmbed/DotNETProfileManager.cpp
@@ -62,7 +62,6 @@ ProfileManager::EnsureProfileService()
   ThrowIfFailed(rv);
 
   sProfileService = profileService.get();
-  NS_ADDREF(sProfileService);
 }
 
 // static
diff --git a/embedding/wrappers/DotNETEmbed/WebChrome.cpp b/embedding/wrappers/DotNETEmbed/WebChrome.cpp
--- a/embedding/wrappers/DotNETEmbed/WebChrome.cpp
+++ b/embedding/wrappers/DotNETEmbed/WebChrome.cpp
@@ -155,7 +155,6 @@ NS_IMETHODIMP WebBrowserChrome::GetWebBr
 {
   NS_ENSURE_ARG_POINTER(aWebBrowser);
   *aWebBrowser = mWebBrowser;
-  NS_IF_ADDREF(*aWebBrowser);
   return NS_OK;
 }
 
@@ -222,7 +221,6 @@ nsresult WebBrowserChrome::CreateBrowser
   if (mWebBrowser)
   {
     *aBrowser = mWebBrowser;
-    NS_ADDREF(*aBrowser);
     return NS_OK;
   }
   return NS_ERROR_FAILURE;
diff --git a/extensions/access-builtin/accessproxy/nsAccessProxy.cpp b/extensions/access-builtin/accessproxy/nsAccessProxy.cpp
--- a/extensions/access-builtin/accessproxy/nsAccessProxy.cpp
+++ b/extensions/access-builtin/accessproxy/nsAccessProxy.cpp
@@ -88,10 +88,8 @@ nsAccessProxy *nsAccessProxy::GetInstanc
   if (mInstance == nsnull) {
     mInstance = new nsAccessProxy();
     // Will be released in the module destructor
-    NS_IF_ADDREF(mInstance);
   }
 
-  NS_IF_ADDREF(mInstance);
   return mInstance;
 }
 
diff --git a/extensions/auth/nsAuthFactory.cpp b/extensions/auth/nsAuthFactory.cpp
--- a/extensions/auth/nsAuthFactory.cpp
+++ b/extensions/auth/nsAuthFactory.cpp
@@ -81,7 +81,6 @@ nsSysNTLMAuthConstructor(nsISupports *ou
   if (!auth)
     return NS_ERROR_OUT_OF_MEMORY;
   
-  NS_ADDREF(auth);
   nsresult rv = auth->QueryInterface(iid, result);
   NS_RELEASE(auth);
   return rv;
@@ -97,7 +96,6 @@ nsKerbSSPIAuthConstructor(nsISupports *o
   if (!auth)
     return NS_ERROR_OUT_OF_MEMORY;
   
-  NS_ADDREF(auth);
   nsresult rv = auth->QueryInterface(iid, result);
   NS_RELEASE(auth);
   return rv;
@@ -169,7 +167,6 @@ nsKerbGSSAPIAuthConstructor(nsISupports 
   if (!auth)
     return NS_ERROR_OUT_OF_MEMORY;
   
-  NS_ADDREF(auth);
   nsresult rv = auth->QueryInterface(iid, result);
   NS_RELEASE(auth);
   return rv;
@@ -185,7 +182,6 @@ nsGSSAPIAuthConstructor(nsISupports *out
   if (!auth)
     return NS_ERROR_OUT_OF_MEMORY;
   
-  NS_ADDREF(auth);
   nsresult rv = auth->QueryInterface(iid, result);
   NS_RELEASE(auth);
   return rv;
diff --git a/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp b/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp
--- a/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp
+++ b/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp
@@ -374,7 +374,7 @@ class nsGnomeVFSInputStream : public XPC
       // cycle since the channel likely owns this stream.  This reference
       // cycle is broken in our Close method.
 
-      NS_ADDREF(mChannel = channel);
+      mChannel = channel;
     }
 
   private:
diff --git a/extensions/java/xpcom/src/nsAppFileLocProviderProxy.cpp b/extensions/java/xpcom/src/nsAppFileLocProviderProxy.cpp
--- a/extensions/java/xpcom/src/nsAppFileLocProviderProxy.cpp
+++ b/extensions/java/xpcom/src/nsAppFileLocProviderProxy.cpp
@@ -224,7 +224,6 @@ nsAppFileLocProviderProxy::GetFiles(cons
     // Parse return value
     *aResult = new DirectoryEnumerator(static_cast<jobjectArray>
                                                   (javaFileArray));
-    NS_ADDREF(*aResult);
     return NS_OK;
   }
 
@@ -245,7 +244,6 @@ NS_NewAppFileLocProviderProxy(jobject aJ
             new nsAppFileLocProviderProxy(aJavaLocProvider);
   if (provider == nsnull)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(provider);
 
   *aResult = provider;
   return NS_OK;
diff --git a/extensions/java/xpcom/src/nsJavaWrapper.cpp b/extensions/java/xpcom/src/nsJavaWrapper.cpp
--- a/extensions/java/xpcom/src/nsJavaWrapper.cpp
+++ b/extensions/java/xpcom/src/nsJavaWrapper.cpp
@@ -761,7 +761,6 @@ SetupParams(JNIEnv *env, const jobject a
             supportsweak->GetWeakReference(getter_AddRefs(weakref));
             NS_RELEASE(isupports);
             xpcom_obj = weakref;
-            NS_ADDREF((nsISupports*) xpcom_obj);
           } else {
             xpcom_obj = nsnull;
           }
diff --git a/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.cpp b/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.cpp
--- a/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.cpp
+++ b/extensions/java/xpcom/src/nsJavaXPCOMBindingUtils.cpp
@@ -774,8 +774,6 @@ JavaXPCOMInstance::JavaXPCOMInstance(nsI
     : mInstance(aInstance)
     , mIInfo(aIInfo)
 {
-  NS_ADDREF(mInstance);
-  NS_ADDREF(mIInfo);
 }
 
 JavaXPCOMInstance::~JavaXPCOMInstance()
diff --git a/extensions/java/xpcom/src/nsJavaXPTCStub.cpp b/extensions/java/xpcom/src/nsJavaXPTCStub.cpp
--- a/extensions/java/xpcom/src/nsJavaXPTCStub.cpp
+++ b/extensions/java/xpcom/src/nsJavaXPTCStub.cpp
@@ -235,7 +235,6 @@ nsJavaXPTCStub::QueryInterface(const nsI
   if (aIID.Equals(NS_GET_IID(nsJavaXPTCStub)))
   {
     *aInstancePtr = master;
-    NS_ADDREF(this);
     return NS_OK;
   }
 
@@ -243,7 +242,6 @@ nsJavaXPTCStub::QueryInterface(const nsI
   if (aIID.Equals(NS_GET_IID(nsISupports)))
   {
     *aInstancePtr = master->mXPTCStub;
-    NS_ADDREF(master);
     return NS_OK;
   }
 
@@ -251,7 +249,6 @@ nsJavaXPTCStub::QueryInterface(const nsI
   if (aIID.Equals(NS_GET_IID(nsISupportsWeakReference)))
   {
     *aInstancePtr = static_cast<nsISupportsWeakReference*>(master);
-    NS_ADDREF(master);
     return NS_OK;
   }
 
@@ -260,7 +257,6 @@ nsJavaXPTCStub::QueryInterface(const nsI
   if (stub)
   {
     *aInstancePtr = stub->mXPTCStub;
-    NS_ADDREF(stub);
     return NS_OK;
   }
 
@@ -348,7 +344,6 @@ nsJavaXPTCStub::QueryInterface(const nsI
   master->mChildren.AppendElement(stub);
 
   *aInstancePtr = stub->mXPTCStub;
-  NS_ADDREF(stub);
   return NS_OK;
 }
 
@@ -1515,7 +1510,6 @@ nsJavaXPTCStub::FinalizeJavaParams(const
             supportsweak->GetWeakReference(getter_AddRefs(weakref));
             NS_RELEASE(isupports);
             xpcom_obj = weakref;
-            NS_ADDREF((nsISupports*) xpcom_obj);
           } else {
             xpcom_obj = nsnull;
           }
@@ -1635,7 +1629,6 @@ nsJavaXPTCStub::GetWeakReference(nsIWeak
     return NS_ERROR_OUT_OF_MEMORY;
 
   *aInstancePtr = weakref;
-  NS_ADDREF(*aInstancePtr);
   ++mWeakRefCnt;
 
   return NS_OK;
@@ -1704,7 +1697,6 @@ nsJavaXPTCStub::GetNewOrUsed(JNIEnv* env
     return rv;
   }
 
-  NS_ADDREF(stub);
   *aResult = stub;
 
   return NS_OK;
diff --git a/extensions/java/xpcom/tools/genifaces/GenerateJavaInterfaces.cpp b/extensions/java/xpcom/tools/genifaces/GenerateJavaInterfaces.cpp
--- a/extensions/java/xpcom/tools/genifaces/GenerateJavaInterfaces.cpp
+++ b/extensions/java/xpcom/tools/genifaces/GenerateJavaInterfaces.cpp
@@ -81,7 +81,6 @@ public:
     NS_ENSURE_SUCCESS(rv, rv);
 
     *aParentInfo = parent;
-    NS_ADDREF(*aParentInfo);
     return rv;
   }
 
@@ -339,7 +338,6 @@ public:
     NS_ENSURE_SUCCESS(rv, rv);
 
     *aResult = out;
-    NS_ADDREF(*aResult);
     return NS_OK;
   }
 
diff --git a/extensions/jssh/nsJSSh.cpp b/extensions/jssh/nsJSSh.cpp
--- a/extensions/jssh/nsJSSh.cpp
+++ b/extensions/jssh/nsJSSh.cpp
@@ -459,7 +459,6 @@ CreateJSSh(nsIInputStream* input, nsIOut
            const nsACString &startupURI)
 {
   nsIRunnable* obj = new nsJSSh(input, output, startupURI);
-  NS_IF_ADDREF(obj);
   return obj;
 }
 
diff --git a/extensions/jssh/nsJSShServer.cpp b/extensions/jssh/nsJSShServer.cpp
--- a/extensions/jssh/nsJSShServer.cpp
+++ b/extensions/jssh/nsJSShServer.cpp
@@ -77,7 +77,6 @@ already_AddRefed<nsIServerSocketListener
 already_AddRefed<nsIServerSocketListener> CreateConnectionListener(const nsACString &startupURI)
 {
   nsIServerSocketListener* obj = new ConnectionListener(startupURI);
-  NS_IF_ADDREF(obj);
   return obj;
 }
 
diff --git a/extensions/layout-debug/src/nsRegressionTester.cpp b/extensions/layout-debug/src/nsRegressionTester.cpp
--- a/extensions/layout-debug/src/nsRegressionTester.cpp
+++ b/extensions/layout-debug/src/nsRegressionTester.cpp
@@ -185,7 +185,6 @@ nsRegressionTester::GetDocShellFromWindo
   if (!window) return NS_ERROR_FAILURE;
 
   *outShell = window->GetDocShell();
-  NS_IF_ADDREF(*outShell);
 
   return NS_OK;
 }
diff --git a/extensions/metrics/src/nsMetricsEventItem.cpp b/extensions/metrics/src/nsMetricsEventItem.cpp
--- a/extensions/metrics/src/nsMetricsEventItem.cpp
+++ b/extensions/metrics/src/nsMetricsEventItem.cpp
@@ -68,7 +68,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsMetricsEventItem::GetProperties(nsIPropertyBag **aProperties)
 {
-  NS_IF_ADDREF(*aProperties = mProperties);
+  *aProperties = mProperties;
   return NS_OK;
 }
 
@@ -86,7 +86,7 @@ nsMetricsEventItem::ChildAt(PRInt32 inde
 {
   NS_ENSURE_ARG_RANGE(index, 0, PRInt32(mChildren.Length()) - 1);
 
-  NS_ADDREF(*result = mChildren[index]);
+  *result = mChildren[index];
   return NS_OK;
 }
 
diff --git a/extensions/metrics/src/nsMetricsService.cpp b/extensions/metrics/src/nsMetricsService.cpp
--- a/extensions/metrics/src/nsMetricsService.cpp
+++ b/extensions/metrics/src/nsMetricsService.cpp
@@ -236,7 +236,7 @@ nsMetricsService::CreateEventItem(const 
   nsMetricsEventItem *item = new nsMetricsEventItem(itemNamespace, itemName);
   NS_ENSURE_TRUE(item, NS_ERROR_OUT_OF_MEMORY);
 
-  NS_ADDREF(*result = item);
+  *result = item;
   return NS_OK;
 }
 
@@ -545,7 +545,7 @@ nsMetricsService::NewChannel(nsIURI *uri
 
   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
-  NS_ADDREF(*result = channel);
+  *result = channel;
   return NS_OK;
 }
 
@@ -1375,7 +1375,7 @@ nsMetricsService::OpenCompleteXMLStream(
   rv = miStream->AppendStream(stringStream);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  NS_ADDREF(*result = miStream);
+  *result = miStream;
   return NS_OK;
 }
 
diff --git a/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp b/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp
--- a/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp
+++ b/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp
@@ -428,7 +428,6 @@ NS_IMETHODIMP nsSystemPrefService::AddOb
     }
 
     pCallbackData->observer = observerRef;
-    NS_ADDREF(pCallbackData->observer);
 
     mObservers->AppendElement(pCallbackData);
     return NS_OK;
diff --git a/extensions/python/dom/src/nsPyRuntime.cpp b/extensions/python/dom/src/nsPyRuntime.cpp
--- a/extensions/python/dom/src/nsPyRuntime.cpp
+++ b/extensions/python/dom/src/nsPyRuntime.cpp
@@ -65,7 +65,6 @@ nsPythonRuntime::CreateContext(nsIScript
     *ret = new nsPythonContext();
     if (!ret)
         return NS_ERROR_OUT_OF_MEMORY;
-    NS_IF_ADDREF(*ret);
     return NS_OK;
 }
 
diff --git a/extensions/spellcheck/hunspell/src/mozHunspell.cpp b/extensions/spellcheck/hunspell/src/mozHunspell.cpp
--- a/extensions/spellcheck/hunspell/src/mozHunspell.cpp
+++ b/extensions/spellcheck/hunspell/src/mozHunspell.cpp
@@ -232,7 +232,6 @@ NS_IMETHODIMP mozHunspell::GetPersonalDi
 NS_IMETHODIMP mozHunspell::GetPersonalDictionary(mozIPersonalDictionary * *aPersonalDictionary)
 {
   *aPersonalDictionary = mPersonalDictionary;
-  NS_IF_ADDREF(*aPersonalDictionary);
   return NS_OK;
 }
 
diff --git a/extensions/spellcheck/hunspell/src/mozHunspellDirProvider.cpp b/extensions/spellcheck/hunspell/src/mozHunspellDirProvider.cpp
--- a/extensions/spellcheck/hunspell/src/mozHunspellDirProvider.cpp
+++ b/extensions/spellcheck/hunspell/src/mozHunspellDirProvider.cpp
@@ -94,7 +94,7 @@ mozHunspellDirProvider::AppendingEnumera
 mozHunspellDirProvider::AppendingEnumerator::GetNext(nsISupports* *aResult)
 {
   if (aResult)
-    NS_ADDREF(*aResult = mNext);
+    *aResult = mNext;
 
   mNext = nsnull;
 
diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.cpp b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -550,7 +550,6 @@ mozInlineSpellChecker::GetSpellChecker(n
 mozInlineSpellChecker::GetSpellChecker(nsIEditorSpellCheck **aSpellCheck)
 {
   *aSpellCheck = mSpellCheck;
-  NS_IF_ADDREF(*aSpellCheck);
   return NS_OK;
 }
 
@@ -1506,7 +1505,7 @@ mozInlineSpellChecker::IsPointInSelectio
 
   // there may be more than one range returned, and we don't know what do
   // do with that, so just get the first one
-  NS_ADDREF(*aRange = ranges[0]);
+  *aRange = ranges[0];
   return NS_OK;
 }
 
diff --git a/extensions/spellcheck/src/mozSpellCheckerFactory.cpp b/extensions/spellcheck/src/mozSpellCheckerFactory.cpp
--- a/extensions/spellcheck/src/mozSpellCheckerFactory.cpp
+++ b/extensions/spellcheck/src/mozSpellCheckerFactory.cpp
@@ -109,7 +109,6 @@ mozInlineSpellCheckerConstructor(nsISupp
     rv = NS_ERROR_OUT_OF_MEMORY;
     return rv;
   }
-  NS_ADDREF(inst);
   rv = inst->QueryInterface(aIID, aResult);
   NS_RELEASE(inst);
 
diff --git a/extensions/spellcheck/src/mozSpellI18NManager.cpp b/extensions/spellcheck/src/mozSpellI18NManager.cpp
--- a/extensions/spellcheck/src/mozSpellI18NManager.cpp
+++ b/extensions/spellcheck/src/mozSpellI18NManager.cpp
@@ -68,6 +68,5 @@ NS_IMETHODIMP mozSpellI18NManager::GetUt
    *_retval = new mozEnglishWordUtils;   
  }
 
- NS_IF_ADDREF(*_retval);
  return NS_OK;
 }
diff --git a/gfx/src/beos/nsDeviceContextBeOS.cpp b/gfx/src/beos/nsDeviceContextBeOS.cpp
--- a/gfx/src/beos/nsDeviceContextBeOS.cpp
+++ b/gfx/src/beos/nsDeviceContextBeOS.cpp
@@ -183,7 +183,6 @@ NS_IMETHODIMP nsDeviceContextBeOS::Creat
  
   if (nsnull != pContext) 
   { 
-    NS_ADDREF(pContext); 
  
     // create the nsDrawingSurfaceBeOS 
     surf = new nsDrawingSurfaceBeOS(); 
diff --git a/gfx/src/beos/nsFontMetricsBeOS.cpp b/gfx/src/beos/nsFontMetricsBeOS.cpp
--- a/gfx/src/beos/nsFontMetricsBeOS.cpp
+++ b/gfx/src/beos/nsFontMetricsBeOS.cpp
@@ -399,7 +399,6 @@ NS_IMETHODIMP  nsFontMetricsBeOS::GetLan
     return NS_ERROR_NULL_POINTER;
 
   *aLangGroup = mLangGroup;
-  NS_IF_ADDREF(*aLangGroup);
 
   return NS_OK;
 }
diff --git a/gfx/src/beos/nsGfxFactoryBeOS.cpp b/gfx/src/beos/nsGfxFactoryBeOS.cpp
--- a/gfx/src/beos/nsGfxFactoryBeOS.cpp
+++ b/gfx/src/beos/nsGfxFactoryBeOS.cpp
@@ -93,7 +93,6 @@ static NS_IMETHODIMP nsScriptableRegionC
     rv = NS_ERROR_OUT_OF_MEMORY; 
     return rv; 
   } 
-  NS_ADDREF(inst); 
   // release our variable above now that we have created our owning
   // reference - we don't want this to go out of scope early!
   scriptableRgn = nsnull;
diff --git a/gfx/src/beos/nsRenderingContextBeOS.cpp b/gfx/src/beos/nsRenderingContextBeOS.cpp
--- a/gfx/src/beos/nsRenderingContextBeOS.cpp
+++ b/gfx/src/beos/nsRenderingContextBeOS.cpp
@@ -106,11 +106,9 @@ NS_IMETHODIMP nsRenderingContextBeOS::In
 		return NS_ERROR_OUT_OF_MEMORY;
 	
 	mContext = aContext;
-	NS_IF_ADDREF(mContext);
 
 	mSurface->Init(view);
 	mOffscreenSurface = mSurface;
-	NS_ADDREF(mSurface);
 	return CommonInit();
 }
 
@@ -120,10 +118,8 @@ NS_IMETHODIMP nsRenderingContextBeOS::In
 		return NS_ERROR_NULL_POINTER;
 		
 	mContext = aContext;
-	NS_IF_ADDREF(mContext);
 	mSurface = (nsDrawingSurfaceBeOS *) aSurface;
 	mOffscreenSurface = mSurface;
-	NS_ADDREF(mSurface);
 	return CommonInit();
 }
 
@@ -184,7 +180,6 @@ NS_IMETHODIMP nsRenderingContextBeOS::Re
 
 NS_IMETHODIMP nsRenderingContextBeOS::GetDeviceContext(nsIDeviceContext *&aContext)
 {
-	NS_IF_ADDREF(mContext);
 	aContext = mContext;
 	return NS_OK;
 }
@@ -222,7 +217,6 @@ NS_IMETHODIMP nsRenderingContextBeOS::Pu
 	// Set state to mClipRegion. SetClip{Rect,Region}() will do copy-on-write stuff
 	state->mClipRegion = mClipRegion;
 
-	NS_IF_ADDREF(mFontMetrics);
 	state->mFontMetrics = mFontMetrics;
 	state->mColor = mCurrentColor;
 	state->mLineStyle = mCurrentLineStyle;
@@ -473,7 +467,7 @@ NS_IMETHODIMP nsRenderingContextBeOS::Ge
 		nsCOMPtr<nsIRegion> newRegion = new nsRegionBeOS();
 		newRegion->Init();
 		newRegion->SetTo(*mClipRegion);
-		NS_ADDREF(*aRegion = newRegion);
+		*aRegion = newRegion;
 	}
 	return NS_OK;
 }
@@ -515,7 +509,6 @@ NS_IMETHODIMP nsRenderingContextBeOS::Se
 	mCurrentBFont = nsnull;
 	NS_IF_RELEASE(mFontMetrics);
 	mFontMetrics = aFontMetrics;
-	NS_IF_ADDREF(mFontMetrics);
 	// Assigning value to mCurrentBFont and setting it as mView font
 	if (LockAndUpdateView())
 		UnlockView();
@@ -549,7 +542,6 @@ NS_IMETHODIMP nsRenderingContextBeOS::Ge
 
 NS_IMETHODIMP nsRenderingContextBeOS::GetFontMetrics(nsIFontMetrics *&aFontMetrics)
 {
-	NS_IF_ADDREF(mFontMetrics);
 	aFontMetrics = mFontMetrics;
 	return NS_OK;
 }
@@ -594,7 +586,6 @@ NS_IMETHODIMP nsRenderingContextBeOS::Cr
 		return NS_ERROR_FAILURE;
 	}
 
-	NS_ADDREF(surf);
 	// Getting drawable and updating context
 	if (LockAndUpdateView())
 		UnlockView();
diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp
--- a/gfx/src/nsDeviceContext.cpp
+++ b/gfx/src/nsDeviceContext.cpp
@@ -137,7 +137,6 @@ NS_IMETHODIMP DeviceContextImpl::CreateR
     rv = InitRenderingContext(pContext, aView->GetWidget());
     if (NS_SUCCEEDED(rv)) {
       aContext = pContext;
-      NS_ADDREF(aContext);
     }
   }
   
@@ -155,7 +154,6 @@ NS_IMETHODIMP DeviceContextImpl::CreateR
     rv = InitRenderingContext(pContext, aWidget);
     if (NS_SUCCEEDED(rv)) {
       aContext = pContext;
-      NS_ADDREF(aContext);
     }
   }    
   
@@ -170,7 +168,6 @@ NS_IMETHODIMP DeviceContextImpl::CreateR
   nsIRenderingContext* pContext = do_CreateInstance(kRenderingContextCID, &rv);
   if (NS_SUCCEEDED(rv)) {
     aContext = pContext;
-    NS_ADDREF(aContext);
   }
   return rv;
 }
@@ -463,7 +460,6 @@ nsFontCache::GetDeviceContext(nsIDeviceC
 nsFontCache::GetDeviceContext(nsIDeviceContext *&aContext) const
 {
   aContext = mContext;
-  NS_IF_ADDREF(aContext);
   return NS_OK;
 }
 
@@ -486,7 +482,7 @@ nsFontCache::GetMetricsFor(const nsFont&
           // promote it to the end of the cache
           mFontMetrics.MoveElement(i, n);
         }
-        NS_ADDREF(aMetrics = fm);
+        aMetrics = fm;
         return NS_OK;
       }
     }
@@ -503,7 +499,6 @@ nsFontCache::GetMetricsFor(const nsFont&
     // cheaper than insert
     mFontMetrics.AppendElement(fm);
     aMetrics = fm;
-    NS_ADDREF(aMetrics);
     return NS_OK;
   }
   fm->Destroy();
@@ -520,7 +515,6 @@ nsFontCache::GetMetricsFor(const nsFont&
   if (NS_SUCCEEDED(rv)) {
     mFontMetrics.AppendElement(fm);
     aMetrics = fm;
-    NS_ADDREF(aMetrics);
     return NS_OK;
   }
   fm->Destroy();
@@ -531,7 +525,6 @@ nsFontCache::GetMetricsFor(const nsFont&
   n = mFontMetrics.Count() - 1; // could have changed in Compact()
   if (n >= 0) {
     aMetrics = static_cast<nsIFontMetrics*>(mFontMetrics[n]);
-    NS_ADDREF(aMetrics);
     return NS_OK;
   }
 
@@ -567,7 +560,6 @@ nsresult nsFontCache::Compact()
     // FontMetricsDeleted() and would have removed itself
     if (mFontMetrics.IndexOf(oldfm) >= 0) {
       // nope, the font is still there, so let's hold onto it too
-      NS_ADDREF(oldfm);
     }
   }
   return NS_OK;
diff --git a/gfx/src/nsScriptableRegion.cpp b/gfx/src/nsScriptableRegion.cpp
--- a/gfx/src/nsScriptableRegion.cpp
+++ b/gfx/src/nsScriptableRegion.cpp
@@ -44,7 +44,6 @@ nsScriptableRegion::nsScriptableRegion(n
 nsScriptableRegion::nsScriptableRegion(nsIRegion* region) : mRegion(nsnull)
 {
 	mRegion = region;
-	NS_IF_ADDREF(mRegion);
 }
 
 nsScriptableRegion::~nsScriptableRegion()
@@ -146,6 +145,5 @@ NS_IMETHODIMP nsScriptableRegion::GetReg
 NS_IMETHODIMP nsScriptableRegion::GetRegion(nsIRegion** outRgn)
 {
   *outRgn = mRegion;
-  NS_IF_ADDREF(*outRgn);
   return NS_OK;
 }
diff --git a/gfx/src/photon/nsDeviceContextPh.cpp b/gfx/src/photon/nsDeviceContextPh.cpp
--- a/gfx/src/photon/nsDeviceContextPh.cpp
+++ b/gfx/src/photon/nsDeviceContextPh.cpp
@@ -223,7 +223,6 @@ NS_IMETHODIMP nsDeviceContextPh :: Creat
 	pContext = new nsRenderingContextPh();
 	
 	if( nsnull != pContext ) {
-	  NS_ADDREF(pContext);
 
 	  surf = new nsDrawingSurfacePh();
 	  if( nsnull != surf ) {
@@ -514,7 +513,6 @@ NS_IMETHODIMP nsDeviceContextPh :: GetDe
 	}
 
 	devConPh->mSpec = aDevice;
-	NS_ADDREF(aDevice);
 	return devConPh->Init(NULL, this);
 	}
 
diff --git a/gfx/src/photon/nsFontMetricsPh.h b/gfx/src/photon/nsFontMetricsPh.h
--- a/gfx/src/photon/nsFontMetricsPh.h
+++ b/gfx/src/photon/nsFontMetricsPh.h
@@ -67,7 +67,6 @@ public:
 		{
 		if( !aLangGroup ) return NS_ERROR_NULL_POINTER;
 		*aLangGroup = mLangGroup;
-		NS_IF_ADDREF(*aLangGroup);
 		return NS_OK;
 		}
 
diff --git a/gfx/src/photon/nsGfxFactoryPh.cpp b/gfx/src/photon/nsGfxFactoryPh.cpp
--- a/gfx/src/photon/nsGfxFactoryPh.cpp
+++ b/gfx/src/photon/nsGfxFactoryPh.cpp
@@ -101,7 +101,6 @@ static nsresult nsScriptableRegionConstr
     rv = NS_ERROR_OUT_OF_MEMORY;
     return rv;
   }
-  NS_ADDREF(inst);
   // release our variable above now that we have created our owning
   // reference - we don't want this to go out of scope early!
   scriptableRgn = nsnull;
diff --git a/gfx/src/photon/nsRenderingContextPh.cpp b/gfx/src/photon/nsRenderingContextPh.cpp
--- a/gfx/src/photon/nsRenderingContextPh.cpp
+++ b/gfx/src/photon/nsRenderingContextPh.cpp
@@ -144,7 +144,6 @@ NS_IMETHODIMP nsRenderingContextPh :: In
 	nsresult res;
 	
 	mContext = aContext;
-	NS_IF_ADDREF(mContext);
 	
 	PtWidget_t *widget = (PtWidget_t*) aWindow->GetNativeData( NS_NATIVE_WIDGET );
 	
@@ -168,7 +167,6 @@ NS_IMETHODIMP nsRenderingContextPh :: In
 				return NS_ERROR_FAILURE;
 			
 			mOffscreenSurface = mSurface;
-			NS_ADDREF( mSurface );
 
 			mSurfaceDC = ((nsDrawingSurfacePh*)mSurface)->GetDC();
 		}
@@ -205,7 +203,6 @@ NS_IMETHODIMP nsRenderingContextPh :: Pu
 	//  if( mClipRegion ) GetClipRegion( &state->mClipRegion );
 	state->mClipRegion = mClipRegion;
 
-	NS_IF_ADDREF(mFontMetrics);
 	state->mFontMetrics = mFontMetrics;
 	
 	state->mColor = mCurrentColor;
@@ -396,7 +393,7 @@ NS_IMETHODIMP nsRenderingContextPh :: Ge
 				  if (NS_SUCCEEDED(rv)) {
 					  newRegion->Init();
 					  newRegion->SetTo(*mClipRegion);
-					  NS_ADDREF(*aRegion = newRegion);
+					  *aRegion = newRegion;
 				  }
 			  }
 	} else {
@@ -414,7 +411,6 @@ NS_IMETHODIMP nsRenderingContextPh :: Se
 	
 	NS_IF_RELEASE(mFontMetrics);
 	mFontMetrics = aFontMetrics;
-	NS_IF_ADDREF(mFontMetrics);
 	
   if( mFontMetrics == nsnull ) return NS_OK;
 	
@@ -434,7 +430,6 @@ NS_IMETHODIMP nsRenderingContextPh :: Cr
 	if( mSurface ) {
 		nsDrawingSurfacePh *surf = new nsDrawingSurfacePh();
 		if( surf ) {
-			NS_ADDREF(surf);
 			/* we pass NULL as aGC here / it means use the default photon gc */
 			if( surf->Init( aBounds.width, aBounds.height, aSurfFlags ) == NS_OK ) {
 				aSurface = surf;
diff --git a/gfx/src/photon/nsRenderingContextPh.h b/gfx/src/photon/nsRenderingContextPh.h
--- a/gfx/src/photon/nsRenderingContextPh.h
+++ b/gfx/src/photon/nsRenderingContextPh.h
@@ -77,10 +77,8 @@ public:
    NS_IMETHODIMP Init(nsIDeviceContext* aContext, nsIDrawingSurface* aSurface)
 		{
 		mContext = aContext;
-		NS_IF_ADDREF(mContext);
 
 		mSurface = (nsDrawingSurfacePh *) aSurface;
-		NS_ADDREF(mSurface);
 		mOffscreenSurface = mSurface;
 
 		mGC = mSurface->GetGC();
diff --git a/gfx/src/photon/nsScreenManagerPh.cpp b/gfx/src/photon/nsScreenManagerPh.cpp
--- a/gfx/src/photon/nsScreenManagerPh.cpp
+++ b/gfx/src/photon/nsScreenManagerPh.cpp
@@ -66,7 +66,7 @@ nsIScreen* nsScreenManagerPh :: CreateNe
 nsIScreen* nsScreenManagerPh :: CreateNewScreenObject( ) {
   nsIScreen* retval = nsnull;
   if( !mCachedMainScreen ) mCachedMainScreen = new nsScreenPh( );
-  NS_IF_ADDREF(retval = mCachedMainScreen.get());
+  retval = mCachedMainScreen.get();
   return retval;
 	}
 
diff --git a/gfx/src/thebes/nsThebesDeviceContext.cpp b/gfx/src/thebes/nsThebesDeviceContext.cpp
--- a/gfx/src/thebes/nsThebesDeviceContext.cpp
+++ b/gfx/src/thebes/nsThebesDeviceContext.cpp
@@ -319,7 +319,6 @@ nsThebesDeviceContext::CreateRenderingCo
 
         if (NS_SUCCEEDED(rv)) {
             aContext = pContext;
-            NS_ADDREF(aContext);
         }
     }
 
@@ -343,7 +342,6 @@ nsThebesDeviceContext::CreateRenderingCo
         if (NS_SUCCEEDED(rv)) {
             pContext->Scale(mPrintingScale, mPrintingScale);
             aContext = pContext;
-            NS_ADDREF(aContext);
         }
     }
 
@@ -358,7 +356,6 @@ nsThebesDeviceContext::CreateRenderingCo
         return NS_ERROR_OUT_OF_MEMORY;
 
     aContext = renderingContext;
-    NS_ADDREF(aContext);
 
     return NS_OK;
 }
diff --git a/gfx/src/thebes/nsThebesFontMetrics.cpp b/gfx/src/thebes/nsThebesFontMetrics.cpp
--- a/gfx/src/thebes/nsThebesFontMetrics.cpp
+++ b/gfx/src/thebes/nsThebesFontMetrics.cpp
@@ -239,7 +239,6 @@ nsThebesFontMetrics::GetLangGroup(nsIAto
 nsThebesFontMetrics::GetLangGroup(nsIAtom** aLangGroup)
 {
     *aLangGroup = mLangGroup;
-    NS_IF_ADDREF(*aLangGroup);
     return NS_OK;
 }
 
diff --git a/gfx/src/thebes/nsThebesGfxFactory.cpp b/gfx/src/thebes/nsThebesGfxFactory.cpp
--- a/gfx/src/thebes/nsThebesGfxFactory.cpp
+++ b/gfx/src/thebes/nsThebesGfxFactory.cpp
@@ -91,7 +91,6 @@ static NS_IMETHODIMP nsScriptableRegionC
     rv = NS_ERROR_OUT_OF_MEMORY;
     return rv;
   }
-  NS_ADDREF(inst);
   // release our variable above now that we have created our owning
   // reference - we don't want this to go out of scope early!
   scriptableRgn = nsnull;
diff --git a/gfx/src/thebes/nsThebesRenderingContext.cpp b/gfx/src/thebes/nsThebesRenderingContext.cpp
--- a/gfx/src/thebes/nsThebesRenderingContext.cpp
+++ b/gfx/src/thebes/nsThebesRenderingContext.cpp
@@ -159,7 +159,6 @@ nsThebesRenderingContext::GetDeviceConte
 nsThebesRenderingContext::GetDeviceContext(nsIDeviceContext *& aDeviceContext)
 {
     aDeviceContext = mDeviceContext;
-    NS_IF_ADDREF(aDeviceContext);
     return NS_OK;
 }
 
@@ -895,7 +894,6 @@ nsThebesRenderingContext::GetFontMetrics
 nsThebesRenderingContext::GetFontMetrics(nsIFontMetrics *&aFontMetrics)
 {
     aFontMetrics = mFontMetrics;
-    NS_IF_ADDREF(aFontMetrics);
     return NS_OK;
 }
 
diff --git a/gfx/tests/coverage/nsCoverage.cpp b/gfx/tests/coverage/nsCoverage.cpp
--- a/gfx/tests/coverage/nsCoverage.cpp
+++ b/gfx/tests/coverage/nsCoverage.cpp
@@ -374,7 +374,6 @@ nsresult CoverageTest(int *argc, char **
     if (NS_OK == res)
     {
       deviceContext->Init(gWindow->GetNativeData(NS_NATIVE_WIDGET));
-      NS_ADDREF(deviceContext);
     }
 
     gWindow->Show(PR_TRUE);
diff --git a/gfx/thebes/src/gfxBeOSPlatform.cpp b/gfx/thebes/src/gfxBeOSPlatform.cpp
--- a/gfx/thebes/src/gfxBeOSPlatform.cpp
+++ b/gfx/thebes/src/gfxBeOSPlatform.cpp
@@ -81,7 +81,6 @@ gfxBeOSPlatform::CreateOffscreenSurface 
                                         imageFormat == gfxASurface::ImageFormatARGB32 ? B_RGBA32 : B_RGB32);
     }
 
-    NS_ADDREF(newSurface);
     return newSurface;
 }
 
diff --git a/gfx/thebes/src/gfxOS2Platform.cpp b/gfx/thebes/src/gfxOS2Platform.cpp
--- a/gfx/thebes/src/gfxOS2Platform.cpp
+++ b/gfx/thebes/src/gfxOS2Platform.cpp
@@ -104,7 +104,6 @@ gfxOS2Platform::CreateOffscreenSurface(c
         return nsnull;
     }
 
-    NS_IF_ADDREF(newSurface);
     return newSurface;
 }
 
diff --git a/gfx/thebes/src/gfxWindowsFonts.cpp b/gfx/thebes/src/gfxWindowsFonts.cpp
--- a/gfx/thebes/src/gfxWindowsFonts.cpp
+++ b/gfx/thebes/src/gfxWindowsFonts.cpp
@@ -1702,7 +1702,6 @@ public:
         // same font as the previous range if we can
         if (IsJoiner(ch) || IsJoiner(prevCh) || IsJoiner(nextCh)) {
             if (aFont && HasCharacter(aFont->GetFontEntry(), ch)) {
-                NS_ADDREF(aFont);
                 return aFont;
             }
         }
diff --git a/intl/locale/src/nsLocaleService.cpp b/intl/locale/src/nsLocaleService.cpp
--- a/intl/locale/src/nsLocaleService.cpp
+++ b/intl/locale/src/nsLocaleService.cpp
@@ -317,7 +317,7 @@ nsLocaleService::NewLocale(const nsAStri
 #endif
     }
 
-    NS_ADDREF(*_retval = resultLocale);
+    *_retval = resultLocale;
     return NS_OK;
 }
 
@@ -326,7 +326,7 @@ nsLocaleService::GetSystemLocale(nsILoca
 nsLocaleService::GetSystemLocale(nsILocale **_retval)
 {
 	if (mSystemLocale) {
-		NS_ADDREF(*_retval = mSystemLocale);
+		*_retval = mSystemLocale;
 		return NS_OK;
 	}
 
@@ -338,7 +338,7 @@ nsLocaleService::GetApplicationLocale(ns
 nsLocaleService::GetApplicationLocale(nsILocale **_retval)
 {
 	if (mApplicationLocale) {
-		NS_ADDREF(*_retval = mApplicationLocale);
+		*_retval = mApplicationLocale;
 		return NS_OK;
 	}
 
@@ -478,6 +478,5 @@ NS_NewLocaleService(nsILocaleService** r
   *result = new nsLocaleService();
   if (! *result)
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(*result);
   return NS_OK;
 }
diff --git a/intl/locale/src/nsScriptableDateFormat.cpp b/intl/locale/src/nsScriptableDateFormat.cpp
--- a/intl/locale/src/nsScriptableDateFormat.cpp
+++ b/intl/locale/src/nsScriptableDateFormat.cpp
@@ -171,7 +171,6 @@ NS_NewScriptableDateFormat(nsISupports* 
   if (! result)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(result);
   nsresult rv = result->QueryInterface(aIID, aResult);
   NS_RELEASE(result);
 
diff --git a/intl/strres/src/nsStringBundleTextOverride.cpp b/intl/strres/src/nsStringBundleTextOverride.cpp
--- a/intl/strres/src/nsStringBundleTextOverride.cpp
+++ b/intl/strres/src/nsStringBundleTextOverride.cpp
@@ -250,7 +250,7 @@ nsStringBundleTextOverride::EnumerateKey
 
     if (!propEnum) return NS_ERROR_OUT_OF_MEMORY;
     
-    NS_ADDREF(*aResult = propEnum);
+    *aResult = propEnum;
     
     return NS_OK;
 }
@@ -270,7 +270,6 @@ nsPropertyEnumeratorByURL::GetNext(nsISu
 
     // wrap mCurrent instead of returning it
     *aResult = new URLPropertyElement(mCurrent, mURL.Length());
-    NS_ADDREF(*aResult);
 
     // release it so we don't return it twice
     mCurrent = nsnull;
diff --git a/intl/uconv/native/nsNativeUConvService.cpp b/intl/uconv/native/nsNativeUConvService.cpp
--- a/intl/uconv/native/nsNativeUConvService.cpp
+++ b/intl/uconv/native/nsNativeUConvService.cpp
@@ -385,7 +385,7 @@ NativeUConvService::GetNativeConverter(c
     //nsresult rv = ucl->Init(from, to);
     nsresult rv=adaptor->Init(from,to);   
     if (NS_SUCCEEDED(rv))
-        NS_ADDREF(*aResult = ucl);
+        *aResult = ucl;
 
     return rv;
 }
diff --git a/intl/uconv/native/nsWinCEUConvService.cpp b/intl/uconv/native/nsWinCEUConvService.cpp
--- a/intl/uconv/native/nsWinCEUConvService.cpp
+++ b/intl/uconv/native/nsWinCEUConvService.cpp
@@ -432,7 +432,7 @@ NativeUConvService::GetNativeConverter(c
   nsresult rv = ucl->Init(from, to);
   
   if (NS_SUCCEEDED(rv)) {
-    NS_ADDREF(*aResult = (nsISupports*)(nsIUnicharEncoder*)ucl);
+    *aResult = (nsISupports*)(nsIUnicharEncoder*)ucl;
   }
   
   return rv;
diff --git a/intl/uconv/src/nsCharsetConverterManager.cpp b/intl/uconv/src/nsCharsetConverterManager.cpp
--- a/intl/uconv/src/nsCharsetConverterManager.cpp
+++ b/intl/uconv/src/nsCharsetConverterManager.cpp
@@ -198,7 +198,7 @@ nsCharsetConverterManager::GetUnicodeEnc
     encoder = do_QueryInterface(supports);
 
     if (encoder) {
-      NS_ADDREF(*aResult = encoder);
+      *aResult = encoder;
       return NS_OK;
     }
   }
@@ -217,7 +217,6 @@ nsCharsetConverterManager::GetUnicodeEnc
   else
   {
     *aResult = encoder;
-    NS_ADDREF(*aResult);
   }
   return rv;
 }
@@ -253,7 +252,7 @@ nsCharsetConverterManager::GetUnicodeDec
     decoder = do_QueryInterface(supports);
 
     if (decoder) {
-      NS_ADDREF(*aResult = decoder);
+      *aResult = decoder;
       return NS_OK;
     }
   }
diff --git a/intl/uconv/src/nsScriptableUConv.cpp b/intl/uconv/src/nsScriptableUConv.cpp
--- a/intl/uconv/src/nsScriptableUConv.cpp
+++ b/intl/uconv/src/nsScriptableUConv.cpp
@@ -248,7 +248,7 @@ nsScriptableUnicodeConverter::ConvertToI
     return rv;
   }
 
-  NS_ADDREF(*_retval = inputStream);
+  *_retval = inputStream;
   return rv;
 }
 
diff --git a/intl/uconv/util/nsUCConstructors.cpp b/intl/uconv/util/nsUCConstructors.cpp
--- a/intl/uconv/util/nsUCConstructors.cpp
+++ b/intl/uconv/util/nsUCConstructors.cpp
@@ -45,7 +45,6 @@ inline NS_METHOD StabilizedQueryInterfac
                                          REFNSIID aIID,
                                          void **aResult)
 {
-    NS_ADDREF(aNewObject);
     nsresult rv = aNewObject->QueryInterface(aIID, aResult);
     NS_RELEASE(aNewObject);
     return rv;
diff --git a/ipc/ipcd/client/src/ipcdclient.cpp b/ipc/ipcd/client/src/ipcdclient.cpp
--- a/ipc/ipcd/client/src/ipcdclient.cpp
+++ b/ipc/ipcd/client/src/ipcdclient.cpp
@@ -462,7 +462,6 @@ CallProcessPendingQ(const nsID &target, 
   nsIRunnable *ev = new ipcEvent_ProcessPendingQ(target);
   if (!ev)
     return;
-  NS_ADDREF(ev);
 
   nsresult rv;
 
@@ -614,7 +613,7 @@ DefineTarget(const nsID           &aTarg
   }
 
   if (aResult)
-    NS_ADDREF(*aResult = td);
+    *aResult = td;
   return NS_OK;
 }
 
diff --git a/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp b/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp
--- a/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp
+++ b/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp
@@ -824,7 +824,6 @@ CreateStub(const nsID &iid, PRUint32 pee
     rv = NS_ERROR_OUT_OF_MEMORY;
   else
   {
-    NS_ADDREF(stub);
     *result = stub;
   }
 
@@ -1001,7 +1000,6 @@ DConnectStub::QueryInterface(const nsID 
   if (aIID.Equals(NS_GET_IID(nsISupports)))
   {
     *aInstancePtr = master;
-    NS_ADDREF(master);
     return NS_OK;
   }
 
@@ -1009,7 +1007,6 @@ DConnectStub::QueryInterface(const nsID 
   if (aIID.Equals(kDConnectStubID))
   {
     *aInstancePtr = this;
-    NS_ADDREF_THIS();
     return NS_OK;
   }
 
@@ -1021,7 +1018,6 @@ DConnectStub::QueryInterface(const nsID 
   if (SupportsIID(aIID))
   {
     *aInstancePtr = this;
-    NS_ADDREF(this);
     return NS_OK;
   }
 #endif
@@ -1031,7 +1027,6 @@ DConnectStub::QueryInterface(const nsID 
   if (stub)
   {
     *aInstancePtr = stub;
-    NS_ADDREF(stub);
     return NS_OK;
   }
 
@@ -1076,14 +1071,13 @@ DConnectStub::QueryInterface(const nsID 
   master->mChildren.AppendElement(stub);
 
   *aInstancePtr = stub;
-  NS_ADDREF(stub);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 DConnectStub::GetInterfaceInfo(nsIInterfaceInfo **aInfo)
 {
-  NS_ADDREF(*aInfo = mIInfo);
+  *aInfo = mIInfo;
   return NS_OK;
 }
 
@@ -1280,7 +1274,6 @@ public:
       return mStatus;
 
     DConnectStub *stub = mStub;
-    NS_IF_ADDREF(stub);
     *aInstancePtr = stub;
     return NS_OK;
   }
diff --git a/ipc/ipcd/extensions/dconnect/test/TestDConnect.cpp b/ipc/ipcd/extensions/dconnect/test/TestDConnect.cpp
--- a/ipc/ipcd/extensions/dconnect/test/TestDConnect.cpp
+++ b/ipc/ipcd/extensions/dconnect/test/TestDConnect.cpp
@@ -219,7 +219,7 @@ int main(int argc, char **argv)
 
     nsCOMPtr<ipcIService> ipcServ(do_GetService(IPC_SERVICE_CONTRACTID, &rv));
     RETURN_IF_FAILED(rv, "do_GetService(ipcServ)");
-    NS_ADDREF(gIpcServ = ipcServ);
+    gIpcServ = ipcServ;
 
     if (!serverMode)
     {
diff --git a/ipc/ipcd/extensions/transmngr/test/tmModuleTest.cpp b/ipc/ipcd/extensions/transmngr/test/tmModuleTest.cpp
--- a/ipc/ipcd/extensions/transmngr/test/tmModuleTest.cpp
+++ b/ipc/ipcd/extensions/transmngr/test/tmModuleTest.cpp
@@ -197,13 +197,13 @@ int main(PRInt32 argc, char *argv[])
     printf("tmModuleTest: getting ipc service\n");
     nsCOMPtr<ipcIService> ipcServ(do_GetService("@mozilla.org/ipc/service;1", &rv));
     RETURN_IF_FAILED(rv, "do_GetService(ipcServ)");
-    NS_ADDREF(gIpcServ = ipcServ);
+    gIpcServ = ipcServ;
 
     // Get the transaction service
     printf("tmModuleTest: getting transaction service\n");
     nsCOMPtr<ipcITransactionService> transServ(do_GetService("@mozilla.org/ipc/transaction-service;1", &rv));
     RETURN_IF_FAILED(rv, "do_GetService(transServ)");
-    NS_ADDREF(gTransServ = transServ);
+    gTransServ = transServ;
 
     // transaction specifc startup stuff, done for all cases
 
diff --git a/ipc/ipcd/test/TestIPC.cpp b/ipc/ipcd/test/TestIPC.cpp
--- a/ipc/ipcd/test/TestIPC.cpp
+++ b/ipc/ipcd/test/TestIPC.cpp
@@ -202,7 +202,7 @@ int main(int argc, char **argv)
         printf("*** getting ipc service\n");
         nsCOMPtr<ipcIService> ipcServ(do_GetService(IPC_SERVICE_CONTRACTID, &rv));
         RETURN_IF_FAILED(rv, "do_GetService(ipcServ)");
-        NS_ADDREF(gIpcServ = ipcServ);
+        gIpcServ = ipcServ;
 
         if (argc > 1) {
             printf("*** using client name [%s]\n", argv[1]);
@@ -292,7 +292,7 @@ int main(int argc, char **argv)
         //
         nsCOMPtr<ipcILockService> lockService = do_GetService(IPC_LOCKSERVICE_CONTRACTID, &rv);
         RETURN_IF_FAILED(rv, "do_GetService(ipcLockServ)");
-        NS_ADDREF(gIpcLockServ = lockService);
+        gIpcLockServ = lockService;
 
         //nsCOMPtr<ipcILockNotify> notify(new myIpcLockNotify());
         gIpcLockServ->AcquireLock("blah", PR_TRUE);
diff --git a/js/jsd/jsd_xpc.cpp b/js/jsd/jsd_xpc.cpp
--- a/js/jsd/jsd_xpc.cpp
+++ b/js/jsd/jsd_xpc.cpp
@@ -179,7 +179,6 @@ jsds_FindEphemeral (LiveEphemeral **list
     {
         if (lv_record->key == key)
         {
-            NS_IF_ADDREF(lv_record->value);
             return lv_record->value;
         }
         lv_record = reinterpret_cast<LiveEphemeral *>
@@ -328,7 +327,6 @@ jsds_SyncFilter (FilterRecord *rec, jsdI
 
     if (rec->filterObject != filter) {
         NS_IF_RELEASE(rec->filterObject);
-        NS_ADDREF(filter);
         rec->filterObject = filter;
     }
     
@@ -471,7 +469,6 @@ jsds_NotifyPendingDeadScripts (JSContext
 
     jsdIScriptHook* hook = nsnull;
     if (jsds) {
-        NS_ADDREF(jsds);
         jsds->GetScriptHook (&hook);
         jsds->Pause(nsnull);
     }
@@ -686,7 +683,6 @@ jsds_ExecutionHookProc (JSDContext* jsdc
                                               native_frame));
     gJsds->Pause(nsnull);
     jsdIValue *inout_rv = js_rv;
-    NS_IF_ADDREF(inout_rv);
     hook->OnExecute (frame, type, &inout_rv, &hook_rv);
     js_rv = inout_rv;
     NS_IF_RELEASE(inout_rv);
@@ -772,7 +768,6 @@ jsds_ScriptHookProc (JSDContext* jsdc, J
         
             ds->jsdc = jsdc;
             ds->script = jsdis;
-            NS_ADDREF(ds->script);
             if (gDeadScripts)
                 /* if the queue exists, add to it */
                 PR_APPEND_LINK(&ds->links, &gDeadScripts->links);
@@ -1491,7 +1486,6 @@ jsdContext::FromPtr (JSDContext *aJSDCx,
     }
 
     jsdIContext *rv = jsdicx;
-    NS_IF_ADDREF(rv);
     return rv;
 }
 
@@ -1578,7 +1572,6 @@ jsdContext::GetPrivateData(nsISupports *
     if (options & JSOPTION_PRIVATE_IS_NSISUPPORTS)
     {
         *_rval = static_cast<nsISupports*>(JS_GetContextPrivate(mJSCx));
-        NS_IF_ADDREF(*_rval);
     }
     else
     {
@@ -1593,7 +1586,6 @@ jsdContext::GetWrappedContext(nsISupport
 {
     ASSERT_VALID_EPHEMERAL;
     *_rval = mISCx;
-    NS_IF_ADDREF(*_rval);
     return NS_OK;
 }
 
@@ -1715,7 +1707,6 @@ jsdStackFrame::FromPtr (JSDContext *aCx,
         rv = new jsdStackFrame (aCx, aThreadState, aStackFrameInfo);
     }
 
-    NS_IF_ADDREF(rv);
     return rv;
 }
 
@@ -1964,7 +1955,6 @@ jsdValue::FromPtr (JSDContext *aCx, JSDV
         return nsnull;
     
     jsdIValue *rv = new jsdValue (aCx, aValue);
-    NS_IF_ADDREF(rv);
     return rv;
 }
 
@@ -3055,7 +3045,6 @@ jsdService::GetErrorHook (jsdIErrorHook 
 jsdService::GetErrorHook (jsdIErrorHook **aHook)
 {
     *aHook = mErrorHook;
-    NS_IF_ADDREF(*aHook);
     
     return NS_OK;
 }
@@ -3071,7 +3060,6 @@ jsdService::GetBreakpointHook (jsdIExecu
 jsdService::GetBreakpointHook (jsdIExecutionHook **aHook)
 {   
     *aHook = mBreakpointHook;
-    NS_IF_ADDREF(*aHook);
     
     return NS_OK;
 }
@@ -3099,7 +3087,6 @@ jsdService::GetDebugHook (jsdIExecutionH
 jsdService::GetDebugHook (jsdIExecutionHook **aHook)
 {   
     *aHook = mDebugHook;
-    NS_IF_ADDREF(*aHook);
     
     return NS_OK;
 }
@@ -3127,7 +3114,6 @@ jsdService::GetDebuggerHook (jsdIExecuti
 jsdService::GetDebuggerHook (jsdIExecutionHook **aHook)
 {   
     *aHook = mDebuggerHook;
-    NS_IF_ADDREF(*aHook);
     
     return NS_OK;
 }
@@ -3155,7 +3141,6 @@ jsdService::GetInterruptHook (jsdIExecut
 jsdService::GetInterruptHook (jsdIExecutionHook **aHook)
 {   
     *aHook = mInterruptHook;
-    NS_IF_ADDREF(*aHook);
     
     return NS_OK;
 }
@@ -3183,7 +3168,6 @@ jsdService::GetScriptHook (jsdIScriptHoo
 jsdService::GetScriptHook (jsdIScriptHook **aHook)
 {   
     *aHook = mScriptHook;
-    NS_IF_ADDREF(*aHook);
     
     return NS_OK;
 }
@@ -3211,7 +3195,6 @@ jsdService::GetThrowHook (jsdIExecutionH
 jsdService::GetThrowHook (jsdIExecutionHook **aHook)
 {   
     *aHook = mThrowHook;
-    NS_IF_ADDREF(*aHook);
     
     return NS_OK;
 }
@@ -3239,7 +3222,6 @@ jsdService::GetTopLevelHook (jsdICallHoo
 jsdService::GetTopLevelHook (jsdICallHook **aHook)
 {   
     *aHook = mTopLevelHook;
-    NS_IF_ADDREF(*aHook);
     
     return NS_OK;
 }
@@ -3267,7 +3249,6 @@ jsdService::GetFunctionHook (jsdICallHoo
 jsdService::GetFunctionHook (jsdICallHook **aHook)
 {   
     *aHook = mFunctionHook;
-    NS_IF_ADDREF(*aHook);
     
     return NS_OK;
 }
@@ -3296,7 +3277,6 @@ jsdService::GetService ()
     if (!gJsds)
         gJsds = new jsdService();
         
-    NS_IF_ADDREF(gJsds);
     return gJsds;
 }
 
diff --git a/js/jsd/jsd_xpc.h b/js/jsd/jsd_xpc.h
--- a/js/jsd/jsd_xpc.h
+++ b/js/jsd/jsd_xpc.h
@@ -84,7 +84,6 @@ class jsdObject : public XPCOMGCFinalize
             return nsnull;
         
         jsdIObject *rv = new jsdObject (aCx, aObject);
-        NS_IF_ADDREF(rv);
         return rv;
     }
 
@@ -114,7 +113,6 @@ class jsdProperty : public XPCOMGCFinali
             return nsnull;
         
         jsdIProperty *rv = new jsdProperty (aCx, aProperty);
-        NS_IF_ADDREF(rv);
         return rv;
     }
 
@@ -346,11 +344,9 @@ class jsdContext : public jsdIContext
             rv = static_cast<jsdIContext *>(data);
         } else {
             rv = new jsdContext (aCx);
-            NS_IF_ADDREF(rv);  // addref for the SetContextPrivate
             JSD_SetContextPrivate (aCx, static_cast<void *>(rv));
         }
         
-        NS_IF_ADDREF(rv); // addref for the return value
         return rv;
     }
 
@@ -388,7 +384,6 @@ class jsdThreadState : public jsdIThread
             return nsnull;
         
         jsdIThreadState *rv = new jsdThreadState (aCx, aThreadState);
-        NS_IF_ADDREF(rv);
         return rv;
     }
 
diff --git a/js/src/xpconnect/loader/mozJSComponentLoader.cpp b/js/src/xpconnect/loader/mozJSComponentLoader.cpp
--- a/js/src/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/src/xpconnect/loader/mozJSComponentLoader.cpp
@@ -335,7 +335,7 @@ nsXPCFastLoadIO::GetInputStream(nsIInput
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
-    NS_ADDREF(*_retval = mInputStream);
+    *_retval = mInputStream;
     return NS_OK;
 }
 
@@ -359,7 +359,7 @@ nsXPCFastLoadIO::GetOutputStream(nsIOutp
         NS_ENSURE_SUCCESS(rv, rv);
     }
 
-    NS_ADDREF(*_retval = mOutputStream);
+    *_retval = mOutputStream;
     return NS_OK;
 }
 
@@ -618,7 +618,7 @@ mozJSComponentLoader::LoadModule(nsILoca
     ModuleEntry* mod;
     if (mModules.Get(lfhash, &mod)) {
         NS_ASSERTION(mod->module, "Bad hashtable data!");
-        NS_ADDREF(*aResult = mod->module);
+        *aResult = mod->module;
         return NS_OK;
     }
 
@@ -734,7 +734,7 @@ mozJSComponentLoader::LoadModule(nsILoca
     if (!mModules.Put(lfhash, entry))
         return NS_ERROR_OUT_OF_MEMORY;
 
-    NS_ADDREF(*aResult = entry->module);
+    *aResult = entry->module;
 
     // The hash owns the ModuleEntry now, forget about it
     entry.forget();
diff --git a/js/src/xpconnect/sample/xpcsample1.cpp b/js/src/xpconnect/sample/xpcsample1.cpp
--- a/js/src/xpconnect/sample/xpcsample1.cpp
+++ b/js/src/xpconnect/sample/xpcsample1.cpp
@@ -134,7 +134,6 @@ NS_IMETHODIMP nsXPCSample_ClassA::GetB(n
     if(!mClassB && !(mClassB = new nsXPCSample_ClassB(mValue)))
         return NS_ERROR_FAILURE;
     *aB = mClassB;
-    NS_ADDREF(*aB);
     return NS_OK;
 }
 
@@ -172,7 +171,6 @@ NS_IMETHODIMP nsXPCSample_ClassB::GetC(n
     if(!mClassC && !(mClassC = new nsXPCSample_ClassC(mValue)))
         return NS_ERROR_FAILURE;
     *aC = mClassC;
-    NS_ADDREF(*aC);
     return NS_OK;
 }
 
diff --git a/js/src/xpconnect/shell/xpcshell.cpp b/js/src/xpconnect/shell/xpcshell.cpp
--- a/js/src/xpconnect/shell/xpcshell.cpp
+++ b/js/src/xpconnect/shell/xpcshell.cpp
@@ -1066,7 +1066,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 FullTrustSecMan::GetSubjectPrincipal(nsIPrincipal **_retval)
 {
-    NS_IF_ADDREF(*_retval = mSystemPrincipal);
+    *_retval = mSystemPrincipal;
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
@@ -1074,7 +1074,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 FullTrustSecMan::GetSystemPrincipal(nsIPrincipal **_retval)
 {
-    NS_IF_ADDREF(*_retval = mSystemPrincipal);
+    *_retval = mSystemPrincipal;
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
@@ -1086,7 +1086,7 @@ FullTrustSecMan::GetCertificatePrincipal
                                          nsISupports *aCert, nsIURI *aURI,
                                          nsIPrincipal **_retval)
 {
-    NS_IF_ADDREF(*_retval = mSystemPrincipal);
+    *_retval = mSystemPrincipal;
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
@@ -1094,7 +1094,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 FullTrustSecMan::GetCodebasePrincipal(nsIURI *aURI, nsIPrincipal **_retval)
 {
-    NS_IF_ADDREF(*_retval = mSystemPrincipal);
+    *_retval = mSystemPrincipal;
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
@@ -1150,7 +1150,7 @@ FullTrustSecMan::GetObjectPrincipal(JSCo
 FullTrustSecMan::GetObjectPrincipal(JSContext * cx, JSObject * obj,
                                     nsIPrincipal **_retval)
 {
-    NS_IF_ADDREF(*_retval = mSystemPrincipal);
+    *_retval = mSystemPrincipal;
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
@@ -1181,7 +1181,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 FullTrustSecMan::GetPrincipalFromContext(JSContext * cx, nsIPrincipal **_retval)
 {
-    NS_IF_ADDREF(*_retval = mSystemPrincipal);
+    *_retval = mSystemPrincipal;
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
@@ -1189,7 +1189,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 FullTrustSecMan::GetChannelPrincipal(nsIChannel *aChannel, nsIPrincipal **_retval)
 {
-    NS_IF_ADDREF(*_retval = mSystemPrincipal);
+    *_retval = mSystemPrincipal;
     return *_retval ? NS_OK : NS_ERROR_FAILURE;
 }
 
@@ -1284,7 +1284,6 @@ nsXPCFunctionThisTranslator::TranslateTh
                                            nsIID * *aIIDOfResult, 
                                            nsISupports **_retval)
 {
-    NS_IF_ADDREF(aInitialThis);
     *_retval = aInitialThis;
     *aHideFirstParamFromJS = JS_FALSE;
     *aIIDOfResult = nsnull;
diff --git a/js/src/xpconnect/src/XPCDispParamPropJSClass.cpp b/js/src/xpconnect/src/XPCDispParamPropJSClass.cpp
--- a/js/src/xpconnect/src/XPCDispParamPropJSClass.cpp
+++ b/js/src/xpconnect/src/XPCDispParamPropJSClass.cpp
@@ -208,7 +208,6 @@ XPCDispParamPropJSClass::XPCDispParamPro
     mDispParams(dispParams),
     mDispObj(nsnull)
 {
-    NS_ADDREF(mWrapper);
     dispObj->QueryInterface(NSID_IDISPATCH, 
                                               reinterpret_cast<void**>
                                                               (&mDispObj));
diff --git a/js/src/xpconnect/src/XPCDispPrivate.h b/js/src/xpconnect/src/XPCDispPrivate.h
--- a/js/src/xpconnect/src/XPCDispPrivate.h
+++ b/js/src/xpconnect/src/XPCDispPrivate.h
@@ -101,7 +101,6 @@ STDMETHODIMP _class::QueryInterface(REFI
     status = E_NOINTERFACE;                                                   \
   else                                                                        \
     {                                                                         \
-      NS_ADDREF(foundInterface);                                              \
       status = S_OK;                                                          \
     }                                                                         \
   *aInstancePtr = foundInterface;                                             \
diff --git a/js/src/xpconnect/src/XPCDispTearOff.cpp b/js/src/xpconnect/src/XPCDispTearOff.cpp
--- a/js/src/xpconnect/src/XPCDispTearOff.cpp
+++ b/js/src/xpconnect/src/XPCDispTearOff.cpp
@@ -173,14 +173,12 @@ STDMETHODIMP XPCDispatchTearOff::QueryIn
     if(IsEqualIID(guid, IID_IDispatch))
     {
         *pPtr = static_cast<IDispatch*>(this);
-        NS_ADDREF_THIS();
         return NS_OK;
     }
 
     if(IsEqualIID(guid, IID_ISupportErrorInfo))
     {
         *pPtr = static_cast<IDispatch*>(this);
-        NS_ADDREF_THIS();
         return NS_OK;
     }
 
@@ -206,7 +204,6 @@ XPCDispTypeInfo * XPCDispatchTearOff::Ge
     if(!obj)
         return nsnull;
     mCOMTypeInfo = XPCDispTypeInfo::New(ccx, obj);
-    NS_IF_ADDREF(mCOMTypeInfo);
     return mCOMTypeInfo;
 }
 
@@ -214,7 +211,6 @@ STDMETHODIMP XPCDispatchTearOff::GetType
                                          ITypeInfo FAR* FAR* ppTInfo)
 {
     *ppTInfo = GetCOMTypeInfo();
-    NS_ADDREF(*ppTInfo);
     return S_OK;
 }
 
diff --git a/js/src/xpconnect/src/XPCDispTypeInfo.cpp b/js/src/xpconnect/src/XPCDispTypeInfo.cpp
--- a/js/src/xpconnect/src/XPCDispTypeInfo.cpp
+++ b/js/src/xpconnect/src/XPCDispTypeInfo.cpp
@@ -241,7 +241,6 @@ XPCDispTypeInfo * XPCDispTypeInfo::New(X
         delete array;
         return nsnull;
     }
-    NS_ADDREF(pTypeInfo);
     return pTypeInfo;
 }
 
diff --git a/js/src/xpconnect/src/XPCIDispatchClassInfo.cpp b/js/src/xpconnect/src/XPCIDispatchClassInfo.cpp
--- a/js/src/xpconnect/src/XPCIDispatchClassInfo.cpp
+++ b/js/src/xpconnect/src/XPCIDispatchClassInfo.cpp
@@ -47,9 +47,7 @@ XPCIDispatchClassInfo* XPCIDispatchClass
     if(!sInstance)
     {
         sInstance = new XPCIDispatchClassInfo;
-        NS_IF_ADDREF(sInstance);
     }
-    NS_IF_ADDREF(sInstance);
     return sInstance;
 }
 
diff --git a/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp b/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp
--- a/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp
+++ b/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp
@@ -115,13 +115,13 @@ FindPrincipals(JSContext *cx, JSObject *
   nsIScriptSecurityManager *ssm = XPCWrapper::GetSecurityManager();
 
   if (subjectPrincipal) {
-    NS_IF_ADDREF(*subjectPrincipal = ssm->GetCxSubjectPrincipal(cx));
+    *subjectPrincipal = ssm->GetCxSubjectPrincipal(cx);
   }
 
   ssm->GetObjectPrincipal(cx, obj, objectPrincipal);
 
   if (secMgr) {
-    NS_ADDREF(*secMgr = ssm);
+    *secMgr = ssm;
   }
 
   return *objectPrincipal ? NS_OK : NS_ERROR_XPC_SECURITY_MANAGER_VETO;
diff --git a/js/src/xpconnect/src/nsDispatchSupport.cpp b/js/src/xpconnect/src/nsDispatchSupport.cpp
--- a/js/src/xpconnect/src/nsDispatchSupport.cpp
+++ b/js/src/xpconnect/src/nsDispatchSupport.cpp
@@ -341,8 +341,6 @@ nsDispatchSupport* nsDispatchSupport::Ge
     if(!mInstance)
     {
         mInstance = new nsDispatchSupport;
-        NS_IF_ADDREF(mInstance);
     }
-    NS_IF_ADDREF(mInstance);
     return mInstance;
 }
diff --git a/js/src/xpconnect/src/xpccallcontext.cpp b/js/src/xpconnect/src/xpccallcontext.cpp
--- a/js/src/xpconnect/src/xpccallcontext.cpp
+++ b/js/src/xpconnect/src/xpccallcontext.cpp
@@ -75,7 +75,6 @@ XPCCallContext::XPCCallContext(XPCContex
     if(!mXPC)
         return;
 
-    NS_ADDREF(mXPC);
 
     mThreadData = XPCPerThreadData::GetData(mJSContext);
 
@@ -424,7 +423,6 @@ XPCCallContext::GetCallee(nsISupports * 
 XPCCallContext::GetCallee(nsISupports * *aCallee)
 {
     nsISupports* temp = mWrapper ? mWrapper->GetIdentityObject() : nsnull;
-    NS_IF_ADDREF(temp);
     *aCallee = temp;
     return NS_OK;
 }
@@ -442,7 +440,6 @@ XPCCallContext::GetCalleeWrapper(nsIXPCo
 XPCCallContext::GetCalleeWrapper(nsIXPConnectWrappedNative * *aCalleeWrapper)
 {
     nsIXPConnectWrappedNative* temp = mWrapper;
-    NS_IF_ADDREF(temp);
     *aCalleeWrapper = temp;
     return NS_OK;
 }
@@ -452,7 +449,6 @@ XPCCallContext::GetCalleeInterface(nsIIn
 XPCCallContext::GetCalleeInterface(nsIInterfaceInfo * *aCalleeInterface)
 {
     nsIInterfaceInfo* temp = mInterface->GetInterfaceInfo();
-    NS_IF_ADDREF(temp);
     *aCalleeInterface = temp;
     return NS_OK;
 }
@@ -462,7 +458,6 @@ XPCCallContext::GetCalleeClassInfo(nsICl
 XPCCallContext::GetCalleeClassInfo(nsIClassInfo * *aCalleeClassInfo)
 {
     nsIClassInfo* temp = mWrapper ? mWrapper->GetClassInfo() : nsnull;
-    NS_IF_ADDREF(temp);
     *aCalleeClassInfo = temp;
     return NS_OK;
 }
diff --git a/js/src/xpconnect/src/xpcconvert.cpp b/js/src/xpconnect/src/xpcconvert.cpp
--- a/js/src/xpconnect/src/xpcconvert.cpp
+++ b/js/src/xpconnect/src/xpcconvert.cpp
@@ -1182,7 +1182,6 @@ XPCConvert::NativeInterface2JSObject(XPC
 
                             if (objHolder)
                             {
-                                NS_ADDREF(objHolder);
                                 NS_RELEASE(wrapper);
 
                                 *dest = objHolder;
@@ -1213,7 +1212,6 @@ XPCConvert::NativeInterface2JSObject(XPC
                             return JS_FALSE;
                         }
 
-                        NS_ADDREF(objHolder);
                         NS_RELEASE(wrapper);
 
                         *dest = objHolder;
@@ -1233,7 +1231,6 @@ XPCConvert::NativeInterface2JSObject(XPC
                         return JS_FALSE;
                     }
 
-                    NS_ADDREF(objHolder);
                     NS_RELEASE(wrapper);
                     *dest = objHolder;
                     return JS_TRUE;
diff --git a/js/src/xpconnect/src/xpcexception.cpp b/js/src/xpconnect/src/xpcexception.cpp
--- a/js/src/xpconnect/src/xpcexception.cpp
+++ b/js/src/xpconnect/src/xpcexception.cpp
@@ -248,7 +248,6 @@ nsXPCException::GetLocation(nsIStackFram
     if(!mInitialized)
         return NS_ERROR_NOT_INITIALIZED;
     *aLocation = mLocation;
-    NS_IF_ADDREF(mLocation);
     return NS_OK;
 }
 
@@ -261,7 +260,6 @@ nsXPCException::GetData(nsISupports * *a
     if(!mInitialized)
         return NS_ERROR_NOT_INITIALIZED;
     *aData = mData;
-    NS_IF_ADDREF(mData);
     return NS_OK;
 }
 
@@ -274,7 +272,6 @@ nsXPCException::GetInner(nsIException* *
     if(!mInitialized)
         return NS_ERROR_NOT_INITIALIZED;
     *aException = mInner;
-    NS_IF_ADDREF(mInner);
     return NS_OK;
 }
 
@@ -306,7 +303,6 @@ nsXPCException::Initialize(const char *a
     if(aLocation)
     {
         mLocation = aLocation;
-        NS_ADDREF(mLocation);
         // For now, fill in our location details from our stack frame.
         // Later we may allow other locations?
         nsresult rc;
@@ -329,12 +325,10 @@ nsXPCException::Initialize(const char *a
     if(aData)
     {
         mData = aData;
-        NS_ADDREF(mData);
     }
     if(aInner)
     {
         mInner = aInner;
-        NS_ADDREF(mInner);
     }
 
     mInitialized = PR_TRUE;
@@ -421,13 +415,11 @@ nsXPCException::NewException(const char 
     nsXPCException* e = new nsXPCException();
     if(e)
     {
-        NS_ADDREF(e);
 
         nsIStackFrame* location;
         if(aLocation)
         {
             location = aLocation;
-            NS_ADDREF(location);
         }
         else
         {
diff --git a/js/src/xpconnect/src/xpcjsid.cpp b/js/src/xpconnect/src/xpcjsid.cpp
--- a/js/src/xpconnect/src/xpcjsid.cpp
+++ b/js/src/xpconnect/src/xpcjsid.cpp
@@ -238,7 +238,6 @@ nsJSID::NewID(const nsID& id)
     nsJSID* idObj = new nsJSID();
     if(idObj)
     {
-        NS_ADDREF(idObj);
         idObj->mID = id;
         idObj->mName = nsnull;
         idObj->mNumber = nsnull;
diff --git a/js/src/xpconnect/src/xpcruntimesvc.cpp b/js/src/xpconnect/src/xpcruntimesvc.cpp
--- a/js/src/xpconnect/src/xpcruntimesvc.cpp
+++ b/js/src/xpconnect/src/xpcruntimesvc.cpp
@@ -201,10 +201,8 @@ nsJSRuntimeServiceImpl::GetSingleton()
     {
         gJSRuntimeService = new nsJSRuntimeServiceImpl();
         // hold an extra reference to lock it down
-        NS_IF_ADDREF(gJSRuntimeService);
 
     }
-    NS_IF_ADDREF(gJSRuntimeService);
 
     return gJSRuntimeService;
 }
@@ -277,6 +275,6 @@ nsJSRuntimeServiceImpl::GetBackstagePass
         if(!mBackstagePass)
             return NS_ERROR_OUT_OF_MEMORY;
     }
-    NS_ADDREF(*bsp = mBackstagePass);
+    *bsp = mBackstagePass;
     return NS_OK;
 }
diff --git a/js/src/xpconnect/src/xpcstack.cpp b/js/src/xpconnect/src/xpcstack.cpp
--- a/js/src/xpconnect/src/xpcstack.cpp
+++ b/js/src/xpconnect/src/xpcstack.cpp
@@ -136,7 +136,6 @@ XPCJSStackFrame::CreateStack(JSContext* 
     JSBool failed = JS_FALSE;
     if(self)
     {
-        NS_ADDREF(self);
 
         if(fp->down)
         {
@@ -234,7 +233,6 @@ XPCJSStackFrame::CreateStackFrameLocatio
 
     if(!failed && aCaller)
     {
-        NS_ADDREF(aCaller);
         self->mCaller = aCaller;
     }
 
diff --git a/js/src/xpconnect/src/xpcthreadcontext.cpp b/js/src/xpconnect/src/xpcthreadcontext.cpp
--- a/js/src/xpconnect/src/xpcthreadcontext.cpp
+++ b/js/src/xpconnect/src/xpcthreadcontext.cpp
@@ -316,9 +316,7 @@ nsXPCThreadJSContextStackImpl::GetSingle
     {
         gXPCThreadJSContextStack = new nsXPCThreadJSContextStackImpl();
         // hold an extra reference to lock it down
-        NS_IF_ADDREF(gXPCThreadJSContextStack);
     }
-    NS_IF_ADDREF(gXPCThreadJSContextStack);
 
     return gXPCThreadJSContextStack;
 }
diff --git a/js/src/xpconnect/src/xpcvariant.cpp b/js/src/xpconnect/src/xpcvariant.cpp
--- a/js/src/xpconnect/src/xpcvariant.cpp
+++ b/js/src/xpconnect/src/xpcvariant.cpp
@@ -102,7 +102,6 @@ XPCVariant* XPCVariant::newVariant(XPCCa
 
     if(!variant)
         return nsnull;
-    NS_ADDREF(variant);
 
     if(!variant->InitializeData(ccx))
         NS_RELEASE(variant);     // Also sets variant to nsnull.
diff --git a/js/src/xpconnect/src/xpcwrappedjsclass.cpp b/js/src/xpconnect/src/xpcwrappedjsclass.cpp
--- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp
+++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp
@@ -139,7 +139,6 @@ nsXPCWrappedJSClass::GetNewOrUsed(XPCCal
         XPCAutoLock lock(rt->GetMapLock());
         IID2WrappedJSClassMap* map = rt->GetWrappedJSClassMap();
         clazz = map->Find(aIID);
-        NS_IF_ADDREF(clazz);
     }
 
     if(!clazz)
@@ -170,8 +169,6 @@ nsXPCWrappedJSClass::nsXPCWrappedJSClass
       mIID(aIID),
       mDescriptors(nsnull)
 {
-    NS_ADDREF(mInfo);
-    NS_ADDREF_THIS();
 
     {   // scoped lock
         XPCAutoLock lock(mRuntime->GetMapLock());
@@ -343,7 +340,6 @@ nsXPCWrappedJSClass::BuildPropertyEnumer
     enumerator = new xpcPropertyBagEnumerator(idArray->length);
     if(!enumerator)
         goto out;
-    NS_ADDREF(enumerator);
         
     for(i = 0; i < idArray->length; i++)
     {
@@ -378,7 +374,7 @@ nsXPCWrappedJSClass::BuildPropertyEnumer
             goto out;
     }
 
-    NS_ADDREF(*aEnumerate = enumerator);
+    *aEnumerate = enumerator;
     retval = NS_OK;
 
 out:
@@ -409,7 +405,7 @@ NS_IMETHODIMP xpcProperty::GetName(nsASt
 /* readonly attribute nsIVariant value; */
 NS_IMETHODIMP xpcProperty::GetValue(nsIVariant * *aValue)
 {
-    NS_ADDREF(*aValue = mValue);
+    *aValue = mValue;
     return NS_OK;
 }
 
@@ -532,7 +528,6 @@ nsXPCWrappedJSClass::DelegatedQueryInter
 {
     if(aIID.Equals(NS_GET_IID(nsIXPConnectJSObjectHolder)))
     {
-        NS_ADDREF(self);
         *aInstancePtr = (void*) static_cast<nsIXPConnectJSObjectHolder*>(self);
         return NS_OK;
     }
@@ -564,7 +559,6 @@ nsXPCWrappedJSClass::DelegatedQueryInter
             return NS_NOINTERFACE;
         }
 
-        NS_ADDREF(root);
         *aInstancePtr = (void*) static_cast<nsIPropertyBag*>(root);
         return NS_OK;
     }
@@ -593,7 +587,6 @@ nsXPCWrappedJSClass::DelegatedQueryInter
             return NS_NOINTERFACE;
         }
 
-        NS_ADDREF(root);
         *aInstancePtr = (void*) static_cast<nsISupportsWeakReference*>(root);
         return NS_OK;
     }
@@ -605,7 +598,6 @@ nsXPCWrappedJSClass::DelegatedQueryInter
     // nsISupports case (for which it returns mRoot).
     if(nsnull != (sibling = self->Find(aIID)))
     {
-        NS_ADDREF(sibling);
         *aInstancePtr = sibling->GetXPTCStub();
         return NS_OK;
     }
@@ -613,7 +605,6 @@ nsXPCWrappedJSClass::DelegatedQueryInter
     // Check if asking for an interface from which one of our wrappers inherits.
     if(nsnull != (sibling = self->FindInherited(aIID)))
     {
-        NS_ADDREF(sibling);
         *aInstancePtr = sibling->GetXPTCStub();
         return NS_OK;
     }
diff --git a/js/src/xpconnect/tests/TestXPC.cpp b/js/src/xpconnect/tests/TestXPC.cpp
--- a/js/src/xpconnect/tests/TestXPC.cpp
+++ b/js/src/xpconnect/tests/TestXPC.cpp
@@ -188,7 +188,6 @@ nsTestXPCFoo::nsTestXPCFoo()
 nsTestXPCFoo::nsTestXPCFoo()
     : mFoo(NULL)
 {
-    NS_ADDREF_THIS();
 }
 
 nsTestXPCFoo::~nsTestXPCFoo()
@@ -223,7 +222,6 @@ MySecMan::MySecMan()
 MySecMan::MySecMan()
     : mMode(OK_ALL)
 {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP
diff --git a/js/src/xpconnect/tests/components/xpctest_array.cpp b/js/src/xpconnect/tests/components/xpctest_array.cpp
--- a/js/src/xpconnect/tests/components/xpctest_array.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_array.cpp
@@ -57,7 +57,6 @@ xpcarraytest::xpcarraytest()
 xpcarraytest::xpcarraytest()
     : mReceiver(NULL)
 {
-    NS_ADDREF_THIS();
 }
 
 xpcarraytest::~xpcarraytest()
@@ -69,7 +68,6 @@ NS_IMPL_ISUPPORTS1(xpcarraytest, nsIXPCT
 
 NS_IMETHODIMP xpcarraytest::SetReceiver(nsIXPCTestArray* aReceiver)
 {
-    NS_IF_ADDREF(aReceiver);
     NS_IF_RELEASE(mReceiver);
     mReceiver = aReceiver;
 
@@ -203,8 +201,6 @@ xpcarraytest::CallEchoMethodOnEachInArra
     }
 
     outArray[0] = outArray[1] = this;    
-    NS_ADDREF(this);
-    NS_ADDREF(this);
     *result = (void**) outArray;
 
     *count = 2;
diff --git a/js/src/xpconnect/tests/components/xpctest_attributes.cpp b/js/src/xpconnect/tests/components/xpctest_attributes.cpp
--- a/js/src/xpconnect/tests/components/xpctest_attributes.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_attributes.cpp
@@ -64,7 +64,6 @@ NS_IMPL_ISUPPORTS1(xpcTestObjectReadOnly
 NS_IMPL_ISUPPORTS1(xpcTestObjectReadOnly, nsIXPCTestObjectReadOnly)
 
 xpcTestObjectReadOnly :: xpcTestObjectReadOnly() {
-    NS_ADDREF_THIS();
 
     boolProperty = PR_TRUE;
     shortProperty = 32767;
@@ -162,7 +161,6 @@ NS_IMPL_ISUPPORTS1(xpcTestObjectReadWrit
 NS_IMPL_ISUPPORTS1(xpcTestObjectReadWrite, nsIXPCTestObjectReadWrite)
 
 xpcTestObjectReadWrite :: xpcTestObjectReadWrite() {
-    NS_ADDREF_THIS();
 
 
     boolProperty = PR_TRUE;
diff --git a/js/src/xpconnect/tests/components/xpctest_calljs.cpp b/js/src/xpconnect/tests/components/xpctest_calljs.cpp
--- a/js/src/xpconnect/tests/components/xpctest_calljs.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_calljs.cpp
@@ -66,7 +66,6 @@ NS_IMPL_ISUPPORTS2_CI(xpcTestCallJS, nsI
 #include "xpc_map_end.h" /* This will #undef the above */
 
 xpcTestCallJS :: xpcTestCallJS() {
-    NS_ADDREF_THIS();
 }
 
 xpcTestCallJS :: ~xpcTestCallJS() {
diff --git a/js/src/xpconnect/tests/components/xpctest_child.cpp b/js/src/xpconnect/tests/components/xpctest_child.cpp
--- a/js/src/xpconnect/tests/components/xpctest_child.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_child.cpp
@@ -71,7 +71,6 @@ NS_IMPL_ISUPPORTS1(xpctestOther, nsIXPCT
 
 xpctestOther::xpctestOther()
 {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP xpctestOther::Method3(PRInt16 i, PRInt16 j, PRInt16 k)
@@ -164,7 +163,6 @@ xpctestChild::QueryInterface(REFNSIID ii
         iid.Equals(NS_GET_IID(nsIXPCTestParent)) ||
         iid.Equals(NS_GET_IID(nsISupports))) {
         *result = static_cast<nsIXPCTestChild*>(this);
-        NS_ADDREF(this);
         return NS_OK;
     }
     else {
@@ -175,7 +173,6 @@ xpctestChild::QueryInterface(REFNSIID ii
 
 xpctestChild::xpctestChild()
 {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP xpctestChild::Method1(PRInt16 i)
diff --git a/js/src/xpconnect/tests/components/xpctest_const.cpp b/js/src/xpconnect/tests/components/xpctest_const.cpp
--- a/js/src/xpconnect/tests/components/xpctest_const.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_const.cpp
@@ -52,7 +52,6 @@ NS_IMPL_ISUPPORTS1(xpcTestConst, nsIXPCT
 NS_IMPL_ISUPPORTS1(xpcTestConst, nsIXPCTestConst)
 
 xpcTestConst :: xpcTestConst() {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP
diff --git a/js/src/xpconnect/tests/components/xpctest_domstring.cpp b/js/src/xpconnect/tests/components/xpctest_domstring.cpp
--- a/js/src/xpconnect/tests/components/xpctest_domstring.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_domstring.cpp
@@ -57,7 +57,6 @@ NS_IMPL_ISUPPORTS1(xpcTestDOMString, nsI
 
 xpcTestDOMString::xpcTestDOMString()
 {
-    NS_ADDREF_THIS();
 }
 
 xpcTestDOMString::~xpcTestDOMString()
diff --git a/js/src/xpconnect/tests/components/xpctest_echo.cpp b/js/src/xpconnect/tests/components/xpctest_echo.cpp
--- a/js/src/xpconnect/tests/components/xpctest_echo.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_echo.cpp
@@ -78,7 +78,6 @@ xpctestEcho::xpctestEcho()
 xpctestEcho::xpctestEcho()
     : mReceiver(nsnull), mString(nsnull), mSomeValue(0)
 {
-    NS_ADDREF_THIS();
 }
 
 xpctestEcho::~xpctestEcho()
@@ -90,7 +89,6 @@ xpctestEcho::~xpctestEcho()
 
 NS_IMETHODIMP xpctestEcho::SetReceiver(nsIEcho* aReceiver)
 {
-    NS_IF_ADDREF(aReceiver);
     NS_IF_RELEASE(mReceiver);
     mReceiver = aReceiver;
     return NS_OK;
diff --git a/js/src/xpconnect/tests/components/xpctest_in.cpp b/js/src/xpconnect/tests/components/xpctest_in.cpp
--- a/js/src/xpconnect/tests/components/xpctest_in.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_in.cpp
@@ -57,7 +57,6 @@ NS_IMPL_ISUPPORTS1(xpcTestIn, nsIXPCTest
 NS_IMPL_ISUPPORTS1(xpcTestIn, nsIXPCTestIn)
 
 xpcTestIn :: xpcTestIn() {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP xpcTestIn :: EchoLong(PRInt32 l, PRInt32 *_retval) {
diff --git a/js/src/xpconnect/tests/components/xpctest_inout.cpp b/js/src/xpconnect/tests/components/xpctest_inout.cpp
--- a/js/src/xpconnect/tests/components/xpctest_inout.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_inout.cpp
@@ -53,7 +53,6 @@ NS_IMPL_ISUPPORTS1(xpcTestInOut, nsIXPCT
 NS_IMPL_ISUPPORTS1(xpcTestInOut, nsIXPCTestInOut)
 
 xpcTestInOut :: xpcTestInOut() {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP xpcTestInOut :: EchoLong(PRInt32 li, PRInt32 *lo){ 
diff --git a/js/src/xpconnect/tests/components/xpctest_multiple.cpp b/js/src/xpconnect/tests/components/xpctest_multiple.cpp
--- a/js/src/xpconnect/tests/components/xpctest_multiple.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_multiple.cpp
@@ -56,7 +56,6 @@ NS_IMPL_ISUPPORTS1(xpcTestParentOne, nsI
 
 xpcTestParentOne :: xpcTestParentOne() 
 {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP xpcTestParentOne :: GetParentOneAttribute(char * *_retval) 
@@ -119,7 +118,6 @@ NS_IMPL_ISUPPORTS1(xpcTestParentTwo, nsI
 
 xpcTestParentTwo :: xpcTestParentTwo()
 {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP                                                 
@@ -189,7 +187,6 @@ NS_IMPL_ISUPPORTS3_CI(xpcTestChild2,nsIX
 
 xpcTestChild2 :: xpcTestChild2() 
 {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP 
@@ -310,7 +307,6 @@ NS_IMPL_ISUPPORTS2(xpcTestChild3,nsIXPCT
 
 xpcTestChild3 :: xpcTestChild3() 
 {
-    NS_ADDREF_THIS();
 
 }
 
@@ -407,7 +403,6 @@ NS_IMPL_ISUPPORTS3(xpcTestChild4,nsIXPCT
 
 xpcTestChild4 :: xpcTestChild4() 
 {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP 
@@ -477,7 +472,6 @@ NS_IMPL_ISUPPORTS3(xpcTestChild5,nsIXPCT
 
 xpcTestChild5 :: xpcTestChild5() 
 {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP 
diff --git a/js/src/xpconnect/tests/components/xpctest_noisy.cpp b/js/src/xpconnect/tests/components/xpctest_noisy.cpp
--- a/js/src/xpconnect/tests/components/xpctest_noisy.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_noisy.cpp
@@ -71,7 +71,6 @@ xpctestNoisy::QueryInterface(REFNSIID ii
         iid.Equals(NS_GET_IID(nsISupports))) {
         *result = static_cast<nsIXPCTestNoisy*>(this);
         printf("Noisy %d - QueryInterface called and succeeding\n", mID);
-        NS_ADDREF(this);
         return NS_OK;
     }
     else {
@@ -86,7 +85,6 @@ xpctestNoisy::xpctestNoisy()
 {
     sCount++;
     printf("Noisy %d - Created, %d total\n", mID, sCount);
-    NS_ADDREF_THIS();
 }
 
 xpctestNoisy::~xpctestNoisy()
diff --git a/js/src/xpconnect/tests/components/xpctest_out.cpp b/js/src/xpconnect/tests/components/xpctest_out.cpp
--- a/js/src/xpconnect/tests/components/xpctest_out.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_out.cpp
@@ -81,7 +81,6 @@ NS_IMPL_ISUPPORTS1(xpcTestOut, nsIXPCTes
 NS_IMPL_ISUPPORTS1(xpcTestOut, nsIXPCTestOut)
 
 xpcTestOut :: xpcTestOut() {
-    NS_ADDREF_THIS();
 }
 
 NS_IMETHODIMP xpcTestOut :: GetLong(PRInt32 *l){
diff --git a/js/src/xpconnect/tests/components/xpctest_overloaded.cpp b/js/src/xpconnect/tests/components/xpctest_overloaded.cpp
--- a/js/src/xpconnect/tests/components/xpctest_overloaded.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_overloaded.cpp
@@ -107,7 +107,6 @@ public:
 
 xpcoverloaded::xpcoverloaded()
 {
-    NS_ADDREF_THIS();
 }
 
 xpcoverloaded::~xpcoverloaded()
diff --git a/js/src/xpconnect/tests/components/xpctest_string.cpp b/js/src/xpconnect/tests/components/xpctest_string.cpp
--- a/js/src/xpconnect/tests/components/xpctest_string.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_string.cpp
@@ -54,7 +54,6 @@ public:
 
 xpcstringtest::xpcstringtest()
 {
-    NS_ADDREF_THIS();
 }
 
 xpcstringtest::~xpcstringtest()
diff --git a/js/src/xpconnect/tests/components/xpctest_variant.cpp b/js/src/xpconnect/tests/components/xpctest_variant.cpp
--- a/js/src/xpconnect/tests/components/xpctest_variant.cpp
+++ b/js/src/xpconnect/tests/components/xpctest_variant.cpp
@@ -67,7 +67,6 @@ NS_IMETHODIMP nsTestVariant::PassThruVar
 NS_IMETHODIMP nsTestVariant::PassThruVariant(nsIVariant *value, nsIVariant **_retval)
 {
     *_retval = value;
-    NS_IF_ADDREF(*_retval);
     return NS_OK;
 }
 
@@ -281,7 +280,6 @@ static nsresult ConvertAndCopyVariant(ns
 
     nsVariant::Cleanup(&du);
     *_retval = outVar;
-    NS_IF_ADDREF(*_retval);
     return NS_OK;
 }        
 
@@ -347,7 +345,6 @@ xpctest::ConstructXPCTestVariant(nsISupp
         rv = NS_ERROR_OUT_OF_MEMORY;
     }
 
-    NS_ADDREF(obj);
     rv = obj->QueryInterface(aIID, aResult);
     NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
     NS_RELEASE(obj);
diff --git a/js/src/xpconnect/tools/src/nsXPCToolsCompiler.cpp b/js/src/xpconnect/tools/src/nsXPCToolsCompiler.cpp
--- a/js/src/xpconnect/tools/src/nsXPCToolsCompiler.cpp
+++ b/js/src/xpconnect/tools/src/nsXPCToolsCompiler.cpp
@@ -65,7 +65,7 @@ NS_IMETHODIMP nsXPCToolsCompiler::GetBin
         return rv;
 
     nsCOMPtr<nsILocalFile> lfile = do_QueryInterface(file);
-    NS_ADDREF(*aBinDir = lfile);
+    *aBinDir = lfile;
     return NS_OK;
 }
 
diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -234,7 +234,7 @@ NS_IMETHODIMP nsCaret::GetCaretDOMSelect
 {
   nsISelection* sel(do_QueryReferent(mDomSelectionWeak));
   
-  NS_IF_ADDREF(*aDOMSel = sel);
+  *aDOMSel = sel;
 
   return NS_OK;
 }
diff --git a/layout/base/nsChildIterator.h b/layout/base/nsChildIterator.h
--- a/layout/base/nsChildIterator.h
+++ b/layout/base/nsChildIterator.h
@@ -105,7 +105,6 @@ public:
       CallQueryInterface(node, &result);
     } else {
       result = mContent->GetChildAt(PRInt32(mIndex));
-      NS_IF_ADDREF(result);
     }
 
     return result;
diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -493,7 +493,6 @@ NS_NewDocumentViewer(nsIDocumentViewer**
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(*aResult);
 
   return NS_OK;
 }
@@ -1312,7 +1311,6 @@ DocumentViewerImpl::Close(nsISHEntry *aS
   // Also, do an extra addref to keep the viewer from going away.
   if (mPrintEngine && !mClosingWhilePrinting) {
     mClosingWhilePrinting = PR_TRUE;
-    NS_ADDREF_THIS();
   } else
 #endif
     {
@@ -1676,7 +1674,7 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 DocumentViewerImpl::GetDocument(nsIDocument** aResult)
 {
-  NS_IF_ADDREF(*aResult = mDocument);
+  *aResult = mDocument;
 
   return NS_OK;
 }
@@ -1721,7 +1719,7 @@ DocumentViewerImpl::GetPresShell(nsIPres
 DocumentViewerImpl::GetPresShell(nsIPresShell** aResult)
 {
   nsIPresShell* shell = GetPresShell();
-  NS_IF_ADDREF(*aResult = shell);
+  *aResult = shell;
   return NS_OK;
 }
 
@@ -1729,7 +1727,7 @@ DocumentViewerImpl::GetPresContext(nsPre
 DocumentViewerImpl::GetPresContext(nsPresContext** aResult)
 {
   nsPresContext* pc = GetPresContext();
-  NS_IF_ADDREF(*aResult = pc);
+  *aResult = pc;
   return NS_OK;
 }
 
@@ -1751,7 +1749,6 @@ DocumentViewerImpl::GetPreviousViewer(ns
 DocumentViewerImpl::GetPreviousViewer(nsIContentViewer** aViewer)
 {
   *aViewer = mPreviousViewer;
-  NS_IF_ADDREF(*aViewer);
   return NS_OK;
 }
 
@@ -3201,7 +3198,6 @@ DocumentViewerImpl::GetPopupLinkNode(nsI
     }
     if (anchor || area || link || xlinkType.EqualsLiteral("simple")) {
       *aNode = node;
-      NS_IF_ADDREF(*aNode); // addref
       return NS_OK;
     }
     else {
@@ -4118,6 +4114,6 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 DocumentViewerImpl::GetHistoryEntry(nsISHEntry **aHistoryEntry)
 {
-  NS_IF_ADDREF(*aHistoryEntry = mSHEntry);
-  return NS_OK;
-}
+  *aHistoryEntry = mSHEntry;
+  return NS_OK;
+}
diff --git a/layout/base/nsFocusEventSuppressor.cpp b/layout/base/nsFocusEventSuppressor.cpp
--- a/layout/base/nsFocusEventSuppressor.cpp
+++ b/layout/base/nsFocusEventSuppressor.cpp
@@ -118,6 +118,6 @@ NS_NewFocusEventSuppressorService(nsIFoc
 {
   nsIFocusEventSuppressorService* it = new nsFocusEventSuppressorService();
   NS_ENSURE_TRUE(it, NS_ERROR_OUT_OF_MEMORY);
-  NS_ADDREF(*aResult = it);
+  *aResult = it;
   return NS_OK;
 }
diff --git a/layout/base/nsFrameTraversal.cpp b/layout/base/nsFrameTraversal.cpp
--- a/layout/base/nsFrameTraversal.cpp
+++ b/layout/base/nsFrameTraversal.cpp
@@ -159,7 +159,6 @@ nsresult NS_CreateFrameTraversal(nsIFram
     return NS_ERROR_OUT_OF_MEMORY;
 
   *aResult = t;
-  NS_ADDREF(*aResult);
 
   return NS_OK;
 }
@@ -186,7 +185,6 @@ NS_NewFrameTraversal(nsIBidirectionalEnu
   if (!trav)
     return NS_ERROR_OUT_OF_MEMORY;
   *aEnumerator = static_cast<nsIBidirectionalEnumerator*>(trav);
-  NS_ADDREF(trav);
   return NS_OK;
 }
 
diff --git a/layout/base/nsLayoutHistoryState.cpp b/layout/base/nsLayoutHistoryState.cpp
--- a/layout/base/nsLayoutHistoryState.cpp
+++ b/layout/base/nsLayoutHistoryState.cpp
@@ -79,7 +79,6 @@ NS_NewLayoutHistoryState(nsILayoutHistor
   if (!state)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(state);
   nsresult rv = state->Init();
   if (NS_SUCCEEDED(rv))
     *aState = state;
diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -737,7 +737,6 @@ nsPresContext::Init(nsIDeviceContext* aD
   NS_ENSURE_ARG(aDeviceContext);
 
   mDeviceContext = aDeviceContext;
-  NS_ADDREF(mDeviceContext);
 
   if (mDeviceContext->SetPixelScale(mFullZoom))
     mDeviceContext->FlushFontCache();
@@ -758,7 +757,6 @@ nsPresContext::Init(nsIDeviceContext* aD
   if (!mEventManager)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  NS_ADDREF(mEventManager);
 
   mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
 
@@ -877,7 +875,7 @@ nsPresContext::UpdateCharSet(const nsAFl
 #if !defined(XP_BEOS) 
     if (mLangGroup == nsGkAtoms::Unicode) {
       NS_RELEASE(mLangGroup);
-      NS_IF_ADDREF(mLangGroup = mLangService->GetLocaleLanguageGroup()); 
+      mLangGroup = mLangService->GetLocaleLanguageGroup();
     }
 #endif
     GetFontPreferences();
diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -1393,7 +1393,6 @@ nsFrameSelection*
 nsFrameSelection*
 nsIPresShell::FrameSelection()
 {
-  NS_IF_ADDREF(mSelection);
   return mSelection;
 }
 
@@ -1488,7 +1487,6 @@ PresShell::Init(nsIDocument* aDocument,
   NS_ENSURE_SUCCESS(result, result);
 
   mDocument = aDocument;
-  NS_ADDREF(mDocument);
   mViewManager = aViewManager;
 
   // Create our frame constructor.
@@ -1500,7 +1498,6 @@ PresShell::Init(nsIDocument* aDocument,
 
   // Bind the context to the presentation shell.
   mPresContext = aPresContext;
-  NS_ADDREF(mPresContext);
   aPresContext->SetShell(this);
 
   // Now we can initialize the style set.
@@ -2224,7 +2221,6 @@ PresShell::GetSelection(SelectionType aT
   if (!(*aSelection))
     return NS_ERROR_INVALID_ARG;
 
-  NS_ADDREF(*aSelection);
 
   return NS_OK;
 }
@@ -2679,7 +2675,6 @@ NS_IMETHODIMP PresShell::GetCaret(nsICar
   NS_ENSURE_ARG_POINTER(outCaret);
   
   *outCaret = mCaret;
-  NS_IF_ADDREF(*outCaret);
   return NS_OK;
 }
 
@@ -4189,7 +4184,6 @@ PresShell::GetSelectionForCopy(nsISelect
   }
 
   *outSelection = sel;
-  NS_IF_ADDREF(*outSelection);
   return rv;
 }
 
@@ -4291,7 +4285,6 @@ PresShell::CaptureHistoryState(nsILayout
   }
 
   *aState = historyState;
-  NS_IF_ADDREF(*aState);
   
   // Capture frame state for the entire frame hierarchy
   nsIFrame* rootFrame = FrameManager()->GetRootFrame();
@@ -5453,7 +5446,6 @@ PresShell::GetEventTargetContent(nsEvent
 {
   if (mCurrentEventContent) {
     *aContent = mCurrentEventContent;
-    NS_IF_ADDREF(*aContent);
   } else {
     nsIFrame* currentEventFrame = GetCurrentEventFrame();
     if (currentEventFrame) {
diff --git a/layout/build/nsContentDLF.cpp b/layout/build/nsContentDLF.cpp
--- a/layout/build/nsContentDLF.cpp
+++ b/layout/build/nsContentDLF.cpp
@@ -313,7 +313,7 @@ nsContentDLF::CreateInstanceForDocument(
     // Bind the document to the Content Viewer
     nsIContentViewer* cv = static_cast<nsIContentViewer*>(docv);
     rv = cv->LoadStart(aDocument);
-    NS_ADDREF(*aDocViewerResult = cv);
+    *aDocViewerResult = cv;
   } while (PR_FALSE);
 
   return rv;
@@ -386,7 +386,6 @@ nsContentDLF::CreateBlankDocument(nsILoa
     blankDoc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8"));
     
     *aDocument = blankDoc;
-    NS_ADDREF(*aDocument);
   }
   return rv;
 }
@@ -442,7 +441,6 @@ nsContentDLF::CreateDocument(const char*
     // Bind the document to the Content Viewer
     rv = docv->LoadStart(doc);
     *aDocViewer = docv;
-    NS_IF_ADDREF(*aDocViewer);
   } while (PR_FALSE);
 
   return rv;
@@ -489,7 +487,6 @@ nsContentDLF::CreateXULDocument(const ch
      */
     rv = docv->LoadStart(doc);
     *aDocViewer = docv;
-    NS_IF_ADDREF(*aDocViewer);
   }
    
   return rv;
diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp
--- a/layout/build/nsLayoutModule.cpp
+++ b/layout/build/nsLayoutModule.cpp
@@ -575,7 +575,6 @@ CreateHTMLImgElement(nsISupports* aOuter
   nsIContent* inst = NS_NewHTMLImageElement(nsnull);
   nsresult rv = NS_ERROR_OUT_OF_MEMORY;
   if (inst) {
-    NS_ADDREF(inst);
     rv = inst->QueryInterface(aIID, aResult);
     NS_RELEASE(inst);
   }
@@ -626,7 +625,6 @@ CreateHTMLOptionElement(nsISupports* aOu
   nsIContent* inst = NS_NewHTMLOptionElement(nsnull);
   nsresult rv = NS_ERROR_OUT_OF_MEMORY;
   if (inst) {
-    NS_ADDREF(inst);
     rv = inst->QueryInterface(aIID, aResult);
     NS_RELEASE(inst);
   }
diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -667,7 +667,6 @@ nsTextInputSelectionImpl::GetSelection(P
   if (!(*_retval))
     return NS_ERROR_FAILURE;
 
-  NS_ADDREF(*_retval);
   return NS_OK;
 }
 
@@ -1434,7 +1433,6 @@ nsTextControlFrame::CreateFrameFor(nsICo
   mTextListener = new nsTextInputListener();
   if (!mTextListener)
     return nsnull;
-  NS_ADDREF(mTextListener);
 
   mTextListener->SetFrame(this);
   mSelCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
@@ -1981,7 +1979,6 @@ nsTextControlFrame::GetEditor(nsIEditor 
 {
   NS_ENSURE_ARG_POINTER(aEditor);
   *aEditor = mEditor;
-  NS_IF_ADDREF(*aEditor);
   return NS_OK;
 }
 
@@ -2260,7 +2257,6 @@ nsTextControlFrame::OffsetToDOMPoint(PRI
   if (!length || aOffset < 0) {
     *aPosition = 0;
     *aResult = rootNode;
-    NS_ADDREF(*aResult);
     return NS_OK;
   }
 
@@ -2285,7 +2281,6 @@ nsTextControlFrame::OffsetToDOMPoint(PRI
       if (aOffset >= textOffset && aOffset <= textOffset+(PRInt32)textLength) {
         *aPosition = aOffset - textOffset;
         *aResult = item;
-        NS_ADDREF(*aResult);
         return NS_OK;
       }
 
@@ -2297,7 +2292,6 @@ nsTextControlFrame::OffsetToDOMPoint(PRI
       if (i == lastIndex) {
         *aPosition = textLength;
         *aResult = item;
-        NS_ADDREF(*aResult);
         return NS_OK;
       }
     }
@@ -2311,7 +2305,6 @@ nsTextControlFrame::OffsetToDOMPoint(PRI
 
         *aPosition = i;
         *aResult = rootNode;
-        NS_ADDREF(*aResult);
         return NS_OK;
       }
 
diff --git a/layout/generic/nsAutoCopyListener.h b/layout/generic/nsAutoCopyListener.h
--- a/layout/generic/nsAutoCopyListener.h
+++ b/layout/generic/nsAutoCopyListener.h
@@ -60,7 +60,6 @@ public:
       if (!sInstance)
         return nsnull;
 
-      NS_ADDREF(sInstance);
     }
 
     return sInstance;
diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -331,7 +331,6 @@ nsBlockFrame::QueryInterface(const nsIID
       *aInstancePtr = nsnull;
       return NS_ERROR_OUT_OF_MEMORY;
     }
-    NS_ADDREF(it); // reference passed to caller
     const nsStyleVisibility* visibility = GetStyleVisibility();
     nsresult rv = it->Init(mLines,
                            visibility->mDirection == NS_STYLE_DIRECTION_RTL);
diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -142,7 +142,6 @@ nsBulletFrame::DidSetStyleContext()
     if (!mListener) {
       nsBulletListener *listener;
       NS_NEWXPCOM(listener, nsBulletListener);
-      NS_ADDREF(listener);
       listener->SetFrame(this);
       listener->QueryInterface(NS_GET_IID(imgIDecoderObserver), getter_AddRefs(mListener));
       NS_ASSERTION(mListener, "queryinterface for the listener failed");
diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -417,7 +417,6 @@ nsFrame::Init(nsIContent*      aContent,
   mParent = aParent;
 
   if (aContent) {
-    NS_ADDREF(aContent);
     aContent->SetMayHaveFrame(PR_TRUE);
     NS_ASSERTION(mContent->MayHaveFrame(), "SetMayHaveFrame failed?");
   }
@@ -1540,7 +1539,6 @@ nsFrame::GetContentForEvent(nsPresContex
                             nsIContent** aContent)
 {
   *aContent = GetContent();
-  NS_IF_ADDREF(*aContent);
   return NS_OK;
 }
 
@@ -1688,7 +1686,6 @@ nsFrame::GetDataForTableSelection(const 
 
   // Everything is OK -- set the return values
   *aParentContent = parentContent;
-  NS_ADDREF(*aParentContent);
 
   *aContentOffset = offset;
 
@@ -4089,7 +4086,7 @@ nsFrame::GetSelectionController(nsPresCo
   while (frame && (frame->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION)) {
     nsITextControlFrame *tcf;
     if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsITextControlFrame),(void**)&tcf))) {
-      NS_IF_ADDREF(*aSelCon = tcf->GetOwnedSelectionController());
+      *aSelCon = tcf->GetOwnedSelectionController();
       return NS_OK;
     }
     frame = frame->GetParent();
@@ -4103,7 +4100,6 @@ nsIFrame::GetFrameSelection()
 {
   nsFrameSelection* fs =
     const_cast<nsFrameSelection*>(GetConstFrameSelection());
-  NS_IF_ADDREF(fs);
   return fs;
 }
 
diff --git a/layout/generic/nsHTMLCanvasFrame.cpp b/layout/generic/nsHTMLCanvasFrame.cpp
--- a/layout/generic/nsHTMLCanvasFrame.cpp
+++ b/layout/generic/nsHTMLCanvasFrame.cpp
@@ -259,7 +259,6 @@ nsHTMLCanvasFrame::GetContentForEvent(ns
 {
   NS_ENSURE_ARG_POINTER(aContent);
   *aContent = GetContent();
-  NS_IF_ADDREF(*aContent);
   return NS_OK;
 }
 
diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1335,7 +1335,6 @@ nsImageFrame::GetImageMap(nsPresContext*
     if (map) {
       mImageMap = new nsImageMap();
       if (mImageMap) {
-        NS_ADDREF(mImageMap);
         mImageMap->Init(aPresContext->PresShell(), this, map);
       }
     }
@@ -1391,7 +1390,7 @@ nsImageFrame::GetAnchorHREFTargetAndNode
       if (anchor) {
         anchor->GetTarget(aTarget);
       }
-      NS_ADDREF(*aNode = content);
+      *aNode = content;
       break;
     }
   }
@@ -1416,13 +1415,11 @@ nsImageFrame::GetContentForEvent(nsPresC
     inside = map->IsInside(p.x, p.y, &area);
     if (inside && area) {
       *aContent = area;
-      NS_ADDREF(*aContent);
       return NS_OK;
     }
   }
 
   *aContent = GetContent();
-  NS_IF_ADDREF(*aContent);
   return NS_OK;
 }
 
@@ -1707,7 +1704,6 @@ nsresult nsImageFrame::LoadIcons(nsPresC
   gIconLoad = new IconLoad(mListener);
   if (!gIconLoad) 
     return NS_ERROR_OUT_OF_MEMORY;
-  NS_ADDREF(gIconLoad);
 
   nsresult rv;
   // create a loader and load the images
diff --git a/layout/generic/nsImageMap.cpp b/layout/generic/nsImageMap.cpp
--- a/layout/generic/nsImageMap.cpp
+++ b/layout/generic/nsImageMap.cpp
@@ -122,7 +122,6 @@ Area::GetArea(nsIContent** aArea) const
 Area::GetArea(nsIContent** aArea) const
 {
   *aArea = mArea;
-  NS_IF_ADDREF(*aArea);
 }
 
 #include <stdlib.h>
diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -2270,7 +2270,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
 
 NS_IMETHODIMP nsPluginInstanceOwner::GetInstance(nsIPluginInstance *&aInstance)
 {
-  NS_IF_ADDREF(aInstance = mInstance);
+  aInstance = mInstance;
 
   return NS_OK;
 }
@@ -2385,7 +2385,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
 
   // XXX sXBL/XBL2 issue: current doc or owner doc?
   // But keep in mind bug 322414 comment 33
-  NS_IF_ADDREF(*aDocument = mContent->GetOwnerDoc());
+  *aDocument = mContent->GetOwnerDoc();
   return NS_OK;
 }
 
@@ -4514,7 +4514,6 @@ static void ConvertRelativeToWindowAbsol
     // Calculate the view's offset from its nearest widget
     nsPoint viewOffset;
     aContainerWidget = view->GetNearestWidget(&viewOffset);
-    NS_IF_ADDREF(aContainerWidget);
     aAbs += viewOffset;
   }
 
diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -587,7 +587,6 @@ nsresult NS_NewSelection(nsFrameSelectio
   if (!rlist)
     return NS_ERROR_OUT_OF_MEMORY;
   *aFrameSelection = rlist;
-  NS_ADDREF(rlist);
   return NS_OK;
 }
 
@@ -597,7 +596,6 @@ nsresult NS_NewDomSelection(nsISelection
   if (!rlist)
     return NS_ERROR_OUT_OF_MEMORY;
   *aDomSelection = (nsISelection *)rlist;
-  NS_ADDREF(rlist);
   return NS_OK;
 }
 
@@ -795,7 +793,6 @@ nsSelectionIterator::CurrentItem(nsIDOMR
   }
 
   *aItem = mDomSelection->mRanges[mIndex].mRange;
-  NS_IF_ADDREF(*aItem);
   return NS_OK;
 }
 
@@ -976,7 +973,7 @@ nsFrameSelection::GetRootForContentSubtr
     child = parent;
   }
 
-  NS_IF_ADDREF(*aParent = child);
+  *aParent = child;
 
   return NS_OK;
 }
@@ -3508,7 +3505,6 @@ nsFrameSelection::GetFirstCellNodeInRang
   if (childNode)
   {
     *aCellNode = childNode;
-    NS_ADDREF(*aCellNode);
   }
   return NS_OK;
 }
@@ -3536,11 +3532,9 @@ nsFrameSelection::GetFirstSelectedCellAn
   if (!cellNode) return NS_OK;
 
   *aCell = cellNode;
-  NS_ADDREF(*aCell);
   if (aRange)
   {
     *aRange = firstRange;
-    NS_ADDREF(*aRange);
   }
 
   // Setup for next cell
@@ -3587,11 +3581,9 @@ nsFrameSelection::GetNextSelectedCellAnd
   if (!cellNode) return NS_OK;
 
   *aCell = cellNode;
-  NS_ADDREF(*aCell);
   if (aRange)
   {
     *aRange = range;
-    NS_ADDREF(*aRange);
   }
 
   // Setup for next cell
@@ -3639,7 +3631,6 @@ nsFrameSelection::IsInSameTable(nsIConte
     if (aTable)
     {
       *aTable = tableNode1;
-      NS_ADDREF(*aTable);
     }
     return PR_TRUE;;
   }
@@ -3658,7 +3649,6 @@ nsFrameSelection::GetParentTable(nsICont
     if (parent->Tag() == nsGkAtoms::table &&
         parent->IsNodeOfType(nsINode::eHTML)) {
       *aTable = parent;
-      NS_ADDREF(*aTable);
 
       return NS_OK;
     }
@@ -4699,7 +4689,7 @@ nsTypedSelection::GetRangesForInterval(n
 
   *aResultCount = results.Count();
   for (PRInt32 i = 0; i < results.Count(); i ++)
-    NS_ADDREF((*aResults)[i] = results[i]);
+    (*aResults)[i] = results[i];
   return NS_OK;
 }
 
@@ -5353,7 +5343,6 @@ nsTypedSelection::GetFrameSelection(nsFr
 nsTypedSelection::GetFrameSelection(nsFrameSelection **aFrameSelection) {
   NS_ENSURE_ARG_POINTER(aFrameSelection);
   *aFrameSelection = mFrameSelection;
-  NS_IF_ADDREF(*aFrameSelection);
   return NS_OK;
 }
 
@@ -6056,7 +6045,6 @@ nsTypedSelection::GetRangeAt(PRInt32 aIn
     return NS_ERROR_INVALID_ARG;
 
   *aReturn = mRanges[aIndex].mRange;
-  NS_IF_ADDREF(*aReturn);
 
   return NS_OK;
 }
@@ -6845,7 +6833,7 @@ nsTypedSelection::GetPresContext(nsPresC
   if (!shell)
     return NS_ERROR_NULL_POINTER;
 
-  NS_IF_ADDREF(*aPresContext = shell->GetPresContext());
+  *aPresContext = shell->GetPresContext();
   return NS_OK;
 }
 
@@ -6856,7 +6844,7 @@ nsTypedSelection::GetPresShell(nsIPresSh
   {
     nsIPresShell* presShell = do_QueryReferent(mPresShellWeak);
     if (presShell)
-      NS_ADDREF(*aPresShell = presShell);
+      *aPresShell = presShell;
     return NS_OK;
   }
   nsresult rv = NS_OK;
@@ -6867,7 +6855,7 @@ nsTypedSelection::GetPresShell(nsIPresSh
 
   mPresShellWeak = do_GetWeakReference(shell);    // the presshell owns us, so no addref
   if (mPresShellWeak)
-    NS_ADDREF(*aPresShell = shell);
+    *aPresShell = shell;
   return rv;
 }
 
diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp
--- a/layout/generic/nsTextFrameThebes.cpp
+++ b/layout/generic/nsTextFrameThebes.cpp
@@ -1282,7 +1282,6 @@ GetFontGroupForFrame(nsIFrame* aFrame,
   nsIFontMetrics* metricsRaw = metrics;
   if (aOutFontMetrics) {
     *aOutFontMetrics = metricsRaw;
-    NS_ADDREF(*aOutFontMetrics);
   }
   nsIThebesFontMetrics* fm = static_cast<nsIThebesFontMetrics*>(metricsRaw);
   // XXX this is a bit bogus, we're releasing 'metrics' so the returned font-group
@@ -2669,7 +2668,6 @@ nsresult nsBlinkTimer::AddBlinkFrame(nsP
     if (!sTextBlinker) return NS_ERROR_OUT_OF_MEMORY;
   }
   
-  NS_ADDREF(sTextBlinker);
 
   sTextBlinker->AddFrame(aPresContext, aFrame);
   return NS_OK;
diff --git a/layout/inspector/src/inCSSValueSearch.cpp b/layout/inspector/src/inCSSValueSearch.cpp
--- a/layout/inspector/src/inCSSValueSearch.cpp
+++ b/layout/inspector/src/inCSSValueSearch.cpp
@@ -202,7 +202,6 @@ inCSSValueSearch::GetDocument(nsIDOMDocu
 inCSSValueSearch::GetDocument(nsIDOMDocument** aDocument)
 {
   *aDocument = mDocument;
-  NS_IF_ADDREF(*aDocument);
   return NS_OK;
 }
 
diff --git a/layout/inspector/src/inDOMUtils.cpp b/layout/inspector/src/inDOMUtils.cpp
--- a/layout/inspector/src/inDOMUtils.cpp
+++ b/layout/inspector/src/inDOMUtils.cpp
@@ -143,7 +143,7 @@ inDOMUtils::GetParentForNode(nsIDOMNode*
     aNode->GetParentNode(&parent);
   }
 
-  NS_IF_ADDREF(*aParent = parent);
+  *aParent = parent;
   return NS_OK;
 }
 
@@ -185,7 +185,6 @@ inDOMUtils::GetCSSStyleRules(nsIDOMEleme
   }
 
   *_retval = rules;
-  NS_ADDREF(*_retval);
 
   return NS_OK;
 }
diff --git a/layout/inspector/src/inDOMView.cpp b/layout/inspector/src/inDOMView.cpp
--- a/layout/inspector/src/inDOMView.cpp
+++ b/layout/inspector/src/inDOMView.cpp
@@ -173,7 +173,6 @@ inDOMView::GetRootNode(nsIDOMNode** aNod
 inDOMView::GetRootNode(nsIDOMNode** aNode)
 {
   *aNode = mRootNode;
-  NS_IF_ADDREF(*aNode);
   return NS_OK;
 }
 
@@ -233,7 +232,6 @@ inDOMView::GetNodeFromRowIndex(PRInt32 r
   RowToNode(rowIndex, &viewNode);
   if (!viewNode) return NS_ERROR_FAILURE;
   *_retval = viewNode->node;
-  NS_IF_ADDREF(*_retval);
 
   return NS_OK;
 }
@@ -594,7 +592,6 @@ inDOMView::GetSelection(nsITreeSelection
 inDOMView::GetSelection(nsITreeSelection * *aSelection)
 {
   *aSelection = mSelection;
-  NS_IF_ADDREF(*aSelection);
   return NS_OK;
 }
 
diff --git a/layout/inspector/src/inDeepTreeWalker.cpp b/layout/inspector/src/inDeepTreeWalker.cpp
--- a/layout/inspector/src/inDeepTreeWalker.cpp
+++ b/layout/inspector/src/inDeepTreeWalker.cpp
@@ -132,7 +132,6 @@ inDeepTreeWalker::GetRoot(nsIDOMNode** a
 inDeepTreeWalker::GetRoot(nsIDOMNode** aRoot)
 {
   *aRoot = mRoot;
-  NS_IF_ADDREF(*aRoot);
   
   return NS_OK;
 }
@@ -160,7 +159,6 @@ inDeepTreeWalker::GetCurrentNode(nsIDOMN
 inDeepTreeWalker::GetCurrentNode(nsIDOMNode** aCurrentNode)
 {
   *aCurrentNode = mCurrentNode;
-  NS_IF_ADDREF(*aCurrentNode);
   
   return NS_OK;
 }
@@ -248,7 +246,6 @@ inDeepTreeWalker::NextNode(nsIDOMNode **
   } 
   
   *_retval = next;
-  NS_IF_ADDREF(*_retval);
   
   return NS_OK;
 }
@@ -327,7 +324,6 @@ inDeepTreeWalker::NextNode(nsIDOMNode **
   mCurrentNode = next;
   
   *_retval = next;
-  NS_IF_ADDREF(*_retval);
   
   return NS_OK;
 }
diff --git a/layout/printing/nsPagePrintTimer.cpp b/layout/printing/nsPagePrintTimer.cpp
--- a/layout/printing/nsPagePrintTimer.cpp
+++ b/layout/printing/nsPagePrintTimer.cpp
@@ -151,7 +151,6 @@ nsresult NS_NewPagePrintTimer(nsPagePrin
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(result);
   *aResult = result;
 
   return NS_OK;
diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -915,7 +915,6 @@ nsPrintEngine::GetCurrentPrintSettings(n
   } else {
     *aCurrentPrintSettings = nsnull;
   }
-  NS_IF_ADDREF(*aCurrentPrintSettings);
   return NS_OK;
 }
 
@@ -2671,7 +2670,7 @@ nsPrintEngine::FindFocusedDOMWindow()
       nsIDOMWindowInternal* theDOMWin = nsnull;
       focusController->GetFocusedWindow(&theDOMWin);
       if(theDOMWin && IsWindowsInOurSubTree(theDOMWin)){
-        NS_ADDREF(domWin = theDOMWin);
+        domWin = theDOMWin;
       }
     }
   }
diff --git a/layout/printing/nsPrintPreviewListener.cpp b/layout/printing/nsPrintPreviewListener.cpp
--- a/layout/printing/nsPrintPreviewListener.cpp
+++ b/layout/printing/nsPrintPreviewListener.cpp
@@ -57,7 +57,6 @@ nsPrintPreviewListener::nsPrintPreviewLi
 nsPrintPreviewListener::nsPrintPreviewListener (nsIDOMEventTarget* aTarget)
   : mEventTarget(aTarget)
 {
-  NS_ADDREF_THIS();
 } // ctor
 
 
diff --git a/layout/style/nsCSSLoader.cpp b/layout/style/nsCSSLoader.cpp
--- a/layout/style/nsCSSLoader.cpp
+++ b/layout/style/nsCSSLoader.cpp
@@ -170,7 +170,6 @@ SheetLoadData::SheetLoadData(CSSLoaderIm
 {
 
   NS_PRECONDITION(mLoader, "Must have a loader!");
-  NS_ADDREF(mLoader);
 }
 
 SheetLoadData::SheetLoadData(CSSLoaderImpl* aLoader,
@@ -199,9 +198,7 @@ SheetLoadData::SheetLoadData(CSSLoaderIm
 {
 
   NS_PRECONDITION(mLoader, "Must have a loader!");
-  NS_ADDREF(mLoader);
   if (mParentData) {
-    NS_ADDREF(mParentData);
     mSyncLoad = mParentData->mSyncLoad;
     mIsNonDocumentSheet = mParentData->mIsNonDocumentSheet;
     mAllowUnsafeRules = mParentData->mAllowUnsafeRules;
@@ -236,7 +233,6 @@ SheetLoadData::SheetLoadData(CSSLoaderIm
 {
 
   NS_PRECONDITION(mLoader, "Must have a loader!");
-  NS_ADDREF(mLoader);
 }
 
 SheetLoadData::~SheetLoadData()
@@ -409,7 +405,6 @@ CSSLoaderImpl::GetParserFor(nsICSSStyleS
   PRInt32 count = gParsers->Count();
   if (0 < count--) {
     *aParser = gParsers->ObjectAt(count);
-    NS_ADDREF(*aParser);
     gParsers->RemoveObjectAt(count);
   }
 
@@ -719,7 +714,7 @@ SheetLoadData::GetReferrerURI()
   if (mParentData)
     mParentData->mSheet->GetSheetURI(&uri);
   if (!uri && mLoader->mDocument)
-    NS_IF_ADDREF(uri = mLoader->mDocument->GetDocumentURI());
+    uri = mLoader->mDocument->GetDocumentURI();
   return uri;
 }
 
@@ -1723,7 +1718,6 @@ CSSLoaderImpl::LoadInlineStyle(nsIConten
   // We never actually load this, so just set its principal directly
   sheet->SetPrincipal(aElement->NodePrincipal());
 
-  NS_ADDREF(data);
   data->mLineNumber = aLineNumber;
   // Parse completion releases the load data
   rv = ParseSheet(aStream, data, *aCompleted);
@@ -1810,7 +1804,6 @@ CSSLoaderImpl::LoadStyleLink(nsIContent*
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(data);
 
   // If we have to parse and it's an alternate non-inline, defer it
   if (aURL && state == eSheetNeedsParser && mLoadingDatas.Count() != 0 &&
@@ -1944,7 +1937,6 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyl
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
-  NS_ADDREF(data);
   PRBool syncLoad = data->mSyncLoad;
 
   // Load completion will release the data
@@ -2048,7 +2040,6 @@ CSSLoaderImpl::InternalLoadNonDocumentSh
     return NS_ERROR_OUT_OF_MEMORY;
   }
   
-  NS_ADDREF(data);
   rv = LoadSheet(data, state);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -2113,7 +2104,6 @@ CSSLoaderImpl::HandleLoadEvent(SheetLoad
   if (!aEvent->mIsCancelled) {
     // SheetComplete will call Release(), so give it a reference to do
     // that with.
-    NS_ADDREF(aEvent);
     SheetComplete(aEvent, NS_OK);
   }
 
@@ -2181,7 +2171,6 @@ CSSLoaderImpl::Stop()
     data->mIsCancelled = PR_TRUE;
     if (arr.AppendElement(data)) {
       // SheetComplete() calls Release(), so give this an extra ref.
-      NS_ADDREF(data);
     }
 #ifdef DEBUG
     else {
@@ -2262,7 +2251,6 @@ CSSLoaderImpl::StopLoadingSheet(nsIURI* 
       curData->mIsCancelled = PR_TRUE;
       if (arr.AppendElement(curData)) {
         // SheetComplete() calls Release(), so give this an extra ref.
-        NS_ADDREF(curData);
       }
 #ifdef DEBUG
       else {
diff --git a/layout/style/nsCSSOMFactory.cpp b/layout/style/nsCSSOMFactory.cpp
--- a/layout/style/nsCSSOMFactory.cpp
+++ b/layout/style/nsCSSOMFactory.cpp
@@ -61,7 +61,6 @@ nsCSSOMFactory::CreateDOMCSSAttributeDec
         *aResult = 0;
         return NS_ERROR_OUT_OF_MEMORY;
     }
-    NS_ADDREF(result);
     *aResult = result;
     return NS_OK;
 }
diff --git a/layout/style/nsCSSRule.cpp b/layout/style/nsCSSRule.cpp
--- a/layout/style/nsCSSRule.cpp
+++ b/layout/style/nsCSSRule.cpp
@@ -64,7 +64,6 @@ NS_IMETHODIMP
 NS_IMETHODIMP
 nsCSSRule::GetStyleSheet(nsIStyleSheet*& aSheet) const
 {
-  NS_IF_ADDREF(mSheet);
   aSheet = mSheet;
   return NS_OK;
 }
diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -724,7 +724,7 @@ nsCSSGroupRule::GetStyleRuleAt(PRInt32 a
     return NS_ERROR_ILLEGAL_VALUE;
   }
 
-  NS_ADDREF(aRule = mRules.ObjectAt(aIndex));
+  aRule = mRules.ObjectAt(aIndex);
   return NS_OK;
 }
 
@@ -830,7 +830,6 @@ nsCSSGroupRule::GetCssRules(nsIDOMCSSRul
     if (!mRuleCollection) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
-    NS_ADDREF(mRuleCollection);
   }
 
   return CallQueryInterface(mRuleCollection, aRuleList);
@@ -1286,7 +1285,6 @@ CSSNameSpaceRuleImpl::CSSNameSpaceRuleIm
     mPrefix(aCopy.mPrefix),
     mURLSpec(aCopy.mURLSpec)
 {
-  NS_IF_ADDREF(mPrefix);
 }
 
 CSSNameSpaceRuleImpl::~CSSNameSpaceRuleImpl(void)
@@ -1354,7 +1352,6 @@ CSSNameSpaceRuleImpl::GetPrefix(nsIAtom*
 CSSNameSpaceRuleImpl::GetPrefix(nsIAtom*& aPrefix) const
 {
   aPrefix = mPrefix;
-  NS_IF_ADDREF(aPrefix);
   return NS_OK;
 }
 
@@ -1363,7 +1360,6 @@ CSSNameSpaceRuleImpl::SetPrefix(nsIAtom*
 {
   NS_IF_RELEASE(mPrefix);
   mPrefix = aPrefix;
-  NS_IF_ADDREF(mPrefix);
   return NS_OK;
 }
 
diff --git a/layout/style/nsCSSStyleRule.cpp b/layout/style/nsCSSStyleRule.cpp
--- a/layout/style/nsCSSStyleRule.cpp
+++ b/layout/style/nsCSSStyleRule.cpp
@@ -976,13 +976,13 @@ DOMCSSDeclarationImpl::GetCSSParsingEnvi
 
       nsICSSStyleSheet* cssSheet(do_QueryInterface(sheet));
       if (cssSheet) {
-        NS_ADDREF(*aSheetPrincipal = cssSheet->Principal());
+        *aSheetPrincipal = cssSheet->Principal();
       }
 
       nsIDocument* document = nsnull;
       sheet->GetOwningDocument(*&document);
       if (document) {
-        NS_ADDREF(*aCSSLoader = document->CSSLoader());
+        *aCSSLoader = document->CSSLoader();
       }
     }
   }
@@ -1148,7 +1148,6 @@ DOMCSSStyleRuleImpl::GetStyle(nsIDOMCSSS
 DOMCSSStyleRuleImpl::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
 {
   *aStyle = &mDOMDeclaration;
-  NS_ADDREF(*aStyle);
   return NS_OK;
 }
 
@@ -1156,7 +1155,6 @@ DOMCSSStyleRuleImpl::GetCSSStyleRule(nsI
 DOMCSSStyleRuleImpl::GetCSSStyleRule(nsICSSStyleRule **aResult)
 {
   *aResult = Rule();
-  NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
@@ -1347,9 +1345,7 @@ nsIStyleRule* CSSStyleRuleImpl::GetImpor
     mImportantRule = new CSSImportantRule(mDeclaration);
     if (!mImportantRule)
       return nsnull;
-    NS_ADDREF(mImportantRule);
   }