Bug 1345957 - Update the use of LocaleService API in gfxPlatformFontList. r=jfkthame

MozReview-Commit-ID: Lj7H2DwlS91

--HG--
extra : rebase_source : 17e8304eb8d2d6640cd44816f1e3e825e26b57d4
This commit is contained in:
Zibi Braniecki 2018-03-06 18:55:22 -08:00
Родитель bb82a08086
Коммит 8264ecd92f
1 изменённых файлов: 19 добавлений и 18 удалений

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

@ -5,6 +5,7 @@
#include "mozilla/Logging.h" #include "mozilla/Logging.h"
#include "mozilla/intl/LocaleService.h" #include "mozilla/intl/LocaleService.h"
#include "mozilla/intl/MozLocale.h"
#include "mozilla/intl/OSPreferences.h" #include "mozilla/intl/OSPreferences.h"
#include "gfxPlatformFontList.h" #include "gfxPlatformFontList.h"
@ -33,6 +34,7 @@
using namespace mozilla; using namespace mozilla;
using mozilla::intl::LocaleService; using mozilla::intl::LocaleService;
using mozilla::intl::Locale;
using mozilla::intl::OSPreferences; using mozilla::intl::OSPreferences;
#define LOG_FONTLIST(args) MOZ_LOG(gfxPlatform::GetLog(eGfxLog_fontlist), \ #define LOG_FONTLIST(args) MOZ_LOG(gfxPlatform::GetLog(eGfxLog_fontlist), \
@ -1243,19 +1245,18 @@ gfxPlatformFontList::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aL
LocaleService::GetInstance()->GetAppLocaleAsLangTag(localeStr); LocaleService::GetInstance()->GetAppLocaleAsLangTag(localeStr);
{ {
const nsACString& lang = Substring(localeStr, 0, 2); Locale locale(localeStr);
if (lang.EqualsLiteral("ja")) { if (locale.GetLanguage().Equals("ja")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese); AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Japanese);
} else if (lang.EqualsLiteral("zh")) { } else if (locale.GetLanguage().Equals("zh")) {
const nsACString& region = Substring(localeStr, 3, 2); if (locale.GetRegion().Equals("CN")) {
if (region.EqualsLiteral("CN")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN); AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseCN);
} else if (region.EqualsLiteral("TW")) { } else if (locale.GetRegion().Equals("TW")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW); AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseTW);
} else if (region.EqualsLiteral("HK")) { } else if (locale.GetRegion().Equals("HK")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK); AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_ChineseHK);
} }
} else if (lang.EqualsLiteral("ko")) { } else if (locale.GetLanguage().Equals("ko")) {
AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean); AppendPrefLang(tempPrefLangs, tempLen, eFontPrefLang_Korean);
} }
} }
@ -1270,28 +1271,28 @@ gfxPlatformFontList::AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t &aL
AutoTArray<nsCString,16> sysLocales; AutoTArray<nsCString,16> sysLocales;
AutoTArray<nsCString,16> negLocales; AutoTArray<nsCString,16> negLocales;
if (OSPreferences::GetInstance()->GetSystemLocales(sysLocales) && if (OSPreferences::GetInstance()->GetSystemLocales(sysLocales)) {
LocaleService::GetInstance()->NegotiateLanguages( LocaleService::GetInstance()->NegotiateLanguages(
sysLocales, prefLocales, NS_LITERAL_CSTRING(""), sysLocales, prefLocales, NS_LITERAL_CSTRING(""),
LocaleService::LangNegStrategy::Filtering, negLocales)) { LocaleService::LangNegStrategy::Filtering, negLocales);
for (const auto& localeStr : negLocales) { for (const auto& localeStr : negLocales) {
const nsACString& lang = Substring(localeStr, 0, 2); Locale locale(localeStr);
if (lang.EqualsLiteral("ja")) {
if (locale.GetLanguage().Equals("ja")) {
AppendPrefLang(tempPrefLangs, tempLen, AppendPrefLang(tempPrefLangs, tempLen,
eFontPrefLang_Japanese); eFontPrefLang_Japanese);
} else if (lang.EqualsLiteral("zh")) { } else if (locale.GetLanguage().Equals("zh")) {
const nsACString& region = Substring(localeStr, 3, 2); if (locale.GetRegion().Equals("CN")) {
if (region.EqualsLiteral("CN")) {
AppendPrefLang(tempPrefLangs, tempLen, AppendPrefLang(tempPrefLangs, tempLen,
eFontPrefLang_ChineseCN); eFontPrefLang_ChineseCN);
} else if (region.EqualsLiteral("TW")) { } else if (locale.GetRegion().Equals("TW")) {
AppendPrefLang(tempPrefLangs, tempLen, AppendPrefLang(tempPrefLangs, tempLen,
eFontPrefLang_ChineseTW); eFontPrefLang_ChineseTW);
} else if (region.EqualsLiteral("HK")) { } else if (locale.GetRegion().Equals("HK")) {
AppendPrefLang(tempPrefLangs, tempLen, AppendPrefLang(tempPrefLangs, tempLen,
eFontPrefLang_ChineseHK); eFontPrefLang_ChineseHK);
} }
} else if (lang.EqualsLiteral("ko")) { } else if (locale.GetLanguage().Equals("ko")) {
AppendPrefLang(tempPrefLangs, tempLen, AppendPrefLang(tempPrefLangs, tempLen,
eFontPrefLang_Korean); eFontPrefLang_Korean);
} }