Bug 495663 - Count newlines correctly if we have an alternate ending position. r+sr=sicking

This commit is contained in:
Blake Kaplan 2009-06-01 20:44:37 -07:00
parent ed18be0cf5
commit c1dd12b814

View File

@ -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 </title>. 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) {