Make tagStack be an array of nsString instead of nsAutoString. Fixes bug 427941. r+sr=sicking, a=beltzner
authorjruderman@hmc.edu
Thu, 10 Apr 2008 21:38:25 -0700
changeset 14205 62ba745c620a62e577a47ed5b3603873b03e2e7d
parent 14204 b031d67bf9588c6e739a6f0ba55ae9b8e5825bff
child 14206 408b540f148c28fb8abe42eb74cbd98280e909c5
push idunknown
push userunknown
push dateunknown
reviewersbeltzner
bugs427941
milestone1.9pre
Make tagStack be an array of nsString instead of nsAutoString. Fixes bug 427941. r+sr=sicking, a=beltzner
content/base/src/nsContentUtils.cpp
editor/libeditor/html/nsHTMLDataTransfer.cpp
editor/libeditor/html/nsHTMLEditor.h
parser/htmlparser/public/nsIParser.h
parser/htmlparser/src/nsParser.cpp
parser/htmlparser/src/nsParser.h
toolkit/components/feeds/src/nsScriptableUnescapeHTML.cpp
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -3393,25 +3393,25 @@ nsContentUtils::CreateContextualFragment
   nsCOMPtr<nsINode> node = do_QueryInterface(aContextNode);
   NS_ENSURE_TRUE(node, NS_ERROR_NOT_AVAILABLE);
 
   // If we don't have a document here, we can't get the right security context
   // for compiling event handlers... so just bail out.
   nsCOMPtr<nsIDocument> document = node->GetOwnerDoc();
   NS_ENSURE_TRUE(document, NS_ERROR_NOT_AVAILABLE);
 
