Bug 215984

Summary: [JSC] Use -2 for grouping options in IntlRelativeTimeFormat
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: New BugsAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, keith_miller, mark.lam, msaboff, ross.kirsling, saam, tzagallo, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 213425    
Attachments:
Description Flags
Patch
ross.kirsling: review+
Patch ews-feeder: commit-queue-

Description Yusuke Suzuki 2020-08-30 00:01:00 PDT
[JSC] Use -2 for grouping options in IntlRelativeTimeFormat
Comment 1 Yusuke Suzuki 2020-08-30 00:03:08 PDT
Created attachment 407563 [details]
Patch
Comment 2 Ross Kirsling 2020-08-30 00:57:44 PDT
Comment on attachment 407563 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=407563&action=review

> Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp:150
> +    // Align to IntlNumberFormat's default.
> +    unum_setAttribute(m_numberFormat.get(), UNUM_MIN_INTEGER_DIGITS, 1);
> +    unum_setAttribute(m_numberFormat.get(), UNUM_MIN_FRACTION_DIGITS, 0);
> +    unum_setAttribute(m_numberFormat.get(), UNUM_MAX_FRACTION_DIGITS, 3);
> +    unum_setAttribute(m_numberFormat.get(), UNUM_GROUPING_USED, true);

Do these need to be set explicitly?
Comment 3 Yusuke Suzuki 2020-08-30 01:04:49 PDT
Comment on attachment 407563 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=407563&action=review

>> Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp:150
>> +    unum_setAttribute(m_numberFormat.get(), UNUM_GROUPING_USED, true);
> 
> Do these need to be set explicitly?

Currently, setting these options to align well to the spec (https://tc39.es/ecma402/#sec-InitializeRelativeTimeFormat uses Intl.NumberFormat).
I think this is safer, because ICU could change default values.
Comment 4 Ross Kirsling 2020-08-30 01:30:30 PDT
Comment on attachment 407563 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=407563&action=review

> Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp:162
> +    unum_setAttribute(m_numberFormat.get(), UNUM_GROUPING_SIZE, useLocaleDefault);
> +    unum_setAttribute(m_numberFormat.get(), UNUM_SECONDARY_GROUPING_SIZE, useLocaleDefault);

Er wait, one more question. Does that enum value really apply to these two attributes as well? It's not very clear from the linked ICU commit.
Comment 5 Yusuke Suzuki 2020-08-30 01:36:13 PDT
Comment on attachment 407563 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=407563&action=review

>> Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp:162
>> +    unum_setAttribute(m_numberFormat.get(), UNUM_SECONDARY_GROUPING_SIZE, useLocaleDefault);
> 
> Er wait, one more question. Does that enum value really apply to these two attributes as well? It's not very clear from the linked ICU commit.

Yes, all three are required. See ICU code for fGrouping1, fGrouping2, and fMinGrouping.
Comment 6 Yusuke Suzuki 2020-08-30 15:46:35 PDT
Created attachment 407576 [details]
Patch

Patch for landing
Comment 7 EWS 2020-08-30 18:12:46 PDT
ChangeLog entry in JSTests/ChangeLog contains OOPS!.
Comment 8 Yusuke Suzuki 2020-08-30 18:29:17 PDT
Committed r266341: <https://trac.webkit.org/changeset/266341>
Comment 9 Radar WebKit Bug Importer 2020-08-30 18:30:16 PDT
<rdar://problem/68046059>