Bug 240933 - Part 11: Optimize setting the bidi flag for modifications to large DOM text nodes; r=smontagu a=dbaron

--HG--
extra : rebase_source : bdd58373ec59cdcdc231ca9eb61bc7a1a0c9191f
This commit is contained in:
Ehsan Akhgari 2010-07-21 19:29:06 -04:00
Родитель 06dfe9b126
Коммит 41095d2237
4 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@ -385,7 +385,7 @@ nsGenericDOMDataNode::SetTextInternal(PRUint32 aOffset, PRUint32 aCount,
delete [] to;
}
SetBidiStatus();
UpdateBidiStatus(aBuffer, aLength);
// Notify observers
if (aNotify) {
@ -1084,7 +1084,7 @@ nsGenericDOMDataNode::AppendTextTo(nsAString& aResult)
mText.AppendTo(aResult);
}
void nsGenericDOMDataNode::SetBidiStatus()
void nsGenericDOMDataNode::UpdateBidiStatus(const PRUnichar* aBuffer, PRUint32 aLength)
{
nsIDocument *document = GetCurrentDoc();
if (document && document->GetBidiEnabled()) {
@ -1092,7 +1092,7 @@ void nsGenericDOMDataNode::SetBidiStatus()
return;
}
mText.SetBidiFlag();
mText.UpdateBidiFlag(aBuffer, aLength);
if (document && mText.IsBidi()) {
document->SetBidiEnabled();

Просмотреть файл

@ -358,7 +358,7 @@ protected:
nsTextFragment mText;
private:
void SetBidiStatus();
void UpdateBidiStatus(const PRUnichar* aBuffer, PRUint32 aLength);
already_AddRefed<nsIAtom> GetCurrentValueAtom();
};

Просмотреть файл

@ -372,11 +372,11 @@ nsTextFragment::Append(const PRUnichar* aBuffer, PRUint32 aLength)
// To save time we only do this when we really want to know, not during
// every allocation
void
nsTextFragment::SetBidiFlag()
nsTextFragment::UpdateBidiFlag(const PRUnichar* aBuffer, PRUint32 aLength)
{
if (mState.mIs2b && !mState.mIsBidi) {
const PRUnichar* cp = m2b;
const PRUnichar* end = cp + mState.mLength;
const PRUnichar* cp = aBuffer;
const PRUnichar* end = cp + aLength;
while (cp < end) {
PRUnichar ch1 = *cp++;
PRUint32 utf32Char = ch1;

Просмотреть файл

@ -112,7 +112,7 @@ public:
/**
* Return PR_TRUE if this fragment contains Bidi text
* For performance reasons this flag is not set automatically, but
* requires an explicit call to SetBidiFlag()
* requires an explicit call to UpdateBidiFlag()
*/
PRBool IsBidi() const
{
@ -209,7 +209,7 @@ public:
* Scan the contents of the fragment and turn on mState.mIsBidi if it
* includes any Bidi characters.
*/
void SetBidiFlag();
void UpdateBidiFlag(const PRUnichar* aBuffer, PRUint32 aLength);
struct FragmentBits {
// PRUint32 to ensure that the values are unsigned, because we