Checking in jeff.qiu@sun.com's fix for bug 77585. Speeding up nsGenericDOMDataNode::AppendData(). r=cbiesinger@web.de, sr=jst@netscape.com
git-svn-id: svn://10.0.0.236/trunk@118652 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
db1e5a6bb9
commit
a5c442b76e
@ -500,12 +500,22 @@ nsGenericDOMDataNode::AppendData(const nsAString& aData)
|
||||
{
|
||||
#if 1
|
||||
nsresult rv = NS_OK;
|
||||
PRInt32 length = 0;
|
||||
|
||||
nsAutoString old_data;
|
||||
// See bugzilla bug 77585.
|
||||
if (mText.Is2b() || (!IsASCII(aData))) {
|
||||
nsAutoString old_data;
|
||||
mText.AppendTo(old_data);
|
||||
length = old_data.Length();
|
||||
rv = SetText(old_data + aData, PR_FALSE);
|
||||
} else {
|
||||
nsCAutoString old_data;
|
||||
mText.AppendTo(old_data);
|
||||
length = old_data.Length();
|
||||
old_data.AppendWithConversion(aData);
|
||||
rv = SetText(old_data.get(), old_data.Length(), PR_FALSE);
|
||||
}
|
||||
|
||||
mText.AppendTo(old_data);
|
||||
|
||||
rv = SetText(old_data + aData, PR_FALSE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Trigger a reflow
|
||||
@ -516,7 +526,7 @@ nsGenericDOMDataNode::AppendData(const nsAString& aData)
|
||||
nsTextContentChangeData* tccd = nsnull;
|
||||
rv = NS_NewTextContentChangeData(&tccd);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
tccd->SetData(nsITextContentChangeData::Append, old_data.Length(),
|
||||
tccd->SetData(nsITextContentChangeData::Append, length,
|
||||
aData.Length());
|
||||
rv = mDocument->ContentChanged(this, tccd);
|
||||
NS_RELEASE(tccd);
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
|
||||
#include "nsAString.h"
|
||||
class nsString;
|
||||
class nsCString;
|
||||
|
||||
// XXX should this normalize the code to keep a \u0000 at the end?
|
||||
|
||||
@ -205,6 +206,11 @@ public:
|
||||
*/
|
||||
void AppendTo(nsString& aString) const;
|
||||
|
||||
/**
|
||||
* Append the contents of this string fragment to aCString
|
||||
*/
|
||||
void AppendTo(nsCString& aCString) const;
|
||||
|
||||
/**
|
||||
* Make a copy of the fragments contents starting at offset for
|
||||
* count characters. The offset and count will be adjusted to
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
|
||||
#include "nsAString.h"
|
||||
class nsString;
|
||||
class nsCString;
|
||||
|
||||
// XXX should this normalize the code to keep a \u0000 at the end?
|
||||
|
||||
@ -205,6 +206,11 @@ public:
|
||||
*/
|
||||
void AppendTo(nsString& aString) const;
|
||||
|
||||
/**
|
||||
* Append the contents of this string fragment to aCString
|
||||
*/
|
||||
void AppendTo(nsCString& aCString) const;
|
||||
|
||||
/**
|
||||
* Make a copy of the fragments contents starting at offset for
|
||||
* count characters. The offset and count will be adjusted to
|
||||
|
||||
@ -278,6 +278,18 @@ nsTextFragment::AppendTo(nsString& aString) const
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTextFragment::AppendTo(nsCString& aCString) const
|
||||
{
|
||||
if (mState.mLength == 0) return;
|
||||
|
||||
if (mState.mIs2b) {
|
||||
aCString.AppendWithConversion((PRUnichar *)m2b, mState.mLength);
|
||||
} else {
|
||||
aCString.Append((char *)m1b, mState.mLength);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsTextFragment::CopyTo(PRUnichar *aDest, PRInt32 aOffset, PRInt32 aCount)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user