Bug 748303 part 3 - Convert (Tag)CanContain(Tag) to nsIAtom*; r=ehsan
authorAryeh Gregor <ayg@aryeh.name>
Tue, 01 May 2012 09:34:52 +0300
changeset 93166 d2596504ce974b94bfcf5312b377a3b3ead016d6
parent 93165 7b44d184f51b36ccfa54ffc1bf7d4bdbb2ed05d4
child 93167 9498c59bfeb1aab7b5f65e877ba395b9cedeb4c5
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersehsan
bugs748303
milestone15.0a1
Bug 748303 part 3 - Convert (Tag)CanContain(Tag) to nsIAtom*; r=ehsan
editor/libeditor/base/nsEditor.cpp
editor/libeditor/base/nsEditor.h
editor/libeditor/html/nsHTMLEditRules.cpp
editor/libeditor/html/nsHTMLEditor.cpp
editor/libeditor/html/nsHTMLEditor.h
editor/libeditor/html/nsHTMLEditorStyle.cpp
editor/libeditor/text/nsPlaintextEditor.cpp
editor/libeditor/text/nsTextEditRules.cpp
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -3526,55 +3526,45 @@ nsEditor::IsBlockNode(nsINode *aNode)
   // to not duplicate the code in GetNextNode/GetPrevNode
   // across both nsEditor/nsHTMLEditor.
   return false;
 }
 
 bool
 nsEditor::CanContain(nsIDOMNode* aParent, nsIDOMNode* aChild)
 {
-  nsCOMPtr<nsIDOMElement> parentElement = do_QueryInterface(aParent);
+  nsCOMPtr<dom::Element> parentElement = do_QueryInterface(aParent);
   NS_ENSURE_TRUE(parentElement, false);
 
-  nsAutoString parentStringTag;
-  parentElement->GetTagName(parentStringTag);
-  return TagCanContain(parentStringTag, aChild);
+  return TagCanContain(parentElement->Tag(), aChild);
 }
 
 bool
