diff --git a/content/base/public/nsIContent.h b/content/base/public/nsIContent.h index 03f0d88d07bc..2c0c302942da 100644 --- a/content/base/public/nsIContent.h +++ b/content/base/public/nsIContent.h @@ -464,7 +464,9 @@ public: /** form controls */ eHTML_FORM_CONTROL = 0x00000008, /** XUL elements */ - eXUL = 0x00000010 + eXUL = 0x00000010, + /** xml processing instructions */ + ePROCESSING_INSTRUCTION = 0x00000020 }; /** diff --git a/content/base/public/nsITextContent.h b/content/base/public/nsITextContent.h index 3f7302c1993c..c224dc2a3ca7 100644 --- a/content/base/public/nsITextContent.h +++ b/content/base/public/nsITextContent.h @@ -102,6 +102,11 @@ public: * method allows you to specify whether to copy the text as well. */ NS_IMETHOD CloneContent(PRBool aCloneText, nsITextContent** aClone) = 0; + + /** + * Append the text content to aResult. + */ + NS_IMETHOD AppendTextTo(nsAString& aResult) = 0; }; //---------------------------------------------------------------------- diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index 22ba80783cee..97af62f3c324 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -1349,6 +1349,21 @@ nsGenericDOMDataNode::CloneContent(PRBool aCloneText, nsITextContent** aClone) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsGenericDOMDataNode::AppendTextTo(nsAString& aResult) +{ + if (mText.Is2b()) { + aResult.Append(mText.Get2b(), mText.GetLength()); + } else { + // XXX we would like to have a AppendASCIItoUCS2 here + aResult.Append(NS_ConvertASCIItoUCS2(mText.Get1b(), + mText.GetLength()).get(), + mText.GetLength()); + } + + return NS_OK; +} + void nsGenericDOMDataNode::LookupListenerManager(nsIEventListenerManager **aListenerManager) const { diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index c5ae9890d5e8..35176298279c 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -241,6 +241,7 @@ public: NS_IMETHOD SetText(const char* aBuffer, PRInt32 aLength, PRBool aNotify); NS_IMETHOD IsOnlyWhitespace(PRBool* aResult); NS_IMETHOD CloneContent(PRBool aCloneText, nsITextContent** aClone); + NS_IMETHOD AppendTextTo(nsAString& aResult); //---------------------------------------- diff --git a/content/html/content/src/nsAttributeContent.cpp b/content/html/content/src/nsAttributeContent.cpp index ea1d75d6e5f6..5ee1a0ddfae2 100644 --- a/content/html/content/src/nsAttributeContent.cpp +++ b/content/html/content/src/nsAttributeContent.cpp @@ -211,7 +211,8 @@ public: PRInt32 aLength, PRBool aNotify); NS_IMETHOD IsOnlyWhitespace(PRBool* aResult); - NS_IMETHOD CloneContent(PRBool aCloneText, nsITextContent** aClone); + NS_IMETHOD CloneContent(PRBool aCloneText, nsITextContent** aClone); + NS_IMETHOD AppendTextTo(nsAString& aResult); //---------------------------------------- @@ -439,7 +440,8 @@ nsAttributeContent::CopyText(nsAString& aResult) aResult.Assign(mText.Get2b(), mText.GetLength()); } else { - aResult.Assign(NS_ConvertASCIItoUCS2(mText.Get1b(), mText.GetLength()).get(), mText.GetLength()); + const char *data = mText.Get1b(); + CopyASCIItoUCS2(Substring(data, data + mText.GetLength()), aResult); } return NS_OK; } @@ -555,3 +557,20 @@ nsAttributeContent::CloneContent(PRBool aCloneText, nsITextContent** aReturn) it->mText = mText; return result; } + +NS_IMETHODIMP +nsAttributeContent::AppendTextTo(nsAString& aResult) +{ + ValidateTextFragment(); + if (mText.Is2b()) { + aResult.Append(mText.Get2b(), mText.GetLength()); + } + else { + // XXX we would like to have a AppendASCIItoUCS2 here + aResult.Append(NS_ConvertASCIItoUCS2(mText.Get1b(), + mText.GetLength()).get(), + mText.GetLength()); + } + + return NS_OK; +} diff --git a/content/xml/content/src/nsXMLCDATASection.cpp b/content/xml/content/src/nsXMLCDATASection.cpp index af0f8b5b2a1d..c7c7fdf64a37 100644 --- a/content/xml/content/src/nsXMLCDATASection.cpp +++ b/content/xml/content/src/nsXMLCDATASection.cpp @@ -67,6 +67,7 @@ public: // nsIContent NS_IMETHOD GetTag(nsIAtom** aResult) const; + NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags); #ifdef DEBUG NS_IMETHOD List(FILE* out, PRInt32 aIndent) const; NS_IMETHOD DumpContent(FILE* out, PRInt32 aIndent,PRBool aDumpAll) const; @@ -120,6 +121,12 @@ nsXMLCDATASection::GetTag(nsIAtom** aResult) const return NS_OK; } +NS_IMETHODIMP_(PRBool) +nsXMLCDATASection::IsContentOfType(PRUint32 aFlags) +{ + return !(aFlags & ~eTEXT); +} + NS_IMETHODIMP nsXMLCDATASection::GetNodeName(nsAString& aNodeName) { diff --git a/content/xml/content/src/nsXMLProcessingInstruction.cpp b/content/xml/content/src/nsXMLProcessingInstruction.cpp index 8ce6911e3e60..637c244d09d7 100644 --- a/content/xml/content/src/nsXMLProcessingInstruction.cpp +++ b/content/xml/content/src/nsXMLProcessingInstruction.cpp @@ -120,6 +120,12 @@ nsXMLProcessingInstruction::GetTag(nsIAtom** aResult) const return NS_OK; } +NS_IMETHODIMP_(PRBool) +nsXMLProcessingInstruction::IsContentOfType(PRUint32 aFlags) +{ + return !(aFlags & ~ePROCESSING_INSTRUCTION); +} + NS_IMETHODIMP nsXMLProcessingInstruction::GetNodeName(nsAString& aNodeName) { diff --git a/content/xml/content/src/nsXMLProcessingInstruction.h b/content/xml/content/src/nsXMLProcessingInstruction.h index 4ed62a08ce56..a3424e07b111 100644 --- a/content/xml/content/src/nsXMLProcessingInstruction.h +++ b/content/xml/content/src/nsXMLProcessingInstruction.h @@ -65,6 +65,7 @@ public: // nsIContent NS_IMETHOD GetTag(nsIAtom** aResult) const; + NS_IMETHOD_(PRBool) IsContentOfType(PRUint32 aFlags); #ifdef DEBUG NS_IMETHOD List(FILE* out, PRInt32 aIndent) const;