Bug 1736017 - Replace MozLocale with Locale in gfxPlatformFontList.cpp; r=platform-i18n-reviewers,gregtatum

Differential Revision: https://phabricator.services.mozilla.com/D129208
This commit is contained in:
Dan Minor 2021-11-04 16:36:03 +00:00
Родитель ab5afa4f54
Коммит bbe54a9742
1 изменённых файлов: 33 добавлений и 27 удалений

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

@ -5,8 +5,8 @@
#include "mozilla/Logging.h"
#include "mozilla/gfx/Logging.h"
#include "mozilla/intl/Locale.h"
#include "mozilla/intl/LocaleService.h"
#include "mozilla/intl/MozLocale.h"
#include "mozilla/intl/OSPreferences.h"
#include "gfxPlatformFontList.h"
@ -50,8 +50,9 @@
#include <numeric>
using namespace mozilla;
using mozilla::intl::Locale;
using mozilla::intl::LocaleParser;
using mozilla::intl::LocaleService;
using mozilla::intl::MozLocale;
using mozilla::intl::OSPreferences;
#define LOG_FONTLIST(args) \
@ -2172,21 +2173,24 @@ void gfxPlatformFontList::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[],
LocaleService::GetInstance()->GetAppLocaleAsBCP47(localeStr);
{
MozLocale locale(localeStr);
if (locale.GetLanguage().Equals("ja")) {
Locale locale;
if (LocaleParser::tryParse(localeStr, locale).isOk() &&
locale.canonicalize().isOk()) {
if (locale.language().equalTo("ja")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese);
} else if (locale.GetLanguage().Equals("zh")) {
if (locale.GetRegion().Equals("CN")) {
} else if (locale.language().equalTo("zh")) {
if (locale.region().equalTo("CN")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN);
} else if (locale.GetRegion().Equals("TW")) {
} else if (locale.region().equalTo("TW")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW);
} else if (locale.GetRegion().Equals("HK")) {
} else if (locale.region().equalTo("HK")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK);
}
} else if (locale.GetLanguage().Equals("ko")) {
} else if (locale.language().equalTo("ko")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean);
}
}
}
// Then add the known CJK prefs in order of system preferred locales
AutoTArray<nsCString, 5> prefLocales;
@ -2204,23 +2208,25 @@ void gfxPlatformFontList::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[],
sysLocales, prefLocales, ""_ns,
LocaleService::kLangNegStrategyFiltering, negLocales);
for (const auto& localeStr : negLocales) {
MozLocale locale(localeStr);
if (locale.GetLanguage().Equals("ja")) {
Locale locale;
if (LocaleParser::tryParse(localeStr, locale).isOk() &&
locale.canonicalize().isOk()) {
if (locale.language().equalTo("ja")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese);
} else if (locale.GetLanguage().Equals("zh")) {
if (locale.GetRegion().Equals("CN")) {
} else if (locale.language().equalTo("zh")) {
if (locale.region().equalTo("CN")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN);
} else if (locale.GetRegion().Equals("TW")) {
} else if (locale.region().equalTo("TW")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW);
} else if (locale.GetRegion().Equals("HK")) {
} else if (locale.region().equalTo("HK")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK);
}
} else if (locale.GetLanguage().Equals("ko")) {
} else if (locale.language().equalTo("ko")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean);
}
}
}
}
// Last resort... set up CJK font prefs in the order listed by the user-
// configurable ordering pref.