-nsEditor::CanContainTag(nsIDOMNode* aParent, const nsAString &aChildTag)
-{
-  nsCOMPtr<nsIDOMElement> parentElement = do_QueryInterface(aParent);
+nsEditor::CanContainTag(nsIDOMNode* aParent, nsIAtom* aChildTag)
+{
+  nsCOMPtr<dom::Element> parentElement = do_QueryInterface(aParent);
   NS_ENSURE_TRUE(parentElement, false);
-  
-  nsAutoString parentStringTag;
-  parentElement->GetTagName(parentStringTag);
-  return TagCanContainTag(parentStringTag, aChildTag);
+
+  return TagCanContainTag(parentElement->Tag(), aChildTag);
 }
 
 bool 
-nsEditor::TagCanContain(const nsAString &aParentTag, nsIDOMNode* aChild)
-{
-  nsAutoString childStringTag;
-  
-  if (IsTextNode(aChild)) 
-  {
-    childStringTag.AssignLiteral("#text");
+nsEditor::TagCanContain(nsIAtom* aParentTag, nsIDOMNode* aChild)
+{
+  if (IsTextNode(aChild)) {
+    return TagCanContainTag(aParentTag, nsGkAtoms::textTagName);
   }
-  else
-  {
-    nsCOMPtr<nsIDOMElement> childElement = do_QueryInterface(aChild);
-    NS_ENSURE_TRUE(childElement, false);
-    childElement->GetTagName(childStringTag);
-  }
-  return TagCanContainTag(aParentTag, childStringTag);
+
+  nsCOMPtr<dom::Element> element = do_QueryInterface(aChild);
+  NS_ENSURE_TRUE(element, false);
+  return TagCanContainTag(aParentTag, element->Tag());
 }
 
 bool 
-nsEditor::TagCanContainTag(const nsAString &aParentTag, const nsAString &aChildTag)
+nsEditor::TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag)
 {
   return true;
 }
 
 bool
 nsEditor::IsRootNode(nsIDOMNode *inNode)
 {
   NS_ENSURE_TRUE(inNode, false);
--- a/editor/libeditor/base/nsEditor.h
+++ b/editor/libeditor/base/nsEditor.h
@@ -530,19 +530,19 @@ public:
   {
     nsIAtom *nodeAtom = GetTag(aNode);
     return nodeAtom && nodeAtom->Equals(aTag);
   }
 
 
   /** returns true if aParent can contain a child of type aTag */
   bool CanContain(nsIDOMNode* aParent, nsIDOMNode* aChild);
-  bool CanContainTag(nsIDOMNode* aParent, const nsAString &aTag);
-  bool TagCanContain(const nsAString &aParentTag, nsIDOMNode* aChild);
-  virtual bool TagCanContainTag(const nsAString &aParentTag, const nsAString &aChildTag);
+  bool CanContainTag(nsIDOMNode* aParent, nsIAtom* aTag);
+  bool TagCanContain(nsIAtom* aParentTag, nsIDOMNode* aChild);
+  virtual bool TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag);
 
   /** returns true if aNode is our root node */
   bool IsRootNode(nsIDOMNode *inNode);
   bool IsRootNode(nsINode *inNode);
 
   /** returns true if aNode is a descendant of our root node */
   bool IsDescendantOfBody(nsIDOMNode *inNode);
   bool IsDescendantOfBody(nsINode *inNode);
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -1323,18 +1323,19 @@ nsHTMLEditRules::WillInsertText(PRInt32 
   *aCancel = false;
   
   // get the (collapsed) selection location
   res = mHTMLEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
   NS_ENSURE_SUCCESS(res, res);
 
   // dont put text in places that can't have it
   if (!mHTMLEditor->IsTextNode(selNode) &&
-      !mHTMLEditor->CanContainTag(selNode, NS_LITERAL_STRING("#text")))
+      !mHTMLEditor->CanContainTag(selNode, nsGkAtoms::textTagName)) {
     return NS_ERROR_FAILURE;
+  }
 
   // we need to get the doc
   nsCOMPtr<nsIDOMDocument> doc = mHTMLEditor->GetDOMDocument();
   NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
     
   if (aAction == kInsertTextIME) 
   { 
     // Right now the nsWSRunObject code bails on empty strings, but IME needs 
@@ -2520,18 +2521,17 @@ nsHTMLEditRules::InsertBRIfNeeded(nsISel
 
   // examine selection
   nsWSRunObject wsObj(mHTMLEditor, node, offset);
   if (((wsObj.mStartReason & nsWSRunObject::eBlock) || (wsObj.mStartReason & nsWSRunObject::eBreak))
       && (wsObj.mEndReason & nsWSRunObject::eBlock))
   {
     // if we are tucked between block boundaries then insert a br
     // first check that we are allowed to
-    if (mHTMLEditor->CanContainTag(node, NS_LITERAL_STRING("br")))
-    {
+    if (mHTMLEditor->CanContainTag(node, nsGkAtoms::br)) {
       nsCOMPtr<nsIDOMNode> brNode;
       res = mHTMLEditor->CreateBR(node, offset, address_of(brNode), nsIEditor::ePrevious);
     }
   }
   return res;
 }
 
 /*****************************************************************************************************
@@ -2813,24 +2813,19 @@ nsHTMLEditRules::MoveBlock(nsIDOMNode *a
 *         nsIDOMNode *aDest         parent to receive moved content
 *         PRInt32 *aOffset          offset in aDest to move content to
 */
 nsresult
 nsHTMLEditRules::MoveNodeSmart(nsIDOMNode *aSource, nsIDOMNode *aDest, PRInt32 *aOffset)
 {
   NS_ENSURE_TRUE(aSource && aDest && aOffset, NS_ERROR_NULL_POINTER);
 
-  nsAutoString tag;
   nsresult res;
-  res = mHTMLEditor->GetTagString(aSource, tag);
-  NS_ENSURE_SUCCESS(res, res);
-  ToLowerCase(tag);
   // check if this node can go into the destination node
-  if (mHTMLEditor->CanContainTag(aDest, tag))
-  {
+  if (mHTMLEditor->CanContain(aDest, aSource)) {
     // if it can, move it there
     res = mHTMLEditor->MoveNode(aSource, aDest, *aOffset);
     NS_ENSURE_SUCCESS(res, res);
     if (*aOffset != -1) ++(*aOffset);
   }
   else
   {
     // if it can't, move its children, and then delete it.
@@ -3022,17 +3017,18 @@ nsHTMLEditRules::WillMakeList(nsISelecti
       }
     }
     
     // get selection location
     res = mHTMLEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(parent), &offset);
     NS_ENSURE_SUCCESS(res, res);
     
     // make sure we can put a list here
-    if (!mHTMLEditor->CanContainTag(parent, *aListType)) {
+    nsCOMPtr<nsIAtom> listTypeAtom = do_GetAtom(*aListType);
+    if (!mHTMLEditor->CanContainTag(parent, listTypeAtom)) {
       *aCancel = true;
       return NS_OK;
     }
     res = SplitAsNeeded(aListType, address_of(parent), &offset);
     NS_ENSURE_SUCCESS(res, res);
     res = mHTMLEditor->CreateNode(*aListType, parent, offset, getter_AddRefs(theList));
     NS_ENSURE_SUCCESS(res, res);
     res = mHTMLEditor->CreateNode(itemType, theList, 0, getter_AddRefs(theListItem));
@@ -3696,20 +3692,21 @@ nsHTMLEditRules::WillCSSIndent(nsISelect
       if (IsBlockNode(curNode)) {
         RelativeChangeIndentationOfElementNode(curNode, +1);
         curQuote = nsnull;
       }
       else {
         if (!curQuote)
         {
           // First, check that our element can contain a div.
+          if (!mEditor->CanContainTag(curParent, nsGkAtoms::div)) {
+            return NS_OK; // cancelled
+          }
+
           NS_NAMED_LITERAL_STRING(divquoteType, "div");
-          if (!mEditor->CanContainTag(curParent, divquoteType))
-            return NS_OK; // cancelled
-
           res = SplitAsNeeded(&divquoteType, address_of(curParent), &offset);
           NS_ENSURE_SUCCESS(res, res);
           res = mHTMLEditor->CreateNode(divquoteType, curParent, offset, getter_AddRefs(curQuote));
           NS_ENSURE_SUCCESS(res, res);
           RelativeChangeIndentationOfElementNode(curQuote, +1);
           // remember our new block for postprocessing
           mNewBlock = curQuote;
           // curQuote is now the correct thing to put curNode in
@@ -3927,18 +3924,19 @@ nsHTMLEditRules::WillHTMLIndent(nsISelec
           NS_ENSURE_SUCCESS(res, res);
           if (bInDifTblElems)
             curQuote = nsnull;
         }
         
         if (!curQuote) 
         {
           // First, check that our element can contain a blockquote.
-          if (!mEditor->CanContainTag(curParent, quoteType))
+          if (!mEditor->CanContainTag(curParent, nsGkAtoms::blockquote)) {
             return NS_OK; // cancelled
+          }
 
           res = SplitAsNeeded(&quoteType, address_of(curParent), &offset);
           NS_ENSURE_SUCCESS(res, res);
           res = mHTMLEditor->CreateNode(quoteType, curParent, offset, getter_AddRefs(curQuote));
           NS_ENSURE_SUCCESS(res, res);
           // remember our new block for postprocessing
           mNewBlock = curQuote;
           // curQuote is now the correct thing to put curNode in
@@ -4771,18 +4769,19 @@ nsHTMLEditRules::WillAlign(nsISelection 
     }      
 
     // need to make a div to put things in if we haven't already,
     // or if this node doesn't go in div we used earlier.
     if (!curDiv || transitionList[i])
     {
       // First, check that our element can contain a div.
       NS_NAMED_LITERAL_STRING(divType, "div");
-      if (!mEditor->CanContainTag(curParent, divType))
+      if (!mEditor->CanContainTag(curParent, nsGkAtoms::div)) {
         return NS_OK; // cancelled
+      }
 
       res = SplitAsNeeded(&divType, address_of(curParent), &offset);
       NS_ENSURE_SUCCESS(res, res);
       res = mHTMLEditor->CreateNode(divType, curParent, offset, getter_AddRefs(curDiv));
       NS_ENSURE_SUCCESS(res, res);
       // remember our new block for postprocessing
       mNewBlock = curDiv;
       // set up the alignment on the div
@@ -7286,32 +7285,32 @@ nsresult
 nsHTMLEditRules::SplitAsNeeded(const nsAString *aTag, 
                                nsCOMPtr<nsIDOMNode> *inOutParent,
                                PRInt32 *inOutOffset)
 {
   NS_ENSURE_TRUE(aTag && inOutParent && inOutOffset, NS_ERROR_NULL_POINTER);
   NS_ENSURE_TRUE(*inOutParent, NS_ERROR_NULL_POINTER);
   nsCOMPtr<nsIDOMNode> tagParent, temp, splitNode, parent = *inOutParent;
   nsresult res = NS_OK;
+  nsCOMPtr<nsIAtom> tagAtom = do_GetAtom(*aTag);
    
   // check that we have a place that can legally contain the tag
   while (!tagParent)
   {
     // sniffing up the parent tree until we find 
     // a legal place for the block
     if (!parent) break;
     // Don't leave the active editing host
     if (!mHTMLEditor->IsNodeInActiveEditor(parent)) {
       nsCOMPtr<nsIContent> parentContent = do_QueryInterface(parent);
       if (parentContent != mHTMLEditor->GetActiveEditingHost()) {
         break;
       }
     }
-    if (mHTMLEditor->CanContainTag(parent, *aTag))
-    {
+    if (mHTMLEditor->CanContainTag(parent, tagAtom)) {
       tagParent = parent;
       break;
     }
     splitNode = parent;
     parent->GetParentNode(getter_AddRefs(temp));
     parent = temp;
   }
   if (!tagParent)
@@ -7731,18 +7730,17 @@ nsHTMLEditRules::AdjustSelection(nsISele
   nsCOMPtr<nsIDOMNode> theblock;
   if (IsBlockNode(selNode)) theblock = selNode;
   else theblock = mHTMLEditor->GetBlockNodeParent(selNode);
   if (theblock && mHTMLEditor->IsEditable(theblock)) {
     bool bIsEmptyNode;
     res = mHTMLEditor->IsEmptyNode(theblock, &bIsEmptyNode, false, false);
     NS_ENSURE_SUCCESS(res, res);
     // check if br can go into the destination node
-    if (bIsEmptyNode && mHTMLEditor->CanContainTag(selNode, NS_LITERAL_STRING("br")))
-    {
+    if (bIsEmptyNode && mHTMLEditor->CanContainTag(selNode, nsGkAtoms::br)) {
       nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(mHTMLEditor->GetRoot());
       NS_ENSURE_TRUE(rootNode, NS_ERROR_FAILURE);
       if (selNode == rootNode)
       {
         // Our root node is completely empty. Don't add a <br> here.
         // AfterEditInner() will add one for us when it calls
         // CreateBogusNodeIfNeeded()!
         return NS_OK;
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -2245,18 +2245,18 @@ nsHTMLEditor::MakeOrChangeList(const nsA
   
     if (isCollapsed)
     {
       // have to find a place to put the list
       nsCOMPtr<nsIDOMNode> parent = node;
       nsCOMPtr<nsIDOMNode> topChild = node;
       nsCOMPtr<nsIDOMNode> tmp;
     
-      while ( !CanContainTag(parent, aListType))
-      {
+      nsCOMPtr<nsIAtom> listAtom = do_GetAtom(aListType);
+      while (!CanContainTag(parent, listAtom)) {
         parent->GetParentNode(getter_AddRefs(tmp));
         NS_ENSURE_TRUE(tmp, NS_ERROR_FAILURE);
         topChild = parent;
         parent = tmp;
       }
     
       if (parent != node)
       {
@@ -2389,18 +2389,18 @@ nsHTMLEditor::InsertBasicBlock(const nsA
   
     if (isCollapsed)
     {
       // have to find a place to put the block
       nsCOMPtr<nsIDOMNode> parent = node;
       nsCOMPtr<nsIDOMNode> topChild = node;
       nsCOMPtr<nsIDOMNode> tmp;
     
-      while ( !CanContainTag(parent, aBlockType))
-      {
+      nsCOMPtr<nsIAtom> blockAtom = do_GetAtom(aBlockType);
+      while (!CanContainTag(parent, blockAtom)) {
         parent->GetParentNode(getter_AddRefs(tmp));
         NS_ENSURE_TRUE(tmp, NS_ERROR_FAILURE);
         topChild = parent;
         parent = tmp;
       }
     
       if (parent != node)
       {
@@ -2470,35 +2470,34 @@ nsHTMLEditor::Indent(const nsAString& aI
     if (aIndent.EqualsLiteral("indent"))
     {
       if (isCollapsed)
       {
         // have to find a place to put the blockquote
         nsCOMPtr<nsIDOMNode> parent = node;
         nsCOMPtr<nsIDOMNode> topChild = node;
         nsCOMPtr<nsIDOMNode> tmp;
-        NS_NAMED_LITERAL_STRING(bq, "blockquote");
-        while ( !CanContainTag(parent, bq))
-        {
+        while (!CanContainTag(parent, nsGkAtoms::blockquote)) {
           parent->GetParentNode(getter_AddRefs(tmp));
           NS_ENSURE_TRUE(tmp, 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);
           NS_ENSURE_SUCCESS(res, res);
         }
 
         // make a blockquote
         nsCOMPtr<nsIDOMNode> newBQ;
-        res = CreateNode(bq, parent, offset, getter_AddRefs(newBQ));
+        res = CreateNode(NS_LITERAL_STRING("blockquote"), parent, offset,
+                         getter_AddRefs(newBQ));
         NS_ENSURE_SUCCESS(res, res);
         // put a space in it so layout will draw the list item
         res = selection->Collapse(newBQ,0);
         NS_ENSURE_SUCCESS(res, res);
         res = InsertText(NS_LITERAL_STRING(" "));
         NS_ENSURE_SUCCESS(res, res);
         // reposition selection to before the space character
         res = GetStartNodeAndOffset(selection, getter_AddRefs(node), &offset);
@@ -3773,30 +3772,31 @@ nsHTMLEditor::EndOperation()
   // post processing
   nsresult res = NS_OK;
   if (mRules) res = mRules->AfterEdit(mAction, mDirection);
   nsEditor::EndOperation();  // will clear mAction, mDirection
   return res;
 }  
 
 bool 
-nsHTMLEditor::TagCanContainTag(const nsAString& aParentTag, const nsAString& aChildTag)  
+nsHTMLEditor::TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag)
 {
+  MOZ_ASSERT(aParentTag && aChildTag);
+
   nsIParserService* parserService = nsContentUtils::GetParserService();
 
   PRInt32 childTagEnum;
   // XXX Should this handle #cdata-section too?
-  if (aChildTag.EqualsLiteral("#text")) {
+  if (aChildTag == nsGkAtoms::textTagName) {
     childTagEnum = eHTMLTag_text;
+  } else {
+    childTagEnum = parserService->HTMLAtomTagToId(aChildTag);
   }
-  else {
-    childTagEnum = parserService->HTMLStringTagToId(aChildTag);
-  }
-
-  PRInt32 parentTagEnum = parserService->HTMLStringTagToId(aParentTag);
+
+  PRInt32 parentTagEnum = parserService->HTMLAtomTagToId(aParentTag);
   NS_ASSERTION(parentTagEnum < NS_HTML_TAG_MAX,
                "Fix the caller, this type of node can never contain children.");
 
   return nsHTMLEditUtils::CanContain(parentTagEnum, childTagEnum);
 }
 
 bool
 nsHTMLEditor::IsContainer(nsINode* aNode)
--- a/editor/libeditor/html/nsHTMLEditor.h
+++ b/editor/libeditor/html/nsHTMLEditor.h
@@ -319,17 +319,17 @@ public:
    *  with a call to StartOperation, naming the action and direction */
   NS_IMETHOD StartOperation(PRInt32 opID, nsIEditor::EDirection aDirection);
 
   /** All editor operations which alter the doc should be followed
    *  with a call to EndOperation */
   NS_IMETHOD EndOperation();
 
   /** returns true if aParentTag can contain a child of type aChildTag */
-  virtual bool TagCanContainTag(const nsAString& aParentTag, const nsAString& aChildTag);
+  virtual bool TagCanContainTag(nsIAtom* aParentTag, nsIAtom* aChildTag);
   
   /** returns true if aNode is a container */
   virtual bool IsContainer(nsINode* aNode);
   virtual bool IsContainer(nsIDOMNode *aNode);
 
   /** make the given selection span the entire document */
   NS_IMETHOD SelectEntireDocument(nsISelection *aSelection);
 
--- a/editor/libeditor/html/nsHTMLEditorStyle.cpp
+++ b/editor/libeditor/html/nsHTMLEditorStyle.cpp
@@ -273,19 +273,19 @@ nsHTMLEditor::SetInlinePropertyOnTextNod
                                             const nsAString *aAttribute,
                                             const nsAString *aValue)
 {
   NS_ENSURE_TRUE(aTextNode, NS_ERROR_NULL_POINTER);
   nsCOMPtr<nsIDOMNode> parent;
   nsresult res = aTextNode->GetParentNode(getter_AddRefs(parent));
   NS_ENSURE_SUCCESS(res, res);
 
-  nsAutoString tagString;
-  aProperty->ToString(tagString);
-  if (!CanContainTag(parent, tagString)) return NS_OK;
+  if (!CanContainTag(parent, aProperty)) {
+    return NS_OK;
+  }
   
   // don't need to do anything if no characters actually selected
   if (aStartOffset == aEndOffset) return NS_OK;
   
   nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aTextNode);
   
   // don't need to do anything if property already set on node
   bool bHasProp;
@@ -365,17 +365,17 @@ nsHTMLEditor::SetInlinePropertyOnNodeImp
   nsresult res;
   nsCOMPtr<nsIDOMNode> tmp;
   nsAutoString tag;
   aProperty->ToString(tag);
   ToLowerCase(tag);
 
   // If this is an element that can't be contained in a span, we have to
   // recurse to its children.
-  if (!TagCanContain(NS_LITERAL_STRING("span"), aNode)) {
+  if (!TagCanContain(nsGkAtoms::span, aNode)) {
     nsCOMPtr<nsIDOMNodeList> childNodes;
     res = aNode->GetChildNodes(getter_AddRefs(childNodes));
     NS_ENSURE_SUCCESS(res, res);
     if (childNodes) {
       PRInt32 j;
       PRUint32 childCount;
       childNodes->GetLength(&childCount);
       if (childCount) {
@@ -1449,19 +1449,19 @@ nsHTMLEditor::RelativeFontChange( PRInt3
     nsCOMPtr<nsIDOMNode> selectedNode;
     res = GetStartNodeAndOffset(selection, getter_AddRefs(selectedNode), &offset);
     if (IsTextNode(selectedNode)) {
       nsCOMPtr<nsIDOMNode> parent;
       res = selectedNode->GetParentNode(getter_AddRefs(parent));
       NS_ENSURE_SUCCESS(res, res);
       selectedNode = parent;
     }
-    nsAutoString tag;
-    atom->ToString(tag);
-    if (!CanContainTag(selectedNode, tag)) return NS_OK;
+    if (!CanContainTag(selectedNode, atom)) {
+      return NS_OK;
+    }
 
     // manipulating text attributes on a collapsed selection only sets state for the next text insertion
     return mTypeInState->SetProp(atom, EmptyString(), EmptyString());
   }
   
   // wrap with txn batching, rules sniffing, and selection preservation code
   nsAutoEditBatch batchIt(this);
   nsAutoRules beginRulesSniffing(this, kOpSetTextProperty, nsIEditor::eNext);
@@ -1594,17 +1594,19 @@ nsHTMLEditor::RelativeFontChangeOnTextNo
   
   // don't need to do anything if no characters actually selected
   if (aStartOffset == aEndOffset) return NS_OK;
   
   nsresult res = NS_OK;
   nsCOMPtr<nsIDOMNode> parent;
   res = aTextNode->GetParentNode(getter_AddRefs(parent));
   NS_ENSURE_SUCCESS(res, res);
-  if (!CanContainTag(parent, NS_LITERAL_STRING("big"))) return NS_OK;
+  if (!CanContainTag(parent, nsGkAtoms::big)) {
+    return NS_OK;
+  }
 
   nsCOMPtr<nsIDOMNode> tmp, node = do_QueryInterface(aTextNode);
 
   // do we need to split the text node?
   PRUint32 textLen;
   aTextNode->GetLength(&textLen);
   
   // -1 is a magic value meaning to the end of node
@@ -1725,34 +1727,36 @@ nsHTMLEditor::RelativeFontChangeOnNode( 
 {
   // Can only change font size by + or - 1
   if ( !( (aSizeChange==1) || (aSizeChange==-1) ) )
     return NS_ERROR_ILLEGAL_VALUE;
   NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
 
   nsresult res = NS_OK;
   nsCOMPtr<nsIDOMNode> tmp;
-  nsAutoString tag;
-  if (aSizeChange == 1) tag.AssignLiteral("big");
-  else tag.AssignLiteral("small");
+  nsIAtom* atom;
+  if (aSizeChange == 1) {
+    atom = nsGkAtoms::big;
+  } else {
+    atom = nsGkAtoms::small;
+  }
   
   // is it the opposite of what we want?  
   if ( ((aSizeChange == 1) && nsHTMLEditUtils::IsSmall(aNode)) || 
        ((aSizeChange == -1) &&  nsHTMLEditUtils::IsBig(aNode)) )
   {
     // first populate any nested font tags that have the size attr set
     res = RelativeFontChangeHelper(aSizeChange, aNode);
     NS_ENSURE_SUCCESS(res, res);
     // in that case, just remove this node and pull up the children
     res = RemoveContainer(aNode);
     return res;
   }
   // can it be put inside a "big" or "small"?
-  if (TagCanContain(tag, aNode))
-  {
+  if (TagCanContain(atom, aNode)) {
     // first populate any nested font tags that have the size attr set
     res = RelativeFontChangeHelper(aSizeChange, aNode);
     NS_ENSURE_SUCCESS(res, res);
     // ok, chuck it in.
     // first look at siblings of aNode for matching bigs or smalls.
     // if we find one, move aNode into it.
     nsCOMPtr<nsIDOMNode> sibling;
     GetPriorHTMLSibling(aNode, address_of(sibling));
@@ -1766,17 +1770,17 @@ nsHTMLEditor::RelativeFontChangeOnNode( 
     GetNextHTMLSibling(aNode, address_of(sibling));
     if (sibling && nsEditor::NodeIsType(sibling, (aSizeChange==1 ? nsEditProperty::big : nsEditProperty::small)))
     {
       // following sib is already right kind of inline node; slide this over into it
       res = MoveNode(aNode, sibling, 0);
       return res;
     }
     // else insert it above aNode
-    res = InsertContainerAbove(aNode, address_of(tmp), tag);
+    res = InsertContainerAbove(aNode, address_of(tmp), nsAtomString(atom));
     return res;
   }
   // none of the above?  then cycle through the children.
   // MOOSE: we should group the children together if possible
   // into a single "big" or "small".  For the moment they are
   // each getting their own.  
   nsCOMPtr<nsIDOMNodeList> childNodes;
   res = aNode->GetChildNodes(getter_AddRefs(childNodes));
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -879,18 +879,19 @@ NS_IMETHODIMP nsPlaintextEditor::InsertL
   {
     // get the (collapsed) selection location
     nsCOMPtr<nsIDOMNode> selNode;
     PRInt32 selOffset;
     res = GetStartNodeAndOffset(selection, getter_AddRefs(selNode), &selOffset);
     NS_ENSURE_SUCCESS(res, res);
 
     // don't put text in places that can't have it
-    if (!IsTextNode(selNode) && !CanContainTag(selNode, NS_LITERAL_STRING("#text")))
+    if (!IsTextNode(selNode) && !CanContainTag(selNode, nsGkAtoms::textTagName)) {
       return NS_ERROR_FAILURE;
+    }
 
     // we need to get the doc
     nsCOMPtr<nsIDOMDocument> doc = GetDOMDocument();
     NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
 
     // don't spaz my selection in subtransactions
     nsAutoTxnsConserveSelection dontSpazMySelection(this);
 
--- a/editor/libeditor/text/nsTextEditRules.cpp
+++ b/editor/libeditor/text/nsTextEditRules.cpp
@@ -702,18 +702,20 @@ nsTextEditRules::WillInsertText(PRInt32 
 
   // get the (collapsed) selection location
   nsCOMPtr<nsIDOMNode> selNode;
   PRInt32 selOffset;
   res = mEditor->GetStartNodeAndOffset(aSelection, getter_AddRefs(selNode), &selOffset);
   NS_ENSURE_SUCCESS(res, res);
 
   // don't put text in places that can't have it
-  if (!mEditor->IsTextNode(selNode) && !mEditor->CanContainTag(selNode, NS_LITERAL_STRING("#text")))
+  if (!mEditor->IsTextNode(selNode) &&
+      !mEditor->CanContainTag(selNode, nsGkAtoms::textTagName)) {
     return NS_ERROR_FAILURE;
+  }
 
   // we need to get the doc
   nsCOMPtr<nsIDOMDocument> doc = mEditor->GetDOMDocument();
   NS_ENSURE_TRUE(doc, NS_ERROR_NOT_INITIALIZED);
     
   if (aAction == kInsertTextIME) 
   { 
     res = mEditor->InsertTextImpl(*outString, address_of(selNode), &selOffset, doc);