Граф коммитов

156 Коммитов

Автор SHA1 Сообщение Дата
André Bargull b6b8f02a94 Bug 1719748 - Part 8: Add mozilla::intl::Locale::GetDefaultLocale(). r=platform-i18n-reviewers,gregtatum
Add `GetDefaultLocale()` to replace the two calls to `uloc_getDefault()`.

Differential Revision: https://phabricator.services.mozilla.com/D126494
2021-09-24 10:22:47 +00:00
André Bargull 1994abfe54 Bug 1719748 - Part 6: Add an enumeration over the list of available locales. r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D126492
2021-09-24 10:22:46 +00:00
André Bargull 032bae8d79 Bug 1719748 - Part 4: Add TimeZone::GetAvailableTimeZones(). r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D126490
2021-09-24 10:22:45 +00:00
André Bargull 362e7b8fd6 Bug 1719748 - Part 2: Add Collator::GetFirstCase(). r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D126488
2021-09-24 10:22:44 +00:00
André Bargull db871aaa56 Bug 1719748 - Part 1: Add an enumeration over the list of available locales. r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D126487
2021-09-24 10:22:44 +00:00
André Bargull 975b298483 Bug 1731620 - Part 8: Add TimeZone::GetHostTimeZone(). r=platform-i18n-reviewers,gregtatum
Add a wrapper for `ucal_getHostTimeZone` to `mozilla::intl::TimeZone`. This
function is only used for the "testing" function framework.

Differential Revision: https://phabricator.services.mozilla.com/D126198
2021-09-23 10:51:59 +00:00
André Bargull f0ef6836c5 Bug 1731620 - Part 6: Add default time zone setters to mozila::intl::TimeZone. r=platform-i18n-reviewers,gregtatum
Add setters to change ICU's default time zone.
1. `SetDefaultTimeZone()` sets the default time zone from a time zone identifier.
2. `SetDefaultTimeZoneFromHostTimeZone()` synchronizes the default time zone with
   the host system's time zone.

The two new methods will be used in the next part to replace ICU calls in
`js::DateTimeInfo::internalResyncICUDefaultTimeZone()`.

Differential Revision: https://phabricator.services.mozilla.com/D126196
2021-09-23 10:51:58 +00:00
André Bargull 7c924a2057 Bug 1731620 - Part 2: Use ICU C++ TimeZone API if available. r=platform-i18n-reviewers,gregtatum
ICU doesn't provide a C-API for time zone functions, but instead requires to
use `UCalendar`. This adds a noticeable overhead, because whenever time zone
offsets are computed, it's first necessary to set the time on a `UCalendar`,
which triggers a recomputation of all calendar fields. And because time zone
offset computation is used for JavaScript's `Date`, which is widely used, we
should avoid performance regressions compared to the current code which is
using the ICU C++ API.

We can only safely use the ICU C++ API when we don't use the system ICU,
because C++ doesn't have a stable ABI, so the ICU C++ API code paths are only
taken when `MOZ_SYSTEM_ICU` is `false`.

Differential Revision: https://phabricator.services.mozilla.com/D126192
2021-09-23 10:51:56 +00:00
André Bargull 216714975c Bug 1731620 - Part 1: Add more time zone functions to mozilla::intl::TimeZone. r=platform-i18n-reviewers,gregtatum
Add four additional methods to `mozilla::intl::TimeZone`:

1. `GetDSTOffsetMs()` to return the daylight saving offset at a specific UTC time.
2. `GetOffsetMs()` to return the time zone offset at a specific UTC time.
3. `GetUTCOffsetMs()` to return the UTC offset at a specific local time.
4. `GetDisplayName()` to return the display name of a time zone.

All four methods will be used to replace ICU calls in "js/src/vm/DateTime.cpp".

Differential Revision: https://phabricator.services.mozilla.com/D126191
2021-09-23 10:51:56 +00:00
Jonathan Kew 08373ecf28 Bug 1719544 - part 1 - Add low-level normalization-data accessors ComposePairNFC and DecomposeRawNFD to mozilla::intl::String. r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D126259
2021-09-22 21:27:53 +00:00
criss 6685fa570d Backed out 2 changesets (bug 1719544) for causing bustages on gtest.h:1445:11. CLOSED TREE
Backed out changeset 4ab330369412 (bug 1719544)
Backed out changeset b5d8d32d8326 (bug 1719544)
2021-09-22 23:33:48 +03:00
Jonathan Kew 2cfc8b9513 Bug 1719544 - part 1 - Add low-level normalization-data accessors ComposePairNFC and DecomposeRawNFD to mozilla::intl::String. r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D126259
2021-09-22 18:48:53 +00:00
André Bargull c495c4e12f Bug 1731080 - Part 5: Add string normalization methods to intl::String. r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D125842
2021-09-21 15:42:18 +00:00
André Bargull b0ea03793a Bug 1731080 - Part 3: Add methods to test if a code point has the properties "Cased" or "Case_Ignorable". r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D125840
2021-09-21 15:42:17 +00:00
André Bargull c6c4656477 Bug 1731080 - Part 1: Add a String class to the unified Intl API. r=platform-i18n-reviewers,gregtatum
The default constructor was deleted because all methods are static.

