backout Bug 562321
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 04 May 2010 12:46:37 +0300
changeset 41756 d6bb0f9e951926d3f4f0d8ee3e70d80b408f6411
parent 41755 719244f1a4dfb510f7bbbf17e14549770ae264f6
child 41757 5d60184d9e988e404541c3333ee0e916c08f1dec
push idunknown
push userunknown
push dateunknown
bugs562321
milestone1.9.3a5pre
first release with
nightly linux32
d6bb0f9e9519 / 3.7a5pre / 20100504032111 / files
nightly linux64
d6bb0f9e9519 / 3.7a5pre / 20100504030632 / files
nightly mac
d6bb0f9e9519 / 3.7a5pre / 20100504030631 / files
nightly win32
d6bb0f9e9519 / 3.7a5pre / 20100504040059 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
backout Bug 562321
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,68 +35,73 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef _nsIContentSerializer_h__
 #define _nsIContentSerializer_h__
 
 #include "nsISupports.h"
 
-class nsIContent;
-class nsIDocument;
+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 nsAString;
 
 /* starting interface:    nsIContentSerializer */
 
 #define NS_ICONTENTSERIALIZER_IID \
-{ 0xb1ee32f2, 0xb8c4, 0x49b9, \
-  { 0x93, 0xdf, 0xb6, 0xfa, 0xb5, 0xd5, 0x46, 0x88 } }
+{ 0x34769de0, 0x30d0, 0x4cef, \
+  { 0x89, 0x4a, 0xfc, 0xd8, 0xbb, 0x27, 0xc4, 0xb4 } }
 
 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(nsIContent* aText, PRInt32 aStartOffset,
+  NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
                         PRInt32 aEndOffset, nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
+  NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
                                 PRInt32 aStartOffset, PRInt32 aEndOffset,
                                 nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
+  NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
                                          PRInt32 aStartOffset,
                                          PRInt32 aEndOffset,
                                          nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
+  NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
                            PRInt32 aEndOffset, nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
+  NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype,
                            nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendElementStart(nsIContent *aElement,
-                                nsIContent *aOriginalElement,
+  NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
+                                nsIDOMElement *aOriginalElement,
                                 nsAString& aStr) = 0;
 
-  NS_IMETHOD AppendElementEnd(nsIContent *aElement,
+  NS_IMETHOD AppendElementEnd(nsIDOMElement *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(nsIDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *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(nsIDocument *aDocument,
+mozSanitizingHTMLSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
                                                  nsAString& aStr)
 {
   return NS_OK;
 }
 
 void
 mozSanitizingHTMLSerializer::Write(const nsAString& aString)
 {
@@ -220,39 +220,40 @@ mozSanitizingHTMLSerializer::GetIdForCon
 
   nsIParserService* parserService = nsContentUtils::GetParserService();
 
   return parserService ? parserService->HTMLAtomTagToId(aContent->Tag()) :
                          eHTMLTag_unknown;
 }
 
 NS_IMETHODIMP 
-mozSanitizingHTMLSerializer::AppendText(nsIContent* aText,
+mozSanitizingHTMLSerializer::AppendText(nsIDOMText* 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(nsIContent *aElement,
-                                                nsIContent *aOriginalElement,
+mozSanitizingHTMLSerializer::AppendElementStart(nsIDOMElement *aElement,
+                                                nsIDOMElement *aOriginalElement,
                                                 nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  mContent = aElement;
+  mContent = do_QueryInterface(aElement);
+  NS_ENSURE_TRUE(mContent, NS_ERROR_FAILURE);
 
   mOutputString = &aStr;
 
   PRInt32 id = GetIdForContent(mContent);
 
   PRBool isContainer = IsContainer(id);
 
   nsresult rv;
@@ -265,22 +266,23 @@ mozSanitizingHTMLSerializer::AppendEleme
 
   mContent = 0;
   mOutputString = nsnull;
 
   return rv;
 } 
  
 NS_IMETHODIMP 
-mozSanitizingHTMLSerializer::AppendElementEnd(nsIContent *aElement,
+mozSanitizingHTMLSerializer::AppendElementEnd(nsIDOMElement *aElement,
                                               nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  mContent = aElement;
+  mContent = do_QueryInterface(aElement);
+  NS_ENSURE_TRUE(mContent, NS_ERROR_FAILURE);
 
   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(nsIContent* aText, PRInt32 aStartOffset,
+  NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
                         PRInt32 aEndOffset, nsAString& aStr);
-  NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
+  NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
                                 PRInt32 aStartOffset, PRInt32 aEndOffset,
                                 nsAString& aStr)
                       { return NS_OK; }
-  NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
+  NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
                                          PRInt32 aStartOffset,
                                          PRInt32 aEndOffset,
                                          nsAString& aStr)
                       { return NS_OK; }
-  NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
+  NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
                            PRInt32 aEndOffset, nsAString& aStr)
                       { return NS_OK; }
-  NS_IMETHOD AppendDoctype(nsIContent *aDoctype, nsAString& aStr)
+  NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype, nsAString& aStr)
                       { return NS_OK; }
-  NS_IMETHOD AppendElementStart(nsIContent *aElement,
-                                nsIContent *aOriginalElement,
+  NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
+                                nsIDOMElement *aOriginalElement,
                                 nsAString& aStr); 
-  NS_IMETHOD AppendElementEnd(nsIContent *aElement, nsAString& aStr);
+  NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement, nsAString& aStr);
   NS_IMETHOD Flush(nsAString& aStr);
 
-  NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *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,67 +287,70 @@ 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:
     {
-      nsIContent* originalElement =
-        aOriginalNode && aOriginalNode->IsElement() ?
-          static_cast<nsIContent*>(aOriginalNode) : nsnull;
-      mSerializer->AppendElementStart(static_cast<nsIContent*>(node),
-                                      originalElement, aStr);
+      nsCOMPtr<nsIDOMElement> element = do_QueryInterface(node);
+      nsCOMPtr<nsIDOMElement> originalElement = do_QueryInterface(aOriginalNode);
+      mSerializer->AppendElementStart(element, originalElement, aStr);
       break;
     }
     case nsIDOMNode::TEXT_NODE:
     {
-      mSerializer->AppendText(static_cast<nsIContent*>(node),
-                              aStartOffset, aEndOffset, aStr);
+      nsCOMPtr<nsIDOMText> text = do_QueryInterface(node);
+      mSerializer->AppendText(text, aStartOffset, aEndOffset, aStr);
       break;
     }
     case nsIDOMNode::CDATA_SECTION_NODE:
     {
-      mSerializer->AppendCDATASection(static_cast<nsIContent*>(node),
-                                      aStartOffset, aEndOffset, aStr);
+      nsCOMPtr<nsIDOMCDATASection> cdata = do_QueryInterface(node);
+      mSerializer->AppendCDATASection(cdata, aStartOffset, aEndOffset, aStr);
       break;
     }
     case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
     {
-      mSerializer->AppendProcessingInstruction(static_cast<nsIContent*>(node),
-                                               aStartOffset, aEndOffset, aStr);
+      nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(node);
+      mSerializer->AppendProcessingInstruction(pi, aStartOffset, aEndOffset,
+                                               aStr);
       break;
     }
     case nsIDOMNode::COMMENT_NODE:
     {
-      mSerializer->AppendComment(static_cast<nsIContent*>(node),
-                                 aStartOffset, aEndOffset, aStr);
+      nsCOMPtr<nsIDOMComment> comment = do_QueryInterface(node);
+      mSerializer->AppendComment(comment, aStartOffset, aEndOffset, aStr);
       break;
     }
     case nsIDOMNode::DOCUMENT_TYPE_NODE:
     {
-      mSerializer->AppendDoctype(static_cast<nsIContent*>(node), aStr);
+      nsCOMPtr<nsIDOMDocumentType> doctype = do_QueryInterface(node);
+      mSerializer->AppendDoctype(doctype, aStr);
       break;
     }
   }
 
   return NS_OK;
 }
 
 nsresult
 nsDocumentEncoder::SerializeNodeEnd(nsINode* aNode,
                                     nsAString& aStr)
 {
+  //XXX Remove QIing to nsIDOM* when fixing bug 562321.
   if (aNode->IsElement()) {
-    mSerializer->AppendElementEnd(static_cast<nsIContent*>(aNode), aStr);
+    nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode);
+    mSerializer->AppendElementEnd(element, aStr);
   }
   return NS_OK;
 }
 
 nsresult
 nsDocumentEncoder::SerializeToStringRecursive(nsINode* aNode,
                                               nsAString& aStr,
                                               PRBool aDontSerializeRoot)
@@ -945,17 +948,18 @@ nsDocumentEncoder::EncodeToString(nsAStr
   } else if (mRange) {
       rv = SerializeRangeToString(mRange, aOutputString);
 
       mRange = nsnull;
   } else if (mNode) {
     rv = SerializeToStringRecursive(mNode, aOutputString, mNodeIsContainer);
     mNode = nsnull;
   } else {
-    rv = mSerializer->AppendDocumentStart(mDocument, aOutputString);
+    nsCOMPtr<nsIDOMDocument> domdoc(do_QueryInterface(mDocument));
+    rv = mSerializer->AppendDocumentStart(domdoc, 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(nsIDocument *aDocument,
+nsHTMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
                                              nsAString& aStr)
 {
   return NS_OK;
 }
 
 void 
 nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
-                                                 nsIContent *aOriginalElement,
+                                                 nsIDOMElement *aOriginalElement,
                                                  nsAString& aTagPrefix,
                                                  const nsAString& aTagNamespaceURI,
                                                  nsIAtom* aTagName,
                                                  nsAString& aStr)
 {
   PRInt32 count = aContent->GetAttrCount();
   if (!count)
     return;
@@ -185,23 +185,24 @@ nsHTMLContentSerializer::SerializeHTMLAt
     if (IsShorthandAttr(attrName, aTagName) && valueStr.IsEmpty()) {
       valueStr = nameStr;
     }
     SerializeAttr(EmptyString(), nameStr, valueStr, aStr, !isJS);
   }
 }
 
 NS_IMETHODIMP
-nsHTMLContentSerializer::AppendElementStart(nsIContent *aElement,
-                                            nsIContent *aOriginalElement,
+nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
+                                            nsIDOMElement *aOriginalElement,
                                             nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  nsIContent* content = aElement;
+  nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
+  if (!content) return NS_ERROR_FAILURE;
 
   PRBool forceFormat = PR_FALSE;
   if (!CheckElementStart(content, forceFormat, aStr)) {
     return NS_OK;
   }
 
   nsIAtom *name = content->Tag();
   PRBool lineBreakBeforeOpen = LineBreakBeforeOpen(content->GetNameSpaceID(), name);
@@ -244,18 +245,17 @@ 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->GetAttr(kNameSpaceID_None, nsGkAtoms::start, start);
+    aElement->GetAttribute(NS_LITERAL_STRING("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,22 +293,23 @@ nsHTMLContentSerializer::AppendElementSt
   }
 
   AfterElementStart(content, aOriginalElement, aStr);
 
   return NS_OK;
 }
   
 NS_IMETHODIMP 
-nsHTMLContentSerializer::AppendElementEnd(nsIContent *aElement,
+nsHTMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
                                           nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  nsIContent* content = aElement;
+  nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
+  if (!content) return NS_ERROR_FAILURE;
 
   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(nsIContent *aElement,
-                                nsIContent *aOriginalElement,
+  NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
+                                nsIDOMElement *aOriginalElement,
                                 nsAString& aStr);
   
-  NS_IMETHOD AppendElementEnd(nsIContent *aElement,
+  NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
                               nsAString& aStr);
 
-  NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
                                  nsAString& aStr);
  protected:
 
   virtual void SerializeHTMLAttributes(nsIContent* aContent,
-                                       nsIContent *aOriginalElement,
+                                       nsIDOMElement *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(nsIContent* aText,
+nsPlainTextSerializer::AppendText(nsIDOMText* aText, 
                                   PRInt32 aStartOffset,
                                   PRInt32 aEndOffset, 
                                   nsAString& aStr)
 {
   if (mIgnoreAboveIndex != (PRUint32)kNotFound) {
     return NS_OK;
   }
     
@@ -304,17 +304,17 @@ nsPlainTextSerializer::AppendText(nsICon
     return NS_ERROR_INVALID_ARG;
 
   NS_ENSURE_ARG(aText);
 
   nsresult rv = NS_OK;
   PRInt32 length = 0;
   nsAutoString textstr;
 
-  nsIContent* content = aText;
+  nsCOMPtr<nsIContent> content = do_QueryInterface(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,32 +367,33 @@ nsPlainTextSerializer::AppendText(nsICon
   }
   
   mOutputString = nsnull;
 
   return rv;
 }
 
 NS_IMETHODIMP
-nsPlainTextSerializer::AppendCDATASection(nsIContent* aCDATASection,
+nsPlainTextSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
                                           PRInt32 aStartOffset,
                                           PRInt32 aEndOffset,
                                           nsAString& aStr)
 {
   return AppendText(aCDATASection, aStartOffset, aEndOffset, aStr);
 }
 
 NS_IMETHODIMP
-nsPlainTextSerializer::AppendElementStart(nsIContent *aElement,
-                                          nsIContent *aOriginalElement,
+nsPlainTextSerializer::AppendElementStart(nsIDOMElement *aElement,
+                                          nsIDOMElement *aOriginalElement,
                                           nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  mContent = aElement;
+  mContent = do_QueryInterface(aElement);
+  if (!mContent) return NS_ERROR_FAILURE;
 
   nsresult rv;
   PRInt32 id = GetIdForContent(mContent);
 
   PRBool isContainer = IsContainer(id);
 
   mOutputString = &aStr;
 
@@ -409,22 +410,23 @@ nsPlainTextSerializer::AppendElementStar
   if (id == eHTMLTag_head) {
     ++mHeadLevel;
   }
 
   return rv;
 } 
  
 NS_IMETHODIMP 
-nsPlainTextSerializer::AppendElementEnd(nsIContent *aElement,
+nsPlainTextSerializer::AppendElementEnd(nsIDOMElement *aElement,
                                         nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  mContent = aElement;
+  mContent = do_QueryInterface(aElement);
+  if (!mContent) return NS_ERROR_FAILURE;
 
   nsresult rv;
   PRInt32 id = GetIdForContent(mContent);
 
   PRBool isContainer = IsContainer(id);
 
   mOutputString = &aStr;
 
@@ -449,18 +451,18 @@ nsPlainTextSerializer::Flush(nsAString& 
 {
   mOutputString = &aStr;
   FlushLine();
   mOutputString = nsnull;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsPlainTextSerializer::AppendDocumentStart(nsIDocument *aDocument,
-                                           nsAString& aStr)
+nsPlainTextSerializer::AppendDocumentStart(nsIDOMDocument *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(nsIContent* aText, PRInt32 aStartOffset,
+  NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
                         PRInt32 aEndOffset, nsAString& aStr);
-  NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
+  NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
                                 PRInt32 aStartOffset, PRInt32 aEndOffset,
                                 nsAString& aStr);
-  NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
+  NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
                                          PRInt32 aStartOffset,
                                          PRInt32 aEndOffset,
                                          nsAString& aStr)  { return NS_OK; }
-  NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
+  NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
                            PRInt32 aEndOffset, nsAString& aStr)  { return NS_OK; }
-  NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
+  NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype,
                            nsAString& aStr)  { return NS_OK; }
-  NS_IMETHOD AppendElementStart(nsIContent *aElement,
-                                nsIContent *aOriginalElement,
+  NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
+                                nsIDOMElement *aOriginalElement,
                                 nsAString& aStr); 
-  NS_IMETHOD AppendElementEnd(nsIContent *aElement,
+  NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
                               nsAString& aStr);
   NS_IMETHOD Flush(nsAString& aStr);
 
-  NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *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(nsIContent* aText,
+nsXHTMLContentSerializer::AppendText(nsIDOMText* 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,
-                                              nsIContent *aOriginalElement,
+                                              nsIDOMElement *aOriginalElement,
                                               nsAString& aTagPrefix,
                                               const nsAString& aTagNamespaceURI,
                                               nsIAtom* aTagName,
                                               nsAString& aStr,
                                               PRUint32 aSkipAttr,
                                               PRBool aAddNSAttr)
 {
   nsresult rv;
@@ -301,18 +301,19 @@ 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(aContent, aStr);
+        SerializeLIValueAttribute(element, aStr);
       }
     }
   }
 
   // If we had to add a new namespace declaration, serialize
   // and push it on the namespace stack
   if (aAddNSAttr) {
     if (aTagPrefix.IsEmpty()) {
@@ -439,32 +440,32 @@ nsXHTMLContentSerializer::SerializeAttri
       SerializeAttr(xmlnsStr, prefixStr, uriStr, aStr, PR_TRUE);
       PushNameSpaceDecl(prefixStr, uriStr, aOriginalElement);
     }
   }
 }
 
 
 void 
-nsXHTMLContentSerializer::AppendEndOfElementStart(nsIContent *aOriginalElement,
+nsXHTMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *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;
   }
 
-  nsIContent* content = aOriginalElement;
+  nsCOMPtr<nsIContent> content = do_QueryInterface(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();
   
@@ -481,17 +482,17 @@ nsXHTMLContentSerializer::AppendEndOfEle
       }
     }
   }
   AppendToString(kGreaterThan, aStr);
 }
 
 void
 nsXHTMLContentSerializer::AfterElementStart(nsIContent * aContent,
-                                            nsIContent *aOriginalElement,
+                                            nsIDOMElement *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.
@@ -544,17 +545,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(nsIDocument *aDocument,
+nsXHTMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
                                               nsAString& aStr)
 {
   if (!mBodyOnly)
     return nsXMLContentSerializer::AppendDocumentStart(aDocument, aStr);
 
   return NS_OK;
 }
 
@@ -973,17 +974,17 @@ nsXHTMLContentSerializer::MaybeLeaveFrom
       name == nsGkAtoms::noscript ||
       name == nsGkAtoms::noframes
     ) {
     --mPreLevel;
   }
 }
 
 void 
-nsXHTMLContentSerializer::SerializeLIValueAttribute(nsIContent* aElement,
+nsXHTMLContentSerializer::SerializeLIValueAttribute(nsIDOMElement* 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;
@@ -1044,17 +1045,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(nsIContent* aElement)
+nsXHTMLContentSerializer::IsFirstChildOfOL(nsIDOMElement* 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(nsIContent* aText,
+  NS_IMETHOD AppendText(nsIDOMText* aText,
                         PRInt32 aStartOffset,
                         PRInt32 aEndOffset,
                         nsAString& aStr);
 
-  NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *aDocument,
                                  nsAString& aStr);
 
  protected:
 
 
   virtual PRBool CheckElementStart(nsIContent * aContent,
                           PRBool & aForceFormat,
                           nsAString& aStr);
 
-  virtual void AppendEndOfElementStart(nsIContent *aOriginalElement,
+  virtual void AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
                                nsIAtom * aName,
                                PRInt32 aNamespaceID,
                                nsAString& aStr);
 
   virtual void AfterElementStart(nsIContent * aContent,
-                         nsIContent *aOriginalElement,
+                         nsIDOMElement *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,
-                           nsIContent *aOriginalElement,
+                           nsIDOMElement *aOriginalElement,
                            nsAString& aTagPrefix,
                            const nsAString& aTagNamespaceURI,
                            nsIAtom* aTagName,
                            nsAString& aStr,
                            PRUint32 aSkipAttr,
                            PRBool aAddNSAttr);
 
-  PRBool IsFirstChildOfOL(nsIContent* aElement);
+  PRBool IsFirstChildOfOL(nsIDOMElement* aElement);
 
-  void SerializeLIValueAttribute(nsIContent* aElement,
+  void SerializeLIValueAttribute(nsIDOMElement* 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(nsIContent* aNode,
+nsXMLContentSerializer::AppendTextData(nsIDOMNode* aNode,
                                        PRInt32 aStartOffset,
                                        PRInt32 aEndOffset,
                                        nsAString& aStr,
                                        PRBool aTranslateEntities)
 {
-  nsIContent* content = aNode;
+  nsCOMPtr<nsIContent> content = do_QueryInterface(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(nsIContent* aText,
+nsXMLContentSerializer::AppendText(nsIDOMText* aText,
                                    PRInt32 aStartOffset,
                                    PRInt32 aEndOffset,
                                    nsAString& aStr)
 {
   NS_ENSURE_ARG(aText);
 
   nsAutoString data;
   nsresult rv;
@@ -220,17 +220,17 @@ nsXMLContentSerializer::AppendText(nsICo
   else {
     AppendToStringConvertLF(data, aStr);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendCDATASection(nsIContent* aCDATASection,
+nsXMLContentSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
                                            PRInt32 aStartOffset,
                                            PRInt32 aEndOffset,
                                            nsAString& aStr)
 {
   NS_ENSURE_ARG(aCDATASection);
   nsresult rv;
 
   NS_NAMED_LITERAL_STRING(cdata , "<![CDATA[");
@@ -255,32 +255,31 @@ nsXMLContentSerializer::AppendCDATASecti
   AppendToStringConvertLF(data, aStr);
 
   AppendToString(NS_LITERAL_STRING("]]>"), aStr);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendProcessingInstruction(nsIContent* aPI,
+nsXMLContentSerializer::AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
                                                     PRInt32 aStartOffset,
                                                     PRInt32 aEndOffset,
                                                     nsAString& aStr)
 {
-  nsCOMPtr<nsIDOMProcessingInstruction> pi = do_QueryInterface(aPI);
-  NS_ENSURE_ARG(pi);
+  NS_ENSURE_ARG(aPI);
   nsresult rv;
   nsAutoString target, data, start;
 
   MaybeAddNewlineForRootNode(aStr);
 
-  rv = pi->GetTarget(target);
+  rv = aPI->GetTarget(target);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
-  rv = pi->GetData(data);
+  rv = aPI->GetData(data);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
   start.AppendLiteral("<?");
   start.Append(target);
 
   if (mPreLevel > 0 || mDoRaw) {
     AppendToString(start, aStr);
   }
@@ -304,27 +303,26 @@ nsXMLContentSerializer::AppendProcessing
   AppendToString(NS_LITERAL_STRING("?>"), aStr);
 
   MaybeFlagNewlineForRootNode(aPI);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendComment(nsIContent* aComment,
+nsXMLContentSerializer::AppendComment(nsIDOMComment* aComment,
                                       PRInt32 aStartOffset,
                                       PRInt32 aEndOffset,
                                       nsAString& aStr)
 {
-  nsCOMPtr<nsIDOMComment> comment = do_QueryInterface(aComment);
-  NS_ENSURE_ARG(comment);
+  NS_ENSURE_ARG(aComment);
   nsresult rv;
   nsAutoString data;
 
-  rv = comment->GetData(data);
+  rv = aComment->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);
@@ -357,31 +355,30 @@ nsXMLContentSerializer::AppendComment(ns
   AppendToString(NS_LITERAL_STRING("-->"), aStr);
 
   MaybeFlagNewlineForRootNode(aComment);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendDoctype(nsIContent* aDocType,
+nsXMLContentSerializer::AppendDoctype(nsIDOMDocumentType *aDoctype,
                                       nsAString& aStr)
 {
-  nsCOMPtr<nsIDOMDocumentType> docType = do_QueryInterface(aDocType);
-  NS_ENSURE_ARG(docType);
+  NS_ENSURE_ARG(aDoctype);
   nsresult rv;
   nsAutoString name, publicId, systemId, internalSubset;
 
-  rv = docType->GetName(name);
+  rv = aDoctype->GetName(name);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-  rv = docType->GetPublicId(publicId);
+  rv = aDoctype->GetPublicId(publicId);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-  rv = docType->GetSystemId(systemId);
+  rv = aDoctype->GetSystemId(systemId);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
-  rv = docType->GetInternalSubset(internalSubset);
+  rv = aDoctype->GetInternalSubset(internalSubset);
   if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
 
   MaybeAddNewlineForRootNode(aStr);
 
   AppendToString(NS_LITERAL_STRING("<!DOCTYPE "), aStr);
   AppendToString(name, aStr);
 
   PRUnichar quote;
@@ -425,55 +422,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,
-                                          nsIContent* aOwner)
+                                          nsIDOMElement* 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(nsIContent* aOwner)
+nsXMLContentSerializer::PopNameSpaceDeclsFor(nsIDOMElement* 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,
-                                      nsIContent* aElement,
+                                      nsIDOMElement* 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,
@@ -714,17 +711,17 @@ nsXMLContentSerializer::SerializeAttr(co
   }
   else {
     AppendToStringConvertLF(attrString, aStr);
   }
 }
 
 PRUint32 
 nsXMLContentSerializer::ScanNamespaceDeclarations(nsIContent* aContent,
-                                                  nsIContent *aOriginalElement,
+                                                  nsIDOMElement *aOriginalElement,
                                                   const nsAString& aTagNamespaceURI)
 {
   PRUint32 index, count;
   nsAutoString uriStr, valueStr;
 
   count = aContent->GetAttrCount();
 
   // First scan for namespace declarations, pushing each on the stack
@@ -810,17 +807,17 @@ nsXMLContentSerializer::IsJavaScript(nsI
                                                 EventNameType_SVGGraphic | EventNameType_SVGSVG);
   }
   return PR_FALSE;
 }
 
 
 void 
 nsXMLContentSerializer::SerializeAttributes(nsIContent* aContent,
-                                            nsIContent *aOriginalElement,
+                                            nsIDOMElement *aOriginalElement,
                                             nsAString& aTagPrefix,
                                             const nsAString& aTagNamespaceURI,
                                             nsIAtom* aTagName,
                                             nsAString& aStr,
                                             PRUint32 aSkipAttr,
                                             PRBool aAddNSAttr)
 {
 
@@ -890,33 +887,34 @@ nsXMLContentSerializer::SerializeAttribu
                    "Namespaced attributes must have a prefix");
       SerializeAttr(xmlnsStr, prefixStr, uriStr, aStr, PR_TRUE);
       PushNameSpaceDecl(prefixStr, uriStr, aOriginalElement);
     }
   }
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendElementStart(nsIContent *aElement,
-                                           nsIContent *aOriginalElement,
+nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
+                                           nsIDOMElement *aOriginalElement,
                                            nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  nsIContent* content = aElement;
+  nsCOMPtr<nsIContent> content(do_QueryInterface(aElement));
+  if (!content) return NS_ERROR_FAILURE;
 
   PRBool forceFormat = PR_FALSE;
   if (!CheckElementStart(content, forceFormat, aStr)) {
     return NS_OK;
   }
 
   nsAutoString tagPrefix, tagLocalName, tagNamespaceURI;
-  aElement->NodeInfo()->GetPrefix(tagPrefix);
-  aElement->NodeInfo()->GetLocalName(tagLocalName);
-  aElement->NodeInfo()->GetNamespaceURI(tagNamespaceURI);
+  aElement->GetPrefix(tagPrefix);
+  aElement->GetLocalName(tagLocalName);
+  aElement->GetNamespaceURI(tagNamespaceURI);
 
   PRUint32 skipAttr = ScanNamespaceDeclarations(content,
                           aOriginalElement, tagNamespaceURI);
 
   nsIAtom *name = content->Tag();
   PRBool lineBreakBeforeOpen = LineBreakBeforeOpen(content->GetNameSpaceID(), name);
 
   if ((mDoFormat || forceFormat) && !mPreLevel && !mDoRaw) {
@@ -976,37 +974,40 @@ nsXMLContentSerializer::AppendElementSta
   }
 
   AfterElementStart(content, aOriginalElement, aStr);
 
   return NS_OK;
 }
 
 void 
-nsXMLContentSerializer::AppendEndOfElementStart(nsIContent *aOriginalElement,
+nsXMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
                                                 nsIAtom * aName,
                                                 PRInt32 aNamespaceID,
                                                 nsAString& aStr)
 {
   // We don't output a separate end tag for empty elements
-  if (!aOriginalElement->GetChildCount()) {
+  PRBool hasChildren = PR_FALSE;
+  if (NS_FAILED(aOriginalElement->HasChildNodes(&hasChildren)) ||
+      !hasChildren) {
     AppendToString(NS_LITERAL_STRING("/>"), aStr);
   }
   else {
     AppendToString(kGreaterThan, aStr);
   }
 }
 
 NS_IMETHODIMP 
-nsXMLContentSerializer::AppendElementEnd(nsIContent *aElement,
+nsXMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
                                          nsAString& aStr)
 {
   NS_ENSURE_ARG(aElement);
 
-  nsIContent* content = aElement;
+  nsCOMPtr<nsIContent> content(do_QueryInterface(aElement));
+  if (!content) return NS_ERROR_FAILURE;
 
   PRBool forceFormat = PR_FALSE, outputElementEnd;
   outputElementEnd = CheckElementEnd(content, forceFormat, aStr);
 
   nsIAtom *name = content->Tag();
 
   if ((mDoFormat || forceFormat) && !mPreLevel && !mDoRaw) {
     DecrIndentation(name);
@@ -1015,19 +1016,19 @@ nsXMLContentSerializer::AppendElementEnd
   if (!outputElementEnd) {
     PopNameSpaceDeclsFor(aElement);
     MaybeFlagNewlineForRootNode(aElement);
     return NS_OK;
   }
 
   nsAutoString tagPrefix, tagLocalName, tagNamespaceURI;
   
-  aElement->NodeInfo()->GetPrefix(tagPrefix);
-  aElement->NodeInfo()->GetLocalName(tagLocalName);
-  aElement->NodeInfo()->GetNamespaceURI(tagNamespaceURI);
+  aElement->GetPrefix(tagPrefix);
+  aElement->GetLocalName(tagLocalName);
+  aElement->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) {
@@ -1071,23 +1072,28 @@ nsXMLContentSerializer::AppendElementEnd
   }
 
   AfterElementEnd(content, aStr);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsXMLContentSerializer::AppendDocumentStart(nsIDocument *aDocument,
+nsXMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
                                             nsAString& aStr)
 {
   NS_ENSURE_ARG_POINTER(aDocument);
 
+  nsCOMPtr<nsIDocument> doc(do_QueryInterface(aDocument));
+  if (!doc) {
+    return NS_OK;
+  }
+
   nsAutoString version, encoding, standalone;
-  aDocument->GetXMLDeclaration(version, encoding, standalone);
+  doc->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;
   
@@ -1123,20 +1129,27 @@ 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;
-  return aContent->GetChildCount() > 0;
+
+  if (NS_SUCCEEDED(node->HasChildNodes(&hasChildren)) && !hasChildren) {
+    return PR_FALSE;
+  }
+  return PR_TRUE;
 }
 
+
 void
 nsXMLContentSerializer::AppendToString(const PRUnichar* aStr,
                                        PRInt32 aLength,
                                        nsAString& aOutputStr)
 {
   PRInt32 length = (aLength == -1) ? nsCRT::strlen(aStr) : aLength;
 
   mColPos += length;
@@ -1227,21 +1240,24 @@ void
 nsXMLContentSerializer::MaybeAddNewlineForRootNode(nsAString& aStr)
 {
   if (mAddNewlineForRootNode) {
     AppendNewLineToString(aStr);
   }
 }
 
 void
-nsXMLContentSerializer::MaybeFlagNewlineForRootNode(nsINode* aNode)
+nsXMLContentSerializer::MaybeFlagNewlineForRootNode(nsIDOMNode* aNode)
 {
-  nsINode* parent = aNode->GetNodeParent();
+  nsCOMPtr<nsIDOMNode> parent;
+  aNode->GetParentNode(getter_AddRefs(parent));
   if (parent) {
-    mAddNewlineForRootNode = aNode->IsNodeOfType(nsINode::eDOCUMENT);
+    PRUint16 type;
+    parent->GetNodeType(&type);
+    mAddNewlineForRootNode = type == nsIDOMNode::DOCUMENT_NODE;
   }
 }
 
 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(nsIContent* aText, PRInt32 aStartOffset,
+  NS_IMETHOD AppendText(nsIDOMText* aText, PRInt32 aStartOffset,
                         PRInt32 aEndOffset, nsAString& aStr);
 
-  NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
+  NS_IMETHOD AppendCDATASection(nsIDOMCDATASection* aCDATASection,
                                 PRInt32 aStartOffset, PRInt32 aEndOffset,
                                 nsAString& aStr);
 
-  NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
+  NS_IMETHOD AppendProcessingInstruction(nsIDOMProcessingInstruction* aPI,
                                          PRInt32 aStartOffset,
                                          PRInt32 aEndOffset,
                                          nsAString& aStr);
 
-  NS_IMETHOD AppendComment(nsIContent* aComment, PRInt32 aStartOffset,
+  NS_IMETHOD AppendComment(nsIDOMComment* aComment, PRInt32 aStartOffset,
                            PRInt32 aEndOffset, nsAString& aStr);
   
-  NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
+  NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype,
                            nsAString& aStr);
 
-  NS_IMETHOD AppendElementStart(nsIContent *aElement,
-                                nsIContent *aOriginalElement,
+  NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
+                                nsIDOMElement *aOriginalElement,
                                 nsAString& aStr);
   
-  NS_IMETHOD AppendElementEnd(nsIContent *aElement,
+  NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
                               nsAString& aStr);
 
   NS_IMETHOD Flush(nsAString& aStr) { return NS_OK; }
 
-  NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
+  NS_IMETHOD AppendDocumentStart(nsIDOMDocument *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(nsIContent* aNode,
+  nsresult AppendTextData(nsIDOMNode* aNode,
                           PRInt32 aStartOffset,
                           PRInt32 aEndOffset,
                           nsAString& aStr,
                           PRBool aTranslateEntities);
 
   virtual nsresult PushNameSpaceDecl(const nsAString& aPrefix,
                                      const nsAString& aURI,
-                                     nsIContent* aOwner);
-  void PopNameSpaceDeclsFor(nsIContent* aOwner);
+                                     nsIDOMElement* aOwner);
+  void PopNameSpaceDeclsFor(nsIDOMElement* 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,
-                       nsIContent* aElement,
+                       nsIDOMElement* aElement,
                        PRBool aIsAttribute);
   /**
    * GenerateNewPrefix generates a new prefix and writes it to aPrefix
    */
   void GenerateNewPrefix(nsAString& aPrefix);
 
   PRUint32 ScanNamespaceDeclarations(nsIContent* aContent,
-                                     nsIContent *aOriginalElement,
+                                     nsIDOMElement *aOriginalElement,
                                      const nsAString& aTagNamespaceURI);
 
   virtual void SerializeAttributes(nsIContent* aContent,
-                                   nsIContent *aOriginalElement,
+                                   nsIDOMElement *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(nsIContent *aOriginalElement,
+  virtual void AppendEndOfElementStart(nsIDOMElement *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,
-                                 nsIContent *aOriginalElement,
+                                 nsIDOMElement *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(nsINode* aNode);
+  void MaybeFlagNewlineForRootNode(nsIDOMNode* 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;
-    nsIContent* mOwner;
+    nsIDOMElement* mOwner;
   };
 
   nsTArray<NameSpaceDecl> mNameSpaceStack;
 
   // nsIDocumentEncoder flags
   PRUint32  mFlags;
 
   // characters to use for line break