Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
bug 724826 pt 3 - replace users of nsIUGenCategory service within lib…
Browse files Browse the repository at this point in the history
…xul with direct access to mozilla::unicode::GetGenCategory. r=smontagu
  • Loading branch information
jfkthame committed Feb 24, 2012
1 parent 1a6e616 commit 2da4553
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 43 deletions.
7 changes: 0 additions & 7 deletions content/base/public/nsContentUtils.h
Expand Up @@ -131,7 +131,6 @@ class nsIInterfaceRequestor;
template<class E> class nsCOMArray; template<class E> class nsCOMArray;
template<class K, class V> class nsRefPtrHashtable; template<class K, class V> class nsRefPtrHashtable;
struct JSRuntime; struct JSRuntime;
class nsIUGenCategory;
class nsIWidget; class nsIWidget;
class nsIDragSession; class nsIDragSession;
class nsIPresShell; class nsIPresShell;
Expand Down Expand Up @@ -625,11 +624,6 @@ class nsContentUtils
return sWordBreaker; return sWordBreaker;
} }


static nsIUGenCategory* GetGenCat()
{
return sGenCat;
}

/** /**
* Regster aObserver as a shutdown observer. A strong reference is held * Regster aObserver as a shutdown observer. A strong reference is held
* to aObserver until UnregisterShutdownObserver is called. * to aObserver until UnregisterShutdownObserver is called.
Expand Down Expand Up @@ -2017,7 +2011,6 @@ class nsContentUtils


static nsILineBreaker* sLineBreaker; static nsILineBreaker* sLineBreaker;
static nsIWordBreaker* sWordBreaker; static nsIWordBreaker* sWordBreaker;
static nsIUGenCategory* sGenCat;


static nsIScriptRuntime* sScriptRuntimes[NS_STID_ARRAY_UBOUND]; static nsIScriptRuntime* sScriptRuntimes[NS_STID_ARRAY_UBOUND];
static PRInt32 sScriptRootCount[NS_STID_ARRAY_UBOUND]; static PRInt32 sScriptRootCount[NS_STID_ARRAY_UBOUND];
Expand Down
9 changes: 2 additions & 7 deletions content/base/src/nsContentUtils.cpp
Expand Up @@ -122,6 +122,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "nsLWBrkCIID.h" #include "nsLWBrkCIID.h"
#include "nsILineBreaker.h" #include "nsILineBreaker.h"
#include "nsIWordBreaker.h" #include "nsIWordBreaker.h"
#include "nsUnicodeProperties.h"
#include "jsdbgapi.h" #include "jsdbgapi.h"
#include "nsIJSRuntimeService.h" #include "nsIJSRuntimeService.h"
#include "nsIDOMDocumentXBL.h" #include "nsIDOMDocumentXBL.h"
Expand Down Expand Up @@ -154,7 +155,6 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "nsGenericHTMLElement.h" #include "nsGenericHTMLElement.h"
#include "nsAttrValue.h" #include "nsAttrValue.h"
#include "nsReferencedElement.h" #include "nsReferencedElement.h"
#include "nsIUGenCategory.h"
#include "nsIDragService.h" #include "nsIDragService.h"
#include "nsIChannelEventSink.h" #include "nsIChannelEventSink.h"
#include "nsIAsyncVerifyRedirectCallback.h" #include "nsIAsyncVerifyRedirectCallback.h"
Expand Down Expand Up @@ -260,7 +260,6 @@ nsIContentPolicy *nsContentUtils::sContentPolicyService;
bool nsContentUtils::sTriedToGetContentPolicy = false; bool nsContentUtils::sTriedToGetContentPolicy = false;
nsILineBreaker *nsContentUtils::sLineBreaker; nsILineBreaker *nsContentUtils::sLineBreaker;
nsIWordBreaker *nsContentUtils::sWordBreaker; nsIWordBreaker *nsContentUtils::sWordBreaker;
nsIUGenCategory *nsContentUtils::sGenCat;
nsIScriptRuntime *nsContentUtils::sScriptRuntimes[NS_STID_ARRAY_UBOUND]; nsIScriptRuntime *nsContentUtils::sScriptRuntimes[NS_STID_ARRAY_UBOUND];
PRInt32 nsContentUtils::sScriptRootCount[NS_STID_ARRAY_UBOUND]; PRInt32 nsContentUtils::sScriptRootCount[NS_STID_ARRAY_UBOUND];
PRUint32 nsContentUtils::sJSGCThingRootCount; PRUint32 nsContentUtils::sJSGCThingRootCount;
Expand Down Expand Up @@ -389,9 +388,6 @@ nsContentUtils::Init()
rv = CallGetService(NS_WBRK_CONTRACTID, &sWordBreaker); rv = CallGetService(NS_WBRK_CONTRACTID, &sWordBreaker);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);


rv = CallGetService(NS_UNICHARCATEGORY_CONTRACTID, &sGenCat);
NS_ENSURE_SUCCESS(rv, rv);

if (!InitializeEventTable()) if (!InitializeEventTable())
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;


Expand Down Expand Up @@ -977,7 +973,7 @@ nsContentUtils::IsPunctuationMarkAt(const nsTextFragment* aFrag, PRUint32 aOffse
// static // static
bool nsContentUtils::IsAlphanumeric(PRUint32 aChar) bool nsContentUtils::IsAlphanumeric(PRUint32 aChar)
{ {
nsIUGenCategory::nsUGenCategory cat = sGenCat->Get(aChar); nsIUGenCategory::nsUGenCategory cat = mozilla::unicode::GetGenCategory(aChar);


return (cat == nsIUGenCategory::kLetter || cat == nsIUGenCategory::kNumber); return (cat == nsIUGenCategory::kLetter || cat == nsIUGenCategory::kNumber);
} }
Expand Down Expand Up @@ -1138,7 +1134,6 @@ nsContentUtils::Shutdown()
NS_IF_RELEASE(sIOService); NS_IF_RELEASE(sIOService);
NS_IF_RELEASE(sLineBreaker); NS_IF_RELEASE(sLineBreaker);
NS_IF_RELEASE(sWordBreaker); NS_IF_RELEASE(sWordBreaker);
NS_IF_RELEASE(sGenCat);
#ifdef MOZ_XTF #ifdef MOZ_XTF
NS_IF_RELEASE(sXTFService); NS_IF_RELEASE(sXTFService);
#endif #endif
Expand Down
7 changes: 3 additions & 4 deletions extensions/spellcheck/src/mozEnglishWordUtils.cpp
Expand Up @@ -41,6 +41,7 @@
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsUnicharUtils.h" #include "nsUnicharUtils.h"
#include "nsUnicharUtilCIID.h" #include "nsUnicharUtilCIID.h"
#include "nsUnicodeProperties.h"
#include "nsCRT.h" #include "nsCRT.h"


NS_IMPL_CYCLE_COLLECTING_ADDREF(mozEnglishWordUtils) NS_IMPL_CYCLE_COLLECTING_ADDREF(mozEnglishWordUtils)
Expand All @@ -52,8 +53,7 @@ NS_INTERFACE_MAP_BEGIN(mozEnglishWordUtils)
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(mozEnglishWordUtils) NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(mozEnglishWordUtils)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END


NS_IMPL_CYCLE_COLLECTION_2(mozEnglishWordUtils, NS_IMPL_CYCLE_COLLECTION_1(mozEnglishWordUtils,
mCategories,
mURLDetector) mURLDetector)


mozEnglishWordUtils::mozEnglishWordUtils() mozEnglishWordUtils::mozEnglishWordUtils()
Expand All @@ -62,7 +62,6 @@ mozEnglishWordUtils::mozEnglishWordUtils()


nsresult rv; nsresult rv;
mURLDetector = do_CreateInstance(MOZ_TXTTOHTMLCONV_CONTRACTID, &rv); mURLDetector = do_CreateInstance(MOZ_TXTTOHTMLCONV_CONTRACTID, &rv);
mCategories = do_GetService(NS_UNICHARCATEGORY_CONTRACTID);
} }


mozEnglishWordUtils::~mozEnglishWordUtils() mozEnglishWordUtils::~mozEnglishWordUtils()
Expand Down Expand Up @@ -168,7 +167,7 @@ NS_IMETHODIMP mozEnglishWordUtils::GetRootForm(const PRUnichar *aWord, PRUint32
bool mozEnglishWordUtils::ucIsAlpha(PRUnichar aChar) bool mozEnglishWordUtils::ucIsAlpha(PRUnichar aChar)
{ {
// XXX we have to fix callers to handle the full Unicode range // XXX we have to fix callers to handle the full Unicode range
return nsIUGenCategory::kLetter == mCategories->Get(PRUint32(aChar)); return nsIUGenCategory::kLetter == mozilla::unicode::GetGenCategory(aChar);
} }


/* void FindNextWord (in wstring word, in PRUint32 length, in PRUint32 offset, out PRUint32 begin, out PRUint32 end); */ /* void FindNextWord (in wstring word, in PRUint32 length, in PRUint32 offset, out PRUint32 begin, out PRUint32 end); */
Expand Down
2 changes: 0 additions & 2 deletions extensions/spellcheck/src/mozEnglishWordUtils.h
Expand Up @@ -43,7 +43,6 @@
#include "nsIUnicodeEncoder.h" #include "nsIUnicodeEncoder.h"
#include "nsIUnicodeDecoder.h" #include "nsIUnicodeDecoder.h"
#include "nsString.h" #include "nsString.h"
#include "nsIUGenCategory.h"


