зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug 332239 (Saved xml content gives xml parsing error in this case). r/zr=bz.
This commit is contained in:
Родитель
64c5f05794
Коммит
2cd741e602
|
@ -85,7 +85,7 @@ class nsIContentSerializer : public nsISupports {
|
|||
nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
|
||||
PRBool aHasChildren,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr) = 0;
|
||||
|
||||
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
|
||||
|
|
|
@ -243,7 +243,7 @@ mozSanitizingHTMLSerializer::AppendText(nsIDOMText* aText,
|
|||
|
||||
NS_IMETHODIMP
|
||||
mozSanitizingHTMLSerializer::AppendElementStart(nsIDOMElement *aElement,
|
||||
PRBool aHasChildren,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr)
|
||||
{
|
||||
NS_ENSURE_ARG(aElement);
|
||||
|
|
|
@ -91,7 +91,8 @@ public:
|
|||
{ return NS_OK; }
|
||||
NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype, nsAString& aStr)
|
||||
{ return NS_OK; }
|
||||
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement, PRBool aHasChildren,
|
||||
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr);
|
||||
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement, nsAString& aStr);
|
||||
NS_IMETHOD Flush(nsAString& aStr);
|
||||
|
|
|
@ -284,14 +284,8 @@ nsDocumentEncoder::SerializeNodeStart(nsIDOMNode* aNode, PRInt32 aStartOffset,
|
|||
case nsIDOMNode::ELEMENT_NODE:
|
||||
{
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(node);
|
||||
// Because FixupNode() may have done a shallow copy of aNode
|
||||
// we need to tell the serializer if the original had children.
|
||||
// Some serializers (notably XML) need this information
|
||||
// in order to handle empty tags properly.
|
||||
PRBool hasChildren;
|
||||
mSerializer->AppendElementStart(element,
|
||||
NS_SUCCEEDED(aNode->HasChildNodes(&hasChildren)) && hasChildren,
|
||||
aStr);
|
||||
nsCOMPtr<nsIDOMElement> originalElement = do_QueryInterface(aNode);
|
||||
mSerializer->AppendElementStart(element, originalElement, aStr);
|
||||
break;
|
||||
}
|
||||
case nsIDOMNode::TEXT_NODE:
|
||||
|
|
|
@ -636,7 +636,7 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
||||
PRBool aHasChildren,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr)
|
||||
{
|
||||
NS_ENSURE_ARG(aElement);
|
||||
|
@ -720,7 +720,7 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
}
|
||||
|
||||
if (mIsCopying && name == nsHTMLAtoms::li) {
|
||||
mIsFirstChildOfOL = IsFirstChildOfOL(aElement);
|
||||
mIsFirstChildOfOL = IsFirstChildOfOL(aOriginalElement);
|
||||
if (mIsFirstChildOfOL){
|
||||
// If OL is parent of this LI, serialize attributes in different manner.
|
||||
SerializeLIValueAttribute(aElement, aStr);
|
||||
|
|
|
@ -65,7 +65,7 @@ class nsHTMLContentSerializer : public nsXMLContentSerializer {
|
|||
PRInt32 aEndOffset,
|
||||
nsAString& aStr);
|
||||
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
|
||||
PRBool aHasChildren,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr);
|
||||
|
||||
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
|
||||
|
|
|
@ -380,7 +380,7 @@ nsPlainTextSerializer::AppendCDATASection(nsIDOMCDATASection* aCDATASection,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsPlainTextSerializer::AppendElementStart(nsIDOMElement *aElement,
|
||||
PRBool aHasChildren,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr)
|
||||
{
|
||||
NS_ENSURE_ARG(aElement);
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
NS_IMETHOD AppendDoctype(nsIDOMDocumentType *aDoctype,
|
||||
nsAString& aStr) { return NS_OK; }
|
||||
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
|
||||
PRBool aHasChildren,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr);
|
||||
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
|
||||
nsAString& aStr);
|
||||
|
|
|
@ -576,7 +576,7 @@ nsXMLContentSerializer::SerializeAttr(const nsAString& aPrefix,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
||||
PRBool aHasChildren,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr)
|
||||
{
|
||||
NS_ENSURE_ARG(aElement);
|
||||
|
@ -629,12 +629,12 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
}
|
||||
else {
|
||||
// Default NS attribute does not have prefix (and the name is "xmlns")
|
||||
PushNameSpaceDecl(EmptyString(), uriStr, aElement);
|
||||
PushNameSpaceDecl(EmptyString(), uriStr, aOriginalElement);
|
||||
}
|
||||
}
|
||||
else {
|
||||
attrName->ToString(nameStr);
|
||||
PushNameSpaceDecl(nameStr, uriStr, aElement);
|
||||
PushNameSpaceDecl(nameStr, uriStr, aOriginalElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -643,7 +643,8 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
|
||||
MaybeAddNewline(aStr);
|
||||
|
||||
addNSAttr = ConfirmPrefix(tagPrefix, tagNamespaceURI, aElement, PR_FALSE);
|
||||
addNSAttr = ConfirmPrefix(tagPrefix, tagNamespaceURI, aOriginalElement,
|
||||
PR_FALSE);
|
||||
// Serialize the qualified name of the element
|
||||
AppendToString(NS_LITERAL_STRING("<"), aStr);
|
||||
if (!tagPrefix.IsEmpty()) {
|
||||
|
@ -662,7 +663,7 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
// Serialize namespace decl
|
||||
SerializeAttr(xmlnsStr, tagPrefix, tagNamespaceURI, aStr, PR_TRUE);
|
||||
}
|
||||
PushNameSpaceDecl(tagPrefix, tagNamespaceURI, aElement);
|
||||
PushNameSpaceDecl(tagPrefix, tagNamespaceURI, aOriginalElement);
|
||||
}
|
||||
|
||||
// Now serialize each of the attributes
|
||||
|
@ -688,7 +689,7 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
addNSAttr = PR_FALSE;
|
||||
if (kNameSpaceID_XMLNS != namespaceID) {
|
||||
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(namespaceID, uriStr);
|
||||
addNSAttr = ConfirmPrefix(prefixStr, uriStr, aElement, PR_TRUE);
|
||||
addNSAttr = ConfirmPrefix(prefixStr, uriStr, aOriginalElement, PR_TRUE);
|
||||
}
|
||||
|
||||
content->GetAttr(namespaceID, attrName, valueStr);
|
||||
|
@ -714,12 +715,14 @@ nsXMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
|
|||
NS_ASSERTION(!prefixStr.IsEmpty(),
|
||||
"Namespaced attributes must have a prefix");
|
||||
SerializeAttr(xmlnsStr, prefixStr, uriStr, aStr, PR_TRUE);
|
||||
PushNameSpaceDecl(prefixStr, uriStr, aElement);
|
||||
PushNameSpaceDecl(prefixStr, uriStr, aOriginalElement);
|
||||
}
|
||||
}
|
||||
|
||||
// We don't output a separate end tag for empty element
|
||||
if (!aHasChildren) {
|
||||
PRBool hasChildren;
|
||||
if (NS_FAILED(aOriginalElement->HasChildNodes(&hasChildren)) ||
|
||||
!hasChildren) {
|
||||
AppendToString(NS_LITERAL_STRING("/>"), aStr);
|
||||
MaybeFlagNewline(aElement);
|
||||
} else {
|
||||
|
|
|
@ -81,7 +81,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
|
|||
nsAString& aStr);
|
||||
|
||||
NS_IMETHOD AppendElementStart(nsIDOMElement *aElement,
|
||||
PRBool aHasChildren,
|
||||
nsIDOMElement *aOriginalElement,
|
||||
nsAString& aStr);
|
||||
|
||||
NS_IMETHOD AppendElementEnd(nsIDOMElement *aElement,
|
||||
|
|
|
@ -627,7 +627,8 @@ nsXBLBinding::GenerateAnonymousContent()
|
|||
if (value.IsEmpty()) {
|
||||
nsAutoString value2;
|
||||
content->GetAttr(namespaceID, name, value2);
|
||||
mBoundElement->SetAttr(namespaceID, name, value2, PR_FALSE);
|
||||
mBoundElement->SetAttr(namespaceID, name, attrName->GetPrefix(),
|
||||
value2, PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче