nsHTMLEditor::Indent(const nsString& aIndent)
nsHTMLEditor::Indent(const nsAReadableString& aIndent)
nsHTMLEditor::Indent(const nsString& aIndent){  nsresult res;  if (!mRules) { return NS_ERROR_NOT_INITIALIZED; }  PRBool cancel, handled;  PRInt32 theAction = nsHTMLEditRules::kIndent;  PRInt32 opID = kOpIndent;  if (aIndent == "outdent")  {    theAction = nsHTMLEditRules::kOutdent;    opID = kOpOutdent;  }  nsAutoEditBatch beginBatching(this);  nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);    // pre-process  nsCOMPtr<nsIDOMSelection> selection;  res = GetSelection(getter_AddRefs(selection));  if (NS_FAILED(res)) return res;  if (!selection) return NS_ERROR_NULL_POINTER;  nsTextRulesInfo ruleInfo(theAction);  res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);  if (cancel || (NS_FAILED(res))) return res;    if (!handled)  {    // Do default - insert a blockquote node if selection collapsed    nsCOMPtr<nsIDOMNode> node;    PRInt32 offset;    PRBool isCollapsed;    res = selection->GetIsCollapsed(&isCollapsed);    if (NS_FAILED(res)) return res;    res = GetStartNodeAndOffset(selection, &node, &offset);    if (!node) res = NS_ERROR_FAILURE;    if (NS_FAILED(res)) return res;      nsAutoString inward("indent");    if (aIndent == inward)    {      if (isCollapsed)      {        // have to find a place to put the blockquote        nsCOMPtr<nsIDOMNode> parent = node;        nsCOMPtr<nsIDOMNode> topChild = node;        nsCOMPtr<nsIDOMNode> tmp;        nsAutoString bq("blockquote");        while ( !CanContainTag(parent, bq))        {          parent->GetParentNode(getter_AddRefs(tmp));          if (!tmp) return NS_ERROR_FAILURE;          topChild = parent;          parent = tmp;        }            if (parent != node)        {          // we need to split up to the child of parent          res = SplitNodeDeep(topChild, node, offset, &offset);          if (NS_FAILED(res)) return res;        }        // make a blockquote        nsCOMPtr<nsIDOMNode> newBQ;        res = CreateNode(bq, parent, offset, getter_AddRefs(newBQ));        if (NS_FAILED(res)) return res;        // put a space in it so layout will draw the list item        res = selection->Collapse(newBQ,0);        if (NS_FAILED(res)) return res;        nsAutoString theText(" ");        res = InsertText(theText);        if (NS_FAILED(res)) return res;        // reposition selection to before the space character        res = GetStartNodeAndOffset(selection, &node, &offset);        if (NS_FAILED(res)) return res;        res = selection->Collapse(node,0);        if (NS_FAILED(res)) return res;      }    }  }  res = mRules->DidDoAction(selection, &ruleInfo, res);  return res;}