parserService->HTMLAtomTagToId(atom, &id);
parserService->HTMLAtomTagToId(content->Tag(), &id);
nsHTMLCopyEncoder::GetPromotedPoint(Endpoint aWhere, nsIDOMNode *aNode, PRInt32 aOffset,                                   nsCOMPtr<nsIDOMNode> *outNode, PRInt32 *outOffset, nsIDOMNode *common){  nsresult rv = NS_OK;  nsCOMPtr<nsIDOMNode> node = aNode;  nsCOMPtr<nsIDOMNode> parent = aNode;  PRInt32 offset = aOffset;  PRBool  bResetPromotion = PR_FALSE;    // default values  *outNode = node;  *outOffset = offset;  if (common == node)     return NS_OK;      if (aWhere == kStart)  {    // some special casing for text nodes    if (IsTextNode(aNode))      {      // if not at beginning of text node, we are done      if (offset >  0)       {        // unless everything before us in just whitespace.  NOTE: we need a more        // general solution that truly detects all cases of non-significant        // whitesace with no false alarms.        nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(aNode);        nsAutoString text;        nodeAsText->SubstringData(0, offset, text);        text.CompressWhitespace();        if (!text.IsEmpty())          return NS_OK;        bResetPromotion = PR_TRUE;      }      // else      rv = GetNodeLocation(aNode, address_of(parent), &offset);      NS_ENSURE_SUCCESS(rv, rv);    }    else    {      node = GetChildAt(parent,offset);    }    if (!node) node = parent;    // finding the real start for this point.  look up the tree for as long as we are the     // first node in the container, and as long as we haven't hit the body node.    if (!IsRoot(node) && (parent != common))    {      rv = GetNodeLocation(node, address_of(parent), &offset);      NS_ENSURE_SUCCESS(rv, rv);      if (offset == -1) return NS_OK; // we hit generated content; STOP      nsIParserService *parserService =        nsContentUtils::GetParserServiceWeakRef();      if (!parserService)        return NS_ERROR_OUT_OF_MEMORY;      while ((IsFirstNode(node)) && (!IsRoot(parent)) && (parent != common))      {        if (bResetPromotion)        {          nsCOMPtr<nsIContent> content = do_QueryInterface(parent);          if (content)          {            nsCOMPtr<nsIAtom> atom;            content->GetTag(getter_AddRefs(atom));            PRInt32 id;            parserService->HTMLAtomTagToId(atom, &id);            PRBool isBlock = PR_FALSE;            parserService->IsBlock(id, isBlock);            if (isBlock)            {              bResetPromotion = PR_FALSE;            }          }           }                 node = parent;        rv = GetNodeLocation(node, address_of(parent), &offset);        NS_ENSURE_SUCCESS(rv, rv);        if (offset == -1)  // we hit generated content; STOP        {          // back up a bit          parent = node;          offset = 0;          break;        }      }       if (bResetPromotion)      {        *outNode = aNode;        *outOffset = aOffset;      }      else      {        *outNode = parent;        *outOffset = offset;      }      return rv;    }  }    if (aWhere == kEnd)  {    // some special casing for text nodes    if (IsTextNode(aNode))      {      // if not at end of text node, we are done      PRUint32 len;      GetLengthOfDOMNode(aNode, len);      if (offset < (PRInt32)len)      {        // unless everything after us in just whitespace.  NOTE: we need a more        // general solution that truly detects all cases of non-significant        // whitesace with no false alarms.        nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(aNode);        nsAutoString text;        nodeAsText->SubstringData(offset, len-offset, text);        text.CompressWhitespace();        if (!text.IsEmpty())          return NS_OK;        bResetPromotion = PR_TRUE;      }      rv = GetNodeLocation(aNode, address_of(parent), &offset);      NS_ENSURE_SUCCESS(rv, rv);    }    else    {      if (offset) offset--; // we want node _before_ offset      node = GetChildAt(parent,offset);    }    if (!node) node = parent;        // finding the real end for this point.  look up the tree for as long as we are the     // last node in the container, and as long as we haven't hit the body node.    if (!IsRoot(node) && (parent != common))    {      rv = GetNodeLocation(node, address_of(parent), &offset);      NS_ENSURE_SUCCESS(rv, rv);      if (offset == -1) return NS_OK; // we hit generated content; STOP      nsIParserService *parserService =        nsContentUtils::GetParserServiceWeakRef();      if (!parserService)        return NS_ERROR_OUT_OF_MEMORY;      while ((IsLastNode(node)) && (!IsRoot(parent)) && (parent != common))      {        if (bResetPromotion)        {          nsCOMPtr<nsIContent> content = do_QueryInterface(parent);          if (content)          {            nsCOMPtr<nsIAtom> atom;            content->GetTag(getter_AddRefs(atom));            PRInt32 id;            parserService->HTMLAtomTagToId(atom, &id);            PRBool isBlock = PR_FALSE;            parserService->IsBlock(id, isBlock);            if (isBlock)            {              bResetPromotion = PR_FALSE;            }          }           }                  node = parent;        rv = GetNodeLocation(node, address_of(parent), &offset);        NS_ENSURE_SUCCESS(rv, rv);        if (offset == -1)  // we hit generated content; STOP        {          // back up a bit          parent = node;          offset = 0;          break;        }      }       if (bResetPromotion)      {        *outNode = aNode;        *outOffset = aOffset;      }      else      {        *outNode = parent;        offset++;  // add one since this in an endpoint - want to be AFTER node.        *outOffset = offset;      }      return rv;    }  }    return rv;}