nsCOMPtr<nsIParserService> parserService = do_GetService(kParserServiceCID, &rv); NS_ENSURE_SUCCESS(rv, rv);
nsIParserService* parserService = nsContentUtils::GetParserServiceWeakRef(); if (!parserService) return NS_ERROR_OUT_OF_MEMORY;
NS_CreateHTMLElement(nsIHTMLContent** aResult, nsINodeInfo *aNodeInfo,                     PRBool aCaseSensitive){  nsresult rv = NS_OK;  // Cache this service! The XML content sink uses this method!  nsCOMPtr<nsIParserService> parserService =    do_GetService(kParserServiceCID, &rv);  NS_ENSURE_SUCCESS(rv, rv);  nsCOMPtr<nsIAtom> name;  rv = aNodeInfo->GetNameAtom(*getter_AddRefs(name));  NS_ENSURE_SUCCESS(rv, rv);  // Find tag in tag table  PRInt32 id;  if (aCaseSensitive) {    parserService->HTMLCaseSensitiveAtomTagToId(name, &id);  } else {    parserService->HTMLAtomTagToId(name, &id);  }  if (aCaseSensitive) {    rv = MakeContentObject(nsHTMLTag(id), aNodeInfo, nsnull, nsnull,                           aResult, nsnull, PR_FALSE, PR_FALSE);  } else {    // Revese map id to name to get the correct character case in    // the tag name.    nsCOMPtr<nsINodeInfo> kungFuDeathGrip;    nsINodeInfo *nodeInfo = aNodeInfo;    if (nsHTMLTag(id) != eHTMLTag_userdefined) {      const PRUnichar *tag = nsnull;      parserService->HTMLIdToStringTag(id, &tag);      NS_ASSERTION(tag, "What? Reverse mapping of id to string broken!!!");      const PRUnichar *name_str = nsnull;      name->GetUnicode(&name_str);      NS_ASSERTION(name_str, "What? No string in atom?!?");      if (nsCRT::strcmp(tag, name_str) != 0) {        nsCOMPtr<nsIAtom> atom(dont_AddRef(NS_NewAtom(tag)));        rv = aNodeInfo->NameChanged(atom, *getter_AddRefs(kungFuDeathGrip));        NS_ENSURE_SUCCESS(rv, rv);        nodeInfo = kungFuDeathGrip;      }    }    rv = MakeContentObject(nsHTMLTag(id), nodeInfo, nsnull, nsnull, aResult,                           nsnull, PR_FALSE, PR_FALSE);  }  return rv;}