firefox/mozilla-1097550-dict-fix.patch

73 lines
3.1 KiB
Diff
Raw Normal View History

2014-12-04 15:48:30 +00:00
diff -up mozilla-release/editor/composer/nsEditorSpellCheck.cpp.1097550-dict-fix mozilla-release/editor/composer/nsEditorSpellCheck.cpp
--- mozilla-release/editor/composer/nsEditorSpellCheck.cpp.1097550-dict-fix 2014-11-26 03:17:14.000000000 +0100
+++ mozilla-release/editor/composer/nsEditorSpellCheck.cpp 2014-12-04 16:45:07.192923283 +0100
@@ -103,6 +103,23 @@ GetLoadContext(nsIEditor* aEditor)
2014-12-03 13:25:01 +00:00
}
/**
+ * Helper function for converting underscore to dash in dictionary name,
+ * ie. en_CA to en-CA. This is required for some Linux distributions which
+ * use underscore as separator in system-wide installed dictionaries.
+ * We use it for nsStyleUtil::DashMatchCompare.
+ */
+static nsString
+GetDictNameWithDash(const nsAString& aDictName)
+{
+ nsString dictNameWithDash(aDictName);
+ int32_t underScore = dictNameWithDash.FindChar('_');
+ if (underScore != -1) {
+ dictNameWithDash.Replace(underScore, 1, '-');
+ }
+ return dictNameWithDash;
+}
+
+/**
* Fetches the dictionary stored in content prefs and maintains state during the
* fetch, which is asynchronous.
*/
2014-12-04 15:48:30 +00:00
@@ -606,8 +623,8 @@ nsEditorSpellCheck::SetCurrentDictionary
2014-12-03 13:25:01 +00:00
} else {
langCode.Assign(aDictionary);
}
-
- if (mPreferredLang.IsEmpty() || !nsStyleUtil::DashMatchCompare(mPreferredLang, langCode, comparator)) {
+ if (mPreferredLang.IsEmpty() ||
+ !nsStyleUtil::DashMatchCompare(GetDictNameWithDash(mPreferredLang), langCode, comparator)) {
// When user sets dictionary manually, we store this value associated
// with editor url.
StoreCurrentDictionary(mEditor, aDictionary);
2014-12-04 15:48:30 +00:00
@@ -763,12 +780,6 @@ nsEditorSpellCheck::DictionaryFetched(Di
2014-12-03 13:25:01 +00:00
// otherwise, get language from preferences
nsAutoString preferedDict(Preferences::GetLocalizedString("spellchecker.dictionary"));
- // Replace '_' with '-' in case the user has an underscore stored in their
- // pref, see bug 992118 for how this could have happened.
- int32_t underScore = preferedDict.FindChar('_');
- if (underScore != -1) {
- preferedDict.Replace(underScore, 1, '-');
- }
if (dictName.IsEmpty()) {
dictName.Assign(preferedDict);
}
2014-12-04 15:48:30 +00:00
@@ -807,8 +818,8 @@ nsEditorSpellCheck::DictionaryFetched(Di
2014-12-03 13:25:01 +00:00
// 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)) {
+ if (!preferedDict.IsEmpty() && !dictName.Equals(preferedDict) &&
+ nsStyleUtil::DashMatchCompare(GetDictNameWithDash(preferedDict), langCode, comparator)) {
rv = SetCurrentDictionary(preferedDict);
}
2014-12-04 15:48:30 +00:00
@@ -836,8 +847,7 @@ nsEditorSpellCheck::DictionaryFetched(Di
2014-12-03 13:25:01 +00:00
// We have already tried it
continue;
}
-
- if (nsStyleUtil::DashMatchCompare(dictStr, langCode, comparator) &&
+ if (nsStyleUtil::DashMatchCompare(GetDictNameWithDash(dictStr), langCode, comparator) &&
NS_SUCCEEDED(SetCurrentDictionary(dictStr))) {
break;
}