De-nsIDOM* nsIContentSerializer methods, r=sicking
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 04 May 2010 11:39:47 +0300
changeset 41755 719244f1a4dfb510f7bbbf17e14549770ae264f6
parent 41754 d660bc26395e6664d162004d54a9cc6cdf7513aa
child 41756 d6bb0f9e951926d3f4f0d8ee3e70d80b408f6411
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
De-nsIDOM* nsIContentSerializer methods, r=sicking
content/base/public/nsIContentSerializer.h
content/base/src/mozSanitizingSerializer.cpp
content/base/src/mozSanitizingSerializer.h
content/base/src/nsDocumentEncoder.cpp
content/base/src/nsHTMLContentSerializer.cpp
content/base/src/nsHTMLContentSerializer.h
content/base/src/nsPlainTextSerializer.cpp
content/base/src/nsPlainTextSerializer.h
content/base/src/nsXHTMLContentSerializer.cpp
content/base/src/nsXHTMLContentSerializer.h
content/base/src/nsXMLContentSerializer.cpp
content/base/src/nsXMLContentSerializer.h
--- a/content/base/public/nsIContentSerializer.h
+++ b/content/base/public/nsIContentSerializer.h
@@ -35,73 +35,68 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef _nsIContentSerializer_h__
 #define _nsIContentSerializer_h__
 
 #include "nsISupports.h"
 
-class nsIDOMText; /* forward declaration */
-class nsIDOMCDATASection; /* forward declaration */
-class nsIDOMProcessingInstruction; /* forward declaration */
-class nsIDOMComment; /* forward declaration */
-class nsIDOMDocumentType; /* forward declaration */
-class nsIDOMElement; /* forward declaration */
-class nsIDOMDocument; /* forward declaration */
+class nsIContent;
+class nsIDocument;
 class nsAString;
 
 /* starting interface:    nsIContentSerializer */
 
 #define NS_ICONTENTSERIALIZER_IID \
-{ 0x34769de0, 0x30d0, 0x4cef, \
-  { 0x89, 0x4a, 0xfc, 0xd8, 0xbb, 0x27, 0xc4, 0xb4 } }
+{ 0xb1ee32f2, 0xb8c4, 0x49b9, \
+  { 0x93, 0xdf, 0xb6, 0xfa, 0xb5, 0xd5, 0x46, 0x88 } }
 
 class nsIContentSerializer : public nsISupports {
  public: 
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTSERIALIZER_IID)
 
   NS_IMETHOD Init(PRUint32 flags, PRUint32 aWrapColumn,
                   const char* aCharSet, PRBool aIsCopying,
                   PRBool aIsWholeDocument) = 0;
 
-  NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
+  NS_IMETHOD AppendText(nsIContent* aText, PRInt32 aStartOffset,
                         PRInt32 aEndOffset, nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
+  NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
                                 PRInt32 aStartOffset, PRInt32 aEndOffset,
                                 nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
+  NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
                                          PRInt32 aStartOffset,
                                          PRInt32 aEndOffset,
                                          nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
+  NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
                            PRInt32 aEndOffset, nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype,
+  NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
                            nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
-                                nsIDOMElement *aOriginalElement,
+  NS_IMETHOD AppendElementStart(nsIContent *aElement,
+                                nsIContent *aOriginalElement,
                                 nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
+  NS_IMETHOD AppendElementEnd(nsIContent *aElement,
                               nsAString& aStr) = 0;
 
   NS_IMETHOD Flush(nsAString& aStr) = 0;
 
   /**
    * Append any items in the beginning of the document that won't be 
    * serialized by other methods. XML declaration is the most likely 
    * thing this method can produce.
    */
-  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
                                  nsAString& aStr) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSerializer, NS_ICONTENTSERIALIZER_IID)
 
 #define NS_CONTENTSERIALIZER_CONTRACTID_PREFIX \
 "@mozilla.org/layout/contentserializer;1?mimetype="
 
--- a/content/base/src/mozSanitizingSerializer.cpp
+++ b/content/base/src/mozSanitizingSerializer.cpp
@@ -160,17 +160,17 @@ mozSanitizingHTMLSerializer::Flush(nsASt
 #ifdef DEBUG_BenB
   printf("Flush: -%s-", NS_LossyConvertUTF16toASCII(aStr).get());
 #endif
   Write(aStr);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-mozSanitizingHTMLSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
+mozSanitizingHTMLSerializer::AppendDocumentStart(nsIDocument *aDocument,
                                                  nsAString& aStr)
 {
   return NS_OK;
 }
 
 void
 mozSanitizingHTMLSerializer::Write(const nsAString& aString)
 {
@@ -220,40 +220,39 @@ mozSanitizingHTMLSerializer::GetIdForCon
 
   nsIParserService* parserService = nsContentUtils::GetParserService();
 
   return parserService ? parserService->HTMLAtomTagToId(aContent->Tag()) :
                          eHTMLTag_unknown;
 }
 
 NS_IMETHODIMP 
-mozSanitizingHTMLSerializer::AppendText(nsIDOMText* aText, 
+mozSanitizingHTMLSerializer::AppendText(nsIContent* aText,
                                         PRInt32 aStartOffset,
                                         PRInt32 aEndOffset, 
                                         nsAString& aStr)
 {
   nsresult rv = NS_OK;
 
   mOutputString = &aStr;
 
   nsAutoString linebuffer;
   rv = DoAddLeaf(eHTMLTag_text, linebuffer);
 
   return rv;
 }
 
 NS_IMETHODIMP 
-mozSanitizingHTMLSerializer::AppendElementStart(nsIDOMElement *aElement,
-                                                nsIDOMElement *aOriginalElement,
+mozSanitizingHTMLSerializer::AppendElementStart(nsIContent *aElement,
+                                                nsIContent *aOriginalElement,
                                                 nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  mContent = do_QueryInterface(aElement);
-  NS_ENSURE_TRUE(mContent, NS_ERROR_FAILURE);
+  mContent = aElement;
 
   mOutputString = &aStr;
 
   PRInt32 id = GetIdForContent(mContent);
 
   PRBool isContainer = IsContainer(id);
 
   nsresult rv;
@@ -266,23 +265,22 @@ mozSanitizingHTMLSerializer::AppendEleme
 
   mContent = 0;
   mOutputString = nsnull;
 
   return rv;
 } 
  
 NS_IMETHODIMP 
-mozSanitizingHTMLSerializer::AppendElementEnd(nsIDOMElement *aElement,
+mozSanitizingHTMLSerializer::AppendElementEnd(nsIContent *aElement,
                                               nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  mContent = do_QueryInterface(aElement);
-  NS_ENSURE_TRUE(mContent, NS_ERROR_FAILURE);
+  mContent = aElement;
 
   mOutputString = &aStr;
 
   nsresult rv = NS_OK;
   PRInt32 id = GetIdForContent(mContent);
 
   PRBool isContainer = IsContainer(id);
 
--- a/content/base/src/mozSanitizingSerializer.h
+++ b/content/base/src/mozSanitizingSerializer.h
@@ -68,39 +68,39 @@ public:
   static PRBool ReleaseProperties(nsHashKey* key, void* data, void* closure);
 
   NS_DECL_ISUPPORTS
 
   // nsIContentSerializer
   NS_IMETHOD Init(PRUint32 flags, PRUint32 dummy, const char* aCharSet, 
                   PRBool aIsCopying, PRBool aIsWholeDocument);
 
-  NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
+  NS_IMETHOD AppendText(nsIContent* aText, PRInt32 aStartOffset,
                         PRInt32 aEndOffset, nsAString& aStr);
-  NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
+  NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
                                 PRInt32 aStartOffset, PRInt32 aEndOffset,
                                 nsAString& aStr)
                       { return NS_OK; }
-  NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
+  NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
                                          PRInt32 aStartOffset,
                                          PRInt32 aEndOffset,
                                          nsAString& aStr)
                       { return NS_OK; }
-  NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
+  NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
                            PRInt32 aEndOffset, nsAString& aStr)
                       { return NS_OK; }
-  NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype, nsAString& aStr)
+  NS_IMETHOD AppendDoctype(nsIContent *aDoctype, nsAString& aStr)
                       { return NS_OK; }
-  NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
-                                nsIDOMElement *aOriginalElement,
+  NS_IMETHOD AppendElementStart(nsIContent *aElement,
+                                nsIContent *aOriginalElement,
                                 nsAString& aStr); 
-  NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement, nsAString& aStr);
+  NS_IMETHOD AppendElementEnd(nsIContent *aElement, nsAString& aStr);
   NS_IMETHOD Flush(nsAString& aStr);
 