-  nsAutoTArray<nsAutoString, 32> tagStack;
+  nsAutoTArray<nsString, 32> tagStack;
   nsAutoString uriStr, nameStr;
   nsCOMPtr<nsIContent> content = do_QueryInterface(aContextNode);
   // just in case we have a text node
   if (content && !content->IsNodeOfType(nsINode::eELEMENT))
     content = content->GetParent();
 
   while (content && content->IsNodeOfType(nsINode::eELEMENT)) {
-    nsAutoString& tagName = *tagStack.AppendElement();
+    nsString& tagName = *tagStack.AppendElement();
     NS_ENSURE_TRUE(&tagName, NS_ERROR_OUT_OF_MEMORY);
 
     content->NodeInfo()->GetQualifiedName(tagName);
 
     // see if we need to add xmlns declarations
     PRUint32 count = content->GetAttrCount();
     PRBool setDefaultNamespace = PR_FALSE;
     if (count > 0) {
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -2519,17 +2519,17 @@ nsresult nsHTMLEditor::CreateDOMFragment
 
   nsCOMPtr<nsIDOMDocument> domDoc;
   GetDocument(getter_AddRefs(domDoc));
 
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
   NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
   
   // if we have context info, create a fragment for that
-  nsAutoTArray<nsAutoString, 32> tagStack;
+  nsAutoTArray<nsString, 32> tagStack;
   nsCOMPtr<nsIDOMDocumentFragment> contextfrag;
   nsCOMPtr<nsIDOMNode> contextLeaf, junk;
   if (!aContextStr.IsEmpty())
   {
     res = ParseFragment(aContextStr, tagStack, doc, address_of(contextAsNode));
     NS_ENSURE_SUCCESS(res, res);
     NS_ENSURE_TRUE(contextAsNode, NS_ERROR_FAILURE);
 
@@ -2604,17 +2604,17 @@ nsresult nsHTMLEditor::CreateDOMFragment
   }
 
   GetLengthOfDOMNode(*outEndNode, (PRUint32&)*outEndOffset);
   return res;
 }
 
 
 nsresult nsHTMLEditor::ParseFragment(const nsAString & aFragStr,
-                                     nsTArray<nsAutoString> &aTagStack,
+                                     nsTArray<nsString> &aTagStack,
                                      nsIDocument* aTargetDocument,
                                      nsCOMPtr<nsIDOMNode> *outNode)
 {
   // figure out if we are parsing full context or not
   PRBool bContext = aTagStack.IsEmpty();
 
   // create the parser to do the conversion.
   nsresult res;
@@ -2645,33 +2645,33 @@ nsresult nsHTMLEditor::ParseFragment(con
   nsCOMPtr<nsIDOMDocumentFragment> contextfrag;
   res = fragSink->GetFragment(PR_TRUE, getter_AddRefs(contextfrag));
   NS_ENSURE_SUCCESS(res, res);
   *outNode = do_QueryInterface(contextfrag);
   
   return res;
 }
 
-nsresult nsHTMLEditor::CreateTagStack(nsTArray<nsAutoString> &aTagStack, nsIDOMNode *aNode)
+nsresult nsHTMLEditor::CreateTagStack(nsTArray<nsString> &aTagStack, nsIDOMNode *aNode)
 {
   nsresult res = NS_OK;
   nsCOMPtr<nsIDOMNode> node= aNode;
   PRBool bSeenBody = PR_FALSE;
   
   while (node) 
   {
     if (nsTextEditUtils::IsBody(node))
       bSeenBody = PR_TRUE;
     nsCOMPtr<nsIDOMNode> temp = node;
     PRUint16 nodeType;
     
     node->GetNodeType(&nodeType);
     if (nsIDOMNode::ELEMENT_NODE == nodeType)
     {
-      nsAutoString* tagName = aTagStack.AppendElement();
+      nsString* tagName = aTagStack.AppendElement();
       NS_ENSURE_TRUE(tagName, NS_ERROR_OUT_OF_MEMORY);
 
       node->GetNodeName(*tagName);
       // printf("%s\n",NS_LossyConvertUTF16toASCII(tagName).get());
     }
 
     res = temp->GetParentNode(getter_AddRefs(node));
     NS_ENSURE_SUCCESS(res, res);  
--- a/editor/libeditor/html/nsHTMLEditor.h
+++ b/editor/libeditor/html/nsHTMLEditor.h
@@ -636,26 +636,26 @@ protected:
   nsresult   CreateDOMFragmentFromPaste(const nsAString & aInputString,
                                         const nsAString & aContextStr,
                                         const nsAString & aInfoStr,
                                         nsCOMPtr<nsIDOMNode> *outFragNode,
                                         nsCOMPtr<nsIDOMNode> *outStartNode,
                                         nsCOMPtr<nsIDOMNode> *outEndNode,
                                         PRInt32 *outStartOffset,
                                         PRInt32 *outEndOffset);
-  nsresult   ParseFragment(const nsAString & aStr, nsTArray<nsAutoString> &aTagStack,
+  nsresult   ParseFragment(const nsAString & aStr, nsTArray<nsString> &aTagStack,
                            nsIDocument* aTargetDoc,
                            nsCOMPtr<nsIDOMNode> *outNode);
   nsresult   CreateListOfNodesToPaste(nsIDOMNode  *aFragmentAsNode,
                                       nsCOMArray<nsIDOMNode>& outNodeList,
                                       nsIDOMNode *aStartNode,
                                       PRInt32 aStartOffset,
                                       nsIDOMNode *aEndNode,
                                       PRInt32 aEndOffset);
-  nsresult CreateTagStack(nsTArray<nsAutoString> &aTagStack,
+  nsresult CreateTagStack(nsTArray<nsString> &aTagStack,
                           nsIDOMNode *aNode);
   nsresult GetListAndTableParents( PRBool aEnd, 
                                    nsCOMArray<nsIDOMNode>& aListOfNodes,
                                    nsCOMArray<nsIDOMNode>& outArray);
   nsresult DiscoverPartialListsAndTables(nsCOMArray<nsIDOMNode>& aPasteNodes,
                                          nsCOMArray<nsIDOMNode>& aListsAndTables,
                                          PRInt32 *outHighWaterMark);
   nsresult ScanForListAndTableStructure(PRBool aEnd,
--- a/parser/htmlparser/public/nsIParser.h
+++ b/parser/htmlparser/public/nsIParser.h
@@ -249,17 +249,17 @@ class nsIParser : public nsISupports {
      * @param aTagStack The context of the source buffer.
      * @param aXMLMode Whether this is XML or HTML
      * @param aContentType The content-type of this document.
      * @param aMode The DTDMode that the parser should parse this fragment in.
      * @return Success or failure.
      */
     NS_IMETHOD ParseFragment(const nsAString& aSourceBuffer,
                              void* aKey,
-                             nsTArray<nsAutoString>& aTagStack,
+                             nsTArray<nsString>& aTagStack,
                              PRBool aXMLMode,
                              const nsACString& aContentType,
                              nsDTDMode aMode = eDTDMode_autodetect) = 0;
 
     /**
      * This method gets called when the tokens have been consumed, and it's time
      * to build the model via the content sink.
      * @update	gess5/11/98
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/src/nsParser.cpp
@@ -1469,17 +1469,17 @@ nsParser::Parse(const nsAString& aSource
   }
 
   return result;
 }
 
 NS_IMETHODIMP
 nsParser::ParseFragment(const nsAString& aSourceBuffer,
                         void* aKey,
-                        nsTArray<nsAutoString>& aTagStack,
+                        nsTArray<nsString>& aTagStack,
                         PRBool aXMLMode,
                         const nsACString& aMimeType,
                         nsDTDMode aMode)
 {
   nsresult result = NS_OK;
   nsAutoString  theContext;
   PRUint32 theCount = aTagStack.Length();
   PRUint32 theIndex = 0;
@@ -1561,17 +1561,17 @@ nsParser::ParseFragment(const nsAString&
     if (NS_SUCCEEDED(result)) {
       nsAutoString endContext;       
       for (theIndex = 0; theIndex < theCount; theIndex++) {
          // we already added an end tag chunk above
         if (theIndex > 0) {
           endContext.AppendLiteral("</");
         }
 
-        nsAutoString& thisTag = aTagStack[theIndex];
+        nsString& thisTag = aTagStack[theIndex];
         // was there an xmlns=?
         PRInt32 endOfTag = thisTag.FindChar(PRUnichar(' '));
         if (endOfTag == -1) {
           endContext.Append(thisTag);
         } else {
           endContext.Append(Substring(thisTag,0,endOfTag));
         }
 
--- a/parser/htmlparser/src/nsParser.h
+++ b/parser/htmlparser/src/nsParser.h
@@ -215,17 +215,17 @@ class nsParser : public nsIParser,
 
     NS_IMETHOD_(void *) GetRootContextKey();
 
     /**
      * This method needs documentation
      */
     NS_IMETHOD ParseFragment(const nsAString& aSourceBuffer,
                              void* aKey,
-                             nsTArray<nsAutoString>& aTagStack,
+                             nsTArray<nsString>& aTagStack,
                              PRBool aXMLMode,
                              const nsACString& aContentType,
                              nsDTDMode aMode = eDTDMode_autodetect);
 
 
     /**
      * This method gets called when the tokens have been consumed, and it's time
      * to build the model via the content sink.
--- a/toolkit/components/feeds/src/nsScriptableUnescapeHTML.cpp
+++ b/toolkit/components/feeds/src/nsScriptableUnescapeHTML.cpp
@@ -141,17 +141,17 @@ nsScriptableUnescapeHTML::ParseFragment(
     scripts_enabled = loader->GetEnabled();
   }
   if (scripts_enabled) {
     loader->SetEnabled(PR_FALSE);
   }
 
   // Wrap things in a div or body for parsing, but it won't show up in
   // the fragment.
-  nsAutoTArray<nsAutoString, 2> tagStack;
+  nsAutoTArray<nsString, 2> tagStack;
   nsCAutoString base, spec;
   if (aIsXML) {
     // XHTML
     if (aBaseURI) {
       base.Append(NS_LITERAL_CSTRING(XHTML_DIV_TAG));
       base.Append(NS_LITERAL_CSTRING(" xml:base=\""));
       aBaseURI->GetSpec(spec);
       // nsEscapeHTML is good enough, because we only need to get