зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
1c8e673ef0
Коммит
27d7fed0f6
|
@ -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;
|
||||||
|
@ -625,11 +624,6 @@ public:
|
||||||
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.
|
||||||
|
@ -2017,7 +2011,6 @@ private:
|
||||||
|
|
||||||
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];
|
||||||
|
|
|
@ -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"
|
||||||
|
@ -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"
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
@ -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()
|
||||||
|
@ -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()
|
||||||
|
@ -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); */
|
||||||
|
|
|
@ -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"
|
||||||
|
@ -68,7 +67,6 @@ protected:
|
||||||
|
|
||||||
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.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
@ -117,14 +116,12 @@ public:
|
||||||
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;
|
||||||
|
|
|
@ -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"
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
|
|
||||||
class nsIURI;
|
class nsIURI;
|
||||||
class nsIUGenCategory;
|
|
||||||
|
|
||||||
class nsHyphenator
|
class nsHyphenator
|
||||||
{
|
{
|
||||||
|
@ -61,7 +60,6 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void *mDict;
|
void *mDict;
|
||||||
nsCOMPtr<nsIUGenCategory> mCategories;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsHyphenator_h__
|
#endif // nsHyphenator_h__
|
||||||
|
|
|
@ -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"
|
||||||
|
|
||||||
|
@ -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()
|
||||||
|
@ -73,7 +71,7 @@ nsHyphenator::~nsHyphenator()
|
||||||
bool
|
bool
|
||||||
nsHyphenator::IsValid()
|
nsHyphenator::IsValid()
|
||||||
{
|
{
|
||||||
return (mDict != nsnull) && (mCategories != nsnull);
|
return (mDict != nsnull);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
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 (cat == nsIUGenCategory::kLetter || cat == nsIUGenCategory::kMark) {
|
||||||
if (!inWord) {
|
if (!inWord) {
|
||||||
inWord = true;
|
inWord = true;
|
||||||
|
|
|
@ -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"
|
||||||
|
@ -6137,7 +6137,6 @@ public:
|
||||||
PRInt32 GetBeforeOffset();
|
PRInt32 GetBeforeOffset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsCOMPtr<nsIUGenCategory> mCategories;
|
|
||||||
gfxSkipCharsIterator mIterator;
|
gfxSkipCharsIterator mIterator;
|
||||||
const nsTextFragment* mFrag;
|
const nsTextFragment* mFrag;
|
||||||
nsTextFrame* mTextFrame;
|
nsTextFrame* mTextFrame;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче