if (aNode != mCommonParent.get())
if (aNode != mCommonParent)
nsDocumentEncoder::SerializeRangeNodes(nsIDOMRange* aRange,                                        nsIDOMNode* aNode,                                        nsAString& aString,                                       PRInt32 aDepth){  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);  NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);  nsresult rv=NS_OK;    // get start and end nodes for this recursion level  nsCOMPtr<nsIContent> startNode, endNode;  PRInt32 start = mStartRootIndex - aDepth;  if (start >= 0 && start <= mStartNodes.Count())    startNode = NS_STATIC_CAST(nsIContent *, mStartNodes[start]);  PRInt32 end = mEndRootIndex - aDepth;  if (end >= 0 && end <= mEndNodes.Count())    endNode = NS_STATIC_CAST(nsIContent *, mEndNodes[end]);  if ((startNode != content) && (endNode != content))  {    // node is completely contained in range.  Serialize the whole subtree    // rooted by this node.    rv = SerializeToStringRecursive(aNode, aString);    NS_ENSURE_SUCCESS(rv, rv);  }  else  {    // due to implementation it is impossible for text node to be both start and end of     // range.  We would have handled that case without getting here.    if (IsTextNode(aNode))    {      if (startNode == content)      {        PRInt32 startOffset;        aRange->GetStartOffset(&startOffset);        rv = SerializeNodeStart(aNode, startOffset, -1, aString);        NS_ENSURE_SUCCESS(rv, rv);      }      else      {        PRInt32 endOffset;        aRange->GetEndOffset(&endOffset);        rv = SerializeNodeStart(aNode, 0, endOffset, aString);        NS_ENSURE_SUCCESS(rv, rv);      }    }    else    {      if (aNode != mCommonParent.get())      {        if (IncludeInContext(aNode))        {          // halt the incrementing of mStartDepth/mEndDepth.  This is          // so paste client will include this node in paste.          mHaltRangeHint = PR_TRUE;        }        if ((startNode == content) && !mHaltRangeHint) mStartDepth++;        if ((endNode == content) && !mHaltRangeHint) mEndDepth++;              // serialize the start of this node        rv = SerializeNodeStart(aNode, 0, -1, aString);        NS_ENSURE_SUCCESS(rv, rv);      }            // do some calculations that will tell us which children of this      // node are in the range.      nsCOMPtr<nsIDOMNode> childAsNode;      PRInt32 startOffset = 0, endOffset = -1;      if (startNode == content && mStartRootIndex >= aDepth)        startOffset = NS_PTR_TO_INT32(mStartOffsets[mStartRootIndex - aDepth]);      if (endNode == content && mEndRootIndex >= aDepth)        endOffset = NS_PTR_TO_INT32(mEndOffsets[mEndRootIndex - aDepth]) ;      // generated content will cause offset values of -1 to be returned.        PRInt32 j;      PRUint32 childCount = content->GetChildCount();      if (startOffset == -1) startOffset = 0;      if (endOffset == -1) endOffset = childCount;      else      {        // if we are at the "tip" of the selection, endOffset is fine.        // otherwise, we need to add one.  This is because of the semantics        // of the offset list created by GetAncestorsAndOffsets().  The        // intermediate points on the list use the endOffset of the         // location of the ancestor, rather than just past it.  So we need        // to add one here in order to include it in the children we serialize.        nsCOMPtr<nsIDOMNode> endParent;        aRange->GetEndContainer(getter_AddRefs(endParent));        if (aNode != endParent.get())        {          endOffset++;        }      }      // serialize the children of this node that are in the range      for (j=startOffset; j<endOffset; j++)      {        childAsNode = do_QueryInterface(content->GetChildAt(j));        if ((j==startOffset) || (j==endOffset-1))          rv = SerializeRangeNodes(aRange, childAsNode, aString, aDepth+1);        else          rv = SerializeToStringRecursive(childAsNode, aString);        NS_ENSURE_SUCCESS(rv, rv);      }      // serialize the end of this node      if (aNode != mCommonParent.get())      {        rv = SerializeNodeEnd(aNode, aString);        NS_ENSURE_SUCCESS(rv, rv);       }    }  }  return NS_OK;}