Backout changeset 9ef862cbcc5e (bug 682564) because of mochitest-oth oranges
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 01 Sep 2011 21:00:05 -0400
changeset 76430 873989b97eefb7b5564be642b55d0450f921f0b4
parent 76429 b6608d4de5f7f225c43cb637e324eb34f190533f
child 76431 dc27139edda025f05db225d9c401b470af85c4f6
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
bugs682564
milestone9.0a1
backs out9ef862cbcc5e8968887f67250dfbd8aa301c9a78
Backout changeset 9ef862cbcc5e (bug 682564) because of mochitest-oth oranges
editor/composer/src/nsEditorSpellCheck.cpp
--- a/editor/composer/src/nsEditorSpellCheck.cpp
+++ b/editor/composer/src/nsEditorSpellCheck.cpp
@@ -724,19 +724,18 @@ nsEditorSpellCheck::UpdateCurrentDiction
   }
 
   // Then, try to use language computed from element
   if (!mPreferredLang.IsEmpty()) {
     dictName.Assign(mPreferredLang);
   }
 
   // otherwise, get language from preferences
-  nsAutoString preferedDict(Preferences::GetLocalizedString("spellchecker.dictionary"));
   if (dictName.IsEmpty()) {
-    dictName.Assign(preferedDict);
+    dictName.Assign(Preferences::GetLocalizedString("spellchecker.dictionary"));
   }
 
   if (dictName.IsEmpty())
   {
     // Prefs didn't give us a dictionary name, so just get the current
     // locale and use that as the default dictionary name!
 
     nsCOMPtr<nsIXULChromeRegistry> packageRegistry =
@@ -751,60 +750,37 @@ nsEditorSpellCheck::UpdateCurrentDiction
   }
 
   SetCurrentDictionary(EmptyString());
 
   if (NS_SUCCEEDED(rv) && !dictName.IsEmpty()) {
     rv = SetCurrentDictionary(dictName);
     if (NS_FAILED(rv)) {
       // required dictionary was not available. Try to get a dictionary
-      // matching at least language part of dictName: 
-
+      // matching at least language part of dictName: If required dictionary is
+      // "aa-bb", we try "aa", then we try any available dictionary aa-XX
       nsAutoString langCode;
       PRInt32 dashIdx = dictName.FindChar('-');
       if (dashIdx != -1) {
         langCode.Assign(Substring(dictName, 0, dashIdx));
+        // try to use langCode
+        rv = SetCurrentDictionary(langCode);
       } else {
         langCode.Assign(dictName);
       }
-
-      nsDefaultStringComparator comparator;
-
-      // try dictionary.spellchecker preference if it starts with langCode (and
-      // if we haven't tried it already)
-      if (!preferedDict.IsEmpty() && !dictName.Equals(preferedDict) && 
-          nsStyleUtil::DashMatchCompare(preferedDict, langCode, comparator)) {
-        rv = SetCurrentDictionary(preferedDict);
-      }
-
-      // Otherwise, try langCode (if we haven't tried it already)
-      if (NS_FAILED(rv)) {
-        if (!dictName.Equals(langCode) && !preferedDict.Equals(langCode)) {
-          rv = SetCurrentDictionary(preferedDict);
-        }
-      }
-
-      // Otherwise, try any available dictionary aa-XX
       if (NS_FAILED(rv)) {
         // loop over avaible dictionaries; if we find one with required
         // language, use it
         nsTArray<nsString> dictList;
         rv = mSpellChecker->GetDictionaryList(&dictList);
         NS_ENSURE_SUCCESS(rv, rv);
+        nsDefaultStringComparator comparator;
         PRInt32 i, count = dictList.Length();
         for (i = 0; i < count; i++) {
           nsAutoString dictStr(dictList.ElementAt(i));
-
-          if (dictStr.Equals(dictName) ||
-              dictStr.Equals(preferedDict) ||
-              dictStr.Equals(langCode)) {
-            // We have already tried it
-            continue;
-          }
-
           if (nsStyleUtil::DashMatchCompare(dictStr, langCode, comparator) &&
               NS_SUCCEEDED(SetCurrentDictionary(dictStr))) {
               break;
           }
         }
       }
     }
   }