mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Fix for bug 343870 (Line breaks normalized twice). r/sr=bz.
This commit is contained in:
parent
7694faac8b
commit
fc80057431
@ -1499,16 +1499,10 @@ nsXMLContentSink::AddText(const PRUnichar* aText,
|
||||
mTextSize = NS_ACCUMULATION_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
const nsAString& str = Substring(aText, aText+aLength);
|
||||
|
||||
// Copy data from string into our buffer; flush buffer when it fills up
|
||||
PRInt32 offset = 0;
|
||||
PRBool isLastCharCR = PR_FALSE;
|
||||
while (0 != aLength) {
|
||||
PRInt32 amount = mTextSize - mTextLength;
|
||||
if (amount > aLength) {
|
||||
amount = aLength;
|
||||
}
|
||||
if (0 == amount) {
|
||||
// XSLT wants adjacent textnodes merged.
|
||||
if (mConstrainSize && !mXSLTProcessor) {
|
||||
@ -1516,22 +1510,26 @@ nsXMLContentSink::AddText(const PRUnichar* aText,
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
amount = mTextSize - mTextLength;
|
||||
}
|
||||
else {
|
||||
mTextSize += aLength;
|
||||
mText = (PRUnichar *) PR_REALLOC(mText, sizeof(PRUnichar) * mTextSize);
|
||||
if (nsnull == mText) {
|
||||
mTextSize = 0;
|
||||
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
amount = aLength;
|
||||
}
|
||||
}
|
||||
// Line breaks should not be normalized twice. See bug 343870.
|
||||
mTextLength +=
|
||||
nsContentUtils::CopyNewlineNormalizedUnicodeTo(str,
|
||||
offset,
|
||||
&mText[mTextLength],
|
||||
amount,
|
||||
isLastCharCR);
|
||||
if (amount > aLength) {
|
||||
amount = aLength;
|
||||
}
|
||||
memcpy(&mText[mTextLength], &aText[offset], sizeof(PRUnichar) * amount);
|
||||
mTextLength += amount;
|
||||
offset += amount;
|
||||
aLength -= amount;
|
||||
}
|
||||
|
@ -537,14 +537,12 @@ nsExpatDriver::HandleDefault(const PRUnichar *aValue,
|
||||
mInternalSubset.Append(aValue, aLength);
|
||||
}
|
||||
else if (mSink) {
|
||||
static const PRUnichar newline[] = { '\n', '\0' };
|
||||
PRUint32 i;
|
||||
for (i = 0; i < aLength && NS_SUCCEEDED(mInternalState); ++i) {
|
||||
if (aValue[i] == '\n' || aValue[i] == '\r') {
|
||||
mInternalState = mSink->HandleCharacterData(newline, 1);
|
||||
mInternalState = mSink->HandleCharacterData(&aValue[i], 1);
|
||||
}
|
||||
}
|
||||
// The line breaks should not be normalized twice. See bug 343870.
|
||||
MaybeStopParser();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user