Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: www-client/firefox/, www-client/firefox/files/
Date: Wed, 11 Mar 2020 19:21:51
Message-Id: 1583954474.e563ffc9a4e8f47d8dd68cab715db394691a7c44.whissi@gentoo
1 commit: e563ffc9a4e8f47d8dd68cab715db394691a7c44
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Wed Mar 11 19:20:47 2020 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 11 19:21:14 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e563ffc9
7
8 www-client/firefox: fix localization
9
10 Package-Manager: Portage-2.3.93, Repoman-2.3.20
11 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
12
13 ...74.0-bug1607052-font-selection-regression.patch | 281 +++++++++++++++++++++
14 ...{firefox-74.0.ebuild => firefox-74.0-r1.ebuild} | 3 +-
15 2 files changed, 283 insertions(+), 1 deletion(-)
16
17 diff --git a/www-client/firefox/files/firefox-74.0-bug1607052-font-selection-regression.patch b/www-client/firefox/files/firefox-74.0-bug1607052-font-selection-regression.patch
18 new file mode 100644
19 index 00000000000..7c962f8ddc1
20 --- /dev/null
21 +++ b/www-client/firefox/files/firefox-74.0-bug1607052-font-selection-regression.patch
22 @@ -0,0 +1,281 @@
23 +commit 9d26727a4e85
24 +Author: Zibi Braniecki <zbraniecki@×××××××.com>
25 +Date: Fri Feb 21 00:39:18 2020 +0000
26 +
27 + Bug 1607052 - Unify language identifier canonicalization in LocaleService and OSPreferences to use unic_langid, and extend GTK's RegionalPrefs reading to fallback on SystemLocales. r=jfkthame
28 +
29 + Differential Revision: https://phabricator.services.mozilla.com/D63393
30 +
31 + --HG--
32 + extra : moz-landing-system : lando
33 +---
34 + intl/locale/LocaleService.cpp | 53 ++-------------------------
35 + intl/locale/LocaleService.h | 18 +++++++++
36 + intl/locale/OSPreferences.cpp | 18 ++-------
37 + intl/locale/rust/unic-langid-ffi/src/lib.rs | 33 ++++++++++++++---
38 + intl/locale/tests/gtest/TestLocaleService.cpp | 23 ++++++++++++
39 + intl/locale/tests/unit/test_localeService.js | 3 +-
40 + 6 files changed, 77 insertions(+), 71 deletions(-)
41 +
42 +diff --git intl/locale/LocaleService.cpp intl/locale/LocaleService.cpp
43 +index f7e13e36ccbc7..6708c4af4b5c3 100644
44 +--- old/intl/locale/LocaleService.cpp
45 ++++ new/intl/locale/LocaleService.cpp
46 +@@ -39,51 +39,6 @@ NS_IMPL_ISUPPORTS(LocaleService, mozILocaleService, nsIObserver,
47 +
48 + mozilla::StaticRefPtr<LocaleService> LocaleService::sInstance;
49 +
50 +-/**
51 +- * This function transforms a canonical Mozilla Language Tag, into it's
52 +- * BCP47 compilant form.
53 +- *
54 +- * Example: "ja-JP-mac" -> "ja-JP-macos"
55 +- *
56 +- * The BCP47 form should be used for all calls to ICU/Intl APIs.
57 +- * The canonical form is used for all internal operations.
58 +- */
59 +-static bool SanitizeForBCP47(nsACString& aLocale, bool strict) {
60 +- // Currently, the only locale code we use that's not BCP47-conformant is
61 +- // "ja-JP-mac" on OS X, and ICU canonicalizes it into a mouthfull
62 +- // "ja-JP-x-lvariant-mac", so instead we're hardcoding a conversion
63 +- // of it to "ja-JP-macos".
64 +- if (aLocale.LowerCaseEqualsASCII("ja-jp-mac")) {
65 +- aLocale.AssignLiteral("ja-JP-macos");
66 +- return true;
67 +- }
68 +-
69 +- nsAutoCString locale(aLocale);
70 +- locale.Trim(" ");
71 +-
72 +- // POSIX may bring us locales such as "en-US.UTF8", which
73 +- // ICU converts to `en-US-u-va-posix`. Let's cut out
74 +- // the `.UTF8`, since it doesn't matter for us.
75 +- int32_t pos = locale.FindChar('.');
76 +- if (pos != -1) {
77 +- locale.Cut(pos, locale.Length() - pos);
78 +- }
79 +-
80 +- // The rest of this function will use ICU canonicalization for any other
81 +- // tag that may come this way.
82 +- const int32_t LANG_TAG_CAPACITY = 128;
83 +- char langTag[LANG_TAG_CAPACITY];
84 +- UErrorCode err = U_ZERO_ERROR;
85 +- // This is a fail-safe method that will set langTag to "und" if it cannot
86 +- // match any part of the input locale code.
87 +- int32_t len = uloc_toLanguageTag(locale.get(), langTag, LANG_TAG_CAPACITY,
88 +- strict, &err);
89 +- if (U_SUCCESS(err) && len > 0) {
90 +- aLocale.Assign(langTag, len);
91 +- }
92 +- return U_SUCCESS(err);
93 +-}
94 +-
95 + /**
96 + * This function splits an input string by `,` delimiter, sanitizes the result
97 + * language tags and returns them to the caller.
98 +@@ -93,7 +48,7 @@ static void SplitLocaleListStringIntoArray(nsACString& str,
99 + if (str.Length() > 0) {
100 + for (const nsACString& part : str.Split(',')) {
101 + nsAutoCString locale(part);
102 +- if (SanitizeForBCP47(locale, true)) {
103 ++ if (LocaleService::CanonicalizeLanguageId(locale)) {
104 + if (!aRetVal.Contains(locale)) {
105 + aRetVal.AppendElement(locale);
106 + }
107 +@@ -421,7 +376,7 @@ LocaleService::GetDefaultLocale(nsACString& aRetVal) {
108 + locale.Trim(" \t\n\r");
109 + // This should never be empty.
110 + MOZ_ASSERT(!locale.IsEmpty());
111 +- if (SanitizeForBCP47(locale, true)) {
112 ++ if (CanonicalizeLanguageId(locale)) {
113 + mDefaultLocale.Assign(locale);
114 + }
115 +
116 +@@ -617,7 +572,7 @@ LocaleService::SetRequestedLocales(const nsTArray<nsCString>& aRequested) {
117 +
118 + for (auto& req : aRequested) {
119 + nsAutoCString locale(req);
120 +- if (!SanitizeForBCP47(locale, true)) {
121 ++ if (!CanonicalizeLanguageId(locale)) {
122 + NS_ERROR("Invalid language tag provided to SetRequestedLocales!");
123 + return NS_ERROR_INVALID_ARG;
124 + }
125 +@@ -667,7 +622,7 @@ LocaleService::SetAvailableLocales(const nsTArray<nsCString>& aAvailable) {
126 +
127 + for (auto& avail : aAvailable) {
128 + nsAutoCString locale(avail);
129 +- if (!SanitizeForBCP47(locale, true)) {
130 ++ if (!CanonicalizeLanguageId(locale)) {
131 + NS_ERROR("Invalid language tag provided to SetAvailableLocales!");
132 + return NS_ERROR_INVALID_ARG;
133 + }
134 +diff --git intl/locale/LocaleService.h intl/locale/LocaleService.h
135 +index 2ff428da3e3fd..5f5152c1fbb7a 100644
136 +--- old/intl/locale/LocaleService.h
137 ++++ new/intl/locale/LocaleService.h
138 +@@ -10,6 +10,7 @@
139 + #include "nsString.h"
140 + #include "nsTArray.h"
141 + #include "nsWeakReference.h"
142 ++#include "MozLocaleBindings.h"
143 +
144 + #include "mozILocaleService.h"
145 +
146 +@@ -104,6 +105,23 @@ class LocaleService final : public mozILocaleService,
147 + return RefPtr<LocaleService>(GetInstance()).forget();
148 + }
149 +
150 ++ /**
151 ++ * Canonicalize a Unicode Language Identifier string.
152 ++ *
153 ++ * The operation is:
154 ++ * * Normalizing casing (`eN-Us-Windows` -> `en-US-windows`)
155 ++ * * Switching `_` to `-` (`en_US` -> `en-US`)
156 ++ * * Rejecting invalid identifiers (`e21-X` sets aLocale to `und` and
157 ++ * returns false)
158 ++ * * Normalizing Mozilla's `ja-JP-mac` to `ja-JP-macos`
159 ++ * * Cutting off POSIX dot postfix (`en-US.utf8` -> `en-US`)
160 ++ *
161 ++ * This operation should be used on any external input before
162 ++ * it gets used in internal operations.
163 ++ */
164 ++ static bool CanonicalizeLanguageId(nsACString& aLocale) {
165 ++ return ffi::unic_langid_canonicalize(&aLocale);
166 ++ }
167 + /**
168 + * This method should only be called in the client mode.
169 + *
170 +diff --git intl/locale/OSPreferences.cpp intl/locale/OSPreferences.cpp
171 +index 283db96e0d718..f816ca57abfea 100644
172 +--- old/intl/locale/OSPreferences.cpp
173 ++++ new/intl/locale/OSPreferences.cpp
174 +@@ -54,19 +54,7 @@ void OSPreferences::Refresh() {
175 + * It returns true if the canonicalization was successful.
176 + */
177 + bool OSPreferences::CanonicalizeLanguageTag(nsCString& aLoc) {
178 +- char langTag[512];
179 +-
180 +- UErrorCode status = U_ZERO_ERROR;
181 +-
182 +- int32_t langTagLen = uloc_toLanguageTag(aLoc.get(), langTag,
183 +- sizeof(langTag) - 1, false, &status);
184 +-
185 +- if (U_FAILURE(status)) {
186 +- return false;
187 +- }
188 +-
189 +- aLoc.Assign(langTag, langTagLen);
190 +- return true;
191 ++ return LocaleService::CanonicalizeLanguageId(aLoc);
192 + }
193 +
194 + /**
195 +@@ -291,7 +279,9 @@ OSPreferences::GetRegionalPrefsLocales(nsTArray<nsCString>& aRetVal) {
196 + return NS_OK;
197 + }
198 +
199 +- return NS_ERROR_FAILURE;
200 ++ // If we failed to read regional prefs locales,
201 ++ // use system locales as last fallback.
202 ++ return GetSystemLocales(aRetVal);
203 + }
204 +
205 + static OSPreferences::DateTimeFormatStyle ToDateTimeFormatStyle(
206 +diff --git intl/locale/rust/unic-langid-ffi/src/lib.rs intl/locale/rust/unic-langid-ffi/src/lib.rs
207 +index 701d3679c4cec..517e08c1a64c1 100644
208 +--- old/intl/locale/rust/unic-langid-ffi/src/lib.rs
209 ++++ new/intl/locale/rust/unic-langid-ffi/src/lib.rs
210 +@@ -5,18 +5,39 @@
211 + use nsstring::nsACString;
212 + use nsstring::nsCString;
213 + use thin_vec::ThinVec;
214 +-pub use unic_langid::LanguageIdentifier;
215 ++pub use unic_langid::{LanguageIdentifier, LanguageIdentifierError};
216 ++
217 ++fn new_langid_for_mozilla(name: &nsACString) -> Result<LanguageIdentifier, LanguageIdentifierError> {
218 ++ if name.eq_ignore_ascii_case(b"ja-jp-mac") {
219 ++ "ja-JP-macos".parse()
220 ++ } else {
221 ++ // Cut out any `.FOO` like `en-US.POSIX`.
222 ++ let mut name: &[u8] = name.as_ref();
223 ++ if let Some(ptr) = name.iter().position(|b| b == &b'.') {
224 ++ name = &name[..ptr];
225 ++ }
226 ++ LanguageIdentifier::from_bytes(name)
227 ++ }
228 ++}
229 ++
230 ++#[no_mangle]
231 ++pub unsafe extern "C" fn unic_langid_canonicalize(name: &mut nsACString) -> bool {
232 ++ let langid = new_langid_for_mozilla(name);
233 ++
234 ++ let result = langid.is_ok();
235 ++
236 ++ name.assign(&langid.unwrap_or_default().to_string());
237 ++
238 ++ result
239 ++}
240 ++
241 +
242 + #[no_mangle]
243 + pub unsafe extern "C" fn unic_langid_new(
244 + name: &nsACString,
245 + ret_val: &mut bool,
246 + ) -> *mut LanguageIdentifier {
247 +- let langid = if name.eq_ignore_ascii_case(b"ja-jp-mac") {
248 +- "ja-JP-macos".parse()
249 +- } else {
250 +- LanguageIdentifier::from_bytes(name)
251 +- };
252 ++ let langid = new_langid_for_mozilla(name);
253 +
254 + *ret_val = langid.is_ok();
255 + Box::into_raw(Box::new(langid.unwrap_or_default()))
256 +diff --git intl/locale/tests/gtest/TestLocaleService.cpp intl/locale/tests/gtest/TestLocaleService.cpp
257 +index b13ecfd237dfa..aaac8615b09fd 100644
258 +--- old/intl/locale/tests/gtest/TestLocaleService.cpp
259 ++++ new/intl/locale/tests/gtest/TestLocaleService.cpp
260 +@@ -10,6 +10,29 @@
261 +
262 + using namespace mozilla::intl;
263 +
264 ++TEST(Intl_Locale_LocaleService, CanonicalizeLanguageId)
265 ++{
266 ++ nsCString locale("en-US.POSIX");
267 ++ ASSERT_TRUE(LocaleService::CanonicalizeLanguageId(locale));
268 ++ ASSERT_TRUE(locale.EqualsLiteral("en-US"));
269 ++
270 ++ locale.AssignLiteral("en-US_POSIX");
271 ++ ASSERT_TRUE(LocaleService::CanonicalizeLanguageId(locale));
272 ++ ASSERT_TRUE(locale.EqualsLiteral("en-US-posix"));
273 ++
274 ++ locale.AssignLiteral("en-US-POSIX");
275 ++ ASSERT_TRUE(LocaleService::CanonicalizeLanguageId(locale));
276 ++ ASSERT_TRUE(locale.EqualsLiteral("en-US-posix"));
277 ++
278 ++ locale.AssignLiteral("C");
279 ++ ASSERT_FALSE(LocaleService::CanonicalizeLanguageId(locale));
280 ++ ASSERT_TRUE(locale.EqualsLiteral("und"));
281 ++
282 ++ locale.AssignLiteral("");
283 ++ ASSERT_FALSE(LocaleService::CanonicalizeLanguageId(locale));
284 ++ ASSERT_TRUE(locale.EqualsLiteral("und"));
285 ++}
286 ++
287 + TEST(Intl_Locale_LocaleService, GetAppLocalesAsBCP47)
288 + {
289 + nsTArray<nsCString> appLocales;
290 +diff --git intl/locale/tests/unit/test_localeService.js intl/locale/tests/unit/test_localeService.js
291 +index 1970ae94b2607..202c2674972a8 100644
292 +--- old/intl/locale/tests/unit/test_localeService.js
293 ++++ new/intl/locale/tests/unit/test_localeService.js
294 +@@ -204,8 +204,7 @@ add_test(function test_requestedLocales_sanitize() {
295 + Assert.equal(locales[0], "de");
296 + Assert.equal(locales[1], "pl");
297 + Assert.equal(locales[2], "de-AT");
298 +- Assert.equal(locales[3], "und");
299 +- Assert.equal(locales.length, 4);
300 ++ Assert.equal(locales.length, 3);
301 +
302 + Services.prefs.clearUserPref(PREF_REQUESTED_LOCALES);
303 +
304
305 diff --git a/www-client/firefox/firefox-74.0.ebuild b/www-client/firefox/firefox-74.0-r1.ebuild
306 similarity index 99%
307 rename from www-client/firefox/firefox-74.0.ebuild
308 rename to www-client/firefox/firefox-74.0-r1.ebuild
309 index 30bb87c2dd0..0e6d6565e55 100644
310 --- a/www-client/firefox/firefox-74.0.ebuild
311 +++ b/www-client/firefox/firefox-74.0-r1.ebuild
312 @@ -286,6 +286,7 @@ src_prepare() {
313
314 eapply "${FILESDIR}/${PN}-73.0_fix_lto_pgo_builds.patch"
315 eapply "${FILESDIR}/${PN}-73.0_fix_llvm9.patch"
316 + eapply "${FILESDIR}/${PN}-74.0-bug1607052-font-selection-regression.patch"
317
318 # Allow user to apply any additional patches without modifing ebuild
319 eapply_user
320 @@ -684,7 +685,7 @@ src_install() {
321 fi
322
323 # Install language packs
324 - MOZ_INSTALL_L10N_XPIFILE="1" mozlinguas_src_install
325 + MOZEXTENSION_TARGET="distribution/extensions" MOZ_INSTALL_L10N_XPIFILE="1" mozlinguas_src_install
326
327 local size sizes icon_path icon name
328 if use bindist ; then