newElement->SetAttribute("_moz_dirty", "");
newElement->SetAttribute(NS_LITERAL_STRING("_moz_dirty"), nsAutoString());
nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement** aReturn){  nsresult res=NS_ERROR_NOT_INITIALIZED;  if (aReturn)    *aReturn = nsnull;  if (aTagName == "" || !aReturn)    return NS_ERROR_NULL_POINTER;      nsAutoString TagName = aTagName;  TagName.ToLowerCase();  nsAutoString realTagName;  if (IsLink(TagName) || IsNamedAnchor(TagName))  {    realTagName = "a";  } else {    realTagName = TagName;  }  //We don't use editor's CreateElement because we don't want to   //  go through the transaction system  nsCOMPtr<nsIDOMElement>newElement;  nsCOMPtr<nsIDOMDocument> doc = do_QueryReferent(mDocWeak);  if (!doc) return NS_ERROR_NOT_INITIALIZED;  res = doc->CreateElement(realTagName, getter_AddRefs(newElement));  if (NS_FAILED(res) || !newElement)    return NS_ERROR_FAILURE;  // Mark the new element dirty, so it will be formatted  newElement->SetAttribute("_moz_dirty", "");  // Set default values for new elements  if (TagName.Equals("hr"))  {    // Note that we read the user's attributes for these from prefs (in InsertHLine JS)    newElement->SetAttribute("align","center");    newElement->SetAttribute("width","100%");    newElement->SetAttribute("size","2");  } else if (TagName.Equals("table"))  {    newElement->SetAttribute("cellpadding","2");    newElement->SetAttribute("cellspacing","2");    newElement->SetAttribute("border","1");  } else if (TagName.Equals("tr"))  {    newElement->SetAttribute("valign","top");  } else if (TagName.Equals("td"))  {    newElement->SetAttribute("valign","top");// I'm def'ing this out to see if auto br insertion is working here#if 0    // Insert the default space in a cell so border displays    nsCOMPtr<nsIDOMNode> newCellNode = do_QueryInterface(newElement);    if (newCellNode)    {      // TODO: This should probably be in the RULES code or       //       preference based for "should we add the nbsp"      nsCOMPtr<nsIDOMText>newTextNode;      nsAutoString space;      // Set contents to the &nbsp character by concatanating the char code      space += nbsp;      // If we fail here, we return NS_OK anyway, since we have an OK cell node      nsresult result = doc->CreateTextNode(space, getter_AddRefs(newTextNode));      if (NS_FAILED(result)) return result;      if (!newTextNode) return NS_ERROR_NULL_POINTER;      nsCOMPtr<nsIDOMNode>resultNode;      result = newCellNode->AppendChild(newTextNode, getter_AddRefs(resultNode));    }#endif  }  // ADD OTHER TAGS HERE  if (NS_SUCCEEDED(res))  {    *aReturn = newElement;    // Getters must addref    NS_ADDREF(*aReturn);  }  return res;}