Bug 770814 - Make nsEditor::GetNodeLocation return already_AddRefed<nsIDOMNode> instead of having it as an out param; r=ehsan
authorLuqman Aden <laden@csclub.uwaterloo.ca>
Sun, 08 Jul 2012 20:45:12 -0400
changeset 99026 392e0ec0088e9b7b4d3ea54d3143e0348c0edbcc
parent 99025 1ee6c61e0a0bcfe916f577d60439aadc7a181e97
child 99027 43993f45c3286c30fd5b71d1a448f474aaf0ca5a
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersehsan
bugs770814
milestone16.0a1
Bug 770814 - Make nsEditor::GetNodeLocation return already_AddRefed<nsIDOMNode> instead of having it as an out param; r=ehsan
editor/libeditor/base/nsEditor.cpp
editor/libeditor/base/nsEditor.h
editor/libeditor/base/nsSelectionState.cpp
editor/libeditor/html/nsHTMLDataTransfer.cpp
editor/libeditor/html/nsHTMLEditRules.cpp
editor/libeditor/html/nsHTMLEditor.cpp
editor/libeditor/html/nsHTMLEditorStyle.cpp
editor/libeditor/html/nsWSRunObject.cpp
editor/libeditor/text/nsPlaintextDataTransfer.cpp
editor/libeditor/text/nsPlaintextEditor.cpp
editor/libeditor/text/nsTextEditRules.cpp
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -1714,19 +1714,18 @@ nsEditor::MoveNode(nsIContent* aNode, ns
 }
 
 nsresult
 nsEditor::MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset)
 {
   NS_ENSURE_TRUE(aNode && aParent, NS_ERROR_NULL_POINTER);
   nsresult res;
 
-  nsCOMPtr<nsIDOMNode> oldParent;
   PRInt32 oldOffset;
-  GetNodeLocation(aNode, address_of(oldParent), &oldOffset);
+  nsCOMPtr<nsIDOMNode> oldParent = GetNodeLocation(aNode, &oldOffset);
   
   if (aOffset == -1)
   {
     PRUint32 unsignedOffset;
     // magic value meaning "move to end of aParent"
     res = GetLengthOfDOMNode(aParent, unsignedOffset);
     NS_ENSURE_SUCCESS(res, res);
     aOffset = (PRInt32)unsignedOffset;
@@ -2927,19 +2926,18 @@ nsEditor::JoinNodesImpl(nsIDOMNode * aNo
     if (aNodeToKeepIsFirst)
       leftNode = aNodeToKeep;
     else
       leftNode = aNodeToJoin;
 
     PRUint32 firstNodeLength;
     result = GetLengthOfDOMNode(leftNode, firstNodeLength);
     NS_ENSURE_SUCCESS(result, result);
-    nsCOMPtr<nsIDOMNode> parent;
-    GetNodeLocation(aNodeToJoin, address_of(parent), &joinOffset);
-    GetNodeLocation(aNodeToKeep, address_of(parent), &keepOffset);
+    nsCOMPtr<nsIDOMNode> parent = GetNodeLocation(aNodeToJoin, &joinOffset);
+    parent = GetNodeLocation(aNodeToKeep, &keepOffset);
     
     // if selection endpoint is between the nodes, remember it as being
     // in the one that is going away instead.  This simplifies later selection
     // adjustment logic at end of this method.
     if (selStartNode)
     {
       if (selStartNode == parent)
       {
@@ -3117,28 +3115,31 @@ nsEditor::GetChildOffset(nsIDOMNode* aCh
   MOZ_ASSERT(parent && child);
 
   PRInt32 idx = parent->IndexOf(child);
   MOZ_ASSERT(idx != -1);
   return idx;
 }
 
 // static
-void
-nsEditor::GetNodeLocation(nsIDOMNode* aChild, nsCOMPtr<nsIDOMNode>* outParent,
-                          PRInt32* outOffset)
-{
-  MOZ_ASSERT(aChild && outParent && outOffset);
+already_AddRefed<nsIDOMNode>
+nsEditor::GetNodeLocation(nsIDOMNode* aChild, PRInt32* outOffset)
+{
+  MOZ_ASSERT(aChild && outOffset);
   *outOffset = -1;
 
+  nsCOMPtr<nsIDOMNode> parent;
+
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
-    aChild->GetParentNode(getter_AddRefs(*outParent))));
-  if (*outParent) {
-    *outOffset = GetChildOffset(aChild, *outParent);
+    aChild->GetParentNode(getter_AddRefs(parent))));
+  if (parent) {
+    *outOffset = GetChildOffset(aChild, parent);
   }
+
+  return parent.forget();
 }
 
 // returns the number of things inside aNode.  
 // If aNode is text, returns number of characters. If not, returns number of children nodes.
 nsresult
 nsEditor::GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount) 
 {
   aCount = 0;
--- a/editor/libeditor/base/nsEditor.h
+++ b/editor/libeditor/base/nsEditor.h
@@ -438,22 +438,21 @@ public:
   /**
    * Return the offset of aChild in aParent.  Asserts fatally if parent or
    * child is null, or parent is not child's parent.
    */
   static PRInt32 GetChildOffset(nsIDOMNode *aChild,
                                 nsIDOMNode *aParent);
 
   /**
-   *  Set outParent to the parent of aChild.
-   *  Set outOffset to the offset of aChild in outParent.
+   *  Set outOffset to the offset of aChild in the parent.
+   *  Returns the parent of aChild.
    */
-  static void GetNodeLocation(nsIDOMNode* aChild,
-                              nsCOMPtr<nsIDOMNode>* outParent,
-                              PRInt32* outOffset);
+  static already_AddRefed<nsIDOMNode> GetNodeLocation(nsIDOMNode* aChild,
+                                                      PRInt32* outOffset);
 
   /** returns the number of things inside aNode in the out-param aCount.  
     * @param  aNode is the node to get the length of.  
     *         If aNode is text, returns number of characters. 
     *         If not, returns number of children nodes.
     * @param  aCount [OUT] the result of the above calculation.
     */
   static nsresult GetLengthOfDOMNode(nsIDOMNode *aNode, PRUint32 &aCount);
--- a/editor/libeditor/base/nsSelectionState.cpp
+++ b/editor/libeditor/base/nsSelectionState.cpp
@@ -251,20 +251,18 @@ nsRangeUpdater::SelAdjDeleteNode(nsIDOMN
     return;
   }
   MOZ_ASSERT(aNode);
   PRUint32 i, count = mArray.Length();
   if (!count) {
     return;
   }
 
-  nsCOMPtr<nsIDOMNode> parent;
   PRInt32 offset = 0;
-  
-  nsEditor::GetNodeLocation(aNode, address_of(parent), &offset);
+  nsCOMPtr<nsIDOMNode> parent = nsEditor::GetNodeLocation(aNode, &offset);
   
   // check for range endpoints that are after aNode and in the same parent
   nsRangeStore *item;
   for (i=0; i<count; i++)
   {
     item = mArray[i];
     MOZ_ASSERT(item);
     
@@ -309,19 +307,18 @@ nsRangeUpdater::SelAdjSplitNode(nsIDOMNo
 {
   if (mLock) return NS_OK;  // lock set by Will/DidReplaceParent, etc...
   NS_ENSURE_TRUE(aOldRightNode && aNewLeftNode, NS_ERROR_NULL_POINTER);
   PRUint32 i, count = mArray.Length();
   if (!count) {
     return NS_OK;
   }
 
-  nsCOMPtr<nsIDOMNode> parent;
   PRInt32 offset;
-  nsEditor::GetNodeLocation(aOldRightNode, address_of(parent), &offset);
+  nsCOMPtr<nsIDOMNode> parent = nsEditor::GetNodeLocation(aOldRightNode, &offset);
   
   // first part is same as inserting aNewLeftnode
   nsresult result = SelAdjInsertNode(parent,offset-1);
   NS_ENSURE_SUCCESS(result, result);
 
   // next step is to check for range enpoints inside aOldRightNode
   nsRangeStore *item;
   
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -536,19 +536,18 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
             // Check if we are pasting into empty list item. If so
             // delete it and paste into parent list instead.
             if (nsHTMLEditUtils::IsListItem(parentNode))
             {
               bool isEmpty;
               rv = IsEmptyNode(parentNode, &isEmpty, true);
               if (NS_SUCCEEDED(rv) && isEmpty)
               {
-                nsCOMPtr<nsIDOMNode> listNode;
                 PRInt32 newOffset;
-                GetNodeLocation(parentNode, address_of(listNode), &newOffset);
+                nsCOMPtr<nsIDOMNode> listNode = GetNodeLocation(parentNode, &newOffset);
                 if (listNode)
                 {
                   DeleteNode(parentNode);
                   parentNode = listNode;
                   offsetOfNewNode = newOffset;
                 }
               }
             }
@@ -613,17 +612,17 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
               lastInsertNode = GetChildAt(parentNode, offsetOfNewNode);
             }
           }
           curNode = parent;
         }
       }
       if (lastInsertNode)
       {
-        GetNodeLocation(lastInsertNode, address_of(parentNode), &offsetOfNewNode);
+        parentNode = GetNodeLocation(lastInsertNode, &offsetOfNewNode);
         offsetOfNewNode++;
       }
     }
 
     // Now collapse the selection to the end of what we just inserted:
     if (lastInsertNode) 
     {
       // set selection to the end of what we just pasted.
@@ -652,17 +651,17 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
       if (IsTextNode(selNode) || (IsContainer(selNode) && !nsHTMLEditUtils::IsTable(selNode)))
       {
         rv = GetLengthOfDOMNode(selNode, (PRUint32&)selOffset);
         NS_ENSURE_SUCCESS(rv, rv);
       }
       else // we need to find a container for selection.  Look up.
       {
         tmp = selNode;
-        GetNodeLocation(tmp, address_of(selNode), &selOffset);
+        selNode = GetNodeLocation(tmp, &selOffset);
         ++selOffset;  // want to be *after* last leaf node in paste
       }
 
       // make sure we don't end up with selection collapsed after an invisible break node
       nsWSRunObject wsRunObj(this, selNode, selOffset);
       PRInt32 outVisOffset=0;
       PRInt16 visType=0;
       wsRunObj.PriorVisibleNode(selNode, selOffset, address_of(visNode),
@@ -672,34 +671,32 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
         // we are after a break.  Is it visible?  Despite the name, 
         // PriorVisibleNode does not make that determination for breaks.
         // It also may not return the break in visNode.  We have to pull it
         // out of the nsWSRunObject's state.
         if (!IsVisBreak(wsRunObj.mStartReasonNode))
         {
           // don't leave selection past an invisible break;
           // reset {selNode,selOffset} to point before break
-          GetNodeLocation(wsRunObj.mStartReasonNode, address_of(selNode),
-                          &selOffset);
+          selNode = GetNodeLocation(wsRunObj.mStartReasonNode, &selOffset);
           // we want to be inside any inline style prior to break
           nsWSRunObject wsRunObj(this, selNode, selOffset);
           wsRunObj.PriorVisibleNode(selNode, selOffset, address_of(visNode),
                                     &outVisOffset, &visType);
           if (visType == nsWSRunObject::eText ||
               visType == nsWSRunObject::eNormalWS)
           {
             selNode = visNode;
             selOffset = outVisOffset;  // PriorVisibleNode already set offset to _after_ the text or ws
           }
           else if (visType == nsWSRunObject::eSpecial)
           {
             // prior visible thing is an image or some other non-text thingy.  
             // We want to be right after it.
-            GetNodeLocation(wsRunObj.mStartReasonNode, address_of(selNode),
-                            &selOffset);
+            selNode = GetNodeLocation(wsRunObj.mStartReasonNode, &selOffset);
             ++selOffset;
           }
         }
       }
       selection->Collapse(selNode, selOffset);
 
       // if we just pasted a link, discontinue link style
       nsCOMPtr<nsIDOMNode> link;
@@ -708,17 +705,17 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
         // so, if we just pasted a link, I split it.  Why do that instead of just
         // nudging selection point beyond it?  Because it might have ended in a BR
         // that is not visible.  If so, the code above just placed selection
         // inside that.  So I split it instead.
         nsCOMPtr<nsIDOMNode> leftLink;
         PRInt32 linkOffset;
         rv = SplitNodeDeep(link, selNode, selOffset, &linkOffset, true, address_of(leftLink));
         NS_ENSURE_SUCCESS(rv, rv);
-        GetNodeLocation(leftLink, address_of(selNode), &selOffset);
+        selNode = GetNodeLocation(leftLink, &selOffset);
         selection->Collapse(selNode, selOffset+1);
       }
     }
   }
 
   return mRules->DidDoAction(selection, &ruleInfo, rv);
 }
 
