Bug 764774 - Remove unused variable and object creation from nsParserUtils. r=smaug.
authorHenri Sivonen <hsivonen@iki.fi>
Fri, 15 Jun 2012 15:28:28 +0300
changeset 96797 a61e819c1855629f0cae542b3dd62a95cedb1280
parent 96796 bc241a81c6a5ddbc20f7402e9a9b06ae0c3e9e74
child 96805 d4fc8a49540cf0c43d067fc827578b24a867e822
push id10716
push userhsivonen@iki.fi
push dateFri, 15 Jun 2012 12:29:09 +0000
treeherdermozilla-inbound@a61e819c1855 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs764774
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 764774 - Remove unused variable and object creation from nsParserUtils. r=smaug.
parser/html/nsParserUtils.cpp
--- a/parser/html/nsParserUtils.cpp
+++ b/parser/html/nsParserUtils.cpp
@@ -132,20 +132,16 @@ nsParserUtils::ParseFragment(const nsASt
                              bool aIsXML,
                              nsIURI* aBaseURI,
                              nsIDOMElement* aContextElement,
                              nsIDOMDocumentFragment** aReturn)
 {
   NS_ENSURE_ARG(aContextElement);
   *aReturn = nsnull;
 
-  nsresult rv;
-  nsCOMPtr<nsIParser> parser = do_CreateInstance(kCParserCID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
   nsCOMPtr<nsIDocument> document;
   nsCOMPtr<nsIDOMDocument> domDocument;
   nsCOMPtr<nsIDOMNode> contextNode;
   contextNode = do_QueryInterface(aContextElement);
   contextNode->GetOwnerDocument(getter_AddRefs(domDocument));
   document = do_QueryInterface(domDocument);
   NS_ENSURE_TRUE(document, NS_ERROR_NOT_AVAILABLE);
 
@@ -180,56 +176,56 @@ nsParserUtils::ParseFragment(const nsASt
       NS_Free(escapedSpec);
       base.Append(NS_LITERAL_CSTRING("\""));
       tagStack.AppendElement(NS_ConvertUTF8toUTF16(base));
     }  else {
       tagStack.AppendElement(NS_LITERAL_STRING(XHTML_DIV_TAG));
     }
   }
 
-  if (NS_SUCCEEDED(rv)) {
-    nsCOMPtr<nsIContent> fragment;
-    if (aIsXML) {
-      rv = nsContentUtils::ParseFragmentXML(aFragment,
-                                            document,
-                                            tagStack,
-                                            true,
-                                            aReturn);
-      fragment = do_QueryInterface(*aReturn);
-    } else {
-      NS_NewDocumentFragment(aReturn,
-                             document->NodeInfoManager());
-      fragment = do_QueryInterface(*aReturn);
-      rv = nsContentUtils::ParseFragmentHTML(aFragment,
-                                             fragment,
-                                             nsGkAtoms::body,
-                                             kNameSpaceID_XHTML,
-                                             false,
-                                             true);
-      // Now, set the base URI on all subtree roots.
-      if (aBaseURI) {
-        aBaseURI->GetSpec(spec);
-        nsAutoString spec16;
-        CopyUTF8toUTF16(spec, spec16);
-        nsIContent* node = fragment->GetFirstChild();
-        while (node) {
-          if (node->IsElement()) {
-            node->SetAttr(kNameSpaceID_XML,
-                          nsGkAtoms::base,
-                          nsGkAtoms::xml,
-                          spec16,
-                          false);
-          }
-          node = node->GetNextSibling();
+  nsresult rv = NS_OK;
+  nsCOMPtr<nsIContent> fragment;
+  if (aIsXML) {
+    rv = nsContentUtils::ParseFragmentXML(aFragment,
+                                          document,
+                                          tagStack,
+                                          true,
+                                          aReturn);
+    fragment = do_QueryInterface(*aReturn);
+  } else {
+    NS_NewDocumentFragment(aReturn,
+                           document->NodeInfoManager());
+    fragment = do_QueryInterface(*aReturn);
+    rv = nsContentUtils::ParseFragmentHTML(aFragment,
+                                           fragment,
+                                           nsGkAtoms::body,
+                                           kNameSpaceID_XHTML,
+                                           false,
+                                           true);
+    // Now, set the base URI on all subtree roots.
+    if (aBaseURI) {
+      aBaseURI->GetSpec(spec);
+      nsAutoString spec16;
+      CopyUTF8toUTF16(spec, spec16);
+      nsIContent* node = fragment->GetFirstChild();
+      while (node) {
+        if (node->IsElement()) {
+          node->SetAttr(kNameSpaceID_XML,
+                        nsGkAtoms::base,
+                        nsGkAtoms::xml,
+                        spec16,
+                        false);
         }
+        node = node->GetNextSibling();
       }
     }
-    if (fragment) {
-      nsTreeSanitizer sanitizer(aFlags);
-      sanitizer.Sanitize(fragment);
-    }
+  }
+  if (fragment) {
+    nsTreeSanitizer sanitizer(aFlags);
+    sanitizer.Sanitize(fragment);
   }
 
-  if (scripts_enabled)
-      loader->SetEnabled(true);
-  
+  if (scripts_enabled) {
+    loader->SetEnabled(true);
+  }
+
   return rv;
 }