diff --git a/parser/htmlparser/src/nsHTMLTokens.cpp b/parser/htmlparser/src/nsHTMLTokens.cpp
index ee553a0f80bc..82897910b57d 100644
--- a/parser/htmlparser/src/nsHTMLTokens.cpp
+++ b/parser/htmlparser/src/nsHTMLTokens.cpp
@@ -775,6 +775,7 @@ CTextToken::ConsumeParsedCharacterData(PRBool aDiscardFirstNewline,
nsScannerIterator currPos, endPos, altEndPos;
PRUint32 truncPos = 0;
+ PRInt32 truncNewlineCount = 0;
aScanner.CurrentPosition(currPos);
aScanner.EndReading(endPos);
@@ -839,6 +840,7 @@ CTextToken::ConsumeParsedCharacterData(PRBool aDiscardFirstNewline,
// We ran out of room looking for a . Go back to the first
// place that looked like a tag and use that as our stopping point.
theContent.writable().Truncate(truncPos);
+ mNewlineCount = truncNewlineCount;
aScanner.SetPosition(altEndPos, PR_FALSE, PR_TRUE);
}
// else we take everything we consumed.
@@ -857,6 +859,7 @@ CTextToken::ConsumeParsedCharacterData(PRBool aDiscardFirstNewline,
// Keep this position in case we need it for later.
altEndPos = currPos;
truncPos = theContent.str().Length();
+ truncNewlineCount = mNewlineCount;
}
if (Distance(currPos, endPos) >= termStrLen) {