-  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
                                  nsAString& aStr);
 
   // nsIContentSink
   NS_IMETHOD WillParse(void) { return NS_OK; }
   NS_IMETHOD WillInterrupt(void) { return NS_OK; }
   NS_IMETHOD WillResume(void) { return NS_OK; }
   NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
   NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
--- a/content/base/src/nsDocumentEncoder.cpp
+++ b/content/base/src/nsDocumentEncoder.cpp
@@ -287,70 +287,67 @@ nsDocumentEncoder::SerializeNodeStart(ns
     }
   }
 
   // Either there was no fixed-up node,
   // or the caller did fixup themselves and aNode is already fixed
   if (!node)
     node = aNode;
 
-  //XXX Remove QIing to nsIDOM* when fixing bug 562321.
   node->GetNodeType(&type);
   switch (type) {
     case nsIDOMNode::ELEMENT_NODE:
     {
-      nsCOMPtr<nsIDOMElement> element = do_QueryInterface(node);
-      nsCOMPtr<nsIDOMElement> originalElement = do_QueryInterface(aOriginalNode);
-      mSerializer->AppendElementStart(element, originalElement, aStr);
+      nsIContent* originalElement =
+        aOriginalNode && aOriginalNode->IsElement() ?
+          static_cast<nsIContent*>(aOriginalNode) : nsnull;
+      mSerializer->AppendElementStart(static_cast<nsIContent*>(node),
+                                      originalElement, aStr);
       break;
     }
     case nsIDOMNode::TEXT_NODE:
     {
-      nsCOMPtr<nsIDOMText> text = do_QueryInterface(node);
-      mSerializer->AppendText(text, aStartOffset, aEndOffset, aStr);
+      mSerializer->AppendText(static_cast<nsIContent*>(node),
+                              aStartOffset, aEndOffset, aStr);
       break;
     }
     case nsIDOMNode::CDATA_SECTION_NODE:
     {
-      nsCOMPtr<nsIDOMCDATASection> cdata = do_QueryInterface(node);
-      mSerializer->AppendCDATASection(cdata, aStartOffset, aEndOffset, aStr);
+      mSerializer->AppendCDATASection(static_cast<nsIContent*>(node),
+                                      aStartOffset, aEndOffset, aStr);
       break;
     }
     case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
     {
-      nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(node);
-      mSerializer->AppendProcessingInstruction(pi, aStartOffset, aEndOffset,
-                                               aStr);
+      mSerializer->AppendProcessingInstruction(static_cast<nsIContent*>(node),
+                                               aStartOffset, aEndOffset, aStr);
       break;
     }
     case nsIDOMNode::COMMENT_NODE:
     {
-      nsCOMPtr<nsIDOMComment> comment = do_QueryInterface(node);
-      mSerializer->AppendComment(comment, aStartOffset, aEndOffset, aStr);
+      mSerializer->AppendComment(static_cast<nsIContent*>(node),
+                                 aStartOffset, aEndOffset, aStr);
       break;
     }
     case nsIDOMNode::DOCUMENT_TYPE_NODE:
     {
-      nsCOMPtr<nsIDOMDocumentType> doctype = do_QueryInterface(node);
-      mSerializer->AppendDoctype(doctype, aStr);
+      mSerializer->AppendDoctype(static_cast<nsIContent*>(node), aStr);
       break;
     }
   }
 
   return NS_OK;
 }
 
 nsresult
 nsDocumentEncoder::SerializeNodeEnd(nsINode* aNode,
                                     nsAString& aStr)
 {
-  //XXX Remove QIing to nsIDOM* when fixing bug 562321.
   if (aNode->IsElement()) {
-    nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode);
-    mSerializer->AppendElementEnd(element, aStr);
+    mSerializer->AppendElementEnd(static_cast<nsIContent*>(aNode), aStr);
   }
   return NS_OK;
 }
 
 nsresult
 nsDocumentEncoder::SerializeToStringRecursive(nsINode* aNode,
                                               nsAString& aStr,
                                               PRBool aDontSerializeRoot)
@@ -948,18 +945,17 @@ nsDocumentEncoder::EncodeToString(nsAStr
   } else if (mRange) {
       rv = SerializeRangeToString(mRange, aOutputString);
 
       mRange = nsnull;
   } else if (mNode) {
     rv = SerializeToStringRecursive(mNode, aOutputString, mNodeIsContainer);
     mNode = nsnull;
   } else {
-    nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(mDocument));
-    rv = mSerializer->AppendDocumentStart(domdoc, aOutputString);
+    rv = mSerializer->AppendDocumentStart(mDocument, aOutputString);
 
     if (NS_SUCCEEDED(rv)) {
       rv = SerializeToStringRecursive(mDocument, aOutputString, PR_FALSE);
     }
   }
 
   NS_ENSURE_SUCCESS(rv, rv);
   rv = mSerializer->Flush(aOutputString);
--- a/content/base/src/nsHTMLContentSerializer.cpp
+++ b/content/base/src/nsHTMLContentSerializer.cpp
@@ -87,25 +87,25 @@ nsHTMLContentSerializer::nsHTMLContentSe
 }
 
 nsHTMLContentSerializer::~nsHTMLContentSerializer()
 {
 }
 
 
 NS_IMETHODIMP
-nsHTMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
+nsHTMLContentSerializer::AppendDocumentStart(nsIDocument *aDocument,
                                              nsAString& aStr)
 {
   return NS_OK;
 }
 
 void 
 nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
