зеркало из https://github.com/mozilla/gecko-dev.git
De-nsIDOM* nsIContentSerializer methods, r=sicking
This commit is contained in:
Родитель
4176cb686d
Коммит
5f229468c1
|
@ -40,20 +40,15 @@
|
|||
|
||||
#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:
|
||||
|
@ -64,29 +59,29 @@ class nsIContentSerializer : public nsISupports {
|
|||
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;
|
||||
|
@ -96,7 +91,7 @@ class nsIContentSerializer : public nsISupports {
|
|||
* 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;
|
||||
};
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ mozSanitizingHTMLSerializer::Flush(nsAString& aStr)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
|
||||
mozSanitizingHTMLSerializer::AppendDocumentStart(nsIDocument *aDocument,
|
||||
nsAString& aStr)
|
||||
{
|
||||
return NS_OK;
|
||||
|
@ -225,7 +225,7 @@ mozSanitizingHTMLSerializer::GetIdForContent(nsIContent* aContent)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::AppendText(nsIDOMText* aText,
|
||||
mozSanitizingHTMLSerializer::AppendText(nsIContent* aText,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsAString& aStr)
|
||||
|
@ -241,14 +241,13 @@ mozSanitizingHTMLSerializer::AppendText(nsIDOMText* aText,
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -271,13 +270,12 @@ mozSanitizingHTMLSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -73,29 +73,29 @@ public:
|
|||
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
|
||||
|
|
|
@ -292,45 +292,44 @@ nsDocumentEncoder::SerializeNodeStart(nsINode* aNode,
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
@ -342,10 +341,8 @@ 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;
|
||||
}
|
||||
|
@ -953,8 +950,7 @@ nsDocumentEncoder::EncodeToString(nsAString& aOutputString)
|
|||
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);
|
||||
|
|
|
@ -92,7 +92,7 @@ nsHTMLContentSerializer::~nsHTMLContentSerializer()
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
|
||||
nsHTMLContentSerializer::AppendDocumentStart(nsIDocument *aDocument,
|
||||
nsAString& aStr)
|
||||
{
|
||||
return NS_OK;
|
||||
|
@ -100,7 +100,7 @@ nsHTMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
|
|||
|
||||
void
|
||||
nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsIContent *aOriginalElement,
|
||||
nsAString& aTagPrefix,
|
||||
const nsAString& aTagNamespaceURI,
|
||||
nsIAtom* aTagName,
|
||||
|
@ -190,14 +190,13 @@ nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
|
|||
}
|
||||
|
||||
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)) {
|
||||
|
@ -250,7 +249,8 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
// 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);
|
||||
|
@ -298,13 +298,12 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
}
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -57,19 +57,19 @@ class nsHTMLContentSerializer : public nsXHTMLContentSerializer {
|
|||
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,
|
||||
|
|
|
@ -290,7 +290,7 @@ nsPlainTextSerializer::Initialize(nsAString* aOutString,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPlainTextSerializer::AppendText(nsIDOMText* aText,
|
||||
nsPlainTextSerializer::AppendText(nsIContent* aText,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsAString& aStr)
|
||||
|
@ -309,7 +309,7 @@ nsPlainTextSerializer::AppendText(nsIDOMText* aText,
|
|||
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;
|
||||
|
@ -372,7 +372,7 @@ nsPlainTextSerializer::AppendText(nsIDOMText* aText,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPlainTextSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
|
||||
nsPlainTextSerializer::AppendCDATASection(nsIContent* aCDATASection,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsAString& aStr)
|
||||
|
@ -381,14 +381,13 @@ nsPlainTextSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -415,13 +414,12 @@ nsPlainTextSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -456,8 +454,8 @@ nsPlainTextSerializer::Flush(nsAString& aStr)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPlainTextSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
|
||||
nsAString& aStr)
|
||||
nsPlainTextSerializer::AppendDocumentStart(nsIDocument *aDocument,
|
||||
nsAString& aStr)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -71,27 +71,27 @@ public:
|
|||
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
|
||||
|
|
|
@ -155,7 +155,7 @@ nsXHTMLContentSerializer::HasLongLines(const nsString& text, PRInt32& aLastNewli
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHTMLContentSerializer::AppendText(nsIDOMText* aText,
|
||||
nsXHTMLContentSerializer::AppendText(nsIContent* aText,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsAString& aStr)
|
||||
|
@ -260,7 +260,7 @@ nsXHTMLContentSerializer::EscapeURI(nsIContent* aContent, const nsAString& aURI,
|
|||
|
||||
void
|
||||
nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsIContent *aOriginalElement,
|
||||
nsAString& aTagPrefix,
|
||||
const nsAString& aTagNamespaceURI,
|
||||
nsIAtom* aTagName,
|
||||
|
@ -306,9 +306,8 @@ nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -445,7 +444,7 @@ nsXHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
|||
|
||||
|
||||
void
|
||||
nsXHTMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
|
||||
nsXHTMLContentSerializer::AppendEndOfElementStart(nsIContent *aOriginalElement,
|
||||
nsIAtom * aName,
|
||||
PRInt32 aNamespaceID,
|
||||
nsAString& aStr)
|
||||
|
@ -460,7 +459,7 @@ nsXHTMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElemen
|
|||
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
|
||||
|
@ -487,7 +486,7 @@ nsXHTMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElemen
|
|||
|
||||
void
|
||||
nsXHTMLContentSerializer::AfterElementStart(nsIContent * aContent,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsIContent *aOriginalElement,
|
||||
nsAString& aStr)
|
||||
{
|
||||
nsIAtom *name = aContent->Tag();
|
||||
|
@ -550,7 +549,7 @@ nsXHTMLContentSerializer::AfterElementEnd(nsIContent * aContent,
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXHTMLContentSerializer::AppendDocumentStart(nsIDOMDocument *aDocument,
|
||||
nsXHTMLContentSerializer::AppendDocumentStart(nsIDocument *aDocument,
|
||||
nsAString& aStr)
|
||||
{
|
||||
if (!mBodyOnly)
|
||||
|
@ -979,7 +978,7 @@ nsXHTMLContentSerializer::MaybeLeaveFromPreContent(nsIContent* aNode)
|
|||
}
|
||||
|
||||
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.
|
||||
|
@ -1050,7 +1049,7 @@ nsXHTMLContentSerializer::SerializeLIValueAttribute(nsIDOMElement* aElement,
|
|||
}
|
||||
|
||||
PRBool
|
||||
nsXHTMLContentSerializer::IsFirstChildOfOL(nsIDOMElement* aElement)
|
||||
nsXHTMLContentSerializer::IsFirstChildOfOL(nsIContent* aElement)
|
||||
{
|
||||
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aElement);
|
||||
nsAutoString parentName;
|
||||
|
|
|
@ -62,12 +62,12 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
|
|||
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:
|
||||
|
@ -77,13 +77,13 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
|
|||
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,
|
||||
|
@ -105,7 +105,7 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
|
|||
virtual void MaybeLeaveFromPreContent(nsIContent* aNode);
|
||||
|
||||
virtual void SerializeAttributes(nsIContent* aContent,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsIContent *aOriginalElement,
|
||||
nsAString& aTagPrefix,
|
||||
const nsAString& aTagNamespaceURI,
|
||||
nsIAtom* aTagName,
|
||||
|
@ -113,9 +113,9 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
|
|||
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);
|
||||
|
|
|
@ -148,13 +148,13 @@ nsXMLContentSerializer::Init(PRUint32 aFlags, PRUint32 aWrapColumn,
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -194,7 +194,7 @@ nsXMLContentSerializer::AppendTextData(nsIDOMNode* aNode,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSerializer::AppendText(nsIDOMText* aText,
|
||||
nsXMLContentSerializer::AppendText(nsIContent* aText,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsAString& aStr)
|
||||
|
@ -225,7 +225,7 @@ nsXMLContentSerializer::AppendText(nsIDOMText* aText,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
|
||||
nsXMLContentSerializer::AppendCDATASection(nsIContent* aCDATASection,
|
||||
PRInt32 aStartOffset,
|
||||
PRInt32 aEndOffset,
|
||||
nsAString& aStr)
|
||||
|
@ -260,21 +260,22 @@ nsXMLContentSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
|
|||
}
|
||||
|
||||
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("<?");
|
||||
|
@ -308,16 +309,17 @@ nsXMLContentSerializer::AppendProcessingInstruction(nsIDOMProcessingInstruction*
|
|||
}
|
||||
|
||||
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)) {
|
||||
|
@ -360,20 +362,21 @@ nsXMLContentSerializer::AppendComment(nsIDOMComment* aComment,
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -427,7 +430,7 @@ nsXMLContentSerializer::AppendDoctype(nsIDOMDocumentType *aDoctype,
|
|||
}
|
||||
|
||||
AppendToString(kGreaterThan, aStr);
|
||||
MaybeFlagNewlineForRootNode(aDoctype);
|
||||
MaybeFlagNewlineForRootNode(aDocType);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -435,7 +438,7 @@ nsXMLContentSerializer::AppendDoctype(nsIDOMDocumentType *aDoctype,
|
|||
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;
|
||||
|
@ -449,7 +452,7 @@ nsXMLContentSerializer::PushNameSpaceDecl(const nsAString& aPrefix,
|
|||
}
|
||||
|
||||
void
|
||||
nsXMLContentSerializer::PopNameSpaceDeclsFor(nsIDOMElement* aOwner)
|
||||
nsXMLContentSerializer::PopNameSpaceDeclsFor(nsIContent* aOwner)
|
||||
{
|
||||
PRInt32 index, count;
|
||||
|
||||
|
@ -465,7 +468,7 @@ nsXMLContentSerializer::PopNameSpaceDeclsFor(nsIDOMElement* aOwner)
|
|||
PRBool
|
||||
nsXMLContentSerializer::ConfirmPrefix(nsAString& aPrefix,
|
||||
const nsAString& aURI,
|
||||
nsIDOMElement* aElement,
|
||||
nsIContent* aElement,
|
||||
PRBool aIsAttribute)
|
||||
{
|
||||
if (aPrefix.EqualsLiteral(kXMLNS)) {
|
||||
|
@ -716,7 +719,7 @@ nsXMLContentSerializer::SerializeAttr(const nsAString& aPrefix,
|
|||
|
||||
PRUint32
|
||||
nsXMLContentSerializer::ScanNamespaceDeclarations(nsIContent* aContent,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsIContent *aOriginalElement,
|
||||
const nsAString& aTagNamespaceURI)
|
||||
{
|
||||
PRUint32 index, count;
|
||||
|
@ -812,7 +815,7 @@ nsXMLContentSerializer::IsJavaScript(nsIContent * aContent, nsIAtom* aAttrNameAt
|
|||
|
||||
void
|
||||
nsXMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsIContent *aOriginalElement,
|
||||
nsAString& aTagPrefix,
|
||||
const nsAString& aTagNamespaceURI,
|
||||
nsIAtom* aTagName,
|
||||
|
@ -892,14 +895,13 @@ nsXMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
|||
}
|
||||
|
||||
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)) {
|
||||
|
@ -907,9 +909,9 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -979,15 +981,13 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -996,13 +996,12 @@ nsXMLContentSerializer::AppendEndOfElementStart(nsIDOMElement *aOriginalElement,
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -1021,9 +1020,9 @@ nsXMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
|
|||
|
||||
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 =
|
||||
|
@ -1077,18 +1076,13 @@ nsXMLContentSerializer::AppendElementEnd(nsIDOMElement *aElement,
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -1134,17 +1128,10 @@ nsXMLContentSerializer::CheckElementEnd(nsIContent * aContent,
|
|||
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,
|
||||
|
@ -1245,14 +1232,11 @@ nsXMLContentSerializer::MaybeAddNewlineForRootNode(nsAString& 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,34 +70,34 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
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:
|
||||
|
@ -185,7 +185,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
* 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,
|
||||
|
@ -193,8 +193,8 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
|
||||
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
|
||||
|
@ -216,7 +216,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
*/
|
||||
PRBool ConfirmPrefix(nsAString& aPrefix,
|
||||
const nsAString& aURI,
|
||||
nsIDOMElement* aElement,
|
||||
nsIContent* aElement,
|
||||
PRBool aIsAttribute);
|
||||
/**
|
||||
* GenerateNewPrefix generates a new prefix and writes it to aPrefix
|
||||
|
@ -224,11 +224,11 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
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,
|
||||
|
@ -263,7 +263,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
* 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);
|
||||
|
@ -274,7 +274,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
* (called at the end of AppendElementStart)
|
||||
*/
|
||||
virtual void AfterElementStart(nsIContent * aContent,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsIContent *aOriginalElement,
|
||||
nsAString& aStr) { };
|
||||
|
||||
/**
|
||||
|
@ -328,7 +328,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
// 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);
|
||||
|
@ -339,7 +339,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
struct NameSpaceDecl {
|
||||
nsString mPrefix;
|
||||
nsString mURI;
|
||||
nsIDOMElement* mOwner;
|
||||
nsIContent* mOwner;
|
||||
};
|
||||
|
||||
nsTArray<NameSpaceDecl> mNameSpaceStack;
|
||||
|
|
Загрузка…
Ссылка в новой задаче