#include "mozITXTToHTMLConv.h" #include "mozITXTToHTMLConv.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
Expand All @@ -68,7 +67,6 @@ class mozEnglishWordUtils : public mozISpellI18NUtil


nsString mLanguage; nsString mLanguage;
nsString mCharset; nsString mCharset;
nsCOMPtr<nsIUGenCategory> mCategories;
nsCOMPtr<mozITXTToHTMLConv> mURLDetector; // used to detect urls so the spell checker can skip them. nsCOMPtr<mozITXTToHTMLConv> mURLDetector; // used to detect urls so the spell checker can skip them.
}; };


Expand Down
7 changes: 2 additions & 5 deletions extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
Expand Up @@ -48,6 +48,7 @@
#include "nsIDOMNode.h" #include "nsIDOMNode.h"
#include "nsIDOMHTMLBRElement.h" #include "nsIDOMHTMLBRElement.h"
#include "nsUnicharUtilCIID.h" #include "nsUnicharUtilCIID.h"
#include "nsUnicodeProperties.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsTextFragment.h" #include "nsTextFragment.h"
Expand Down Expand Up @@ -87,10 +88,6 @@ mozInlineSpellWordUtil::Init(nsWeakPtr aWeakEditor)
{ {
nsresult rv; nsresult rv;


mCategories = do_GetService(NS_UNICHARCATEGORY_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;

// getting the editor can fail commonly because the editor was detached, so // getting the editor can fail commonly because the editor was detached, so
// don't assert // don't assert
nsCOMPtr<nsIEditor> editor = do_QueryReferent(aWeakEditor, &rv); nsCOMPtr<nsIEditor> editor = do_QueryReferent(aWeakEditor, &rv);
Expand Down Expand Up @@ -806,7 +803,7 @@ WordSplitState::ClassifyCharacter(PRInt32 aIndex, bool aRecurse) const
// this will classify the character, we want to treat "ignorable" characters // this will classify the character, we want to treat "ignorable" characters
// such as soft hyphens as word characters. // such as soft hyphens as word characters.
nsIUGenCategory::nsUGenCategory nsIUGenCategory::nsUGenCategory
charCategory = mWordUtil->GetCategories()->Get(PRUint32(mDOMWordText[aIndex])); charCategory = mozilla::unicode::GetGenCategory(mDOMWordText[aIndex]);
if (charCategory == nsIUGenCategory::kLetter || if (charCategory == nsIUGenCategory::kLetter ||
IsIgnorableCharacter(mDOMWordText[aIndex])) IsIgnorableCharacter(mDOMWordText[aIndex]))
return CHAR_CLASS_WORD; return CHAR_CLASS_WORD;
Expand Down
3 changes: 0 additions & 3 deletions extensions/spellcheck/src/mozInlineSpellWordUtil.h
Expand Up @@ -40,7 +40,6 @@
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsString.h" #include "nsString.h"
#include "nsTArray.h" #include "nsTArray.h"
#include "nsIUGenCategory.h"


//#define DEBUG_SPELLCHECK //#define DEBUG_SPELLCHECK


Expand Down Expand Up @@ -117,14 +116,12 @@ class mozInlineSpellWordUtil
nsIDOMDocument* GetDOMDocument() const { return mDOMDocument; } nsIDOMDocument* GetDOMDocument() const { return mDOMDocument; }
nsIDocument* GetDocument() const { return mDocument; } nsIDocument* GetDocument() const { return mDocument; }
nsINode* GetRootNode() { return mRootNode; } nsINode* GetRootNode() { return mRootNode; }
nsIUGenCategory* GetCategories() { return mCategories; }


private: private:


// cached stuff for the editor, set by Init // cached stuff for the editor, set by Init
nsCOMPtr<nsIDOMDocument> mDOMDocument; nsCOMPtr<nsIDOMDocument> mDOMDocument;
nsCOMPtr<nsIDocument> mDocument; nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsIUGenCategory> mCategories;


// range to check, see SetPosition and SetEnd // range to check, see SetPosition and SetEnd
nsINode* mRootNode; nsINode* mRootNode;
Expand Down
1 change: 0 additions & 1 deletion gfx/thebes/gfxPlatform.cpp
Expand Up @@ -71,7 +71,6 @@
#include "nsUnicodeRange.h" #include "nsUnicodeRange.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "nsTArray.h" #include "nsTArray.h"
#include "nsIUGenCategory.h"
#include "nsUnicharUtilCIID.h" #include "nsUnicharUtilCIID.h"
#include "nsILocaleService.h" #include "nsILocaleService.h"


Expand Down
2 changes: 0 additions & 2 deletions intl/hyphenation/public/nsHyphenator.h
Expand Up @@ -43,7 +43,6 @@
#include "nsTArray.h" #include "nsTArray.h"


class nsIURI; class nsIURI;
class nsIUGenCategory;


class nsHyphenator class nsHyphenator
{ {
Expand All @@ -61,7 +60,6 @@ class nsHyphenator


protected: protected:
void *mDict; void *mDict;
nsCOMPtr<nsIUGenCategory> mCategories;
}; };


#endif // nsHyphenator_h__ #endif // nsHyphenator_h__
8 changes: 3 additions & 5 deletions intl/hyphenation/src/nsHyphenator.cpp
Expand Up @@ -38,7 +38,7 @@
#include "nsHyphenator.h" #include "nsHyphenator.h"
#include "nsIFile.h" #include "nsIFile.h"
#include "nsUTF8Utils.h" #include "nsUTF8Utils.h"
#include "nsIUGenCategory.h" #include "nsUnicodeProperties.h"
#include "nsUnicharUtilCIID.h" #include "nsUnicharUtilCIID.h"
#include "nsIURI.h" #include "nsIURI.h"


Expand All @@ -58,8 +58,6 @@ nsHyphenator::nsHyphenator(nsIURI *aURI)
printf("loaded hyphenation patterns from %s\n", uriSpec.get()); printf("loaded hyphenation patterns from %s\n", uriSpec.get());
} }
#endif #endif
mCategories = do_GetService(NS_UNICHARCATEGORY_CONTRACTID, &rv);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get category service");
} }