-                                                 nsIDOMElement *aOriginalElement,
+                                                 nsIContent *aOriginalElement,
                                                  nsAString& aTagPrefix,
                                                  const nsAString& aTagNamespaceURI,
                                                  nsIAtom* aTagName,
                                                  nsAString& aStr)
 {
   PRInt32 count = aContent->GetAttrCount();
   if (!count)
     return;
@@ -185,24 +185,23 @@ nsHTMLContentSerializer::SerializeHTMLAt
     if (IsShorthandAttr(attrName, aTagName) && valueStr.IsEmpty()) {
       valueStr = nameStr;
     }
     SerializeAttr(EmptyString(), nameStr, valueStr, aStr, !isJS);
   }
 }
 
 NS_IMETHODIMP
-nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
-                                            nsIDOMElement *aOriginalElement,
+nsHTMLContentSerializer::AppendElementStart(nsIContent *aElement,
+                                            nsIContent *aOriginalElement,
                                             nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
-  if (!content) return NS_ERROR_FAILURE;
+  nsIContent* content = aElement;
 
   PRBool forceFormat = PR_FALSE;
   if (!CheckElementStart(content, forceFormat, aStr)) {
     return NS_OK;
   }
 
   nsIAtom *name = content->Tag();
   PRBool lineBreakBeforeOpen = LineBreakBeforeOpen(content->GetNameSpaceID(), name);
@@ -245,17 +244,18 @@ nsHTMLContentSerializer::AppendElementSt
 
   // Need to keep track of OL and LI elements in order to get ordinal number 
   // for the LI.
   if (mIsCopying && name == nsGkAtoms::ol){
     // We are copying and current node is an OL;
     // Store its start attribute value in olState->startVal.
     nsAutoString start;
     PRInt32 startAttrVal = 0;
-    aElement->GetAttribute(NS_LITERAL_STRING("start"), start);
+
+    aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::start, start);
     if (!start.IsEmpty()){
       PRInt32 rv = 0;
       startAttrVal = start.ToInteger(&rv);
       //If OL has "start" attribute, first LI element has to start with that value
       //Therefore subtracting 1 as all the LI elements are incrementing it before using it;
       //In failure of ToInteger(), default StartAttrValue to 0.
       if (NS_SUCCEEDED(rv))
         startAttrVal--; 
@@ -293,23 +293,22 @@ nsHTMLContentSerializer::AppendElementSt
   }
 
   AfterElementStart(content, aOriginalElement, aStr);
 
   return NS_OK;
 }
   
 NS_IMETHODIMP 
-nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
+nsHTMLContentSerializer::AppendElementEnd(nsIContent *aElement,
                                           nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
-  if (!content) return NS_ERROR_FAILURE;
+  nsIContent* content = aElement;
 
   nsIAtom *name = content->Tag();
 
   if (name == nsGkAtoms::script ||
       name == nsGkAtoms::style ||
       name == nsGkAtoms::noscript ||
       name == nsGkAtoms::noframes) {
     --mDisableEntityEncoding;
--- a/content/base/src/nsHTMLContentSerializer.h
+++ b/content/base/src/nsHTMLContentSerializer.h
@@ -52,29 +52,29 @@
 class nsIContent;
 class nsIAtom;
 
 class nsHTMLContentSerializer : public nsXHTMLContentSerializer {
  public:
   nsHTMLContentSerializer();
   virtual ~nsHTMLContentSerializer();
 
-  NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
-                                nsIDOMElement *aOriginalElement,
+  NS_IMETHOD AppendElementStart(nsIContent *aElement,
+                                nsIContent *aOriginalElement,
                                 nsAString& aStr);
   
-  NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
+  NS_IMETHOD AppendElementEnd(nsIContent *aElement,
                               nsAString& aStr);
 
-  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
                                  nsAString& aStr);
  protected:
 
   virtual void SerializeHTMLAttributes(nsIContent* aContent,
-                                       nsIDOMElement *aOriginalElement,
+                                       nsIContent *aOriginalElement,
                                        nsAString& aTagPrefix,
                                        const nsAString& aTagNamespaceURI,
                                        nsIAtom* aTagName,
                                        nsAString& aStr);
 
   virtual void AppendAndTranslateEntities(const nsAString& aStr,
                                           nsAString& aOutputStr);
 
--- a/content/base/src/nsPlainTextSerializer.cpp
+++ b/content/base/src/nsPlainTextSerializer.cpp
@@ -285,17 +285,17 @@ nsPlainTextSerializer::Initialize(nsAStr
   // We're only getting away with this because instances of this
   // class are restricted to single function scope.
   mOutputString = aOutString;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsPlainTextSerializer::AppendText(nsIDOMText* aText, 
+nsPlainTextSerializer::AppendText(nsIContent* aText,
                                   PRInt32 aStartOffset,
                                   PRInt32 aEndOffset, 
                                   nsAString& aStr)
 {
   if (mIgnoreAboveIndex != (PRUint32)kNotFound) {
     return NS_OK;
   }
     
@@ -304,17 +304,17 @@ nsPlainTextSerializer::AppendText(nsIDOM
     return NS_ERROR_INVALID_ARG;
 
   NS_ENSURE_ARG(aText);
 
   nsresult rv = NS_OK;
   PRInt32 length = 0;
   nsAutoString textstr;
 
-  nsCOMPtr<nsIContent> content = do_QueryInterface(aText);
+  nsIContent* content = aText;
   const nsTextFragment* frag;
   if (!content || !(frag = content->GetText())) {
     return NS_ERROR_FAILURE;
   }
   
   PRInt32 endoffset = (aEndOffset == -1) ? frag->GetLength() : aEndOffset;
   NS_ASSERTION(aStartOffset <= endoffset, "A start offset is beyond the end of the text fragment!");
 
@@ -367,33 +367,32 @@ nsPlainTextSerializer::AppendText(nsIDOM
   }
   
   mOutputString = nsnull;
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsPlainTextSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
+nsPlainTextSerializer::AppendCDATASection(nsIContent* aCDATASection,
                                           PRInt32 aStartOffset,
                                           PRInt32 aEndOffset,
                                           nsAString& aStr)
 {
   return AppendText(aCDATASection, aStartOffset, aEndOffset, aStr);
 }
 
 NS_IMETHODIMP
-nsPlainTextSerializer::AppendElementStart(nsIDOMElement *aElement,
-                                          nsIDOMElement *aOriginalElement,
+nsPlainTextSerializer::AppendElementStart(nsIContent *aElement,
+                                          nsIContent *aOriginalElement,
                                           nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  mContent = do_QueryInterface(aElement);
-  if (!mContent) return NS_ERROR_FAILURE;
+  mContent = aElement;
 
   nsresult rv;
   PRInt32 id = GetIdForContent(mContent);
 
   PRBool isContainer = IsContainer(id);
 
   mOutputString = &aStr;
 
@@ -410,23 +409,22 @@ nsPlainTextSerializer::AppendElementStar
   if (id == eHTMLTag_head) {
     ++mHeadLevel;
   }
 
   return rv;
 } 
  
 NS_IMETHODIMP 
-nsPlainTextSerializer::AppendElementEnd(nsIDOMElement *aElement,
+nsPlainTextSerializer::AppendElementEnd(nsIContent *aElement,
                                         nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  mContent = do_QueryInterface(aElement);
-  if (!mContent) return NS_ERROR_FAILURE;
+  mContent = aElement;
 
   nsresult rv;
   PRInt32 id = GetIdForContent(mContent);
 
   PRBool isContainer = IsContainer(id);
 
   mOutputString = &aStr;
 
@@ -451,18 +449,18 @@ nsPlainTextSerializer::Flush(nsAString& 
 {
   mOutputString = &aStr;
   FlushLine();
   mOutputString = nsnull;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPlainTextSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
-                                             nsAString& aStr)
+nsPlainTextSerializer::AppendDocumentStart(nsIDocument *aDocument,
+                                           nsAString& aStr)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsPlainTextSerializer::OpenContainer(const nsIParserNode& aNode)
 {
   PRInt32 type = aNode.GetNodeType();
--- a/content/base/src/nsPlainTextSerializer.h
+++ b/content/base/src/nsPlainTextSerializer.h
@@ -66,37 +66,37 @@ public:
 
   NS_DECL_ISUPPORTS
 
   // nsIContentSerializer
   NS_IMETHOD Init(PRUint32 flags, PRUint32 aWrapColumn,
                   const char* aCharSet, PRBool aIsCopying,
                   PRBool aIsWholeDocument);
 
-  NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
+  NS_IMETHOD AppendText(nsIContent* aText, PRInt32 aStartOffset,
                         PRInt32 aEndOffset, nsAString& aStr);
-  NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
+  NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
                                 PRInt32 aStartOffset, PRInt32 aEndOffset,
                                 nsAString& aStr);
-  NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
+  NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
                                          PRInt32 aStartOffset,
                                          PRInt32 aEndOffset,
                                          nsAString& aStr)  { return NS_OK; }
-  NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
+  NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
                            PRInt32 aEndOffset, nsAString& aStr)  { return NS_OK; }
-  NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype,
+  NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
                            nsAString& aStr)  { return NS_OK; }
-  NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
-                                nsIDOMElement *aOriginalElement,
+  NS_IMETHOD AppendElementStart(nsIContent *aElement,
+                                nsIContent *aOriginalElement,
                                 nsAString& aStr); 
-  NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
+  NS_IMETHOD AppendElementEnd(nsIContent *aElement,
                               nsAString& aStr);
   NS_IMETHOD Flush(nsAString& aStr);
 
-  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
                                  nsAString& aStr);
 
   // nsIContentSink
   NS_IMETHOD WillParse(void) { return NS_OK; }
   NS_IMETHOD WillInterrupt(void) { return NS_OK; }
   NS_IMETHOD WillResume(void) { return NS_OK; }
   NS_IMETHOD SetParser(nsIParser* aParser) { return NS_OK; }
   NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
--- a/content/base/src/nsXHTMLContentSerializer.cpp
+++ b/content/base/src/nsXHTMLContentSerializer.cpp
@@ -150,17 +150,17 @@ nsXHTMLContentSerializer::HasLongLines(c
     if (PRInt32(eol - start) > kLongLineLen)
       rv = PR_TRUE;
     start = eol + 1;
   }
   return rv;
 }
 
 NS_IMETHODIMP
-nsXHTMLContentSerializer::AppendText(nsIDOMText* aText,
+nsXHTMLContentSerializer::AppendText(nsIContent* aText,
                                      PRInt32 aStartOffset,
                                      PRInt32 aEndOffset,
                                      nsAString& aStr)
 {
   NS_ENSURE_ARG(aText);
 
   nsAutoString data;
   nsresult rv;
@@ -255,17 +255,17 @@ nsXHTMLContentSerializer::EscapeURI(nsIC
     AppendASCIItoUTF16(escapedURI, aEscapedURI);
   }
 
   return rv;
 }
 
 void
 nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
-                                              nsIDOMElement *aOriginalElement,
+                                              nsIContent *aOriginalElement,
                                               nsAString& aTagPrefix,
                                               const nsAString& aTagNamespaceURI,
                                               nsIAtom* aTagName,
                                               nsAString& aStr,
                                               PRUint32 aSkipAttr,
                                               PRBool aAddNSAttr)
 {
   nsresult rv;
@@ -301,19 +301,18 @@ nsXHTMLContentSerializer::SerializeAttri
           startAttrVal = 0;
       }
       olState state (startAttrVal, PR_TRUE);
       mOLStateStack.AppendElement(state);
     }
     else if (aTagName == nsGkAtoms::li) {
       mIsFirstChildOfOL = IsFirstChildOfOL(aOriginalElement);
       if (mIsFirstChildOfOL) {
-        nsCOMPtr<nsIDOMElement> element (do_QueryInterface(aContent));
         // If OL is parent of this LI, serialize attributes in different manner.
-        SerializeLIValueAttribute(element, aStr);
+        SerializeLIValueAttribute(aContent, aStr);
       }
     }
   }
 
   // If we had to add a new namespace declaration, serialize
   // and push it on the namespace stack
   if (aAddNSAttr) {
     if (aTagPrefix.IsEmpty()) {
@@ -440,32 +439,32 @@ nsXHTMLContentSerializer::SerializeAttri
       SerializeAttr(xmlnsStr, prefixStr, uriStr, aStr, PR_TRUE);
       PushNameSpaceDecl(prefixStr, uriStr, aOriginalElement);
     }
   }
 }
 
 
 void 
-nsXHTMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
+nsXHTMLContentSerializer::AppendEndOfElementStart(nsIContent *aOriginalElement,
                                                   nsIAtom * aName,
                                                   PRInt32 aNamespaceID,
                                                   nsAString& aStr)
 {
   // this method is not called by nsHTMLContentSerializer
   // so we don't have to check HTML element, just XHTML
   NS_ASSERTION(!mIsHTMLSerializer, "nsHTMLContentSerializer shouldn't call this method !");
 
   if (kNameSpaceID_XHTML != aNamespaceID) {
     nsXMLContentSerializer::AppendEndOfElementStart(aOriginalElement, aName,
                                                     aNamespaceID, aStr);
     return;
   }
 
-  nsCOMPtr<nsIContent> content = do_QueryInterface(aOriginalElement);
+  nsIContent* content = aOriginalElement;
 
   // for non empty elements, even if they are not a container, we always
   // serialize their content, because the XHTML element could contain non XHTML
   // nodes useful in some context, like in an XSLT stylesheet
   if (HasNoChildren(content)) {
 
     nsIParserService* parserService = nsContentUtils::GetParserService();
   
@@ -482,17 +481,17 @@ nsXHTMLContentSerializer::AppendEndOfEle
       }
     }
   }
   AppendToString(kGreaterThan, aStr);
 }
 
 void
 nsXHTMLContentSerializer::AfterElementStart(nsIContent * aContent,
-                                            nsIDOMElement *aOriginalElement,
+                                            nsIContent *aOriginalElement,
                                             nsAString& aStr)
 {
   nsIAtom *name = aContent->Tag();
   if (aContent->GetNameSpaceID() == kNameSpaceID_XHTML &&
       mRewriteEncodingDeclaration &&
       name == nsGkAtoms::head) {
 
     // Check if there already are any content-type meta children.
@@ -545,17 +544,17 @@ nsXHTMLContentSerializer::AfterElementEn
   // so we don't have to check HTML element, just XHTML
   if (kNameSpaceID_XHTML == namespaceID && name == nsGkAtoms::body) {
     --mInBody;
   }
 }
 
 
 NS_IMETHODIMP
-nsXHTMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
+nsXHTMLContentSerializer::AppendDocumentStart(nsIDocument *aDocument,
                                               nsAString& aStr)
 {
   if (!mBodyOnly)
     return nsXMLContentSerializer::AppendDocumentStart(aDocument, aStr);
 
   return NS_OK;
 }
 
@@ -974,17 +973,17 @@ nsXHTMLContentSerializer::MaybeLeaveFrom
       name == nsGkAtoms::noscript ||
       name == nsGkAtoms::noframes
     ) {
     --mPreLevel;
   }
 }
 
 void 
