From 41095d22376cde445962f1cc65a58bdd2fdd882c Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Wed, 21 Jul 2010 19:29:06 -0400 Subject: [PATCH] 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 --- content/base/src/nsGenericDOMDataNode.cpp | 6 +++--- content/base/src/nsGenericDOMDataNode.h | 2 +- content/base/src/nsTextFragment.cpp | 6 +++--- content/base/src/nsTextFragment.h | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/content/base/src/nsGenericDOMDataNode.cpp b/content/base/src/nsGenericDOMDataNode.cpp index 34344f644b28..166fa69205c7 100644 --- a/content/base/src/nsGenericDOMDataNode.cpp +++ b/content/base/src/nsGenericDOMDataNode.cpp @@ -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(); diff --git a/content/base/src/nsGenericDOMDataNode.h b/content/base/src/nsGenericDOMDataNode.h index a90f7243e01f..83c461fbb93d 100644 --- a/content/base/src/nsGenericDOMDataNode.h +++ b/content/base/src/nsGenericDOMDataNode.h @@ -358,7 +358,7 @@ protected: nsTextFragment mText; private: - void SetBidiStatus(); + void UpdateBidiStatus(const PRUnichar* aBuffer, PRUint32 aLength); already_AddRefed GetCurrentValueAtom(); }; diff --git a/content/base/src/nsTextFragment.cpp b/content/base/src/nsTextFragment.cpp index ce1aab9f3924..87f4f8e91dd2 100644 --- a/content/base/src/nsTextFragment.cpp +++ b/content/base/src/nsTextFragment.cpp @@ -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; diff --git a/content/base/src/nsTextFragment.h b/content/base/src/nsTextFragment.h index bbdd602c3961..4a5c27aca21e 100644 --- a/content/base/src/nsTextFragment.h +++ b/content/base/src/nsTextFragment.h @@ -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