Differential Revision: https://phabricator.services.mozilla.com/D125838
2021-09-21 15:42:16 +00:00
André Bargull 27cd54a779 Bug 1693576 - Part 8: Add a method to retrieve week day information to Calendar. r=platform-i18n-reviewers,gregtatum
The last addition for the "Intl Locale Info API" proposal.

Differential Revision: https://phabricator.services.mozilla.com/D125578
2021-09-21 08:51:22 +00:00
André Bargull ea30633946 Bug 1693576 - Part 7: Add method to enumerate over all time zones used in a region. r=platform-i18n-reviewers,gregtatum
The filter type is `UCAL_ZONE_TYPE_ANY` to ensure all possible time zones are
returned, and not just CLDR canonical time zones. (CLDR canonical time zones
are different from IANA canonical time zones.)

Differential Revision: https://phabricator.services.mozilla.com/D125576
2021-09-21 08:51:22 +00:00
André Bargull 17e8b2c855 Bug 1693576 - Part 6: Rename GetDefaultTimeZoneOffsetMs() to GetRawOffsetMs(). r=platform-i18n-reviewers,gregtatum
- `TimeZone` objects can be created with any time zone identifier, so the "Default"
  part in the name isn't correct.
- The "TimeZone" part is no longer needed, now that there's a distinct class for
  `TimeZone` objects.

Therefore let's rename `GetDefaultTimeZoneOffsetMs()` to `GetRawOffsetMs()`.