-nsXHTMLContentSerializer::SerializeLIValueAttribute(nsIDOMElement* aElement,
+nsXHTMLContentSerializer::SerializeLIValueAttribute(nsIContent* aElement,
                                                     nsAString& aStr)
 {
   // We are copying and we are at the "first" LI node of OL in selected range.
   // It may not be the first LI child of OL but it's first in the selected range.
   // Note that we get into this condition only once per a OL.
   PRBool found = PR_FALSE;
   nsCOMPtr<nsIDOMNode> currNode = do_QueryInterface(aElement);
   nsAutoString valueStr;
@@ -1045,17 +1044,17 @@ nsXHTMLContentSerializer::SerializeLIVal
 
     //As serializer needs to use this valueAttr we are creating here, 
     valueStr.AppendInt(startVal + offset);
     SerializeAttr(EmptyString(), NS_LITERAL_STRING("value"), valueStr, aStr, PR_FALSE);
   }
 }
 
 PRBool
-nsXHTMLContentSerializer::IsFirstChildOfOL(nsIDOMElement* aElement)
+nsXHTMLContentSerializer::IsFirstChildOfOL(nsIContent* aElement)
 {
   nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement);
   nsAutoString parentName;
 
   nsCOMPtr<nsIDOMNode> parentNode;
   node->GetParentNode(getter_AddRefs(parentNode));
   if (parentNode)
     parentNode->GetNodeName(parentName);
--- a/content/base/src/nsXHTMLContentSerializer.h
+++ b/content/base/src/nsXHTMLContentSerializer.h
@@ -57,38 +57,38 @@ class nsXHTMLContentSerializer : public 
  public:
   nsXHTMLContentSerializer();
   virtual ~nsXHTMLContentSerializer();
 
   NS_IMETHOD Init(PRUint32 flags, PRUint32 aWrapColumn,
                   const char* aCharSet, PRBool aIsCopying,
                   PRBool aRewriteEncodingDeclaration);
 
-  NS_IMETHOD AppendText(nsIDOMText* aText,
+  NS_IMETHOD AppendText(nsIContent* aText,
                         PRInt32 aStartOffset,
                         PRInt32 aEndOffset,
                         nsAString& aStr);
 
-  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
                                  nsAString& aStr);
 
  protected:
 
 
   virtual PRBool CheckElementStart(nsIContent * aContent,
                           PRBool & aForceFormat,
                           nsAString& aStr);
 
-  virtual void AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
+  virtual void AppendEndOfElementStart(nsIContent *aOriginalElement,
                                nsIAtom * aName,
                                PRInt32 aNamespaceID,
                                nsAString& aStr);
 
   virtual void AfterElementStart(nsIContent * aContent,
-                         nsIDOMElement *aOriginalElement,
+                         nsIContent *aOriginalElement,
                          nsAString& aStr);
 
   virtual PRBool CheckElementEnd(nsIContent * aContent,
                           PRBool & aForceFormat,
                           nsAString& aStr);
 
   virtual void AfterElementEnd(nsIContent * aContent,
                                nsAString& aStr);
@@ -100,27 +100,27 @@ class nsXHTMLContentSerializer : public 
 
   PRBool HasLongLines(const nsString& text, PRInt32& aLastNewlineOffset);
 
   // functions to check if we enter in or leave from a preformated content
   virtual void MaybeEnterInPreContent(nsIContent* aNode);
   virtual void MaybeLeaveFromPreContent(nsIContent* aNode);
 
   virtual void SerializeAttributes(nsIContent* aContent,
-                           nsIDOMElement *aOriginalElement,
+                           nsIContent *aOriginalElement,
                            nsAString& aTagPrefix,
                            const nsAString& aTagNamespaceURI,
                            nsIAtom* aTagName,
                            nsAString& aStr,
                            PRUint32 aSkipAttr,
                            PRBool aAddNSAttr);
 
-  PRBool IsFirstChildOfOL(nsIDOMElement* aElement);
+  PRBool IsFirstChildOfOL(nsIContent* aElement);
 
