bug 724826 pt 3 - replace users of nsIUGenCategory service within libxul with direct access to mozilla::unicode::GetGenCategory. r=smontagu

This commit is contained in:
Jonathan Kew 2012-02-24 10:15:46 +00:00
Родитель 1c8e673ef0
Коммит 27d7fed0f6
10 изменённых файлов: 13 добавлений и 43 удалений

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

@ -131,7 +131,6 @@ class nsIInterfaceRequestor;
template<class E> class nsCOMArray;
template<class K, class V> class nsRefPtrHashtable;
struct JSRuntime;
class nsIUGenCategory;
class nsIWidget;
class nsIDragSession;
class nsIPresShell;
@ -625,11 +624,6 @@ public:
return sWordBreaker;
}
static nsIUGenCategory* GetGenCat()
{
return sGenCat;
}
/**
* Regster aObserver as a shutdown observer. A strong reference is held
* to aObserver until UnregisterShutdownObserver is called.
@ -2017,7 +2011,6 @@ private:
static nsILineBreaker* sLineBreaker;
static nsIWordBreaker* sWordBreaker;
static nsIUGenCategory* sGenCat;
static nsIScriptRuntime* sScriptRuntimes[NS_STID_ARRAY_UBOUND];
static PRInt32 sScriptRootCount[NS_STID_ARRAY_UBOUND];

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

@ -122,6 +122,7 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "nsLWBrkCIID.h"
#include "nsILineBreaker.h"
#include "nsIWordBreaker.h"
#include "nsUnicodeProperties.h"
#include "jsdbgapi.h"
#include "nsIJSRuntimeService.h"
#include "nsIDOMDocumentXBL.h"
@ -154,7 +155,6 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "nsGenericHTMLElement.h"
#include "nsAttrValue.h"
#include "nsReferencedElement.h"
#include "nsIUGenCategory.h"
#include "nsIDragService.h"
#include "nsIChannelEventSink.h"
#include "nsIAsyncVerifyRedirectCallback.h"
@ -260,7 +260,6 @@ nsIContentPolicy *nsContentUtils::sContentPolicyService;
bool nsContentUtils::sTriedToGetContentPolicy = false;
nsILineBreaker *nsContentUtils::sLineBreaker;
nsIWordBreaker *nsContentUtils::sWordBreaker;
nsIUGenCategory *nsContentUtils::sGenCat;
nsIScriptRuntime *nsContentUtils::sScriptRuntimes[NS_STID_ARRAY_UBOUND];
PRInt32 nsContentUtils::sScriptRootCount[NS_STID_ARRAY_UBOUND];
PRUint32 nsContentUtils::sJSGCThingRootCount;
@ -389,9 +388,6 @@ nsContentUtils::Init()
rv = CallGetService(NS_WBRK_CONTRACTID, &sWordBreaker);
NS_ENSURE_SUCCESS(rv, rv);
rv = CallGetService(NS_UNICHARCATEGORY_CONTRACTID, &sGenCat);
NS_ENSURE_SUCCESS(rv, rv);
if (!InitializeEventTable())
return NS_ERROR_FAILURE;
@ -977,7 +973,7 @@ nsContentUtils::IsPunctuationMarkAt(const nsTextFragment* aFrag, PRUint32 aOffse
// static
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);
}
@ -1138,7 +1134,6 @@ nsContentUtils::Shutdown()
NS_IF_RELEASE(sIOService);
NS_IF_RELEASE(sLineBreaker);
NS_IF_RELEASE(sWordBreaker);
NS_IF_RELEASE(sGenCat);
#ifdef MOZ_XTF
NS_IF_RELEASE(sXTFService);
#endif

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

@ -41,6 +41,7 @@
#include "nsIServiceManager.h"
#include "nsUnicharUtils.h"
#include "nsUnicharUtilCIID.h"
#include "nsUnicodeProperties.h"
#include "nsCRT.h"
NS_IMPL_CYCLE_COLLECTING_ADDREF(mozEnglishWordUtils)
@ -52,8 +53,7 @@ NS_INTERFACE_MAP_BEGIN(mozEnglishWordUtils)
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(mozEnglishWordUtils)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_2(mozEnglishWordUtils,
mCategories,
NS_IMPL_CYCLE_COLLECTION_1(mozEnglishWordUtils,
mURLDetector)
mozEnglishWordUtils::mozEnglishWordUtils()
@ -62,7 +62,6 @@ mozEnglishWordUtils::mozEnglishWordUtils()
nsresult rv;
mURLDetector = do_CreateInstance(MOZ_TXTTOHTMLCONV_CONTRACTID, &rv);
mCategories = do_GetService(NS_UNICHARCATEGORY_CONTRACTID);
}
mozEnglishWordUtils::~mozEnglishWordUtils()
@ -168,7 +167,7 @@ NS_IMETHODIMP mozEnglishWordUtils::GetRootForm(const PRUnichar *aWord, PRUint32
bool mozEnglishWordUtils::ucIsAlpha(PRUnichar aChar)
{
// 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); */

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

@ -43,7 +43,6 @@
#include "nsIUnicodeEncoder.h"
#include "nsIUnicodeDecoder.h"
#include "nsString.h"
#include "nsIUGenCategory.h"
#include "mozITXTToHTMLConv.h"
#include "nsCycleCollectionParticipant.h"
@ -68,7 +67,6 @@ protected:
nsString mLanguage;
nsString mCharset;
nsCOMPtr<nsIUGenCategory> mCategories;
nsCOMPtr<mozITXTToHTMLConv> mURLDetector; // used to detect urls so the spell checker can skip them.
};

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

@ -48,6 +48,7 @@
#include "nsIDOMNode.h"
#include "nsIDOMHTMLBRElement.h"
#include "nsUnicharUtilCIID.h"
#include "nsUnicodeProperties.h"
#include "nsServiceManagerUtils.h"
#include "nsIContent.h"
#include "nsTextFragment.h"
@ -87,10 +88,6 @@ mozInlineSpellWordUtil::Init(nsWeakPtr aWeakEditor)
{
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
// don't assert
nsCOMPtr<nsIEditor> editor = do_QueryReferent(aWeakEditor, &rv);
@ -806,7 +803,7 @@ WordSplitState::ClassifyCharacter(PRInt32 aIndex, bool aRecurse) const
// this will classify the character, we want to treat "ignorable" characters
// such as soft hyphens as word characters.
nsIUGenCategory::nsUGenCategory
charCategory = mWordUtil->GetCategories()->Get(PRUint32(mDOMWordText[aIndex]));
charCategory = mozilla::unicode::GetGenCategory(mDOMWordText[aIndex]);
if (charCategory == nsIUGenCategory::kLetter ||
IsIgnorableCharacter(mDOMWordText[aIndex]))
return CHAR_CLASS_WORD;

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

@ -40,7 +40,6 @@
#include "nsIDocument.h"
#include "nsString.h"
#include "nsTArray.h"
#include "nsIUGenCategory.h"
//#define DEBUG_SPELLCHECK
@ -117,14 +116,12 @@ public:
nsIDOMDocument* GetDOMDocument() const { return mDOMDocument; }
nsIDocument* GetDocument() const { return mDocument; }
nsINode* GetRootNode() { return mRootNode; }
nsIUGenCategory* GetCategories() { return mCategories; }
private:
// cached stuff for the editor, set by Init
nsCOMPtr<nsIDOMDocument> mDOMDocument;
nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsIUGenCategory> mCategories;
// range to check, see SetPosition and SetEnd
nsINode* mRootNode;

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

@ -71,7 +71,6 @@
#include "nsUnicodeRange.h"
#include "nsServiceManagerUtils.h"
#include "nsTArray.h"
#include "nsIUGenCategory.h"
#include "nsUnicharUtilCIID.h"
#include "nsILocaleService.h"

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

@ -43,7 +43,6 @@
#include "nsTArray.h"
class nsIURI;
class nsIUGenCategory;
class nsHyphenator
{
@ -61,7 +60,6 @@ private:
protected:
void *mDict;
nsCOMPtr<nsIUGenCategory> mCategories;
};
#endif // nsHyphenator_h__

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

@ -38,7 +38,7 @@
#include "nsHyphenator.h"
#include "nsIFile.h"
#include "nsUTF8Utils.h"
#include "nsIUGenCategory.h"
#include "nsUnicodeProperties.h"
#include "nsUnicharUtilCIID.h"
#include "nsIURI.h"
@ -58,8 +58,6 @@ nsHyphenator::nsHyphenator(nsIURI *aURI)
printf("loaded hyphenation patterns from %s\n", uriSpec.get());
}
#endif
mCategories = do_GetService(NS_UNICHARCATEGORY_CONTRACTID, &rv);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get category service");
}
nsHyphenator::~nsHyphenator()
@ -73,7 +71,7 @@ nsHyphenator::~nsHyphenator()
bool
nsHyphenator::IsValid()
{
return (mDict != nsnull) && (mCategories != nsnull);
return (mDict != nsnull);
}
nsresult
@ -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 (!inWord) {
inWord = true;

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

@ -84,7 +84,7 @@
#include "nsTextFrameTextRunCache.h"
#include "nsExpirationTracker.h"
#include "nsTextFrame.h"
#include "nsIUGenCategory.h"
#include "nsUnicodeProperties.h"
#include "nsUnicharUtilCIID.h"
#include "nsTextFragment.h"
@ -6137,7 +6137,6 @@ public:
PRInt32 GetBeforeOffset();
private:
nsCOMPtr<nsIUGenCategory> mCategories;
gfxSkipCharsIterator mIterator;
const nsTextFragment* mFrag;
nsTextFrame* mTextFrame;
@ -6239,9 +6238,8 @@ bool
ClusterIterator::IsPunctuation()
{
NS_ASSERTION(mCharIndex >= 0, "No cluster selected");
if (!mCategories)
return false;
nsIUGenCategory::nsUGenCategory c = mCategories->Get(mFrag->CharAt(mCharIndex));
nsIUGenCategory::nsUGenCategory c =
mozilla::unicode::GetGenCategory(mFrag->CharAt(mCharIndex));
return c == nsIUGenCategory::kPunctuation || c == nsIUGenCategory::kSymbol;
}
@ -6306,8 +6304,6 @@ ClusterIterator::ClusterIterator(nsTextFrame* aTextFrame, PRInt32 aPosition,
}
mIterator.SetOriginalOffset(aPosition);
mCategories = do_GetService(NS_UNICHARCATEGORY_CONTRACTID);
mFrag = aTextFrame->GetContent()->GetText();
mTrimmed = aTextFrame->GetTrimmedOffsets(mFrag, true);