Bug 1193293 - Don't pick a new dictionary which checking. r=roc

This commit is contained in:
Jorg K 2015-09-21 21:51:00 +02:00
Родитель b6b5862949
Коммит 62c77a53c5
3 изменённых файлов: 15 добавлений и 36 удалений

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

@ -639,27 +639,6 @@ NS_IMETHODIMP
nsEditorSpellCheck::CheckCurrentDictionary()
{
mSpellChecker->CheckCurrentDictionary();
// Check if our current dictionary is still available.
nsAutoString currentDictionary;
nsresult rv = GetCurrentDictionary(currentDictionary);
if (NS_SUCCEEDED(rv) && !currentDictionary.IsEmpty()) {
return NS_OK;
}
// If our preferred current dictionary has gone, pick another one.
nsTArray<nsString> dictList;
rv = mSpellChecker->GetDictionaryList(&dictList);
NS_ENSURE_SUCCESS(rv, rv);
if (dictList.Length() > 0) {
// Use RAII object to prevent content preferences being written during
// this call.
UpdateDictionaryHolder holder(this);
rv = SetCurrentDictionary(dictList[0]);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}
@ -764,7 +743,7 @@ nsEditorSpellCheck::TryDictionary(nsAutoString aDictName,
break;
}
if (equals) {
rv = SetCurrentDictionary(dictStr);
rv = mSpellChecker->SetCurrentDictionary(dictStr);
#ifdef DEBUG_DICT
if (NS_SUCCEEDED(rv))
printf("***** Set |%s|.\n", NS_ConvertUTF16toUTF8(dictStr).get());
@ -835,6 +814,14 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher)
#endif
}
// Auxiliary status.
nsresult rv2;
// We obtain a list of available dictionaries.
nsTArray<nsString> dictList;
rv2 = mSpellChecker->GetDictionaryList(&dictList);
NS_ENSURE_SUCCESS(rv2, rv2);
// Priority 1:
// If we successfully fetched a dictionary from content prefs, do not go
// further. Use this exact dictionary.
@ -845,7 +832,7 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher)
if (!(flags & nsIPlaintextEditor::eEditorMailMask)) {
dictName.Assign(aFetcher->mDictionary);
if (!dictName.IsEmpty()) {
if (NS_SUCCEEDED(SetCurrentDictionary(dictName))) {
if (NS_SUCCEEDED(TryDictionary(dictName, dictList, DICT_NORMAL_COMPARE))) {
#ifdef DEBUG_DICT
printf("***** Assigned from content preferences |%s|\n",
NS_ConvertUTF16toUTF8(dictName).get());
@ -871,14 +858,6 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher)
NS_ConvertUTF16toUTF8(dictName).get());
#endif
// Auxiliary status.
nsresult rv2;
// We obtain a list of available dictionaries.
nsTArray<nsString> dictList;
rv2 = mSpellChecker->GetDictionaryList(&dictList);
NS_ENSURE_SUCCESS(rv2, rv2);
// Get the preference value.
nsAutoString preferredDict;
preferredDict = Preferences::GetLocalizedString("spellchecker.dictionary");
@ -1006,7 +985,9 @@ nsEditorSpellCheck::DictionaryFetched(DictionaryFetcher* aFetcher)
// If it does not work, pick the first one.
if (NS_FAILED(rv)) {
if (dictList.Length() > 0) {
rv = SetCurrentDictionary(dictList[0]);
nsAutoString firstInList;
firstInList.Assign(dictList[0]);
rv = TryDictionary(firstInList, dictList, DICT_NORMAL_COMPARE);
#ifdef DEBUG_DICT
printf("***** Trying first of list |%s|\n",
NS_ConvertUTF16toUTF8(dictList[0]).get());

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

@ -1328,12 +1328,11 @@ NS_IMETHODIMP nsEditor::Observe(nsISupports* aSubj, const char *aTopic,
// When nsIEditorSpellCheck::GetCurrentDictionary changes
if (mInlineSpellChecker) {
// if the current dictionary is no longer available, find another one
// Do the right thing in the spellchecker, if the dictionary is no longer
// available. This will not set a new dictionary.
nsCOMPtr<nsIEditorSpellCheck> editorSpellCheck;
mInlineSpellChecker->GetSpellChecker(getter_AddRefs(editorSpellCheck));
if (editorSpellCheck) {
// Note: This might change the current dictionary, which may call
// this observer recursively.
editorSpellCheck->CheckCurrentDictionary();
}

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

@ -16,7 +16,6 @@ interface nsIEditorSpellCheck : nsISupports
/**
* Call this on any change in installed dictionaries to ensure that the spell
* checker is not using a current dictionary which is no longer available.
* If the current dictionary is no longer available, then pick another one.
*/
void checkCurrentDictionary();