-  void SerializeLIValueAttribute(nsIDOMElement* aElement,
+  void SerializeLIValueAttribute(nsIContent* aElement,
                                  nsAString& aStr);
   PRBool IsShorthandAttr(const nsIAtom* aAttrName,
                          const nsIAtom* aElementName);
 
   virtual void AppendToString(const PRUnichar* aStr,
                               PRInt32 aLength,
                               nsAString& aOutputStr);
   virtual void AppendToString(const PRUnichar aChar,
--- a/content/base/src/nsXMLContentSerializer.cpp
+++ b/content/base/src/nsXMLContentSerializer.cpp
@@ -143,23 +143,23 @@ nsXMLContentSerializer::Init(PRUint32 aF
   }
 
   mPreLevel = 0;
   mIsIndentationAddedOnCurrentLine = PR_FALSE;
   return NS_OK;
 }
 
 nsresult
-nsXMLContentSerializer::AppendTextData(nsIDOMNode* aNode,
+nsXMLContentSerializer::AppendTextData(nsIContent* aNode,
                                        PRInt32 aStartOffset,
                                        PRInt32 aEndOffset,
                                        nsAString& aStr,
                                        PRBool aTranslateEntities)
 {
-  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
+  nsIContent* content = aNode;
   const nsTextFragment* frag;
   if (!content || !(frag = content->GetText())) {
     return NS_ERROR_FAILURE;
   }
 
   PRInt32 endoffset = (aEndOffset == -1) ? frag->GetLength() : aEndOffset;
   PRInt32 length = endoffset - aStartOffset;
 
@@ -189,17 +189,17 @@ nsXMLContentSerializer::AppendTextData(n
       aStr.Append(NS_ConvertASCIItoUTF16(frag->Get1b()+aStartOffset, length));
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendText(nsIDOMText* aText,
+nsXMLContentSerializer::AppendText(nsIContent* aText,
                                    PRInt32 aStartOffset,
                                    PRInt32 aEndOffset,
                                    nsAString& aStr)
 {
   NS_ENSURE_ARG(aText);
 
   nsAutoString data;
   nsresult rv;
@@ -220,17 +220,17 @@ nsXMLContentSerializer::AppendText(nsIDO
   else {
     AppendToStringConvertLF(data, aStr);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
+nsXMLContentSerializer::AppendCDATASection(nsIContent* aCDATASection,
                                            PRInt32 aStartOffset,
                                            PRInt32 aEndOffset,
                                            nsAString& aStr)
 {
   NS_ENSURE_ARG(aCDATASection);
   nsresult rv;
 
   NS_NAMED_LITERAL_STRING(cdata , "<![CDATA[");
@@ -255,31 +255,32 @@ nsXMLContentSerializer::AppendCDATASecti
   AppendToStringConvertLF(data, aStr);
 
   AppendToString(NS_LITERAL_STRING("]]>"), aStr);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
+nsXMLContentSerializer::AppendProcessingInstruction(nsIContent* aPI,
                                                     PRInt32 aStartOffset,
                                                     PRInt32 aEndOffset,
                                                     nsAString& aStr)
 {
-  NS_ENSURE_ARG(aPI);
+  nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(aPI);
+  NS_ENSURE_ARG(pi);
   nsresult rv;
   nsAutoString target, data, start;
 
   MaybeAddNewlineForRootNode(aStr);
 
-  rv = aPI->GetTarget(target);
+  rv = pi->GetTarget(target);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
-  rv = aPI->GetData(data);
+  rv = pi->GetData(data);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
   start.AppendLiteral("<?");
   start.Append(target);
 
   if (mPreLevel > 0 || mDoRaw) {
     AppendToString(start, aStr);
   }
@@ -303,26 +304,27 @@ nsXMLContentSerializer::AppendProcessing
   AppendToString(NS_LITERAL_STRING("?>"), aStr);
 
   MaybeFlagNewlineForRootNode(aPI);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendComment(nsIDOMComment* aComment,
+nsXMLContentSerializer::AppendComment(nsIContent* aComment,
                                       PRInt32 aStartOffset,
                                       PRInt32 aEndOffset,
                                       nsAString& aStr)
 {
-  NS_ENSURE_ARG(aComment);
+  nsCOMPtr<nsIDOMComment> comment = do_QueryInterface(aComment);
+  NS_ENSURE_ARG(comment);
   nsresult rv;
   nsAutoString data;
 
-  rv = aComment->GetData(data);
+  rv = comment->GetData(data);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
   if (aStartOffset || (aEndOffset != -1)) {
     PRInt32 length = (aEndOffset == -1) ? data.Length() : aEndOffset;
     length -= aStartOffset;
 
     nsAutoString frag;
     data.Mid(frag, aStartOffset, length);
@@ -355,30 +357,31 @@ nsXMLContentSerializer::AppendComment(ns
   AppendToString(NS_LITERAL_STRING("-->"), aStr);
 
   MaybeFlagNewlineForRootNode(aComment);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendDoctype(nsIDOMDocumentType *aDoctype,
+nsXMLContentSerializer::AppendDoctype(nsIContent* aDocType,
                                       nsAString& aStr)
 {
-  NS_ENSURE_ARG(aDoctype);
+  nsCOMPtr<nsIDOMDocumentType> docType = do_QueryInterface(aDocType);
+  NS_ENSURE_ARG(docType);
   nsresult rv;
   nsAutoString name, publicId, systemId, internalSubset;
 
-  rv = aDoctype->GetName(name);
+  rv = docType->GetName(name);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-  rv = aDoctype->GetPublicId(publicId);
+  rv = docType->GetPublicId(publicId);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-  rv = aDoctype->GetSystemId(systemId);
+  rv = docType->GetSystemId(systemId);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-  rv = aDoctype->GetInternalSubset(internalSubset);
+  rv = docType->GetInternalSubset(internalSubset);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
   MaybeAddNewlineForRootNode(aStr);
 
   AppendToString(NS_LITERAL_STRING("<!DOCTYPE "), aStr);
   AppendToString(name, aStr);
 
   PRUnichar quote;
@@ -422,55 +425,55 @@ nsXMLContentSerializer::AppendDoctype(ns
   
   if (!internalSubset.IsEmpty()) {
     AppendToString(NS_LITERAL_STRING(" ["), aStr);
     AppendToString(internalSubset, aStr);
     AppendToString(PRUnichar(']'), aStr);
   }
     
   AppendToString(kGreaterThan, aStr);
-  MaybeFlagNewlineForRootNode(aDoctype);
+  MaybeFlagNewlineForRootNode(aDocType);
 
   return NS_OK;
 }
 
 nsresult
 nsXMLContentSerializer::PushNameSpaceDecl(const nsAString& aPrefix,
                                           const nsAString& aURI,
-                                          nsIDOMElement* aOwner)
+                                          nsIContent* aOwner)
 {
   NameSpaceDecl* decl = mNameSpaceStack.AppendElement();
   if (!decl) return NS_ERROR_OUT_OF_MEMORY;
 
   decl->mPrefix.Assign(aPrefix);
   decl->mURI.Assign(aURI);
   // Don't addref - this weak reference will be removed when
   // we pop the stack
   decl->mOwner = aOwner;
   return NS_OK;
 }
 
 void
-nsXMLContentSerializer::PopNameSpaceDeclsFor(nsIDOMElement* aOwner)
+nsXMLContentSerializer::PopNameSpaceDeclsFor(nsIContent* aOwner)
 {
   PRInt32 index, count;
 
   count = mNameSpaceStack.Length();
   for (index = count - 1; index >= 0; index--) {
     if (mNameSpaceStack[index].mOwner != aOwner) {
       break;
     }
     mNameSpaceStack.RemoveElementAt(index);
   }
 }
 
 PRBool
 nsXMLContentSerializer::ConfirmPrefix(nsAString& aPrefix,
                                       const nsAString& aURI,
-                                      nsIDOMElement* aElement,
+                                      nsIContent* aElement,
                                       PRBool aIsAttribute)
 {
   if (aPrefix.EqualsLiteral(kXMLNS)) {
     return PR_FALSE;
   }
 
   if (aURI.EqualsLiteral("http://www.w3.org/XML/1998/namespace")) {
     // The prefix must be xml for this namespace. We don't need to declare it,
@@ -711,17 +714,17 @@ nsXMLContentSerializer::SerializeAttr(co
   }
   else {
     AppendToStringConvertLF(attrString, aStr);
   }
 }
 
 PRUint32 
 nsXMLContentSerializer::ScanNamespaceDeclarations(nsIContent* aContent,
-                                                  nsIDOMElement *aOriginalElement,
+                                                  nsIContent *aOriginalElement,
                                                   const nsAString& aTagNamespaceURI)
 {
   PRUint32 index, count;
   nsAutoString uriStr, valueStr;
 
   count = aContent->GetAttrCount();
 
   // First scan for namespace declarations, pushing each on the stack
@@ -807,17 +810,17 @@ nsXMLContentSerializer::IsJavaScript(nsI
                                                 EventNameType_SVGGraphic | EventNameType_SVGSVG);
   }
   return PR_FALSE;
 }
 
 
 void 
 nsXMLContentSerializer::SerializeAttributes(nsIContent* aContent,
-                                            nsIDOMElement *aOriginalElement,
+                                            nsIContent *aOriginalElement,
                                             nsAString& aTagPrefix,
                                             const nsAString& aTagNamespaceURI,
                                             nsIAtom* aTagName,
                                             nsAString& aStr,
                                             PRUint32 aSkipAttr,
                                             PRBool aAddNSAttr)
 {
 
@@ -887,34 +890,33 @@ nsXMLContentSerializer::SerializeAttribu
                    "Namespaced attributes must have a prefix");
       SerializeAttr(xmlnsStr, prefixStr, uriStr, aStr, PR_TRUE);
       PushNameSpaceDecl(prefixStr, uriStr, aOriginalElement);
     }
   }
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
-                                           nsIDOMElement *aOriginalElement,
+nsXMLContentSerializer::AppendElementStart(nsIContent *aElement,
+                                           nsIContent *aOriginalElement,
                                            nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  nsCOMPtr<nsIContent> content(do_QueryInterface(aElement));
-  if (!content) return NS_ERROR_FAILURE;
+  nsIContent* content = aElement;
 
   PRBool forceFormat = PR_FALSE;
   if (!CheckElementStart(content, forceFormat, aStr)) {
     return NS_OK;
   }
 
   nsAutoString tagPrefix, tagLocalName, tagNamespaceURI;
-  aElement->GetPrefix(tagPrefix);
-  aElement->GetLocalName(tagLocalName);
-  aElement->GetNamespaceURI(tagNamespaceURI);
+  aElement->NodeInfo()->GetPrefix(tagPrefix);
+  aElement->NodeInfo()->GetLocalName(tagLocalName);
+  aElement->NodeInfo()->GetNamespaceURI(tagNamespaceURI);
 
   PRUint32 skipAttr = ScanNamespaceDeclarations(content,
                           aOriginalElement, tagNamespaceURI);
 
   nsIAtom *name = content->Tag();
   PRBool lineBreakBeforeOpen = LineBreakBeforeOpen(content->GetNameSpaceID(), name);
 
   if ((mDoFormat || forceFormat) && !mPreLevel && !mDoRaw) {
@@ -974,40 +976,37 @@ nsXMLContentSerializer::AppendElementSta
   }
 
   AfterElementStart(content, aOriginalElement, aStr);
 
   return NS_OK;
 }
 
 void 
-nsXMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
+nsXMLContentSerializer::AppendEndOfElementStart(nsIContent *aOriginalElement,
                                                 nsIAtom * aName,
                                                 PRInt32 aNamespaceID,
                                                 nsAString& aStr)
 {
   // We don't output a separate end tag for empty elements
-  PRBool hasChildren = PR_FALSE;
-  if (NS_FAILED(aOriginalElement->HasChildNodes(&hasChildren)) ||
-      !hasChildren) {
+  if (!aOriginalElement->GetChildCount()) {
     AppendToString(NS_LITERAL_STRING("/>"), aStr);
   }
   else {
     AppendToString(kGreaterThan, aStr);
   }
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
+nsXMLContentSerializer::AppendElementEnd(nsIContent *aElement,
                                          nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  nsCOMPtr<nsIContent> content(do_QueryInterface(aElement));
-  if (!content) return NS_ERROR_FAILURE;
+  nsIContent* content = aElement;
 
   PRBool forceFormat = PR_FALSE, outputElementEnd;
   outputElementEnd = CheckElementEnd(content, forceFormat, aStr);
 
   nsIAtom *name = content->Tag();
 
   if ((mDoFormat || forceFormat) && !mPreLevel && !mDoRaw) {
     DecrIndentation(name);
@@ -1016,19 +1015,19 @@ nsXMLContentSerializer::AppendElementEnd
   if (!outputElementEnd) {
     PopNameSpaceDeclsFor(aElement);
     MaybeFlagNewlineForRootNode(aElement);
     return NS_OK;
   }
 
   nsAutoString tagPrefix, tagLocalName, tagNamespaceURI;
   
-  aElement->GetPrefix(tagPrefix);
-  aElement->GetLocalName(tagLocalName);
-  aElement->GetNamespaceURI(tagNamespaceURI);
+  aElement->NodeInfo()->GetPrefix(tagPrefix);
+  aElement->NodeInfo()->GetLocalName(tagLocalName);
+  aElement->NodeInfo()->GetNamespaceURI(tagNamespaceURI);
 
 #ifdef DEBUG
   PRBool debugNeedToPushNamespace =
 #endif
   ConfirmPrefix(tagPrefix, tagNamespaceURI, aElement, PR_FALSE);
   NS_ASSERTION(!debugNeedToPushNamespace, "Can't push namespaces in closing tag!");
 
   if ((mDoFormat || forceFormat) && !mPreLevel && !mDoRaw) {
@@ -1072,28 +1071,23 @@ nsXMLContentSerializer::AppendElementEnd
   }
 
   AfterElementEnd(content, aStr);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsXMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
+nsXMLContentSerializer::AppendDocumentStart(nsIDocument *aDocument,
                                             nsAString& aStr)
 {
   NS_ENSURE_ARG_POINTER(aDocument);
 
-  nsCOMPtr<nsIDocument> doc(do_QueryInterface(aDocument));
-  if (!doc) {
-    return NS_OK;
-  }
-
   nsAutoString version, encoding, standalone;
-  doc->GetXMLDeclaration(version, encoding, standalone);
+  aDocument->GetXMLDeclaration(version, encoding, standalone);
 
   if (version.IsEmpty())
     return NS_OK; // A declaration must have version, or there is no decl
 
   NS_NAMED_LITERAL_STRING(endQuote, "\"");
 
   aStr += NS_LITERAL_STRING("<?xml version=\"") + version + endQuote;
   
@@ -1129,27 +1123,20 @@ nsXMLContentSerializer::CheckElementStar
 }
 
 PRBool
 nsXMLContentSerializer::CheckElementEnd(nsIContent * aContent,
                                         PRBool & aForceFormat,
                                         nsAString& aStr)
 {
   // We don't output a separate end tag for empty element
-  nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aContent));
-  PRBool hasChildren;
   aForceFormat = PR_FALSE;
-
-  if (NS_SUCCEEDED(node->HasChildNodes(&hasChildren)) && !hasChildren) {
-    return PR_FALSE;
-  }
-  return PR_TRUE;
+  return aContent->GetChildCount() > 0;
 }
 
-
 void
 nsXMLContentSerializer::AppendToString(const PRUnichar* aStr,
                                        PRInt32 aLength,
                                        nsAString& aOutputStr)
 {
   PRInt32 length = (aLength == -1) ? nsCRT::strlen(aStr) : aLength;
 
   mColPos += length;
@@ -1240,24 +1227,21 @@ void
 nsXMLContentSerializer::MaybeAddNewlineForRootNode(nsAString& aStr)
 {
   if (mAddNewlineForRootNode) {
     AppendNewLineToString(aStr);
   }
 }
 
 void
-nsXMLContentSerializer::MaybeFlagNewlineForRootNode(nsIDOMNode* aNode)
+nsXMLContentSerializer::MaybeFlagNewlineForRootNode(nsINode* aNode)
 {
-  nsCOMPtr<nsIDOMNode> parent;
-  aNode->GetParentNode(getter_AddRefs(parent));
+  nsINode* parent = aNode->GetNodeParent();
   if (parent) {
-    PRUint16 type;
-    parent->GetNodeType(&type);
-    mAddNewlineForRootNode = type == nsIDOMNode::DOCUMENT_NODE;
+    mAddNewlineForRootNode = aNode->IsNodeOfType(nsINode::eDOCUMENT);
   }
 }
 
 void
 nsXMLContentSerializer::MaybeEnterInPreContent(nsIContent* aNode)
 {
   // support of the xml:space attribute
   if (aNode->HasAttr(kNameSpaceID_XML, nsGkAtoms::space)) {
--- a/content/base/src/nsXMLContentSerializer.h
+++ b/content/base/src/nsXMLContentSerializer.h
@@ -65,44 +65,44 @@ class nsXMLContentSerializer : public ns
   virtual ~nsXMLContentSerializer();
 
   NS_DECL_ISUPPORTS
 
   NS_IMETHOD Init(PRUint32 flags, PRUint32 aWrapColumn,
                   const char* aCharSet, PRBool aIsCopying,
                   PRBool aRewriteEncodingDeclaration);
 
-  NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
+  NS_IMETHOD AppendText(nsIContent* aText, PRInt32 aStartOffset,
                         PRInt32 aEndOffset, nsAString& aStr);
 
-  NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
+  NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
                                 PRInt32 aStartOffset, PRInt32 aEndOffset,
                                 nsAString& aStr);
 
-  NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
+  NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
                                          PRInt32 aStartOffset,
                                          PRInt32 aEndOffset,
                                          nsAString& aStr);
 
-  NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
+  NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
                            PRInt32 aEndOffset, nsAString& aStr);
   
-  NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype,
+  NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
                            nsAString& aStr);
 
-  NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
-                                nsIDOMElement *aOriginalElement,
+  NS_IMETHOD AppendElementStart(nsIContent *aElement,
+                                nsIContent *aOriginalElement,
                                 nsAString& aStr);
   
-  NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
+  NS_IMETHOD AppendElementEnd(nsIContent *aElement,
                               nsAString& aStr);
 
   NS_IMETHOD Flush(nsAString& aStr) { return NS_OK; }
 
-  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
                                  nsAString& aStr);
 
  protected:
 
   /**
    * Appends a PRUnichar string and increments the column position
    */
   virtual void AppendToString(const PRUnichar* aStr,
@@ -180,26 +180,26 @@ class nsXMLContentSerializer : public ns
    */
   virtual void AppendAndTranslateEntities(const nsAString& aStr,
                                           nsAString& aOutputStr);
 
   /**
    * retrieve the text content of the node and append it to the given string
    * It doesn't increment the column position
    */
-  nsresult AppendTextData(nsIDOMNode* aNode,
+  nsresult AppendTextData(nsIContent* aNode,
                           PRInt32 aStartOffset,
                           PRInt32 aEndOffset,
                           nsAString& aStr,
                           PRBool aTranslateEntities);
 
   virtual nsresult PushNameSpaceDecl(const nsAString& aPrefix,
                                      const nsAString& aURI,
-                                     nsIDOMElement* aOwner);
-  void PopNameSpaceDeclsFor(nsIDOMElement* aOwner);
+                                     nsIContent* aOwner);
+  void PopNameSpaceDeclsFor(nsIContent* aOwner);
 
   /**
    * The problem that ConfirmPrefix fixes is that anyone can insert nodes
    * through the DOM that have a namespace URI and a random or empty or
    * previously existing prefix that's totally unrelated to the prefixes
    * declared at that point through xmlns attributes.  So what ConfirmPrefix
    * does is ensure that we can map aPrefix to the namespace URI aURI (for
    * example, that the prefix is not already mapped to some other namespace).
@@ -211,29 +211,29 @@ class nsXMLContentSerializer : public ns
    *                 namespace handling)
    * @param aIsAttribute PR_TRUE if we're confirming a prefix for an attribute.
    * @return PR_TRUE if we need to push the (prefix, uri) pair on the namespace
    *                 stack (note that this can happen even if the prefix is
    *                 empty).
    */
   PRBool ConfirmPrefix(nsAString& aPrefix,
                        const nsAString& aURI,
-                       nsIDOMElement* aElement,
+                       nsIContent* aElement,
                        PRBool aIsAttribute);
   /**
    * GenerateNewPrefix generates a new prefix and writes it to aPrefix
    */
   void GenerateNewPrefix(nsAString& aPrefix);
 
   PRUint32 ScanNamespaceDeclarations(nsIContent* aContent,
-                                     nsIDOMElement *aOriginalElement,
+                                     nsIContent *aOriginalElement,
                                      const nsAString& aTagNamespaceURI);
 
   virtual void SerializeAttributes(nsIContent* aContent,
-                                   nsIDOMElement *aOriginalElement,
+                                   nsIContent *aOriginalElement,
                                    nsAString& aTagPrefix,
                                    const nsAString& aTagNamespaceURI,
                                    nsIAtom* aTagName,
                                    nsAString& aStr,
                                    PRUint32 aSkipAttr,
                                    PRBool aAddNSAttr);
 
   void SerializeAttr(const nsAString& aPrefix,
@@ -258,28 +258,28 @@ class nsXMLContentSerializer : public ns
   virtual PRBool CheckElementStart(nsIContent * aContent,
                                    PRBool & aForceFormat,
                                    nsAString& aStr);
 
   /**
    * this method is responsible to finish the start tag,
    * in particulary to append the "greater than" sign
    */
-  virtual void AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
+  virtual void AppendEndOfElementStart(nsIContent *aOriginalElement,
                                        nsIAtom * aName,
                                        PRInt32 aNamespaceID,
                                        nsAString& aStr);
 
   /**
    * This method can be redefine to serialize additional things just after
    * after the serialization ot the start tag.
    * (called at the end of AppendElementStart)
    */
   virtual void AfterElementStart(nsIContent * aContent,
-                                 nsIDOMElement *aOriginalElement,
+                                 nsIContent *aOriginalElement,
                                  nsAString& aStr) { };
 
   /**
    * This method can be redefined to check if the element can be serialized.
    * It is called when the serialization of the end tag is asked 
    * (AppendElementEnd)
    * In this method you can also force the formating
    * by setting aForceFormat to PR_TRUE.
@@ -323,28 +323,28 @@ class nsXMLContentSerializer : public ns
    */
   void AppendIndentation(nsAString& aStr);
   virtual void IncrIndentation(nsIAtom* aName);
   virtual void DecrIndentation(nsIAtom* aName);
 
   // Functions to check for newlines that needs to be added between nodes in
   // the root of a document. See mAddNewlineForRootNode
   void MaybeAddNewlineForRootNode(nsAString& aStr);
-  void MaybeFlagNewlineForRootNode(nsIDOMNode* aNode);
+  void MaybeFlagNewlineForRootNode(nsINode* aNode);
 
   // Functions to check if we enter in or leave from a preformated content
   virtual void MaybeEnterInPreContent(nsIContent* aNode);
   virtual void MaybeLeaveFromPreContent(nsIContent* aNode);
 
   PRInt32 mPrefixIndex;
 
   struct NameSpaceDecl {
     nsString mPrefix;
     nsString mURI;
-    nsIDOMElement* mOwner;
+    nsIContent* mOwner;
   };
 
   nsTArray<NameSpaceDecl> mNameSpaceStack;
 
   // nsIDocumentEncoder flags
   PRUint32  mFlags;
 
   // characters to use for line break