nsHyphenator::~nsHyphenator() nsHyphenator::~nsHyphenator()
Expand All @@ -73,7 +71,7 @@ nsHyphenator::~nsHyphenator()
bool bool
nsHyphenator::IsValid() nsHyphenator::IsValid()
{ {
return (mDict != nsnull) && (mCategories != nsnull); return (mDict != nsnull);
} }


nsresult nsresult
Expand Down Expand Up @@ -101,7 +99,7 @@ nsHyphenator::Hyphenate(const nsAString& aString,
} }
} }


nsIUGenCategory::nsUGenCategory cat = mCategories->Get(ch); nsIUGenCategory::nsUGenCategory cat = mozilla::unicode::GetGenCategory(ch);
if (cat == nsIUGenCategory::kLetter || cat == nsIUGenCategory::kMark) { if (cat == nsIUGenCategory::kLetter || cat == nsIUGenCategory::kMark) {
if (!inWord) { if (!inWord) {
inWord = true; inWord = true;
Expand Down
10 changes: 3 additions & 7 deletions layout/generic/nsTextFrameThebes.cpp
Expand Up @@ -84,7 +84,7 @@
#include "nsTextFrameTextRunCache.h" #include "nsTextFrameTextRunCache.h"
#include "nsExpirationTracker.h" #include "nsExpirationTracker.h"
#include "nsTextFrame.h" #include "nsTextFrame.h"
#include "nsIUGenCategory.h" #include "nsUnicodeProperties.h"
#include "nsUnicharUtilCIID.h" #include "nsUnicharUtilCIID.h"


#include "nsTextFragment.h" #include "nsTextFragment.h"
Expand Down Expand Up @@ -6137,7 +6137,6 @@ class NS_STACK_CLASS ClusterIterator {
PRInt32 GetBeforeOffset(); PRInt32 GetBeforeOffset();


private: private:
nsCOMPtr<nsIUGenCategory> mCategories;
gfxSkipCharsIterator mIterator; gfxSkipCharsIterator mIterator;
const nsTextFragment* mFrag; const nsTextFragment* mFrag;
nsTextFrame* mTextFrame; nsTextFrame* mTextFrame;
Expand Down Expand Up @@ -6239,9 +6238,8 @@ bool
ClusterIterator::IsPunctuation() ClusterIterator::IsPunctuation()
{ {
NS_ASSERTION(mCharIndex >= 0, "No cluster selected"); NS_ASSERTION(mCharIndex >= 0, "No cluster selected");
if (!mCategories) nsIUGenCategory::nsUGenCategory c =
return false; mozilla::unicode::GetGenCategory(mFrag->CharAt(mCharIndex));
nsIUGenCategory::nsUGenCategory c = mCategories->Get(mFrag->CharAt(mCharIndex));
return c == nsIUGenCategory::kPunctuation || c == nsIUGenCategory::kSymbol; return c == nsIUGenCategory::kPunctuation || c == nsIUGenCategory::kSymbol;
} }


Expand Down Expand Up @@ -6306,8 +6304,6 @@ ClusterIterator::ClusterIterator(nsTextFrame* aTextFrame, PRInt32 aPosition,
} }
mIterator.SetOriginalOffset(aPosition); mIterator.SetOriginalOffset(aPosition);


mCategories = do_GetService(NS_UNICHARCATEGORY_CONTRACTID);

mFrag = aTextFrame->GetContent()->GetText(); mFrag = aTextFrame->GetContent()->GetText();
mTrimmed = aTextFrame->GetTrimmedOffsets(mFrag, true); mTrimmed = aTextFrame->GetTrimmedOffsets(mFrag, true);


Expand Down

0 comments on commit 2da4553

Please sign in to comment.