Bug 1309326. Fix the HTML serializer's handling of self-closing tags inside <pre> to correctly keep track of our mPreLevel. r=ehsan

The test change makes sure the test actually tests this codepath. The resulting
test expectation changes are all due to the test now recognizing <pre> as preformatted.
This commit is contained in:
Boris Zbarsky
2016-10-13 12:44:20 -04:00
parent 21b46c4c9c
commit 1bbfea463e
12 changed files with 32 additions and 49 deletions

View File

@@ -185,6 +185,10 @@ nsHTMLContentSerializer::AppendElementStart(Element* aElement,
bool forceFormat = false;
nsresult rv = NS_OK;
if (!CheckElementStart(content, forceFormat, aStr, rv)) {
// When we go to AppendElementEnd for this element, we're going to
// MaybeLeaveFromPreContent(). So make sure to MaybeEnterInPreContent()
// now, so our PreLevel() doesn't get confused.
MaybeEnterInPreContent(content);
return rv;
}
@@ -351,6 +355,9 @@ nsHTMLContentSerializer::AppendElementEnd(Element* aElement,
IsContainer(parserService->HTMLCaseSensitiveAtomTagToId(name),
isContainer);
if (!isContainer) {
// Keep this in sync with the cleanup at the end of this method.
MOZ_ASSERT(name != nsGkAtoms::body);
MaybeLeaveFromPreContent(content);
return NS_OK;
}
}
@@ -382,6 +389,7 @@ nsHTMLContentSerializer::AppendElementEnd(Element* aElement,
NS_ENSURE_TRUE(AppendToString(nsDependentAtomString(name), aStr), NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(AppendToString(kGreaterThan, aStr), NS_ERROR_OUT_OF_MEMORY);
// Keep this cleanup in sync with the IsContainer() early return above.
MaybeLeaveFromPreContent(content);
if ((mDoFormat || forceFormat)&& !mDoRaw && !PreLevel()