Bug 331991 - Save as "Web Page, Complete" for HTML should include meta charset or encode all non-ASCII characters as entitiesp=Ryan Jones <sciguyryan@gmail.com>r=glazou, sr=peterv

This commit is contained in:
asqueella@gmail.com 2007-05-13 09:44:06 -07:00
Родитель 4e7a615a2d
Коммит 876c7afe0e
1 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -654,6 +654,16 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
nsIAtom *name = content->Tag();
if (name == nsGkAtoms::meta) {
// We need too skip any meta tags that set the content type
// becase we set our own later.
nsAutoString header;
content->GetAttr(kNameSpaceID_None, nsGkAtoms::httpEquiv, header);
if (header.LowerCaseEqualsLiteral("content-type")) {
return NS_OK;
}
}
if (name == nsGkAtoms::br && mPreLevel > 0
&& (mFlags & nsIDocumentEncoder::OutputNoFormattingInPre)) {
AppendToString(mLineBreak, aStr);
@ -748,6 +758,18 @@ nsHTMLContentSerializer::AppendElementStart(nsIDOMElement *aElement,
mInCDATA = PR_TRUE;
}
if (name == nsGkAtoms::head) {
// We should also obey the line break rules set for a normal meta tag here.
// We add a line break before and after the tag's opening.
AppendToString(mLineBreak, aStr);
AppendToString(NS_LITERAL_STRING("<meta http-equiv=\"content-type\""),
aStr);
AppendToString(NS_LITERAL_STRING(" content=\"text/html; "), aStr);
AppendToString(NS_ConvertASCIItoUTF16(mCharset), aStr);
AppendToString(NS_LITERAL_STRING("\">"), aStr);
AppendToString(mLineBreak, aStr);
}
return NS_OK;
}