Bug 1469759 - Part 3. Remove unused methods of mozISpellI18NUtil. r=masayuki

Some methods in mozISpellI18NUtil are unused now.

MozReview-Commit-ID: Ku9FojuJW3T

--HG--
extra : rebase_source : a6c3afc7c7b116c1ba2c71bd93744f2ee8c724c2
This commit is contained in:
Makoto Kato 2018-07-02 11:21:28 +09:00
Родитель 445dde1b84
Коммит 428be3d211
3 изменённых файлов: 6 добавлений и 214 удалений

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

@ -12,32 +12,6 @@
*/
interface mozISpellI18NUtil : nsISupports {
const uint32_t kCheck=0;
const uint32_t kSuggest=1;
/**
* The language being used to check spelling
*/
readonly attribute wstring language;
/**
* Given a word return a list of possible root forms of that word
*/
void getRootForm(in wstring word,
in uint32_t type,
[array, size_is(count)] out wstring words,
out uint32_t count);
/**
* Given a word return a list of possible root forms of that word
*/
void fromRootForm(in wstring word,
[array, size_is(icount)] in wstring iwords,
in uint32_t icount,
[array, size_is(ocount)] out wstring owords,
out uint32_t ocount);
/**
* Given a unicode string and an offset, find the beginning and end of the
* next word. begin and end are -1 if there are no words remaining in the

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

@ -26,112 +26,18 @@ NS_IMPL_CYCLE_COLLECTION(mozEnglishWordUtils,
mozEnglishWordUtils::mozEnglishWordUtils()
{
mLanguage.AssignLiteral("en");
nsresult rv;
mURLDetector = do_CreateInstance(MOZ_TXTTOHTMLCONV_CONTRACTID, &rv);
mURLDetector = do_CreateInstance(MOZ_TXTTOHTMLCONV_CONTRACTID);
}
mozEnglishWordUtils::~mozEnglishWordUtils()
{
}
NS_IMETHODIMP mozEnglishWordUtils::GetLanguage(char16_t * *aLanguage)
{
NS_ENSURE_ARG_POINTER(aLanguage);
*aLanguage = ToNewUnicode(mLanguage);
if (!*aLanguage) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
// return the possible root forms of aWord.
NS_IMETHODIMP mozEnglishWordUtils::GetRootForm(const char16_t *aWord, uint32_t type, char16_t ***words, uint32_t *count)
{
nsAutoString word(aWord);
char16_t **tmpPtr;
int32_t length = word.Length();
*count = 0;
mozEnglishWordUtils::myspCapitalization ct = captype(word);
switch (ct)
{
case HuhCap:
case NoCap:
tmpPtr = (char16_t **)moz_xmalloc(sizeof(char16_t *));
if (!tmpPtr)
return NS_ERROR_OUT_OF_MEMORY;
tmpPtr[0] = ToNewUnicode(word);
if (!tmpPtr[0]) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(0, tmpPtr);
return NS_ERROR_OUT_OF_MEMORY;
}
*words = tmpPtr;
*count = 1;
break;
case AllCap:
tmpPtr = (char16_t **)moz_xmalloc(sizeof(char16_t *) * 3);
if (!tmpPtr)
return NS_ERROR_OUT_OF_MEMORY;
tmpPtr[0] = ToNewUnicode(word);
if (!tmpPtr[0]) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(0, tmpPtr);
return NS_ERROR_OUT_OF_MEMORY;
}
ToLowerCase(tmpPtr[0], tmpPtr[0], length);
tmpPtr[1] = ToNewUnicode(word);
if (!tmpPtr[1]) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(1, tmpPtr);
return NS_ERROR_OUT_OF_MEMORY;
}
ToLowerCase(tmpPtr[1], tmpPtr[1], length);
ToUpperCase(tmpPtr[1], tmpPtr[1], 1);
tmpPtr[2] = ToNewUnicode(word);
if (!tmpPtr[2]) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(2, tmpPtr);
return NS_ERROR_OUT_OF_MEMORY;
}
*words = tmpPtr;
*count = 3;
break;
case InitCap:
tmpPtr = (char16_t **)moz_xmalloc(sizeof(char16_t *) * 2);
if (!tmpPtr)
return NS_ERROR_OUT_OF_MEMORY;
tmpPtr[0] = ToNewUnicode(word);
if (!tmpPtr[0]) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(0, tmpPtr);
return NS_ERROR_OUT_OF_MEMORY;
}
ToLowerCase(tmpPtr[0], tmpPtr[0], length);
tmpPtr[1] = ToNewUnicode(word);
if (!tmpPtr[1]) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(1, tmpPtr);
return NS_ERROR_OUT_OF_MEMORY;
}
*words = tmpPtr;
*count = 2;
break;
default:
return NS_ERROR_FAILURE; // should never get here;
}
return NS_OK;
}
// This needs vast improvement
bool mozEnglishWordUtils::ucIsAlpha(char16_t aChar)
// static
bool
mozEnglishWordUtils::ucIsAlpha(char16_t aChar)
{
// XXX we have to fix callers to handle the full Unicode range
return nsUGenCategory::kLetter == mozilla::unicode::GetGenCategory(aChar);
@ -205,80 +111,3 @@ NS_IMETHODIMP mozEnglishWordUtils::FindNextWord(const char16_t *word, uint32_t l
}
return NS_OK;
}
mozEnglishWordUtils::myspCapitalization
mozEnglishWordUtils::captype(const nsString &word)
{
char16_t* lword=ToNewUnicode(word);
ToUpperCase(lword,lword,word.Length());
if(word.Equals(lword)){
free(lword);
return AllCap;
}
ToLowerCase(lword,lword,word.Length());
if(word.Equals(lword)){
free(lword);
return NoCap;
}
int32_t length=word.Length();
if(Substring(word,1,length-1).Equals(lword+1)){
free(lword);
return InitCap;
}
free(lword);
return HuhCap;
}
// Convert the list of words in iwords to the same capitalization aWord and
// return them in owords.
NS_IMETHODIMP mozEnglishWordUtils::FromRootForm(const char16_t *aWord, const char16_t **iwords, uint32_t icount, char16_t ***owords, uint32_t *ocount)
{
nsAutoString word(aWord);
nsresult rv = NS_OK;
int32_t length;
char16_t **tmpPtr = (char16_t **)moz_xmalloc(sizeof(char16_t *)*icount);
if (!tmpPtr)
return NS_ERROR_OUT_OF_MEMORY;
mozEnglishWordUtils::myspCapitalization ct = captype(word);
for(uint32_t i = 0; i < icount; ++i) {
length = NS_strlen(iwords[i]);
tmpPtr[i] = (char16_t *) moz_xmalloc(sizeof(char16_t) * (length + 1));
if (MOZ_UNLIKELY(!tmpPtr[i])) {
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, tmpPtr);
return NS_ERROR_OUT_OF_MEMORY;
}
memcpy(tmpPtr[i], iwords[i], (length + 1) * sizeof(char16_t));
nsAutoString capTest(tmpPtr[i]);
mozEnglishWordUtils::myspCapitalization newCt=captype(capTest);
if(newCt == NoCap){
switch(ct)
{
case HuhCap:
case NoCap:
break;
case AllCap:
ToUpperCase(tmpPtr[i],tmpPtr[i],length);
rv = NS_OK;
break;
case InitCap:
ToUpperCase(tmpPtr[i],tmpPtr[i],1);
rv = NS_OK;
break;
default:
rv = NS_ERROR_FAILURE; // should never get here;
break;
}
}
}
if (NS_SUCCEEDED(rv)){
*owords = tmpPtr;
*ocount = icount;
}
return rv;
}

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

@ -21,23 +21,12 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS(mozEnglishWordUtils)
mozEnglishWordUtils();
/* additional members */
enum myspCapitalization
{
NoCap,
InitCap,
AllCap,
HuhCap
};
protected:
virtual ~mozEnglishWordUtils();
mozEnglishWordUtils::myspCapitalization captype(const nsString &word);
bool ucIsAlpha(char16_t aChar);
static bool ucIsAlpha(char16_t aChar);
nsString mLanguage;
nsString mCharset;
nsCOMPtr<mozITXTToHTMLConv> mURLDetector; // used to detect urls so the spell checker can skip them.
};