зеркало из https://github.com/mozilla/pjs.git
Image alt text was not being emitted in plaintext serializer because it was inadvertently moved into a method where it would never be called; moving it back.
Written by Akkana, r=brade, sr=jst (bug 212177)
This commit is contained in:
Родитель
cb563ef820
Коммит
225a6c2c20
|
@ -899,29 +899,6 @@ nsPlainTextSerializer::DoOpenContainer(const nsIParserNode* aNode, PRInt32 aTag)
|
|||
else if (type == eHTMLTag_u && mStructs && !currentNodeIsConverted) {
|
||||
Write(NS_LITERAL_STRING("_"));
|
||||
}
|
||||
else if (type == eHTMLTag_img) {
|
||||
/* Output (in decreasing order of preference)
|
||||
alt, title or nothing */
|
||||
// See <http://www.w3.org/TR/REC-html40/struct/objects.html#edef-IMG>
|
||||
nsAutoString imageDescription;
|
||||
if (NS_SUCCEEDED(GetAttributeValue(aNode,
|
||||
nsHTMLAtoms::alt,
|
||||
imageDescription))) {
|
||||
// If the alt attribute has an empty value (|alt=""|), output nothing
|
||||
}
|
||||
else if (NS_SUCCEEDED(GetAttributeValue(aNode,
|
||||
nsHTMLAtoms::title,
|
||||
imageDescription))
|
||||
&& !imageDescription.IsEmpty()) {
|
||||
imageDescription = NS_LITERAL_STRING(" [") +
|
||||
imageDescription +
|
||||
NS_LITERAL_STRING("] ");
|
||||
}
|
||||
|
||||
if (!imageDescription.IsEmpty()) {
|
||||
Write(imageDescription);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1227,6 +1204,28 @@ nsPlainTextSerializer::DoAddLeaf(const nsIParserNode *aNode, PRInt32 aTag,
|
|||
|
||||
EnsureVerticalSpace(0);
|
||||
}
|
||||
else if (type == eHTMLTag_img) {
|
||||
/* Output (in decreasing order of preference)
|
||||
alt, title or nothing */
|
||||
// See <http://www.w3.org/TR/REC-html40/struct/objects.html#edef-IMG>
|
||||
nsAutoString imageDescription;
|
||||
if (NS_SUCCEEDED(GetAttributeValue(aNode,
|
||||
nsHTMLAtoms::alt,
|
||||
imageDescription))) {
|
||||
// If the alt attribute has an empty value (|alt=""|), output nothing
|
||||
}
|
||||
else if (NS_SUCCEEDED(GetAttributeValue(aNode,
|
||||
nsHTMLAtoms::title,
|
||||
imageDescription))
|
||||
&& !imageDescription.IsEmpty()) {
|
||||
imageDescription = NS_LITERAL_STRING(" [") +
|
||||
imageDescription +
|
||||
NS_LITERAL_STRING("] ");
|
||||
}
|
||||
|
||||
Write(imageDescription);
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче