Convert InsertData calls into AppendData calls (which require less

reflow/painting to handle) when the data is inserted at the end.  Bug 300797,
r=sicking, sr=roc, a=bsmedberg
This commit is contained in:
bzbarsky%mit.edu 2005-07-19 20:52:12 +00:00
parent 2ecae9f664
commit ae5c6e2f82

View File

@ -396,7 +396,6 @@ nsGenericDOMDataNode::SubstringData(PRUint32 aStart, PRUint32 aCount,
nsresult
nsGenericDOMDataNode::AppendData(const nsAString& aData)
{
#if 1
PRInt32 length = 0;
// See bugzilla bug 77585.
@ -426,9 +425,6 @@ nsGenericDOMDataNode::AppendData(const nsAString& aData)
}
return NS_OK;
#else
return ReplaceData(mText.GetLength(), 0, aData);
#endif
}
nsresult
@ -455,6 +451,15 @@ nsGenericDOMDataNode::ReplaceData(PRUint32 aOffset, PRUint32 aCount,
return NS_ERROR_DOM_INDEX_SIZE_ERR;
}
// Fast path (hit by editor when typing at the end of the paragraph, for
// example): aOffset == textLength (so just doing an append; note that in
// this case any value of aCount would just get converted to 0 by the very
// next if block). Call AppendData so that we pass PR_TRUE for our aAppend
// arg to CharacterDataChanged.
if (aOffset == textLength) {
return AppendData(aData);
}
// Allocate new buffer
PRUint32 endOffset = aOffset + aCount;
if (endOffset > textLength) {