nsHTMLCopyEncoder::EncodeToStringWithContext(nsAString& aEncodedString,
nsDocumentEncoder::EncodeToStringWithContext(nsAString& aEncodedString,
nsHTMLCopyEncoder::EncodeToStringWithContext(nsAString& aEncodedString,                                              nsAString& aContextString,                                             nsAString& aInfoString){  nsresult rv = EncodeToString(aEncodedString);  NS_ENSURE_SUCCESS(rv, rv);  // do not encode any context info or range hints if we are in a text widget.  if (mIsTextWidget) return NS_OK;  // now encode common ancestors into aContextString.  Note that the common ancestors  // will be for the last range in the selection in the case of multirange selections.  // encoding ancestors every range in a multirange selection in a way that could be   // understood by the paste code would be a lot more work to do.  As a practical matter,  // selections are single range, and the ones that aren't are table cell selections  // where all the cells are in the same table.  // leaf of ancestors might be text node.  If so discard it.  PRInt32 count = mCommonAncestors.Count();  PRInt32 i;  nsCOMPtr<nsIDOMNode> node;  if (count > 0)    node = NS_STATIC_CAST(nsIDOMNode *, mCommonAncestors.ElementAt(0));  if (node && IsTextNode(node))   {    mCommonAncestors.RemoveElementAt(0);    // don't forget to adjust range depth info    if (mStartDepth) mStartDepth--;    if (mEndDepth) mEndDepth--;    // and the count    count--;  }    i = count;  while (i > 0)  {    node = NS_STATIC_CAST(nsIDOMNode *, mCommonAncestors.ElementAt(--i));    SerializeNodeStart(node, 0, -1, aContextString);  }  //i = 0; guaranteed by above  while (i < count)  {    node = NS_STATIC_CAST(nsIDOMNode *, mCommonAncestors.ElementAt(i++));    SerializeNodeEnd(node, aContextString);  }  // encode range info : the start and end depth of the selection, where the depth is   // distance down in the parent hierarchy.  Later we will need to add leading/trailing  // whitespace info to this.  nsAutoString infoString;  infoString.AppendInt(mStartDepth);  infoString.Append(PRUnichar(','));  infoString.AppendInt(mEndDepth);  aInfoString = infoString;    return NS_OK;}