Differential Revision: https://phabricator.services.mozilla.com/D125575
2021-09-21 08:51:21 +00:00
André Bargull 5638c044f2 Bug 1693576 - Part 5: Move time zone functions from mozilla::Calendar into mozilla::TimeZone. r=platform-i18n-reviewers,gregtatum
Time zone functions being part of `UCalendar` is an internal implementation
detail of ICU4C. For the public unified Intl API we should rather follow
Temporal (or ICU4C's C++ API) and have a separate `TimeZone` class.

The files were moved using `hg cp` to preserve the file history.

Differential Revision: https://phabricator.services.mozilla.com/D125574
2021-09-21 08:51:21 +00:00
André Bargull 67b7d804e6 Bug 1693576 - Part 3: Add NumberingSystem class to the unified Intl API component. r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D125572
2021-09-21 08:51:20 +00:00
André Bargull 1919267c6d Bug 1693576 - Part 2: Add DateTimeFormat::GetAllowedHourCycles(). r=platform-i18n-reviewers,gregtatum
ICU's public API only provides a function to return the preferred hour cycle
(`udatpg_getDefaultHourCycle()`), whereas for `Intl.Locale` we want to be able
to determine all allowed hour cycles. So we have to do it the hard way and
directly read ICU resource bundles to get the data we need for this feature.

Differential Revision: https://phabricator.services.mozilla.com/D125571
2021-09-21 08:51:20 +00:00
André Bargull ed57b49cb4 Bug 1693576 - Part 1: Add "commonlyUsed" to Calendar and Collator. r=platform-i18n-reviewers,gregtatum
Pass through the "commonlyUsed" parameter to ICU to be able to filter any
uncommon keyword values.

Differential Revision: https://phabricator.services.mozilla.com/D125570
2021-09-21 08:51:19 +00:00
André Bargull ee78515033 Bug 1719733 - Part 1: Add a MeasureUnit class to the unified Intl API. r=platform-i18n-reviewers,dminor
Currently only provides a single method to retrieve all available measurement units.

`MeasureUnit::GetAvailable()` returns an enumeration similar to the other Intl
classes which use `intl::Enumeration`. This approach gives us a more consistent
API, because it abstracts away the internal ICU implementation, which looks up
the measurement units through `UResourceBundle`. But it also means the
implementation is slightly more complicated due to this additional abstraction.

The default constructor was deleted because all methods are static.

Differential Revision: https://phabricator.services.mozilla.com/D125966
2021-09-20 20:04:17 +00:00
André Bargull a5116d4ff5 Bug 1728184 - Part 1: Add a Currency class to the unified Intl API. r=platform-i18n-reviewers,dminor
Currently only provides a single method to retrieve all ISO currency codes.

The default constructor was deleted because all methods are static.

Depends on D125674

Differential Revision: https://phabricator.services.mozilla.com/D125675
2021-09-17 10:15:36 +00:00
André Bargull e50c440591 Bug 1728183 - Part 2: Add Collator::GetBcp47KeywordValues() method to retrieve all possible collations. r=platform-i18n-reviewers,dminor
In contrast to the existing `GetBcp47KeywordValuesForLocale()` method, this
method returns all possible collation types, even the ones which aren't supported
by a specific locale.

Depends on D125672

Differential Revision: https://phabricator.services.mozilla.com/D125673
2021-09-17 10:15:35 +00:00
Yoshi Cheng-Hao Huang 7ded87e9a4 Bug 1728104 - Part 4: Merge NumberFormatFieldsUtil.[cpp|h] into NumberFormatFields.[cpp|h]. r=platform-i18n-reviewers,anba,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125758
2021-09-16 14:47:03 +00:00
Yoshi Cheng-Hao Huang 70b53c7640 Bug 1728104 - Part 3: Remove NumberFormatFields.h from exported headers. r=platform-i18n-reviewers,anba,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125757
2021-09-16 14:47:03 +00:00
Yoshi Cheng-Hao Huang 0b48e561d6 Bug 1728104 - Part 2: Add NumberPart.h. r=platform-i18n-reviewers,anba,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125684
2021-09-16 14:47:02 +00:00
Yoshi Cheng-Hao Huang 234cb720ff Bug 1728104 - Part 1: Fix non-unified build error on ListFormat.cpp. r=tcampbell
Differential Revision: https://phabricator.services.mozilla.com/D125683
2021-09-16 14:47:02 +00:00
André Bargull b8019db021 Bug 1730508 - Part 3: Enable UnusedZero and HasFreeLSB Result optimisations. r=platform-i18n-reviewers,gregtatum,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125410
2021-09-14 16:10:10 +00:00
André Bargull 2ffa3169a5 Bug 1730508 - Part 2: Remove unused function NullTerminatedMapper. r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D125409
2021-09-14 16:10:09 +00:00
André Bargull b1647a4555 Bug 1730508 - Part 1: Propagate ICUError where possible. r=platform-i18n-reviewers,gregtatum
Fully propagate `ICUError` instead of using `InternalError`.

Differential Revision: https://phabricator.services.mozilla.com/D125408
2021-09-14 16:10:09 +00:00
Greg Tatum b0d6525aca Bug 1719696 - Cache the original skeleton, and use it in DateIntervalFormat; r=anba,platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125254
2021-09-13 20:53:01 +00:00
Greg Tatum 21e515adad Bug 1719696 - Rework FillUTF8Buffer to FillBuffer; r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D125252
2021-09-13 20:53:00 +00:00
Greg Tatum 8c790b7cb7 Bug 1719696 - Add ICUPointer to DateTimePatternGenerator; r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D124498
2021-09-13 20:53:00 +00:00
Greg Tatum 129339b6b8 Bug 1719696 - Create a components bag abstraction for mozilla::intl::DateTimeFormat; r=anba,platform-i18n-reviewers,dminor
This patch will probably not compile on its own, but requires the SpiderMonkey
side as well. It aims at building a components bag interface that can be
then used in SpiderMonkey to back the ECMA 402 API.

Differential Revision: https://phabricator.services.mozilla.com/D123822
2021-09-13 20:52:59 +00:00
Greg Tatum b2eb7b49ba Bug 1719696 - Naively move the hour cycle computations; r=anba,platform-i18n-reviewers,dminor
This patch will not compile. It naively copies over the hour cycle code
from SpiderMonkey into the unified components. In a following patch,
these will be modified to use only the unified types.

Differential Revision: https://phabricator.services.mozilla.com/D123821
2021-09-13 20:52:59 +00:00
Greg Tatum 3971654d9f Bug 1719696 - Add a nicer assertion for checking the buffer contents; r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D123820
2021-09-13 20:52:58 +00:00
Greg Tatum 7eeb5c0b59 Bug 1719696 - Use ICUError in mozilla::intl::DateTimeFormat; r=platform-i18n-reviewers,dminor
This is part of the work for Bug 1713206

Differential Revision: https://phabricator.services.mozilla.com/D123819
2021-09-13 20:52:58 +00:00
Greg Tatum 238d8b17c7 Bug 1715980 - Fix the calendar keyword in Calendar::GetBcp47Type docs; r=platform-i18n-reviewers,dminor DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D124982
2021-09-09 14:57:37 +00:00
Yoshi Cheng-Hao Huang d92ecbcd8b Bug 1719747 - Part 3: ListFormat::FormatToParts takes a callback. r=gregtatum,tcampbell
As discussed in https://bugzilla.mozilla.org/show_bug.cgi?id=1719747#c6,
In Part 1, the ownership of the Span in PartsVector is maintained by
ICU. This method adds a callback so js::intl::ListFormat could copy the
content of the Span to Spidermonkey, and mozilla::intl::ListFormat could
use ScopedICUObject to release the string owned by ICU earlier.

Differential Revision: https://phabricator.services.mozilla.com/D123166
2021-09-09 12:02:22 +00:00
Yoshi Cheng-Hao Huang 39cadacc67 Bug 1719747 - Part 1: Unify ListFormat in SM. r=gregtatum,anba,platform-i18n-reviewers,tcampbell
Move implementations to mozilla::intl::ListFormat

Differential Revision: https://phabricator.services.mozilla.com/D122334
2021-09-09 12:02:21 +00:00
Greg Tatum 12c9670cc5 Bug 1713206 - Propagate ICU statuses to ICUErrors; r=platform-i18n-reviewers,dminor
Depends on D124963

Differential Revision: https://phabricator.services.mozilla.com/D124964
2021-09-08 21:36:29 +00:00
Greg Tatum 46c00b33ef Bug 1713206 - Flatten nested namespaces in mozilla::intl components; r=platform-i18n-reviewers,dminor
This is a drive-by clean-up while I'm working on errors.

Depends on D124962

Differential Revision: https://phabricator.services.mozilla.com/D124963
2021-09-08 21:36:29 +00:00
Greg Tatum e5f56207b3 Bug 1713206 - Add missing ICUError.h headers; r=platform-i18n-reviewers,dminor
Depends on D124961

Differential Revision: https://phabricator.services.mozilla.com/D124962
2021-09-08 21:36:29 +00:00
Greg Tatum 65a2bb16fc Bug 1713206 - Use ICUError in mozilla::intl::PluralRules; r=platform-i18n-reviewers,dminor
Depends on D124960

Differential Revision: https://phabricator.services.mozilla.com/D124961
2021-09-08 21:36:28 +00:00
Greg Tatum b917c44dd2 Bug 1713206 - Use ICUError in mozilla::intl::DateTimePatternGenerator; r=platform-i18n-reviewers,dminor
Depends on D124959

Differential Revision: https://phabricator.services.mozilla.com/D124960
2021-09-08 21:36:28 +00:00
Greg Tatum c5836fc86a Bug 1713206 - Use ICUError in mozilla::intl::Calendar; r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D124959
2021-09-08 21:36:27 +00:00
Greg Tatum 7666a8132a Bug 1719540 - Fix unified build imports bustages for mozilla::intl; r=dminor
Depends on D120249

Differential Revision: https://phabricator.services.mozilla.com/D124116
2021-09-01 00:02:31 +00:00
Greg Tatum 443160a426 Bug 1719540 - Implement a unified Locale canonicalizer; r=platform-i18n-reviewers,dminor
I used the C api here, but verified that the behavior was the same
as using the C++ getBaseName API.

927fee5656/src/features/icu.cpp (L249-L268)

I tried to keep the implementation naming at least similar to the
work in: https://phabricator.services.mozilla.com/D118070

However, the implementation do diverge. I figure in the future, the
APIs can be made similar, but at least the gtests will ensure the
behavior remains the same.

Differential Revision: https://phabricator.services.mozilla.com/D120248
2021-09-01 00:02:30 +00:00
Alexandru Michis 7be95b70ef Backed out 2 changesets (bug 1719540) for causing bustages in RelativeTimeFormat.cpp
CLOSED TREE

Backed out changeset a6ab150a89f2 (bug 1719540)
Backed out changeset e8b05f56aa75 (bug 1719540)
2021-08-31 21:14:11 +03:00
Greg Tatum 1909173425 Bug 1719540 - Implement a unified Locale canonicalizer; r=platform-i18n-reviewers,dminor
I used the C api here, but verified that the behavior was the same
as using the C++ getBaseName API.

927fee5656/src/features/icu.cpp (L249-L268)

I tried to keep the implementation naming at least similar to the
work in: https://phabricator.services.mozilla.com/D118070

However, the implementation do diverge. I figure in the future, the
APIs can be made similar, but at least the gtests will ensure the
behavior remains the same.

Differential Revision: https://phabricator.services.mozilla.com/D120248
2021-08-31 15:39:39 +00:00
Dan Minor a7c1a01337 Bug 1719462 - Add intl::RelativeTimeFormat; r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D121413
2021-08-30 19:50:20 +00:00
Dan Minor 76fa3fdc8c Bug 1719462 - Improve comments for NumberFormat::formatToParts; r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D121412
2021-08-30 19:50:20 +00:00
Dan Minor 9ea8b755f2 Bug 1719462 - Move FormatResultToParts to NumberFormatFields; r=platform-i18n-reviewers,gregtatum
This code will be used by RelativeTimeFormat, so we need to move it to a place
where it will be accessible to both NumberFormat and RelativeTimeFormat.

Differential Revision: https://phabricator.services.mozilla.com/D121411
2021-08-30 19:50:20 +00:00
Dan Minor d8d32990af Bug 1719462 - Use ICUError in NumberFormat; r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D121410
2021-08-30 19:50:19 +00:00
Dan Minor 962b25b43e Bug 1719462 - Add TestBuffer::clear(); r=platform-i18n-reviewers,gregtatum
This allows reusing the same buffer multiple times in a test, which
keeps test code simpler.

Differential Revision: https://phabricator.services.mozilla.com/D121409
2021-08-30 19:50:19 +00:00
Andi-Bogdan Postelnicu 2fc4f70e9b Bug 1725145 - Preparation for the hybrid build env. r=necko-reviewers,firefox-build-system-reviewers,valentin,glandium
Automatically generated path that adds flag `REQUIRES_UNIFIED_BUILD = True` to `moz.build`
when the module governed by the build config file is not buildable outside on the unified environment.

This needs to be done in order to have a hybrid build system that adds the possibility of combing
unified build components with ones that are built outside of the unified eco system.

Differential Revision: https://phabricator.services.mozilla.com/D122345
2021-08-25 10:46:17 +00:00
André Bargull 4741c41fed Bug 1648137 - Part 18: Add decimal number and formatToParts support to NumberRangeFormat. r=platform-i18n-reviewers,nordzilla
These new functions match the similarily named functions on `intl::NumberFormat`.

Also add some assertions to `NumberFormat::formatToParts()` when called with
decimal number strings to ensure non-finite number strings aren't used here,
because we always pass `Nothing()` for the number in this method.

Differential Revision: https://phabricator.services.mozilla.com/D119758
2021-08-24 09:34:52 +00:00
André Bargull 777449a2c5 Bug 1648137 - Part 17: Add separate number range options struct. r=platform-i18n-reviewers,nordzilla
`NumberFormatterSkeleton::toRangeFormatter()` receives the two additional options
as extra parameters, because that's simpler to implement compared to storing the
`NumberRangeFormatOptions` struct in `NumberFormatterSkeleton`. We can revisit
this approach should `NumberRangeFormatOptions` ever get more additional options.

Differential Revision: https://phabricator.services.mozilla.com/D119757
2021-08-24 09:34:52 +00:00
André Bargull 982d8dbbbf Bug 1648137 - Part 15: Record the source of a number part. r=platform-i18n-reviewers,nordzilla
Add `NumberPartSource` to `NumberPart` in preparation for part 18.

Also changes the underlying type of `NumberPartType` to `int16_t` to ensure the
size of `NumberPart` doesn't change on 32-bit platforms when adding
`NumberPartSource`. (Note: `sizeof(NumberPart)` is 16 on 64-platforms with or
without this change.)

Differential Revision: https://phabricator.services.mozilla.com/D119755
2021-08-24 09:34:51 +00:00
André Bargull 52d6dde648 Bug 1648137 - Part 14: Make NumberPart a proper struct. r=platform-i18n-reviewers,dminor
In the next part of this patch stack, we want to record the "source" of a
number part. The source is used when formatting number ranges to record if the
formatted number part belongs to the start resp. end of the number range.

Differential Revision: https://phabricator.services.mozilla.com/D119754
2021-08-24 09:34:50 +00:00
André Bargull 59f5314db5 Bug 1648137 - Part 13: Move GetPartTypeForNumberField into NumberFormatFields.h. r=platform-i18n-reviewers,dminor
Change `GetPartTypeForNumberField` to a free function so a later part in this
patch stack can call it when processing number ranges.

Differential Revision: https://phabricator.services.mozilla.com/D119753
2021-08-24 09:34:50 +00:00
André Bargull e6e2c90a1e Bug 1648137 - Part 12: Add support for formatting number strings. r=tcampbell
The "Intl.NumberFormat v3 API" proposal adds support to format arbitrarily large
decimal numbers. For example it's now possible to format the decimal number
1e1000 by passing the string `"1e1000"` to the `format` function.

`ToIntlMathematicalValue()` preprocesses the number as follows:
- Non-finite values (NaN and infinities) are always stored as `double` values.
- Positive and negative zero are also stored as `double` values.
- Non-decimal strings like `"0x10"` are stored as BigInts, because ICU only
  supports decimal number strings.
- An error is thrown if the exponent is too large to workaround ICU limitations.

Normalising non-finite values and ±0 is done in preparation for part 17.

Differential Revision: https://phabricator.services.mozilla.com/D119752
2021-08-24 09:34:50 +00:00
André Bargull 93782a6021 Bug 1648137 - Part 9: Add support for roundingPriority option to intl::NumberFormat. r=platform-i18n-reviewers,dminor
The rounding priority names match the names in the Intl proposal.

Differential Revision: https://phabricator.services.mozilla.com/D119749
2021-08-24 09:34:49 +00:00
André Bargull e1b120bd3d Bug 1648137 - Part 7: Add support for new useGrouping value options to intl::NumberFormat. r=platform-i18n-reviewers,dminor
Change `mUseGrouping` to `mGrouping` and use an `enum` to represent the two
new additional modes "Always" and "Min2".

Differential Revision: https://phabricator.services.mozilla.com/D119747
2021-08-24 09:34:48 +00:00
André Bargull 83a11eb7f8 Bug 1648137 - Part 5: Add support for roundingIncrement, roundingMode, and trailingZeroDisplay options to intl::NumberFormat. r=platform-i18n-reviewers,dminor
First set of new options added in the "Intl.NumberFormat v3 API" proposal.

- All ICU rounding modes are added. (The Intl proposal doesn't support "HalfOdd".)
- The rounding mode names match the names in the Intl proposal, which are
  different compared to the ICU names.
- Significant digits options are ignored when rounding increment is used. This is
  an ICU limitation. The Intl proposal will throw an error if both options are
  used at the same time.

Differential Revision: https://phabricator.services.mozilla.com/D119745
2021-08-24 09:34:47 +00:00
André Bargull b921491f4b Bug 1648137 - Part 2: Add PluralRules::SelectRange(). r=dminor,platform-i18n-reviewers,nordzilla
Add `intl::NumberRangeFormat` based on the existing `intl::NumberFormat` class
and use it to implement `intl::PluralRules::SelectRange()`.

Most ICU number range formatting functions are still draft APIs and therefore
are guarded by `#ifndef U_HIDE_DRAFT_API`. Instead of requiring `mozilla::intl`
users to also use `U_HIDE_DRAFT_API`, add two additional preprocessor definitions
(`MOZ_INTL_PLURAL_RULES_HAS_SELECT_RANGE` and `MOZ_INTL_HAS_NUMBER_RANGE_FORMAT`).

When `MOZ_INTL_HAS_NUMBER_RANGE_FORMAT` isn't defined, `intl::NumberRangeFormat`
is an empty class. We could also hide the complete class if the preprocessor
guard isn't defined, but the other approach results in fewer `#ifdef` guards.

Differential Revision: https://phabricator.services.mozilla.com/D119742
2021-08-24 09:34:46 +00:00
André Bargull d2bbf86876 Bug 1726123 - Part 5: Add missing "js/" includes outside of SM. r=arai
In preparation for the next part, add missing includes to "js/" public headers.

Differential Revision: https://phabricator.services.mozilla.com/D122843
2021-08-17 15:45:39 +00:00
Greg Tatum b41f145a38 Bug 1719550 - Add support for BCP 47 extensions to mozilla::intl::Collator; r=platform-i18n-reviewers,nordzilla
SpiderMonkey requires the BCP 47 locale extensions, which involves iterating
over the keywords in ICU, and mapping them to the BCP 47 version. Specifically,
this will change the "phonebook" keyword to "phonebk". This should hopefully
expose a simpler API to SpiderMonkey, the only consumer.

Differential Revision: https://phabricator.services.mozilla.com/D120903
2021-08-10 16:01:15 +00:00
Greg Tatum c2cf97af11 Bug 1719550 - Build an initial unified mozilla::intl::Collator; r=platform-i18n-reviewers,nordzilla
This collator attempts to match the options bag from the Intl.Collator API
from ECMA-402. It is built to be compatible and consistent across both Gecko
code and SpiderMonkey code. Its behavior is designed to match ECMA-402.

Differential Revision: https://phabricator.services.mozilla.com/D120494
2021-08-10 16:01:15 +00:00
Narcis Beleuzu daed5248e2 Backed out 12 changesets (bug 1719550) for bustages on TestCollator.cpp . CLOSED TREE
Backed out changeset 3b2735a29138 (bug 1719550)
Backed out changeset 5e2019335244 (bug 1719550)
Backed out changeset 105676dd2d6f (bug 1719550)
Backed out changeset b4b0d58778e9 (bug 1719550)
Backed out changeset 3ef5792020bb (bug 1719550)
Backed out changeset 389a77da6ddc (bug 1719550)
Backed out changeset 48f39b5ef77f (bug 1719550)
Backed out changeset bd125cc5b9b4 (bug 1719550)
Backed out changeset a8b778ca2375 (bug 1719550)
Backed out changeset b14702168fb9 (bug 1719550)
Backed out changeset 7b46b5cc7424 (bug 1719550)
Backed out changeset 6b04162618a1 (bug 1719550)
2021-08-10 17:46:34 +03:00
Greg Tatum 1fb2daab2a Bug 1719550 - Add support for BCP 47 extensions to mozilla::intl::Collator; r=platform-i18n-reviewers,nordzilla
SpiderMonkey requires the BCP 47 locale extensions, which involves iterating
over the keywords in ICU, and mapping them to the BCP 47 version. Specifically,
this will change the "phonebook" keyword to "phonebk". This should hopefully
expose a simpler API to SpiderMonkey, the only consumer.

Differential Revision: https://phabricator.services.mozilla.com/D120903
2021-08-10 11:46:34 +00:00
Greg Tatum 0087d035b9 Bug 1719550 - Build an initial unified mozilla::intl::Collator; r=platform-i18n-reviewers,nordzilla
This collator attempts to match the options bag from the Intl.Collator API
from ECMA-402. It is built to be compatible and consistent across both Gecko
code and SpiderMonkey code. Its behavior is designed to match ECMA-402.

Differential Revision: https://phabricator.services.mozilla.com/D120494
2021-08-10 11:46:34 +00:00
Dan Minor 26b1e33737 Bug 1715595 - Use char rather than uint8_t for utf-8 in unified components r=platform-i18n-reviewers,gregtatum
Differential Revision: https://phabricator.services.mozilla.com/D120508
2021-07-23 14:58:00 +00:00
Erik Nordin 0990d59463 Bug 1719758 - Test result values before unwrapping in TestPluralRules r=platform-i18n-reviewers,dminor
Modifies TestPluralRules.cpp to assert that all result values are okay
before unwrapping them. Previously the test suite would crash if an
error result was unwrapped. Now it will fail the test and report the
failure.

Differential Revision: https://phabricator.services.mozilla.com/D119465
2021-07-09 17:49:38 +00:00
Greg Tatum 8c72f6e6ae Bug 1715979 - Do not leak ICU objects in mozilla:intl component moves; r=nordzilla
Differential Revision: https://phabricator.services.mozilla.com/D117569
2021-06-29 15:25:44 +00:00
Erik Nordin ed5c7b4262 Bug 1718345 - Add PluralRules tests for three-letter langids r=platform-i18n-reviewers,dminor
Differential Revision: https://phabricator.services.mozilla.com/D118869
2021-06-28 16:24:03 +00:00
André Bargull 90a85eee9f Bug 1284868: Adjust field widths for hour/minute/second when the user requested 2-digit representation. r=dminor
Change `DateTimePatternGenerator::GetBestPattern()` to call `udatpg_getBestPatternWithOptions()`,
so we can adjust the computed pattern to use 2-digit representation when it was requested by the
user.

Differential Revision: https://phabricator.services.mozilla.com/D118728
2021-06-28 13:20:44 +00:00
Dan Minor eeaf61de24 Bug 1715982 - Fix initial capacity of NumberPartVector; r=anba
Differential Revision: https://phabricator.services.mozilla.com/D117540
2021-06-11 21:22:15 +00:00
Greg Tatum 07cc89dd24 Bug 1711902 - Add Calendar::GetCanonicalTimeZoneID; r=dminor
This finishes the UCalendar unification in DateTimeFormat.cpp

Differential Revision: https://phabricator.services.mozilla.com/D116158
2021-06-10 20:14:17 +00:00
Greg Tatum db78fe91b5 Bug 1711902 - Unify most of UCalendar in SpiderMonkey; r=dminor,anba
This adds a bigger unification primitive of an Enumeration iterator over the
UEnumeration ICU type.

Differential Revision: https://phabricator.services.mozilla.com/D116157
2021-06-10 20:14:17 +00:00
Greg Tatum 23873163d1 Bug 1711902 - Unify the DateTimePatternGenerator in SpiderMonkey; r=dminor,anba
Differential Revision: https://phabricator.services.mozilla.com/D115731
2021-06-10 20:14:17 +00:00
Greg Tatum cb9860735f Bug 1711902 - Remove UDateFormat from SpiderMonkey; r=dminor,anba
This patch starts the work of unifying the DateTimeFormat. It removes the uses
of UDateFormat.

Differential Revision: https://phabricator.services.mozilla.com/D115730
2021-06-10 20:14:16 +00:00
Greg Tatum efe295fd94 Bug 1711902 - Add a FormatBuffer for use in SpiderMonkey; r=anba
Differential Revision: https://phabricator.services.mozilla.com/D116911
2021-06-10 20:14:16 +00:00
Erik Nordin 875656873e Bug 1704509 - Add Unified PuralRules Impl For SpiderMonkey r=anba,dminor
- Adds mozilla::intl::PluralRules
    - Modifies SpiderMonkey code to use PluralRules.
    - Adds gtest suite for PluralRules

Differential Revision: https://phabricator.services.mozilla.com/D115783
2021-06-09 19:04:54 +00:00
Greg Tatum bf5ee6077d Bug 1705156 - Add a unified DateTimeFormat component; r=dminor,anba
This patch adds a DateTimeFormat class for use in the unified
internationalization API. Currently it's only targeting the
ICU code in the Fluent API. The plan is to use it in the Fluent DOM
code, as well as in SpiderMonkey as a centralized API for performing
datetime formatting.

Differential Revision: https://phabricator.services.mozilla.com/D114114
2021-05-27 23:03:43 +00:00
Dan Minor 0452666d00 Bug 1701695 - Add NumberFormat::TryCreate; r=tcampbell
This adds a fallible factory method to create new NumberFormat instances. This
allows us to report initialization errors at time of initialization, rather than
when format is called, and remove internal checks in the implementation for
successful initialization.

The existing fluent code assumes that creating a NumberFormat instance always
succeeds. This patch updates that code to handle failures.

Differential Revision: https://phabricator.services.mozilla.com/D114593
2021-05-12 17:22:51 +00:00
Dan Minor 3b533cd007 Bug 1701695 - Add documentation to NumberFormat.h; r=gregtatum,nordzilla
Differential Revision: https://phabricator.services.mozilla.com/D113145
2021-05-12 17:22:51 +00:00
Dan Minor 5f755ac1ab Bug 1701695 - Use intl::NumberFormatterSkeleton in PluralRules r=tcampbell
This temporarily adds intl::NumberFormatterSkeleton to the public API so that
we can use it in PluralRules. This allows us to remove the SpiderMonkey
NumberFormatterSkeleton implementation when we convert SpiderMonkey to use
intl::NumberFormat.

We can remove intl::NumberFormatterSkeleton from the public API when we
implement intl::PluralRules in Bug 1704509.

Differential Revision: https://phabricator.services.mozilla.com/D111887
2021-05-12 17:22:50 +00:00
Dan Minor d5183e8bf1 Bug 1701695 - Add support for format to parts to intl::NumberFormat r=gregtatum,tcampbell,anba
Differential Revision: https://phabricator.services.mozilla.com/D111886
2021-05-12 17:22:49 +00:00
Dan Minor 4b3bf83c4b Bug 1701695 - Restore [[nodiscard]] annotations to NumberFormatterSkeleton; r=gregtatum
I foolishly dropped these when bringing the code over from SpiderMonkey.

Differential Revision: https://phabricator.services.mozilla.com/D113558
2021-05-12 17:22:49 +00:00
Dan Minor afc8a3b58a Bug 1701695 - Rename NumberFormatOptions::CurrencyDisplayStyle; r=gregtatum
This should be CurrencyDisplay to be consistent with ecma-402.

Differential Revision: https://phabricator.services.mozilla.com/D113557
2021-05-12 17:22:48 +00:00
Dan Minor 27dd93eb84 Bug 1701695 - Return std::u16string_view instead of char16_t* in intl::NumberFormat r=gregtatum
The SpiderMonkey call sites need both the pointer and the length when
copying/deflating the string, so this changes the API to expose the underlying
string_view.

While we're here, this updates the API to use mozilla::Result.

Differential Revision: https://phabricator.services.mozilla.com/D112801
2021-05-12 17:22:48 +00:00
Brindusan Cristian efd8dfd0cf Backed out 9 changesets (bug 1701695) for causing xpcshell failures in test_messagecontext.js. CLOSED TREE
Backed out changeset e88dd41c0a90 (bug 1701695)
Backed out changeset 823ed70ef5fe (bug 1701695)
Backed out changeset 11f97bc74622 (bug 1701695)
Backed out changeset fdf12ac55593 (bug 1701695)
Backed out changeset abcf774d3b58 (bug 1701695)
Backed out changeset 4239fe67d69f (bug 1701695)
Backed out changeset 216472b634b9 (bug 1701695)
Backed out changeset 89ff5f91d8e9 (bug 1701695)
Backed out changeset 9c0dbc73dad2 (bug 1701695)
2021-05-11 15:25:46 +03:00
Dan Minor 7a648a32c3 Bug 1701695 - Add NumberFormat::TryCreate; r=tcampbell
This adds a fallible factory method to create new NumberFormat instances. This
allows us to report initialization errors at time of initialization, rather than
when format is called, and remove internal checks in the implementation for
successful initialization.

The existing fluent code assumes that creating a NumberFormat instance always
succeeds. This patch updates that code to handle failures.

Differential Revision: https://phabricator.services.mozilla.com/D114593
2021-05-11 11:37:40 +00:00
Dan Minor 6eaea879f1 Bug 1701695 - Add documentation to NumberFormat.h; r=gregtatum,nordzilla
Differential Revision: https://phabricator.services.mozilla.com/D113145
2021-05-11 11:37:40 +00:00
Dan Minor 3322d3ceb6 Bug 1701695 - Use intl::NumberFormatterSkeleton in PluralRules r=tcampbell
This temporarily adds intl::NumberFormatterSkeleton to the public API so that
we can use it in PluralRules. This allows us to remove the SpiderMonkey
NumberFormatterSkeleton implementation when we convert SpiderMonkey to use
intl::NumberFormat.

We can remove intl::NumberFormatterSkeleton from the public API when we
implement intl::PluralRules in Bug 1704509.

Differential Revision: https://phabricator.services.mozilla.com/D111887
2021-05-11 11:37:38 +00:00
Dan Minor c6f5bbceb4 Bug 1701695 - Add support for format to parts to intl::NumberFormat r=gregtatum,tcampbell,anba
Differential Revision: https://phabricator.services.mozilla.com/D111886
2021-05-11 11:37:38 +00:00
Dan Minor 8cf0f1089a Bug 1701695 - Restore [[nodiscard]] annotations to NumberFormatterSkeleton; r=gregtatum
I foolishly dropped these when bringing the code over from SpiderMonkey.

Differential Revision: https://phabricator.services.mozilla.com/D113558
2021-05-11 11:37:38 +00:00