if (quotesInPre) {  preElement->SetAttribute(NS_LITERAL_STRING("style"), NS_LITERAL_STRING("margin: 0 0 0 0px;")); } else {  preElement->SetAttribute(NS_LITERAL_STRING("style"), NS_LITERAL_STRING("white-space: pre;")); }
preElement->SetAttribute(NS_LITERAL_STRING("style"), NS_LITERAL_STRING("margin: 0 0 0 0px;"));
nsHTMLEditor::InsertAsPlaintextQuotation(const nsAReadableString & aQuotedText,                                         nsIDOMNode **aNodeInserted){  nsresult rv;  // The quotesPreformatted pref is a temporary measure. See bug 69638.  // Eventually we'll pick one way or the other.  PRBool quotesInPre;  nsCOMPtr<nsIPref> prefs = do_GetService(kPrefServiceCID, &rv);  if (NS_SUCCEEDED(rv) && prefs)    rv = prefs->GetBoolPref("editor.quotesPreformatted", &quotesInPre);  nsCOMPtr<nsIDOMNode> preNode;  // get selection  nsCOMPtr<nsISelection> selection;  rv = GetSelection(getter_AddRefs(selection));  if (NS_FAILED(rv)) return rv;  if (!selection) return NS_ERROR_NULL_POINTER;  else  {    nsAutoEditBatch beginBatching(this);    nsAutoRules beginRulesSniffing(this, kOpInsertQuotation, nsIEditor::eNext);    // give rules a chance to handle or cancel    nsTextRulesInfo ruleInfo(nsTextEditRules::kInsertElement);    PRBool cancel, handled;    rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);    if (NS_FAILED(rv)) return rv;    if (cancel) return NS_OK; // rules canceled the operation    if (!handled)    {      // Wrap the inserted quote in a <pre> so it won't be wrapped:      nsAutoString tag;      if (quotesInPre)        tag.Assign(NS_LITERAL_STRING("pre"));      else        tag.Assign(NS_LITERAL_STRING("span"));      rv = DeleteSelectionAndCreateNode(tag, getter_AddRefs(preNode));            // If this succeeded, then set selection inside the pre      // so the inserted text will end up there.      // If it failed, we don't care what the return value was,      // but we'll fall through and try to insert the text anyway.      if (NS_SUCCEEDED(rv) && preNode)      {        // Add an attribute on the pre node so we'll know it's a quotation.        // Do this after the insertion, so that         nsCOMPtr<nsIDOMElement> preElement (do_QueryInterface(preNode));        if (preElement)        {          preElement->SetAttribute(NS_LITERAL_STRING("_moz_quote"),                                   NS_LITERAL_STRING("true"));          if (quotesInPre)          {            // set style to not have unwanted vertical margins            preElement->SetAttribute(NS_LITERAL_STRING("style"),                                     NS_LITERAL_STRING("margin: 0 0 0 0px;"));          }          else          {            // turn off wrapping on spans            preElement->SetAttribute(NS_LITERAL_STRING("style"),                                     NS_LITERAL_STRING("white-space: pre;"));          }        }        // and set the selection inside it:        selection->Collapse(preNode, 0);      }      //rv = InsertText(quotedStuff.get());      rv = nsPlaintextEditor::InsertAsQuotation(aQuotedText, aNodeInserted);      if (aNodeInserted && NS_SUCCEEDED(rv))      {        *aNodeInserted = preNode;        NS_IF_ADDREF(*aNodeInserted);      }    }  }      // Set the selection to just after the inserted node:  if (NS_SUCCEEDED(rv) && preNode)  {    nsCOMPtr<nsIDOMNode> parent;    PRInt32 offset;    if (NS_SUCCEEDED(GetNodeLocation(preNode, address_of(parent), &offset)) && parent)      selection->Collapse(parent, offset+1);  }  return rv;}