Closed
Bug 1491394
Opened 3 years ago
Closed 3 years ago
Migrate mozILocaleService to use Array<>
Categories
(Core :: Internationalization, enhancement, P3)
Core
Internationalization
Tracking
()
RESOLVED
FIXED
mozilla64
| Tracking | Status | |
|---|---|---|
| firefox64 | --- | fixed |
People
(Reporter: zbraniecki, Assigned: zbraniecki)
References
(Blocks 1 open bug)
Details
Attachments
(3 files)
mozILocaleService uses the old array XPIDL API. In bug 1474369 Nika added a new one. Let's switch to it.
| Assignee | ||
Updated•3 years ago
|
Assignee: nobody → gandalf
Status: NEW → ASSIGNED
| Assignee | ||
Comment 1•3 years ago
|
||
| Assignee | ||
Comment 2•3 years ago
|
||
This patch removes most of the duplication between C++ and XPIDL targeting methods in LocaleService. I left one - negotiateLanguages - because I need to convert the int to enum for C++. Everywhere else I just moved the non-XPIDL API to XPIDL API and turned return value to NS_IMETHODIMP. I removed several invalid tests because XPIDL will not throw if you try to pass a non-array to the API.
| Assignee | ||
Comment 3•3 years ago
|
||
try run: https://treeherder.mozilla.org/#/jobs?repo=try&revision=34e24a89bc1056afa7bff1110a660855610adfe6
| Assignee | ||
Comment 4•3 years ago
|
||
Jonathan: I updated the patch to include the test for erroring out when not-array is passed. There's one more issue in tests. Before this change, we convert empty array elements to empty strings, so things like this: ``` negotiateLanguages([null], [undefined], ...); ``` pass. With this change, we just pass it and then error in FilterMatches on [0] but only in debug mode. What should I do? Remove the test? Make us throw in optimized mode too? [0] https://searchfox.org/mozilla-central/source/intl/locale/LocaleService.cpp#437
Flags: needinfo?(jfkthame)
Comment 5•3 years ago
|
||
I think I'd favor making it consistently throw an error, like passing a non-array where an array is expected; consider it part of an overall tightening up of the API strictness. There's no good reason we actually need to support such usage, is there?
Flags: needinfo?(jfkthame)
| Assignee | ||
Comment 6•3 years ago
|
||
(In reply to Jonathan Kew (:jfkthame) from comment #5) > I think I'd favor making it consistently throw an error, like passing a > non-array where an array is expected; consider it part of an overall > tightening up of the API strictness. There's no good reason we actually need > to support such usage, is there? The only things that come to mind are malformed `intl.locale.request` strings or malformed `multilingual.txt`. Do you want to cover C++ with this as well? Should we turn `NegotiateLanguages` into a bool that can fail if any of the requested/available is empty?
Flags: needinfo?(jfkthame)
Comment 7•3 years ago
|
||
(In reply to Zibi Braniecki [:gandalf][:zibi] from comment #6) > (In reply to Jonathan Kew (:jfkthame) from comment #5) > > I think I'd favor making it consistently throw an error, like passing a > > non-array where an array is expected; consider it part of an overall > > tightening up of the API strictness. There's no good reason we actually need > > to support such usage, is there? > > The only things that come to mind are malformed `intl.locale.request` > strings or malformed `multilingual.txt`. I think we should fix ReadRequestedLocales() so that it falls back to the default locale if parsing the intl.locale.request string doesn't result in any valid locale codes. (While we're here, change its return type to `void`, as it never returns false anyhow, and nobody checks it.) InitPackagedLocales() already looks like it would handle a malformed multilingual.txt by falling back to the default locale if it ends up with an empty array after parsing the file, so that should be OK. > Do you want to cover C++ with this as well? Should we turn > `NegotiateLanguages` into a bool that can fail if any of the > requested/available is empty? I'm not sure it's worth adding extra checking here. AFAICS there's only one direct C++ caller at the moment, and if it were to pass in empty arrays (and potentially get empty results back), that seems reasonable behavior.
Flags: needinfo?(jfkthame)
| Assignee | ||
Comment 8•3 years ago
|
||
Depends on D5924
| Assignee | ||
Comment 9•3 years ago
|
||
All right! The patch is ready and I updated all callsites I found. Testing on try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=56cadf618fbc2a3b1adf8468eb18ab3b466a3865 This is going to be a bitrotting machine, so lets try to land it soon :)
| Assignee | ||
Comment 10•3 years ago
|
||
Updated try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=05852b96d839cba3e32b7b01748adba462b0f934
| Assignee | ||
Comment 11•3 years ago
|
||
Updated to feedback. Green try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=74fa167e2003675e3a8b97f442689806cb44ae83&selectedJob=200563168
Comment 12•3 years ago
|
||
Comment on attachment 9009308 [details] Bug 1491394 - Migrate mozILocaleService to use Array<> interface. r=jfkthame Jonathan Kew (:jfkthame) has approved the revision.
Attachment #9009308 -
Flags: review+
Comment 13•3 years ago
|
||
Comment on attachment 9010468 [details] Bug 1491394 - Update callsites to use new mozILocaleService API. r=jfkthame Jonathan Kew (:jfkthame) has approved the revision.
Attachment #9010468 -
Flags: review+
Comment 14•3 years ago
|
||
Pushed by zbraniecki@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a33fb1d3cda0 Migrate mozILocaleService to use Array<> interface. r=jfkthame https://hg.mozilla.org/integration/autoland/rev/54dba2807ef8 Update callsites to use new mozILocaleService API. r=jfkthame
Comment 15•3 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/a33fb1d3cda0 https://hg.mozilla.org/mozilla-central/rev/54dba2807ef8
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
status-firefox64:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
Comment 16•3 years ago
|
||
I don't see anyone from Activity Stream in this bug (CCed a couple of folks). Did you get in touch or upstream these patches? m-c is just a dump of external code for AS.
Comment 17•3 years ago
|
||
Comment 18•3 years ago
|
||
Commit pushed to master at https://github.com/mozilla/activity-stream https://github.com/mozilla/activity-stream/commit/96fa15450f8e8efae75420d47c34946614c3fff6 Backport Bug 1491394 - Update callsites to use new mozILocaleService API. r=jfkthame (#4446)
You need to log in
before you can comment on or make changes to this bug.
Description
•