@@ -2004,19 +2001,18 @@ nsHTMLEditor::InsertAsPlaintextQuotation
   {
     *aNodeInserted = newNode;
     NS_IF_ADDREF(*aNodeInserted);
   }
 
   // Set the selection to just after the inserted node:
   if (NS_SUCCEEDED(rv) && newNode)
   {
-    nsCOMPtr<nsIDOMNode> parent;
     PRInt32 offset;
-    GetNodeLocation(newNode, address_of(parent), &offset);
+    nsCOMPtr<nsIDOMNode> parent = GetNodeLocation(newNode, &offset);
     if (parent) {
       selection->Collapse(parent, offset + 1);
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
@@ -2089,19 +2085,18 @@ nsHTMLEditor::InsertAsCitedQuotation(con
   {
     *aNodeInserted = newNode;
     NS_IF_ADDREF(*aNodeInserted);
   }
 
   // Set the selection to just after the inserted node:
   if (NS_SUCCEEDED(rv) && newNode)
   {
-    nsCOMPtr<nsIDOMNode> parent;
     PRInt32 offset;
-    GetNodeLocation(newNode, address_of(parent), &offset);
+    nsCOMPtr<nsIDOMNode> parent = GetNodeLocation(newNode, &offset);
     if (parent) {
       selection->Collapse(parent, offset + 1);
     }
   }
   return rv;
 }
 
 
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -750,22 +750,21 @@ nsHTMLEditRules::GetAlignment(bool *aMix
   *aAlign = nsIHTMLEditor::eLeft;
 
   // get selection
   nsCOMPtr<nsISelection>selection;
   nsresult res = mHTMLEditor->GetSelection(getter_AddRefs(selection));
   NS_ENSURE_SUCCESS(res, res);
 
   // get selection location
-  nsCOMPtr<nsIDOMNode> parent;
   nsCOMPtr<nsIDOMElement> rootElem = do_QueryInterface(mHTMLEditor->GetRoot());
   NS_ENSURE_TRUE(rootElem, NS_ERROR_FAILURE);
 
   PRInt32 offset, rootOffset;
-  nsEditor::GetNodeLocation(rootElem, address_of(parent), &rootOffset);
+  nsCOMPtr<nsIDOMNode> parent = nsEditor::GetNodeLocation(rootElem, &rootOffset);
   res = mHTMLEditor->GetStartNodeAndOffset(selection, getter_AddRefs(parent), &offset);
   NS_ENSURE_SUCCESS(res, res);
 
   // is the selection collapsed?
   nsCOMPtr<nsIDOMNode> nodeToExamine;
   if (selection->Collapsed()) {
     // if it is, we want to look at 'parent' and its ancestors
     // for divs with alignment on them
@@ -1198,17 +1197,17 @@ nsHTMLEditRules::WillInsert(nsISelection
     else block1 = mHTMLEditor->GetBlockNodeParent(selNode);
     block2 = mHTMLEditor->GetBlockNodeParent(priorNode);
   
     if (block1 == block2)
     {
       // if we are here then the selection is right after a mozBR
       // that is in the same block as the selection.  We need to move
       // the selection start to be before the mozBR.
-      nsEditor::GetNodeLocation(priorNode, address_of(selNode), &selOffset);
+      selNode = nsEditor::GetNodeLocation(priorNode, &selOffset);
       res = aSelection->Collapse(selNode,selOffset);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
 
   if (mDidDeleteSelection &&
       (mTheAction == nsEditor::kOpInsertText ||
        mTheAction == nsEditor::kOpInsertIMEText ||
@@ -1603,17 +1602,17 @@ nsHTMLEditRules::StandardBreakImpl(nsIDO
       // reset {node,aOffset} to the point where link was split
       node = linkParent;
       aOffset = newOffset;
     }
     res = wsObj.InsertBreak(address_of(node), &aOffset,
                             address_of(brNode), nsIEditor::eNone);
   }
   NS_ENSURE_SUCCESS(res, res);
-  nsEditor::GetNodeLocation(brNode, address_of(node), &aOffset);
+  node = nsEditor::GetNodeLocation(brNode, &aOffset);
   NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
   if (bAfterBlock && bBeforeBlock) {
     // we just placed a br between block boundaries.  This is the one case
     // where we want the selection to be before the br we just placed, as the
     // br will be on a new line, rather than at end of prior line.
     selPriv->SetInterlinePosition(true);
     res = aSelection->Collapse(node, aOffset);
   } else {
@@ -1625,19 +1624,18 @@ nsHTMLEditRules::StandardBreakImpl(nsIDO
                           &visOffset, &wsType);
     if (wsType == nsWSRunObject::eBreak) {
       // the next thing after the break we inserted is another break.  Move
       // the 2nd break to be the first breaks sibling.  This will prevent them
       // from being in different inline nodes, which would break
       // SetInterlinePosition().  It will also assure that if the user clicks
       // away and then clicks back on their new blank line, they will still
       // get the style from the line above.
-      nsCOMPtr<nsIDOMNode> brParent;
       PRInt32 brOffset;
-      nsEditor::GetNodeLocation(secondBR, address_of(brParent), &brOffset);
+      nsCOMPtr<nsIDOMNode> brParent = nsEditor::GetNodeLocation(secondBR, &brOffset);
       if (brParent != node || brOffset != aOffset + 1) {
         res = mHTMLEditor->MoveNode(secondBR, node, aOffset+1);
         NS_ENSURE_SUCCESS(res, res);
       }
     }
     // SetInterlinePosition(true) means we want the caret to stick to the
     // content on the "right".  We want the caret to stick to whatever is past
     // the break.  This is because the break is on the same line we were on,
@@ -1693,17 +1691,17 @@ nsHTMLEditRules::SplitMailCites(nsISelec
                           &visOffset, &wsType);
     if (wsType==nsWSRunObject::eBreak)
     {
       // ok, we are just before a break.  is it inside the mailquote?
       PRInt32 unused;
       if (nsEditorUtils::IsDescendantOf(visNode, citeNode, &unused))
       {
         // it is.  so lets reset our selection to be just after it.
-        mHTMLEditor->GetNodeLocation(visNode, address_of(selNode), &selOffset);
+        selNode = mHTMLEditor->GetNodeLocation(visNode, &selOffset);
         ++selOffset;
       }
     }
      
     nsCOMPtr<nsIDOMNode> brNode;
     res = mHTMLEditor->SplitNodeDeep(citeNode, selNode, selOffset, &newOffset, 
                        true, address_of(leftCite), address_of(rightCite));
     NS_ENSURE_SUCCESS(res, res);
@@ -1958,17 +1956,17 @@ nsHTMLEditRules::WillDeleteSelection(Sel
 
           In any other case we set the position to 
           startnode -1 and interlineposition to false,
           only moving the caret to the end-of-hr-line position.
         */
 
         bool moveOnly = true;
 
-        nsEditor::GetNodeLocation(visNode, address_of(selNode), &selOffset);
+        selNode = nsEditor::GetNodeLocation(visNode, &selOffset);
 
         bool interLineIsRight;
         res = aSelection->GetInterlinePosition(&interLineIsRight);
         NS_ENSURE_SUCCESS(res, res);
 
         if (startNode == selNode &&
             startOffset -1 == selOffset &&
             !interLineIsRight)
@@ -2504,17 +2502,17 @@ nsHTMLEditRules::GetGoodSelPointForNode(
       PRUint32 len;
       res = mHTMLEditor->GetLengthOfDOMNode(aNode, len);
       *outSelOffset = PRInt32(len);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
   else 
   {
-    nsEditor::GetNodeLocation(aNode, outSelNode, outSelOffset);
+    *outSelNode = nsEditor::GetNodeLocation(aNode, outSelOffset);
     if (!nsTextEditUtils::IsBreak(aNode) || mHTMLEditor->IsVisBreak(aNode))
     {
       if (aAction == nsIEditor::ePrevious)
         (*outSelOffset)++;
     }
   }
   return res;
 }
@@ -2847,19 +2845,19 @@ nsHTMLEditRules::DidDeleteSelection(nsIS
                                 IsPlaintextEditor());
   NS_ENSURE_SUCCESS(res, res);
   if (citeNode) {
     nsCOMPtr<nsINode> cite = do_QueryInterface(citeNode);
     bool isEmpty = true, seenBR = false;
     mHTMLEditor->IsEmptyNodeImpl(cite, &isEmpty, true, true, false, &seenBR);
     if (isEmpty)
     {
-      nsCOMPtr<nsIDOMNode> parent, brNode;
+      nsCOMPtr<nsIDOMNode> brNode;
       PRInt32 offset;
-      nsEditor::GetNodeLocation(citeNode, address_of(parent), &offset);
+      nsCOMPtr<nsIDOMNode> parent = nsEditor::GetNodeLocation(citeNode, &offset);
       res = mHTMLEditor->DeleteNode(citeNode);
       NS_ENSURE_SUCCESS(res, res);
       if (parent && seenBR)
       {
         res = mHTMLEditor->CreateBR(parent, offset, address_of(brNode));
         NS_ENSURE_SUCCESS(res, res);
         aSelection->Collapse(parent, offset);
       }
@@ -2988,17 +2986,17 @@ nsHTMLEditRules::WillMakeList(nsISelecti
   nsCOMPtr<nsIDOMNode> curList;
   nsCOMPtr<nsIDOMNode> prevListItem;
 
   for (PRInt32 i = 0; i < listCount; i++) {
     // here's where we actually figure out what to do
     nsCOMPtr<nsIDOMNode> newBlock;
     nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
     PRInt32 offset;
-    nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset);
+    curParent = nsEditor::GetNodeLocation(curNode, &offset);
 
     // make sure we don't assemble content that is in different table cells
     // into the same list.  respect table cell boundaries when listifying.
     if (curList) {
       bool bInDifTblElems;
       res = InDifferentTableElements(curList, curNode, &bInDifTblElems);
       NS_ENSURE_SUCCESS(res, res);
       if (bInDifTblElems) {
@@ -3047,19 +3045,18 @@ nsHTMLEditRules::WillMakeList(nsISelecti
     if (nsHTMLEditUtils::IsListItem(curNode)) {
       if (mHTMLEditor->GetTag(curParent) != listTypeAtom) {
         // list item is in wrong type of list. if we don't have a curList,
         // split the old list and make a new list of correct type.
         if (!curList || nsEditorUtils::IsDescendantOf(curNode, curList)) {
           res = mHTMLEditor->SplitNode(curParent, offset,
                                        getter_AddRefs(newBlock));
           NS_ENSURE_SUCCESS(res, res);
-          nsCOMPtr<nsIDOMNode> parent;
           PRInt32 offset;
-          nsEditor::GetNodeLocation(curParent, address_of(parent), &offset);
+          nsCOMPtr<nsIDOMNode> parent = nsEditor::GetNodeLocation(curParent, &offset);
           res = mHTMLEditor->CreateNode(*aListType, parent, offset,
                                         getter_AddRefs(curList));
           NS_ENSURE_SUCCESS(res, res);
         }
         // move list item to new list
         res = mHTMLEditor->MoveNode(curNode, curList, -1);
         NS_ENSURE_SUCCESS(res, res);
         // convert list item type if needed
@@ -3202,17 +3199,17 @@ nsHTMLEditRules::WillRemoveList(nsISelec
   
   // Only act on lists or list items in the array
   nsCOMPtr<nsIDOMNode> curParent;
   for (i=0; i<listCount; i++)
   {
     // here's where we actually figure out what to do
     nsIDOMNode* curNode = arrayOfNodes[i];
     PRInt32 offset;
-    nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset);
+    curParent = nsEditor::GetNodeLocation(curNode, &offset);
     
     if (nsHTMLEditUtils::IsListItem(curNode))  // unlist this listitem
     {
       bool bOutOfList;
       do
       {
         res = PopListItem(curNode, &bOutOfList);
         NS_ENSURE_SUCCESS(res, res);
@@ -3506,17 +3503,17 @@ nsHTMLEditRules::WillCSSIndent(nsISelect
   {
     // here's where we actually figure out what to do
     nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
 
     // Ignore all non-editable nodes.  Leave them be.
     if (!mHTMLEditor->IsEditable(curNode)) continue;
 
     PRInt32 offset;
-    nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset);
+    curParent = nsEditor::GetNodeLocation(curNode, &offset);
     
     // some logic for putting list items into nested lists...
     if (nsHTMLEditUtils::IsList(curParent))
     {
       sibling = nsnull;
 
       // Check for whether we should join a list that follows curNode.
       // We do this if the next element is a list, and the list is of the
@@ -3689,17 +3686,17 @@ nsHTMLEditRules::WillHTMLIndent(nsISelec
   {
     // here's where we actually figure out what to do
     nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
 
     // Ignore all non-editable nodes.  Leave them be.
     if (!mHTMLEditor->IsEditable(curNode)) continue;
 
     PRInt32 offset;
-    nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset);
+    curParent = nsEditor::GetNodeLocation(curNode, &offset);
      
     // some logic for putting list items into nested lists...
     if (nsHTMLEditUtils::IsList(curParent))
     {
       sibling = nsnull;
 
       // Check for whether we should join a list that follows curNode.
       // We do this if the next element is a list, and the list is of the
@@ -3770,17 +3767,17 @@ nsHTMLEditRules::WillHTMLIndent(nsISelec
       // array of nodes to act on, that are in the same list item.  Since
       // we only want to indent that li once, we must keep track of the most
       // recent indented list item, and not indent it if we find another node
       // to act on that is still inside the same li.
       nsCOMPtr<nsIDOMNode> listitem=IsInListItem(curNode);
       if (listitem)
       {
         if (indentedLI == listitem) continue;  // already indented this list item
-        nsEditor::GetNodeLocation(listitem, address_of(curParent), &offset);
+        curParent = nsEditor::GetNodeLocation(listitem, &offset);
         // check to see if curList is still appropriate.  Which it is if
         // curNode is still right after it in the same list.
         if (curList)
         {
           sibling = nsnull;
           mHTMLEditor->GetPriorHTMLSibling(curNode, address_of(sibling));
         }
          
@@ -3878,17 +3875,17 @@ nsHTMLEditRules::WillOutdent(nsISelectio
     PRInt32 listCount = arrayOfNodes.Count();
     PRInt32 i;
     nsCOMPtr<nsIDOMNode> curParent;
     for (i=0; i<listCount; i++)
     {
       // here's where we actually figure out what to do
       nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
       PRInt32 offset;
-      nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset);
+      curParent = nsEditor::GetNodeLocation(curNode, &offset);
       
       // is it a blockquote?
       if (nsHTMLEditUtils::IsBlockquote(curNode)) 
       {
         // if it is a blockquote, remove it.
         // So we need to finish up dealng with any curBlockQuote first.
         if (curBlockQuote)
         {
@@ -4086,27 +4083,27 @@ nsHTMLEditRules::WillOutdent(nsISelectio
       // push selection past end of rememberedLeftBQ
       nsCOMPtr<nsIDOMNode> sNode;
       PRInt32 sOffset;
       mHTMLEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(sNode), &sOffset);
       if (rememberedLeftBQ &&
           ((sNode == rememberedLeftBQ) || nsEditorUtils::IsDescendantOf(sNode, rememberedLeftBQ)))
       {
         // selection is inside rememberedLeftBQ - push it past it.
-        nsEditor::GetNodeLocation(rememberedLeftBQ, address_of(sNode), &sOffset);
+        sNode = nsEditor::GetNodeLocation(rememberedLeftBQ, &sOffset);
         sOffset++;
         aSelection->Collapse(sNode, sOffset);
       }
       // and pull selection before beginning of rememberedRightBQ
       mHTMLEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(sNode), &sOffset);
       if (rememberedRightBQ &&
           ((sNode == rememberedRightBQ) || nsEditorUtils::IsDescendantOf(sNode, rememberedRightBQ)))
       {
         // selection is inside rememberedRightBQ - push it before it.
-        nsEditor::GetNodeLocation(rememberedRightBQ, address_of(sNode), &sOffset);
+        sNode = nsEditor::GetNodeLocation(rememberedRightBQ, &sOffset);
         aSelection->Collapse(sNode, sOffset);
       }
     }
     return NS_OK;
   }
   return res;
 }
 
@@ -4139,35 +4136,35 @@ nsHTMLEditRules::SplitBlock(nsIDOMNode *
                             nsIDOMNode *aStartChild, 
                             nsIDOMNode *aEndChild,
                             nsCOMPtr<nsIDOMNode> *aLeftNode,
                             nsCOMPtr<nsIDOMNode> *aRightNode,
                             nsCOMPtr<nsIDOMNode> *aMiddleNode)
 {
   NS_ENSURE_TRUE(aBlock && aStartChild && aEndChild, NS_ERROR_NULL_POINTER);
   
-  nsCOMPtr<nsIDOMNode> startParent, endParent, leftNode, rightNode;
+  nsCOMPtr<nsIDOMNode> leftNode, rightNode;
   PRInt32 startOffset, endOffset, offset;
   nsresult res;
 
   // get split point location
-  nsEditor::GetNodeLocation(aStartChild, address_of(startParent), &startOffset);
+  nsCOMPtr<nsIDOMNode> startParent = nsEditor::GetNodeLocation(aStartChild, &startOffset);
   
   // do the splits!
   res = mHTMLEditor->SplitNodeDeep(aBlock, startParent, startOffset, &offset, 
                                    true, address_of(leftNode), address_of(rightNode));
   NS_ENSURE_SUCCESS(res, res);
   if (rightNode)  aBlock = rightNode;
 
   // remember left portion of block if caller requested
   if (aLeftNode) 
     *aLeftNode = leftNode;
 
   // get split point location
-  nsEditor::GetNodeLocation(aEndChild, address_of(endParent), &endOffset);
+  nsCOMPtr<nsIDOMNode> endParent = nsEditor::GetNodeLocation(aEndChild, &endOffset);
   endOffset++;  // want to be after lastBQChild
 
   // do the splits!
   res = mHTMLEditor->SplitNodeDeep(aBlock, endParent, endOffset, &offset, 
                                    true, address_of(leftNode), address_of(rightNode));
   NS_ENSURE_SUCCESS(res, res);
   if (leftNode)  aBlock = leftNode;
   
@@ -4546,17 +4543,17 @@ nsHTMLEditRules::WillAlign(nsISelection 
   for (PRInt32 i = 0; i < listCount; ++i) {
     // here's where we actually figure out what to do
     nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
 
     // Ignore all non-editable nodes.  Leave them be.
     if (!mHTMLEditor->IsEditable(curNode)) continue;
 
     PRInt32 offset;
-    nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset);
+    curParent = nsEditor::GetNodeLocation(curNode, &offset);
 
     // the node is a table element, an horiz rule, a paragraph, a div
     // or a section header; in HTML 4, it can directly carry the ALIGN
     // attribute and we don't need to nest it, just set the alignment.
     // In CSS, assign the corresponding CSS styles in AlignBlock
     if (nsHTMLEditUtils::SupportsAlignAttr(curNode))
     {
       nsCOMPtr<nsIDOMElement> curElem = do_QueryInterface(curNode);
@@ -4765,33 +4762,31 @@ nsHTMLEditRules::CheckForEmptyBlock(nsID
       res = mHTMLEditor->IsEmptyNode(block, &bIsEmptyNode, true, false);
       NS_ENSURE_SUCCESS(res, res);
     }
   }
 
   nsCOMPtr<nsIContent> emptyContent = do_QueryInterface(emptyBlock);
   if (emptyBlock && emptyContent->IsEditable())
   {
-    nsCOMPtr<nsIDOMNode> blockParent;
     PRInt32 offset;
-    nsEditor::GetNodeLocation(emptyBlock, address_of(blockParent), &offset);
+    nsCOMPtr<nsIDOMNode> blockParent = nsEditor::GetNodeLocation(emptyBlock, &offset);
     NS_ENSURE_TRUE(blockParent && offset >= 0, NS_ERROR_FAILURE);
 
     if (nsHTMLEditUtils::IsListItem(emptyBlock))
     {
       // are we the first list item in the list?
       bool bIsFirst;
       res = mHTMLEditor->IsFirstEditableChild(emptyBlock, &bIsFirst);
       NS_ENSURE_SUCCESS(res, res);
       if (bIsFirst)
       {
-        nsCOMPtr<nsIDOMNode> listParent;
         PRInt32 listOffset;
-        nsEditor::GetNodeLocation(blockParent, address_of(listParent),
-                                  &listOffset);
+        nsCOMPtr<nsIDOMNode> listParent = nsEditor::GetNodeLocation(blockParent,
+                                                                    &listOffset);
         NS_ENSURE_TRUE(listParent && listOffset >= 0, NS_ERROR_FAILURE);
         // if we are a sublist, skip the br creation
         if (!nsHTMLEditUtils::IsList(listParent))
         {
           // create a br before list
           nsCOMPtr<nsIDOMNode> brNode;
           res = mHTMLEditor->CreateBR(listParent, listOffset, address_of(brNode));
           NS_ENSURE_SUCCESS(res, res);
@@ -4829,21 +4824,19 @@ nsHTMLEditRules::CheckForInvisibleBR(nsI
 
   if (aWhere == kBlockEnd)
   {
     nsCOMPtr<nsIDOMNode> rightmostNode =
       mHTMLEditor->GetRightmostChild(aBlock, true); // no block crossing
 
     if (rightmostNode)
     {
-      nsCOMPtr<nsIDOMNode> nodeParent;
       PRInt32 nodeOffset;
-
-      nsEditor::GetNodeLocation(rightmostNode, address_of(nodeParent),
-                                &nodeOffset);
+      nsCOMPtr<nsIDOMNode> nodeParent = nsEditor::GetNodeLocation(rightmostNode,
+                                                                  &nodeOffset);
       runTest = true;
       testNode = nodeParent;
       // use offset + 1, because we want the last node included in our
       // evaluation
       testOffset = nodeOffset + 1;
     }
   }
   else if (aOffset)
@@ -4974,17 +4967,18 @@ nsHTMLEditRules::ExpandSelectionForDelet
         if ( nsHTMLEditUtils::IsTableElement(wsObj.mStartReasonNode) ||
             (selCommon == wsObj.mStartReasonNode)                    ||
             (rootElement == wsObj.mStartReasonNode) )
         {
           stillLooking = false;
         }
         else
         { 
-          nsEditor::GetNodeLocation(wsObj.mStartReasonNode, address_of(selStartNode), &selStartOffset);
+          selStartNode = nsEditor::GetNodeLocation(wsObj.mStartReasonNode,
+                                                   &selStartOffset);
         }
       }
       else
       {
         stillLooking = false;
       }
     }
   }
@@ -5006,33 +5000,33 @@ nsHTMLEditRules::ExpandSelectionForDelet
         }
         else
         { 
           if (!firstBRParent)
           {
             firstBRParent = selEndNode;
             firstBROffset = selEndOffset;
           }
-          nsEditor::GetNodeLocation(wsObj.mEndReasonNode, address_of(selEndNode), &selEndOffset);
+          selEndNode = nsEditor::GetNodeLocation(wsObj.mEndReasonNode, &selEndOffset);
           ++selEndOffset;
         }
       }
       else if (wsType == nsWSRunObject::eThisBlock)
       {
         // we want to keep looking up.  But stop if we are crossing table element
         // boundaries, or if we hit the root.
         if ( nsHTMLEditUtils::IsTableElement(wsObj.mEndReasonNode) ||
             (selCommon == wsObj.mEndReasonNode)                    ||
             (rootElement == wsObj.mEndReasonNode) )
         {
           stillLooking = false;
         }
         else
         { 
-          nsEditor::GetNodeLocation(wsObj.mEndReasonNode, address_of(selEndNode), &selEndOffset);
+          selEndNode = nsEditor::GetNodeLocation(wsObj.mEndReasonNode, &selEndOffset);
           ++selEndOffset;
         }
        }
       else
       {
         stillLooking = false;
       }
     }
@@ -5145,39 +5139,38 @@ nsHTMLEditRules::NormalizeSelection(nsIS
     // eThisBlock and eOtherBlock conveniently distinquish cases
     // of going "down" into a block and "up" out of a block.
     if (wsEndObj.mStartReason == nsWSRunObject::eOtherBlock) 
     {
       // endpoint is just after the close of a block.
       nsCOMPtr<nsIDOMNode> child = mHTMLEditor->GetRightmostChild(wsEndObj.mStartReasonNode, true);
       if (child)
       {
-        nsEditor::GetNodeLocation(child, address_of(newEndNode), &newEndOffset);
+        newEndNode = nsEditor::GetNodeLocation(child, &newEndOffset);
         ++newEndOffset; // offset *after* child
       }
       // else block is empty - we can leave selection alone here, i think.
     }
     else if (wsEndObj.mStartReason == nsWSRunObject::eThisBlock)
     {
       // endpoint is just after start of this block
       nsCOMPtr<nsIDOMNode> child;
       res = mHTMLEditor->GetPriorHTMLNode(endNode, endOffset, address_of(child));
       if (child)
       {
-        nsEditor::GetNodeLocation(child, address_of(newEndNode),
-                                  &newEndOffset);
+        newEndNode = nsEditor::GetNodeLocation(child, &newEndOffset);
         ++newEndOffset; // offset *after* child
       }
       // else block is empty - we can leave selection alone here, i think.
     }
     else if (wsEndObj.mStartReason == nsWSRunObject::eBreak)
     {                                       
       // endpoint is just after break.  lets adjust it to before it.
-      nsEditor::GetNodeLocation(wsEndObj.mStartReasonNode,
-                                address_of(newEndNode), &newEndOffset);
+      newEndNode = nsEditor::GetNodeLocation(wsEndObj.mStartReasonNode,
+                                             &newEndOffset);
     }
   }
   
   
   // similar dealio for start of range
   nsWSRunObject wsStartObj(mHTMLEditor, startNode, startOffset);
   // is there any intervening visible whitespace?  if so we can't push selection past that,
   // it would visibly change maening of users selection
@@ -5188,38 +5181,36 @@ nsHTMLEditRules::NormalizeSelection(nsIS
     // eThisBlock and eOtherBlock conveniently distinquish cases
     // of going "down" into a block and "up" out of a block.
     if (wsStartObj.mEndReason == nsWSRunObject::eOtherBlock) 
     {
       // startpoint is just before the start of a block.
       nsCOMPtr<nsIDOMNode> child = mHTMLEditor->GetLeftmostChild(wsStartObj.mEndReasonNode, true);
       if (child)
       {
-        nsEditor::GetNodeLocation(child, address_of(newStartNode),
-                                  &newStartOffset);
+        newStartNode = nsEditor::GetNodeLocation(child, &newStartOffset);
       }
       // else block is empty - we can leave selection alone here, i think.
     }
     else if (wsStartObj.mEndReason == nsWSRunObject::eThisBlock)
     {
       // startpoint is just before end of this block
       nsCOMPtr<nsIDOMNode> child;
       res = mHTMLEditor->GetNextHTMLNode(startNode, startOffset, address_of(child));
       if (child)
       {
-        nsEditor::GetNodeLocation(child, address_of(newStartNode),
-                                  &newStartOffset);
+        newStartNode = nsEditor::GetNodeLocation(child, &newStartOffset);
       }
       // else block is empty - we can leave selection alone here, i think.
     }
     else if (wsStartObj.mEndReason == nsWSRunObject::eBreak)
     {                                       
       // startpoint is just before a break.  lets adjust it to after it.
-      nsEditor::GetNodeLocation(wsStartObj.mEndReasonNode,
-                                address_of(newStartNode), &newStartOffset);
+      newStartNode = nsEditor::GetNodeLocation(wsStartObj.mEndReasonNode,
+                                               &newStartOffset);
       ++newStartOffset; // offset *after* break
     }
   }
   
   // there is a demented possiblity we have to check for.  We might have a very strange selection
   // that is not collapsed and yet does not contain any editable content, and satisfies some of the
   // above conditions that cause tweaking.  In this case we don't want to tweak the selection into
   // a block it was never in, etc.  There are a variety of strategies one might use to try to
@@ -6054,18 +6045,17 @@ nsHTMLEditRules::BustUpInlinesAtBRs(nsID
     PRInt32 splitOffset, resultOffset, i;
     inNode->GetParentNode(getter_AddRefs(inlineParentNode));
     
     for (i=0; i< listCount; i++)
     {
       breakNode = arrayOfBreaks[i];
       NS_ENSURE_TRUE(breakNode, NS_ERROR_NULL_POINTER);
       NS_ENSURE_TRUE(splitDeepNode, NS_ERROR_NULL_POINTER);
-      nsEditor::GetNodeLocation(breakNode, address_of(splitParentNode),
-                                &splitOffset);
+      splitParentNode = nsEditor::GetNodeLocation(breakNode, &splitOffset);
       res = mHTMLEditor->SplitNodeDeep(splitDeepNode, splitParentNode, splitOffset,
                           &resultOffset, false, address_of(leftNode), address_of(rightNode));
       NS_ENSURE_SUCCESS(res, res);
       // put left node in node list
       if (leftNode)
       {
         // might not be a left node.  a break might have been at the very
         // beginning of inline container, in which case splitnodedeep
@@ -6255,19 +6245,18 @@ nsresult
 nsHTMLEditRules::ReturnInHeader(nsISelection *aSelection, 
                                 nsIDOMNode *aHeader, 
                                 nsIDOMNode *aNode, 
                                 PRInt32 aOffset)
 {
   NS_ENSURE_TRUE(aSelection && aHeader && aNode, NS_ERROR_NULL_POINTER);  
   
   // remeber where the header is
-  nsCOMPtr<nsIDOMNode> headerParent;
   PRInt32 offset;
-  nsEditor::GetNodeLocation(aHeader, address_of(headerParent), &offset);
+  nsCOMPtr<nsIDOMNode> headerParent = nsEditor::GetNodeLocation(aHeader, &offset);
 
   // get ws code to adjust any ws
   nsCOMPtr<nsIDOMNode> selNode = aNode;
   nsresult res = nsWSRunObject::PrepareToSplitAcrossBlocks(mHTMLEditor,
                                                            address_of(selNode),
                                                            &aOffset);
   NS_ENSURE_SUCCESS(res, res);
 
@@ -6316,17 +6305,17 @@ nsHTMLEditRules::ReturnInHeader(nsISelec
       res = mHTMLEditor->CreateBR(pNode, 0, address_of(brNode));
       NS_ENSURE_SUCCESS(res, res);
 
       // set selection to before the break
       res = aSelection->Collapse(pNode, 0);
     }
     else
     {
-      nsEditor::GetNodeLocation(sibling, address_of(headerParent), &offset);
+      headerParent = nsEditor::GetNodeLocation(sibling, &offset);
       // put selection after break
       res = aSelection->Collapse(headerParent,offset+1);
     }
   }
   else
   {
     // put selection at front of righthand heading
     res = aSelection->Collapse(aHeader,0);
@@ -6347,19 +6336,18 @@ nsHTMLEditRules::ReturnInParagraph(nsISe
 {
   if (!aSelection || !aPara || !aNode || !aCancel || !aHandled) {
     return NS_ERROR_NULL_POINTER;
   }
   *aCancel = false;
   *aHandled = false;
   nsresult res;
 
-  nsCOMPtr<nsIDOMNode> parent;
   PRInt32 offset;
-  nsEditor::GetNodeLocation(aNode, address_of(parent), &offset);
+  nsCOMPtr<nsIDOMNode> parent = nsEditor::GetNodeLocation(aNode, &offset);
 
   bool doesCRCreateNewP = mHTMLEditor->GetReturnInParagraphCreatesNewParagraph();
 
   bool newBRneeded = false;
   nsCOMPtr<nsIDOMNode> sibling;
 
   if (aNode == aPara && doesCRCreateNewP) {
     // we are at the edges of the block, newBRneeded not needed!
@@ -6476,19 +6464,18 @@ nsHTMLEditRules::SplitParagraph(nsIDOMNo
   // look inside any containers that are up front.
   nsCOMPtr<nsIDOMNode> child = mHTMLEditor->GetLeftmostChild(rightPara, true);
   if (mHTMLEditor->IsTextNode(child) || mHTMLEditor->IsContainer(child))
   {
     aSelection->Collapse(child,0);
   }
   else
   {
-    nsCOMPtr<nsIDOMNode> parent;
     PRInt32 offset;
-    nsEditor::GetNodeLocation(child, address_of(parent), &offset);
+    nsCOMPtr<nsIDOMNode> parent = nsEditor::GetNodeLocation(child, &offset);
     aSelection->Collapse(parent,offset);
   }
   return res;
 }
 
 
 ///////////////////////////////////////////////////////////////////////////
 // ReturnInListItem: do the right thing for returns pressed in list items
@@ -6508,31 +6495,29 @@ nsHTMLEditRules::ReturnInListItem(nsISel
   
   // sanity check
   NS_PRECONDITION(true == nsHTMLEditUtils::IsListItem(aListItem),
                   "expected a list item and didn't get one");
   
   // get the listitem parent and the active editing host.
   nsIContent* rootContent = mHTMLEditor->GetActiveEditingHost();
   nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(rootContent);
-  nsCOMPtr<nsIDOMNode> list;
   PRInt32 itemOffset;
-  nsEditor::GetNodeLocation(aListItem, address_of(list), &itemOffset);
+  nsCOMPtr<nsIDOMNode> list = nsEditor::GetNodeLocation(aListItem, &itemOffset);
 
   // if we are in an empty listitem, then we want to pop up out of the list
   // but only if prefs says it's ok and if the parent isn't the active editing host.
   bool isEmpty;
   res = IsEmptyBlock(aListItem, &isEmpty, true, false);
   NS_ENSURE_SUCCESS(res, res);
   if (isEmpty && (rootNode != list) && mReturnInEmptyLIKillsList)
   {
     // get the list offset now -- before we might eventually split the list
-    nsCOMPtr<nsIDOMNode> listparent;
     PRInt32 offset;
-    nsEditor::GetNodeLocation(list, address_of(listparent), &offset);
+    nsCOMPtr<nsIDOMNode> listparent = nsEditor::GetNodeLocation(list, &offset);
 
     // are we the last list item in the list?
     bool bIsLast;
     res = mHTMLEditor->IsLastEditableChild(aListItem, &bIsLast);
     NS_ENSURE_SUCCESS(res, res);
     if (!bIsLast)
     {
       // we need to split the list!
@@ -6598,55 +6583,52 @@ nsHTMLEditRules::ReturnInListItem(nsISel
     } else {
       res = mHTMLEditor->IsEmptyNode(aListItem, &bIsEmptyNode, true);
       NS_ENSURE_SUCCESS(res, res);
       if (bIsEmptyNode) 
       {
         nsCOMPtr<nsIAtom> nodeAtom = nsEditor::GetTag(aListItem);
         if (nodeAtom == nsEditProperty::dd || nodeAtom == nsEditProperty::dt)
         {
-          nsCOMPtr<nsIDOMNode> list;
           PRInt32 itemOffset;
-          nsEditor::GetNodeLocation(aListItem, address_of(list), &itemOffset);
+          nsCOMPtr<nsIDOMNode> list = nsEditor::GetNodeLocation(aListItem, &itemOffset);
 
           nsAutoString listTag((nodeAtom == nsEditProperty::dt) ? NS_LITERAL_STRING("dd") : NS_LITERAL_STRING("dt"));
           nsCOMPtr<nsIDOMNode> newListItem;
           res = mHTMLEditor->CreateNode(listTag, list, itemOffset+1, getter_AddRefs(newListItem));
           NS_ENSURE_SUCCESS(res, res);
           res = mEditor->DeleteNode(aListItem);
           NS_ENSURE_SUCCESS(res, res);
           return aSelection->Collapse(newListItem, 0);
         }
 
         nsCOMPtr<nsIDOMNode> brNode;
         res = mHTMLEditor->CopyLastEditableChildStyles(prevItem, aListItem, getter_AddRefs(brNode));
         NS_ENSURE_SUCCESS(res, res);
         if (brNode) 
         {
-          nsCOMPtr<nsIDOMNode> brParent;
           PRInt32 offset;
-          nsEditor::GetNodeLocation(brNode, address_of(brParent), &offset);
+          nsCOMPtr<nsIDOMNode> brParent = nsEditor::GetNodeLocation(brNode, &offset);
           return aSelection->Collapse(brParent, offset);
         }
       }
       else
       {
         nsWSRunObject wsObj(mHTMLEditor, aListItem, 0);
         nsCOMPtr<nsIDOMNode> visNode;
         PRInt32 visOffset = 0;
         PRInt16 wsType;
         wsObj.NextVisibleNode(aListItem, 0, address_of(visNode),
                               &visOffset, &wsType);
         if ( (wsType==nsWSRunObject::eSpecial)  || 
              (wsType==nsWSRunObject::eBreak)    ||
              nsHTMLEditUtils::IsHR(visNode) ) 
         {
-          nsCOMPtr<nsIDOMNode> parent;
           PRInt32 offset;
-          nsEditor::GetNodeLocation(visNode, address_of(parent), &offset);
+          nsCOMPtr<nsIDOMNode> parent = nsEditor::GetNodeLocation(visNode, &offset);
           return aSelection->Collapse(parent, offset);
         }
         else
         {
           return aSelection->Collapse(visNode, visOffset);
         }
       }
     }
@@ -6675,17 +6657,17 @@ nsHTMLEditRules::MakeBlockquote(nsCOMArr
   
   nsCOMPtr<nsIDOMNode> prevParent;
   
   PRInt32 i;
   for (i=0; i<listCount; i++)
   {
     // get the node to act on, and its location
     curNode = arrayOfNodes[i];
-    nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset);
+    curParent = nsEditor::GetNodeLocation(curNode, &offset);
 
     // if the node is a table element or list item, dive inside
     if (nsHTMLEditUtils::IsTableElementButNotTable(curNode) || 
         nsHTMLEditUtils::IsListItem(curNode))
     {
       curBlock = 0;  // forget any previous block
       // recursion time
       nsCOMArray<nsIDOMNode> childArray;
@@ -6873,17 +6855,17 @@ nsHTMLEditRules::ApplyBlockStyle(nsCOMAr
   // reset list count
   listCount = arrayOfNodes.Count();
   
   PRInt32 i;
   for (i=0; i<listCount; i++)
   {
     // get the node to act on, and its location
     curNode = arrayOfNodes[i];
-    nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset);
+    curParent = nsEditor::GetNodeLocation(curNode, &offset);
     nsAutoString curNodeTag;
     nsEditor::GetTagString(curNode, curNodeTag);
     ToLowerCase(curNodeTag);
  
     // is it already the right kind of block?
     if (curNodeTag == *aBlockTag)
     {
       curBlock = 0;  // forget any previous block used for previous inline nodes
@@ -7065,18 +7047,18 @@ nsHTMLEditRules::JoinNodesSmart( nsIDOMN
       aNodeRight && 
       aOutMergeParent &&
       aOutMergeOffset, NS_ERROR_NULL_POINTER);
   
   nsresult res = NS_OK;
   // caller responsible for:
   //   left & right node are same type
   PRInt32 parOffset;
-  nsCOMPtr<nsIDOMNode> parent, rightParent;
-  nsEditor::GetNodeLocation(aNodeLeft, address_of(parent), &parOffset);
+  nsCOMPtr<nsIDOMNode> rightParent;
+  nsCOMPtr<nsIDOMNode> parent = nsEditor::GetNodeLocation(aNodeLeft, &parOffset);
   aNodeRight->GetParentNode(getter_AddRefs(rightParent));
 
   // if they don't have the same parent, first move the 'right' node 
   // to after the 'left' one
   if (parent != rightParent)
   {
     res = mHTMLEditor->MoveNode(aNodeRight, parent, parOffset);
     NS_ENSURE_SUCCESS(res, res);
@@ -7337,34 +7319,30 @@ nsHTMLEditRules::PinSelectionToNewBlock(
     PRUint32 endPoint;
     if (mHTMLEditor->IsTextNode(tmp) || mHTMLEditor->IsContainer(tmp))
     {
       res = nsEditor::GetLengthOfDOMNode(tmp, endPoint);
       NS_ENSURE_SUCCESS(res, res);
     }
     else
     {
-      nsCOMPtr<nsIDOMNode> tmp2;
-      nsEditor::GetNodeLocation(tmp, address_of(tmp2), (PRInt32*)&endPoint);
-      tmp = tmp2;
+      tmp = nsEditor::GetNodeLocation(tmp, (PRInt32*)&endPoint);
       endPoint++;  // want to be after this node
     }
     return aSelection->Collapse(tmp, (PRInt32)endPoint);
   }
   else
   {
     // selection is before block.  put at start of block.
     nsCOMPtr<nsIDOMNode> tmp = mNewBlock;
     mHTMLEditor->GetFirstEditableChild(mNewBlock, address_of(tmp));
     PRInt32 offset;
     if (!(mHTMLEditor->IsTextNode(tmp) || mHTMLEditor->IsContainer(tmp)))
     {
-      nsCOMPtr<nsIDOMNode> tmp2;
-      nsEditor::GetNodeLocation(tmp, address_of(tmp2), &offset);
-      tmp = tmp2;
+      tmp = nsEditor::GetNodeLocation(tmp, &offset);
     }
     return aSelection->Collapse(tmp, 0);
   }
 }
 
 nsresult 
 nsHTMLEditRules::CheckInterlinePosition(nsISelection *aSelection)
 {
@@ -7428,17 +7406,17 @@ nsHTMLEditRules::AdjustSelection(nsISele
   nsresult res = mHTMLEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
   NS_ENSURE_SUCCESS(res, res);
   temp = selNode;
   
   // are we in an editable node?
   while (!mHTMLEditor->IsEditable(selNode))
   {
     // scan up the tree until we find an editable place to be
-    nsEditor::GetNodeLocation(temp, address_of(selNode), &selOffset);
+    selNode = nsEditor::GetNodeLocation(temp, &selOffset);
     NS_ENSURE_TRUE(selNode, NS_ERROR_FAILURE);
     temp = selNode;
   }
   
   // make sure we aren't in an empty block - user will see no cursor.  If this
   // is happening, put a <br> in the block if allowed.
   nsCOMPtr<nsIDOMNode> theblock;
   if (IsBlockNode(selNode)) theblock = selNode;
@@ -7491,17 +7469,17 @@ nsHTMLEditRules::AdjustSelection(nsISele
         if (!mHTMLEditor->IsVisBreak(nearNode))
         {
           // need to insert special moz BR. Why?  Because if we don't
           // the user will see no new line for the break.  Also, things
           // like table cells won't grow in height.
           nsCOMPtr<nsIDOMNode> brNode;
           res = CreateMozBR(selNode, selOffset, getter_AddRefs(brNode));
           NS_ENSURE_SUCCESS(res, res);
-          nsEditor::GetNodeLocation(brNode, address_of(selNode), &selOffset);
+          selNode = nsEditor::GetNodeLocation(brNode, &selOffset);
           // selection stays *before* moz-br, sticking to it
           selPriv->SetInterlinePosition(true);
           res = aSelection->Collapse(selNode,selOffset);
           NS_ENSURE_SUCCESS(res, res);
         }
         else
         {
           nsCOMPtr<nsIDOMNode> nextNode;
@@ -7547,17 +7525,17 @@ nsHTMLEditRules::AdjustSelection(nsISele
       PRInt32 offset = 0;
       // put selection in right place:
       if (aAction == nsIEditor::ePrevious)
         textNode->GetLength((PRUint32*)&offset);
       res = aSelection->Collapse(nearNode,offset);
     }
     else  // must be break or image
     {
-      nsEditor::GetNodeLocation(nearNode, address_of(selNode), &selOffset);
+      selNode = nsEditor::GetNodeLocation(nearNode, &selOffset);
       if (aAction == nsIEditor::ePrevious) selOffset++;  // want to be beyond it if we backed up to it
       res = aSelection->Collapse(selNode, selOffset);
     }
   }
   return res;
 }
 
 
@@ -7778,17 +7756,17 @@ nsHTMLEditRules::RemoveEmptyNodes()
     res = mHTMLEditor->IsEmptyNode(delNode, &bIsEmptyNode, false, true);
     NS_ENSURE_SUCCESS(res, res);
     if (!bIsEmptyNode)
     {
       // we are deleting a cite that has just a br.  We want to delete cite, 
       // but preserve br.
       nsCOMPtr<nsIDOMNode> parent, brNode;
       PRInt32 offset;
-      nsEditor::GetNodeLocation(delNode, address_of(parent), &offset);
+      parent = nsEditor::GetNodeLocation(delNode, &offset);
       res = mHTMLEditor->CreateBR(parent, offset, address_of(brNode));
       NS_ENSURE_SUCCESS(res, res);
     }
     res = mHTMLEditor->DeleteNode(delNode);
     NS_ENSURE_SUCCESS(res, res);
   }
   
   return res;
@@ -7904,29 +7882,27 @@ nsresult
 nsHTMLEditRules::PopListItem(nsIDOMNode *aListItem, bool *aOutOfList)
 {
   // check parms
   NS_ENSURE_TRUE(aListItem && aOutOfList, NS_ERROR_NULL_POINTER);
   
   // init out params
   *aOutOfList = false;
   
-  nsCOMPtr<nsIDOMNode> curParent;
   nsCOMPtr<nsIDOMNode> curNode( do_QueryInterface(aListItem));
   PRInt32 offset;
-  nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset);
+  nsCOMPtr<nsIDOMNode> curParent = nsEditor::GetNodeLocation(curNode, &offset);
     
   if (!nsHTMLEditUtils::IsListItem(curNode))
     return NS_ERROR_FAILURE;
     
   // if it's first or last list item, don't need to split the list
   // otherwise we do.
-  nsCOMPtr<nsIDOMNode> curParPar;
   PRInt32 parOffset;
-  nsEditor::GetNodeLocation(curParent, address_of(curParPar), &parOffset);
+  nsCOMPtr<nsIDOMNode> curParPar = nsEditor::GetNodeLocation(curParent, &parOffset);
   
   bool bIsFirstListItem;
   nsresult res = mHTMLEditor->IsFirstEditableChild(curNode, &bIsFirstListItem);
   NS_ENSURE_SUCCESS(res, res);
 
   bool bIsLastListItem;
   res = mHTMLEditor->IsLastEditableChild(curNode, &bIsLastListItem);
   NS_ENSURE_SUCCESS(res, res);
@@ -8697,17 +8673,17 @@ nsHTMLEditRules::WillAbsolutePosition(ns
   {
     // here's where we actually figure out what to do
     nsCOMPtr<nsIDOMNode> curNode = arrayOfNodes[i];
 
     // Ignore all non-editable nodes.  Leave them be.
     if (!mHTMLEditor->IsEditable(curNode)) continue;
 
     PRInt32 offset;
-    nsEditor::GetNodeLocation(curNode, address_of(curParent), &offset);
+    curParent = nsEditor::GetNodeLocation(curNode, &offset);
      
     // some logic for putting list items into nested lists...
     if (nsHTMLEditUtils::IsList(curParent))
     {
       // check to see if curList is still appropriate.  Which it is if
       // curNode is still right after it in the same list.
       if (curList)
       {
@@ -8720,19 +8696,17 @@ nsHTMLEditRules::WillAbsolutePosition(ns
         nsAutoString listTag;
         nsEditor::GetTagString(curParent,listTag);
         ToLowerCase(listTag);
         // create a new nested list of correct type
         res = SplitAsNeeded(&listTag, address_of(curParent), &offset);
         NS_ENSURE_SUCCESS(res, res);
         if (!curPositionedDiv) {
           PRInt32 parentOffset;
-          nsCOMPtr<nsIDOMNode> curParentParent;
-          nsEditor::GetNodeLocation(curParent, address_of(curParentParent),
-                                    &parentOffset);
+          nsCOMPtr<nsIDOMNode> curParentParent = nsEditor::GetNodeLocation(curParent, &parentOffset);
           res = mHTMLEditor->CreateNode(divType, curParentParent, parentOffset, getter_AddRefs(curPositionedDiv));
           mNewBlock = curPositionedDiv;
         }
         res = mHTMLEditor->CreateNode(listTag, curPositionedDiv, -1, getter_AddRefs(curList));
         NS_ENSURE_SUCCESS(res, res);
         // curList is now the correct thing to put curNode in
         // remember our new block for postprocessing
         // mNewBlock = curList;
@@ -8751,17 +8725,17 @@ nsHTMLEditRules::WillAbsolutePosition(ns
       // array of nodes to act on, that are in the same list item.  Since
       // we only want to indent that li once, we must keep track of the most
       // recent indented list item, and not indent it if we find another node
       // to act on that is still inside the same li.
       nsCOMPtr<nsIDOMNode> listitem=IsInListItem(curNode);
       if (listitem)
       {
         if (indentedLI == listitem) continue;  // already indented this list item
-        nsEditor::GetNodeLocation(listitem, address_of(curParent), &offset);
+        curParent = nsEditor::GetNodeLocation(listitem, &offset);
         // check to see if curList is still appropriate.  Which it is if
         // curNode is still right after it in the same list.
         if (curList)
         {
           sibling = nsnull;
           mHTMLEditor->GetPriorHTMLSibling(curNode, address_of(sibling));
         }
          
@@ -8770,19 +8744,17 @@ nsHTMLEditRules::WillAbsolutePosition(ns
           nsAutoString listTag;
           nsEditor::GetTagString(curParent,listTag);
           ToLowerCase(listTag);
           // create a new nested list of correct type
           res = SplitAsNeeded(&listTag, address_of(curParent), &offset);
           NS_ENSURE_SUCCESS(res, res);
           if (!curPositionedDiv) {
           PRInt32 parentOffset;
-          nsCOMPtr<nsIDOMNode> curParentParent;
-          nsEditor::GetNodeLocation(curParent, address_of(curParentParent),
-                                    &parentOffset);
+          nsCOMPtr<nsIDOMNode> curParentParent = nsEditor::GetNodeLocation(curParent, &parentOffset);
           res = mHTMLEditor->CreateNode(divType, curParentParent, parentOffset, getter_AddRefs(curPositionedDiv));
             mNewBlock = curPositionedDiv;
           }
           res = mHTMLEditor->CreateNode(listTag, curPositionedDiv, -1, getter_AddRefs(curList));
           NS_ENSURE_SUCCESS(res, res);
         }
         res = mHTMLEditor->MoveNode(listitem, curList, -1);
         NS_ENSURE_SUCCESS(res, res);
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -521,17 +521,17 @@ nsHTMLEditor::BeginningOfDocument()
     {
       selNode = visNode;
       selOffset = visOffset;
       done = true;
     }
     else if ((visType==nsWSRunObject::eBreak)    ||
              (visType==nsWSRunObject::eSpecial))
     {
-      GetNodeLocation(visNode, address_of(selNode), &selOffset);
+      selNode = GetNodeLocation(visNode, &selOffset);
       done = true;
     }
     else if (visType==nsWSRunObject::eOtherBlock)
     {
       // By definition of nsWSRunObject, a block element terminates 
       // a whitespace run. That is, although we are calling a method 
       // that is named "NextVisibleNode", the node returned
       // might not be visible/editable!
@@ -541,27 +541,27 @@ nsHTMLEditor::BeginningOfDocument()
       if (!IsContainer(visNode))
       {
         // However, we were given a block that is not a container.
         // Since the block can not contain anything that's visible,
         // such a block only makes sense if it is visible by itself,
         // like a <hr>
         // We want to place the caret in front of that block.
 
-        GetNodeLocation(visNode, address_of(selNode), &selOffset);
+        selNode = GetNodeLocation(visNode, &selOffset);
         done = true;
       }
       else
       {
         bool isEmptyBlock;
         if (NS_SUCCEEDED(IsEmptyNode(visNode, &isEmptyBlock)) &&
             isEmptyBlock)
         {
           // skip the empty block
-          GetNodeLocation(visNode, address_of(curNode), &curOffset);
+          curNode = GetNodeLocation(visNode, &curOffset);
           ++curOffset;
         }
         else
         {
           curNode = visNode;
           curOffset = 0;
         }
         // keep looping
@@ -936,17 +936,17 @@ bool nsHTMLEditor::IsVisBreak(nsIDOMNode
   NS_ENSURE_TRUE(nextNode, false);  // this break is trailer in block, it's not visible
   if (IsBlockNode(nextNode))
     return false; // break is right before a block, it's not visible
     
   // sigh.  We have to use expensive whitespace calculation code to 
   // determine what is going on
   nsCOMPtr<nsIDOMNode> selNode, tmp;
   PRInt32 selOffset;
-  GetNodeLocation(aNode, address_of(selNode), &selOffset);
+  selNode = GetNodeLocation(aNode, &selOffset);
   selOffset++; // lets look after the break
   nsWSRunObject wsObj(this, selNode, selOffset);
   nsCOMPtr<nsIDOMNode> visNode;
   PRInt32 visOffset=0;
   PRInt16 visType=0;
   wsObj.NextVisibleNode(selNode, selOffset, address_of(visNode), &visOffset, &visType);
   if (visType & nsWSRunObject::eBlock)
     return false;
@@ -1463,20 +1463,18 @@ nsHTMLEditor::NormalizeEOLInsertPosition
     return;
 
   if (prevVisType & nsWSRunObject::eBreak)
     return;
 
   if (prevVisType & nsWSRunObject::eThisBlock)
     return;
 
-  nsCOMPtr<nsIDOMNode> brNode;
   PRInt32 brOffset=0;
-
-  GetNodeLocation(nextVisNode, address_of(brNode), &brOffset);
+  nsCOMPtr<nsIDOMNode> brNode = GetNodeLocation(nextVisNode, &brOffset);
 
   *insertParentNode = brNode;
   *insertOffset = brOffset + 1;
 }
 
 NS_IMETHODIMP
 nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSelection)
 {
--- a/editor/libeditor/html/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/html/nsHTMLEditorStyle.cpp
@@ -932,39 +932,39 @@ nsresult nsHTMLEditor::PromoteRangeIfSta
   res = inRange->GetEndOffset(&endOffset);
   NS_ENSURE_SUCCESS(res, res);
 
   tmp = startNode;
   while ( tmp && 
           !nsTextEditUtils::IsBody(tmp) &&
           !nsHTMLEditUtils::IsNamedAnchor(tmp))
   {
-    GetNodeLocation(tmp, address_of(parent), &tmpOffset);
+    parent = GetNodeLocation(tmp, &tmpOffset);
     tmp = parent;
   }
   NS_ENSURE_TRUE(tmp, NS_ERROR_NULL_POINTER);
   if (nsHTMLEditUtils::IsNamedAnchor(tmp))
   {
-    GetNodeLocation(tmp, address_of(parent), &tmpOffset);
+    parent = GetNodeLocation(tmp, &tmpOffset);
     startNode = parent;
     startOffset = tmpOffset;
   }
 
   tmp = endNode;
   while ( tmp && 
           !nsTextEditUtils::IsBody(tmp) &&
           !nsHTMLEditUtils::IsNamedAnchor(tmp))
   {
-    GetNodeLocation(tmp, address_of(parent), &tmpOffset);
+    parent = GetNodeLocation(tmp, &tmpOffset);
     tmp = parent;
   }
   NS_ENSURE_TRUE(tmp, NS_ERROR_NULL_POINTER);
   if (nsHTMLEditUtils::IsNamedAnchor(tmp))
   {
-    GetNodeLocation(tmp, address_of(parent), &tmpOffset);
+    parent = GetNodeLocation(tmp, &tmpOffset);
     endNode = parent;
     endOffset = tmpOffset + 1;
   }
 
   res = inRange->SetStart(startNode, startOffset);
   NS_ENSURE_SUCCESS(res, res);
   res = inRange->SetEnd(endNode, endOffset);
   return res;
@@ -986,27 +986,27 @@ nsresult nsHTMLEditor::PromoteInlineRang
   res = inRange->GetEndOffset(&endOffset);
   NS_ENSURE_SUCCESS(res, res);
   
   while ( startNode && 
           !nsTextEditUtils::IsBody(startNode) && 
           IsEditable(startNode) &&
           IsAtFrontOfNode(startNode, startOffset) )
   {
-    GetNodeLocation(startNode, address_of(parent), &startOffset);
+    parent = GetNodeLocation(startNode, &startOffset);
     startNode = parent;
   }
   NS_ENSURE_TRUE(startNode, NS_ERROR_NULL_POINTER);
   
   while ( endNode && 
           !nsTextEditUtils::IsBody(endNode) && 
           IsEditable(endNode) &&
           IsAtEndOfNode(endNode, endOffset) )
   {
-    GetNodeLocation(endNode, address_of(parent), &endOffset);
+    parent = GetNodeLocation(endNode, &endOffset);
     endNode = parent;
     endOffset++;  // we are AFTER this node
   }
   NS_ENSURE_TRUE(endNode, NS_ERROR_NULL_POINTER);
   
   res = inRange->SetStart(startNode, startOffset);
   NS_ENSURE_SUCCESS(res, res);
   res = inRange->SetEnd(endNode, endOffset);
--- a/editor/libeditor/html/nsWSRunObject.cpp
+++ b/editor/libeditor/html/nsWSRunObject.cpp
@@ -111,19 +111,18 @@ nsWSRunObject::PrepareToDeleteRange(nsHT
 }
 
 nsresult 
 nsWSRunObject::PrepareToDeleteNode(nsHTMLEditor *aHTMLEd, 
                                    nsIDOMNode *aNode)
 {
   NS_ENSURE_TRUE(aNode && aHTMLEd, NS_ERROR_NULL_POINTER);
   
-  nsCOMPtr<nsIDOMNode> parent;
   PRInt32 offset;
-  aHTMLEd->GetNodeLocation(aNode, address_of(parent), &offset);
+  nsCOMPtr<nsIDOMNode> parent = aHTMLEd->GetNodeLocation(aNode, &offset);
   
   nsWSRunObject leftWSObj(aHTMLEd, parent, offset);
   nsWSRunObject rightWSObj(aHTMLEd, parent, offset+1);
 
   return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
 }
 
 nsresult 
--- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp
@@ -223,18 +223,17 @@ nsresult nsPlaintextEditor::InsertFromDr
     // subtree so make sure the content we insert goes before
     // the root of the subtree.
     //
     // XXX: Note that inserting before the subtree matches the
     //      current behavior when dropping on top of an image.
     //      The decision for dropping before or after the
     //      subtree should really be done based on coordinates.
 
-    GetNodeLocation(userSelectNode, address_of(newSelectionParent),
-                    &newSelectionOffset);
+    newSelectionParent = GetNodeLocation(userSelectNode, &newSelectionOffset);
 
     NS_ENSURE_TRUE(newSelectionParent, NS_ERROR_FAILURE);
   }
 
   // Check if mouse is in the selection
   // if so, jump through some hoops to determine if mouse is over selection (bail)
   // and whether user wants to copy selection or delete it
   if (!isCollapsed)
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -422,37 +422,36 @@ nsPlaintextEditor::CreateBRImpl(nsCOMPtr
   // we need to insert a br.  unfortunately, we may have to split a text node to do it.
   nsCOMPtr<nsIDOMNode> node = *aInOutParent;
   PRInt32 theOffset = *aInOutOffset;
   nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(node);
   NS_NAMED_LITERAL_STRING(brType, "br");
   nsCOMPtr<nsIDOMNode> brNode;
   if (nodeAsText)  
   {
-    nsCOMPtr<nsIDOMNode> tmp;
     PRInt32 offset;
     PRUint32 len;
     nodeAsText->GetLength(&len);
-    GetNodeLocation(node, address_of(tmp), &offset);
+    nsCOMPtr<nsIDOMNode> tmp = GetNodeLocation(node, &offset);
     NS_ENSURE_TRUE(tmp, NS_ERROR_FAILURE);
     if (!theOffset)
     {
       // we are already set to go
     }
     else if (theOffset == (PRInt32)len)
     {
       // update offset to point AFTER the text node
       offset++;
     }
     else
     {
       // split the text node
       res = SplitNode(node, theOffset, getter_AddRefs(tmp));
       NS_ENSURE_SUCCESS(res, res);
-      GetNodeLocation(node, address_of(tmp), &offset);
+      tmp = GetNodeLocation(node, &offset);
     }
     // create br
     res = CreateNode(brType, tmp, offset, getter_AddRefs(brNode));
     NS_ENSURE_SUCCESS(res, res);
     *aInOutParent = tmp;
     *aInOutOffset = offset+1;
   }
   else
@@ -460,19 +459,18 @@ nsPlaintextEditor::CreateBRImpl(nsCOMPtr
     res = CreateNode(brType, node, theOffset, getter_AddRefs(brNode));
     NS_ENSURE_SUCCESS(res, res);
     (*aInOutOffset)++;
   }
 
   *outBRNode = brNode;
   if (*outBRNode && (aSelect != eNone))
   {
-    nsCOMPtr<nsIDOMNode> parent;
     PRInt32 offset;
-    GetNodeLocation(*outBRNode, address_of(parent), &offset);
+    nsCOMPtr<nsIDOMNode> parent = GetNodeLocation(*outBRNode, &offset);
 
     nsCOMPtr<nsISelection> selection;
     res = GetSelection(getter_AddRefs(selection));
     NS_ENSURE_SUCCESS(res, res);
     nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
     if (aSelect == eNext)
     {
       // position selection after br
@@ -519,17 +517,17 @@ nsPlaintextEditor::InsertBR(nsCOMPtr<nsI
   PRInt32 selOffset;
   res = GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
   NS_ENSURE_SUCCESS(res, res);
   
   res = CreateBR(selNode, selOffset, outBRNode);
   NS_ENSURE_SUCCESS(res, res);
     
   // position selection after br
-  GetNodeLocation(*outBRNode, address_of(selNode), &selOffset);
+  selNode = GetNodeLocation(*outBRNode, &selOffset);
   nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
   selPriv->SetInterlinePosition(true);
   return selection->Collapse(selNode, selOffset+1);
 }
 
 nsresult
 nsPlaintextEditor::ExtendSelectionForDelete(nsISelection *aSelection,
                                             nsIEditor::EDirection *aAction)
@@ -1560,19 +1558,18 @@ nsPlaintextEditor::SelectEntireDocument(
   PRInt32 selOffset;
   nsCOMPtr<nsIDOMNode> selNode;
   rv = GetEndNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDOMNode> childNode = GetChildAt(selNode, selOffset - 1);
 
   if (childNode && nsTextEditUtils::IsMozBR(childNode)) {
-    nsCOMPtr<nsIDOMNode> parentNode;
     PRInt32 parentOffset;
-    GetNodeLocation(childNode, address_of(parentNode), &parentOffset);
+    nsCOMPtr<nsIDOMNode> parentNode = GetNodeLocation(childNode, &parentOffset);
 
     return aSelection->Extend(parentNode, parentOffset);
   }
 
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMEventTarget>
--- a/editor/libeditor/text/nsTextEditRules.cpp
+++ b/editor/libeditor/text/nsTextEditRules.cpp
@@ -412,19 +412,18 @@ nsTextEditRules::CollapseSelectionToTrai
   PRUint32 length;
   res = nodeAsText->GetLength(&length);
   NS_ENSURE_SUCCESS(res, res);
 
   // nothing to do if we're not at the end of the text node
   if (selOffset != PRInt32(length))
     return NS_OK;
 
-  nsCOMPtr<nsIDOMNode> parentNode;
   PRInt32 parentOffset;
-  nsEditor::GetNodeLocation(selNode, address_of(parentNode), &parentOffset);
+  nsCOMPtr<nsIDOMNode> parentNode = nsEditor::GetNodeLocation(selNode, &parentOffset);
 
   nsCOMPtr<nsIDOMNode> root = do_QueryInterface(mEditor->GetRoot());
   NS_ENSURE_TRUE(root, NS_ERROR_NULL_POINTER);
   if (parentNode != root) return NS_OK;
 
   nsCOMPtr<nsIDOMNode> nextNode = mEditor->GetChildAt(parentNode,
                                                       parentOffset + 1);
   if (nextNode && nsTextEditUtils::IsMozBR(nextNode))