Changeset 261182 in webkit
- Timestamp:
- May 5, 2020 11:21:32 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r261175 r261182 1 2020-05-05 Ross Kirsling <ross.kirsling@sony.com> 2 3 [Intl] Alphabetize extension keys and correctly mark const methods 4 https://bugs.webkit.org/show_bug.cgi?id=211359 5 6 Reviewed by Darin Adler. 7 8 * stress/intl-collator.js: 9 * stress/intl-datetimeformat.js: 10 Add tests. 11 1 12 2020-05-05 Keith Miller <keith_miller@apple.com> 2 13 -
trunk/JSTests/stress/intl-collator.js
r260697 r261182 406 406 shouldBe(JSON.stringify(options), '{"usage":"sort","sensitivity":"variant","ignorePunctuation":false,"collation":"default","numeric":false,"caseFirst":"false"}'); 407 407 } 408 409 shouldBe(new Intl.Collator('de-u-kn-false-kf-upper-co-phonebk-hc-h12').resolvedOptions().locale, 'de-u-co-phonebk-kf-upper-kn-false'); -
trunk/JSTests/stress/intl-datetimeformat.js
r260697 r261182 215 215 shouldThrow(() => Intl.DateTimeFormat('en', null), TypeError); 216 216 217 shouldBe(new Intl.DateTimeFormat('en-u-nu-latn-hc-h12-ca-gregory-kf-upper').resolvedOptions().locale, 'en-u-ca-gregory-hc-h12-nu-latn'); 218 217 219 // Defaults to month, day, year. 218 220 shouldBe(Intl.DateTimeFormat('en').resolvedOptions().weekday, undefined); -
trunk/Source/JavaScriptCore/ChangeLog
r261181 r261182 1 2020-05-05 Ross Kirsling <ross.kirsling@sony.com> 2 3 [Intl] Alphabetize extension keys and correctly mark const methods 4 https://bugs.webkit.org/show_bug.cgi?id=211359 5 6 Reviewed by Darin Adler. 7 8 Two cleanup items for Intl classes: 9 10 1. Ensure `resolvedOptions().locale` returns relevant extension keys in alphabetical order. 11 ICU does this for us via Intl.getCanonicalLocales / Intl.*.supportedLocalesOf but not via ResolveLocale. 12 However, we don't need to do any sorting in ResolveLocale; we can just pre-alphabetize relevantExtensionKeys. 13 (See also https://github.com/tc39/ecma402/pull/433.) 14 15 2. Ensure Intl classes are marking const methods correctly. 16 17 * runtime/IntlCollator.cpp: 18 (JSC::IntlCollator::sortLocaleData): 19 (JSC::IntlCollator::searchLocaleData): 20 (JSC::IntlCollator::compareStrings const): Add const specifier. 21 (JSC::IntlCollator::resolvedOptions const): Add const specifier. 22 * runtime/IntlCollator.h: 23 * runtime/IntlDateTimeFormat.cpp: 24 (JSC::IntlDateTimeFormat::localeData): 25 (JSC::IntlDateTimeFormat::resolvedOptions const): Add const specifier. 26 (JSC::IntlDateTimeFormat::format const): Add const specifier. 27 (JSC::IntlDateTimeFormat::formatToParts const): Add const specifier. 28 * runtime/IntlDateTimeFormat.h: 29 * runtime/IntlNumberFormat.cpp: 30 (JSC::IntlNumberFormat::format const): Add const specifier. 31 (JSC::IntlNumberFormat::resolvedOptions const): Add const specifier. 32 (JSC::IntlNumberFormat::formatToParts const): Add const specifier. 33 * runtime/IntlNumberFormat.h: 34 * runtime/IntlPluralRules.cpp: 35 (JSC::IntlPluralRules::resolvedOptions const): Add const specifier. 36 (JSC::IntlPluralRules::select const): Add const specifier. 37 * runtime/IntlPluralRules.h: 38 * runtime/IntlRelativeTimeFormat.cpp: 39 (JSC::IntlRelativeTimeFormat::resolvedOptions const): Add const specifier. 40 (JSC::IntlRelativeTimeFormat::formatInternal const): Add const specifier. 41 (JSC::IntlRelativeTimeFormat::format const): Add const specifier. 42 (JSC::IntlRelativeTimeFormat::formatToParts const): Add const specifier. 43 * runtime/IntlRelativeTimeFormat.h: 44 1 45 2020-05-05 Keith Miller <keith_miller@apple.com> 2 46 -
trunk/Source/JavaScriptCore/runtime/IntlCollator.cpp
r260984 r261182 45 45 46 46 namespace IntlCollatorInternal { 47 constexpr const char* const relevantExtensionKeys[3] = { "co", "kn", "kf" };47 constexpr const char* relevantExtensionKeys[3] = { "co", "kf", "kn" }; 48 48 constexpr size_t collationIndex = 0; 49 constexpr size_t numericIndex = 1;50 constexpr size_t caseFirstIndex = 2;49 constexpr size_t caseFirstIndex = 1; 50 constexpr size_t numericIndex = 2; 51 51 } 52 52 … … 124 124 break; 125 125 } 126 case IntlCollatorInternal::numericIndex:127 keyLocaleData.reserveInitialCapacity(2);128 keyLocaleData.uncheckedAppend("false"_s);129 keyLocaleData.uncheckedAppend("true"_s);130 break;131 126 case IntlCollatorInternal::caseFirstIndex: 132 127 keyLocaleData.reserveInitialCapacity(3); … … 134 129 keyLocaleData.uncheckedAppend("lower"_s); 135 130 keyLocaleData.uncheckedAppend("upper"_s); 131 break; 132 case IntlCollatorInternal::numericIndex: 133 keyLocaleData.reserveInitialCapacity(2); 134 keyLocaleData.uncheckedAppend("false"_s); 135 keyLocaleData.uncheckedAppend("true"_s); 136 136 break; 137 137 default: … … 151 151 keyLocaleData.append({ }); 152 152 break; 153 case IntlCollatorInternal::numericIndex:154 keyLocaleData.reserveInitialCapacity(2);155 keyLocaleData.uncheckedAppend("false"_s);156 keyLocaleData.uncheckedAppend("true"_s);157 break;158 153 case IntlCollatorInternal::caseFirstIndex: 159 154 keyLocaleData.reserveInitialCapacity(3); … … 161 156 keyLocaleData.uncheckedAppend("lower"_s); 162 157 keyLocaleData.uncheckedAppend("upper"_s); 158 break; 159 case IntlCollatorInternal::numericIndex: 160 keyLocaleData.reserveInitialCapacity(2); 161 keyLocaleData.uncheckedAppend("false"_s); 162 keyLocaleData.uncheckedAppend("true"_s); 163 163 break; 164 164 default: … … 296 296 297 297 // https://tc39.es/ecma402/#sec-collator-comparestrings 298 JSValue IntlCollator::compareStrings(JSGlobalObject* globalObject, StringView x, StringView y) 298 JSValue IntlCollator::compareStrings(JSGlobalObject* globalObject, StringView x, StringView y) const 299 299 { 300 300 ASSERT(m_collator); … … 370 370 371 371 // https://tc39.es/ecma402/#sec-intl.collator.prototype.resolvedoptions 372 JSObject* IntlCollator::resolvedOptions(JSGlobalObject* globalObject) 372 JSObject* IntlCollator::resolvedOptions(JSGlobalObject* globalObject) const 373 373 { 374 374 VM& vm = globalObject->vm(); -
trunk/Source/JavaScriptCore/runtime/IntlCollator.h
r260931 r261182 57 57 58 58 void initializeCollator(JSGlobalObject*, JSValue locales, JSValue optionsValue); 59 JSValue compareStrings(JSGlobalObject*, StringView, StringView) ;60 JSObject* resolvedOptions(JSGlobalObject*) ;59 JSValue compareStrings(JSGlobalObject*, StringView, StringView) const; 60 JSObject* resolvedOptions(JSGlobalObject*) const; 61 61 62 62 JSBoundFunction* boundCompare() const { return m_boundCompare.get(); } -
trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
r260984 r261182 48 48 49 49 namespace IntlDateTimeFormatInternal { 50 constexpr const char* relevantExtensionKeys[3] = { "ca", " nu", "hc" };50 constexpr const char* relevantExtensionKeys[3] = { "ca", "hc", "nu" }; 51 51 constexpr size_t calendarIndex = 0; 52 constexpr size_t numberingSystemIndex = 1;53 constexpr size_t hourCycleIndex = 2;52 constexpr size_t hourCycleIndex = 1; 53 constexpr size_t numberingSystemIndex = 2; 54 54 } 55 55 … … 210 210 break; 211 211 } 212 case IntlDateTimeFormatInternal::numberingSystemIndex:213 keyLocaleData = numberingSystemsForLocale(locale);214 break;215 212 case IntlDateTimeFormatInternal::hourCycleIndex: 216 213 // Null default so we know to use 'j' in pattern. … … 220 217 keyLocaleData.append("h23"_s); 221 218 keyLocaleData.append("h24"_s); 219 break; 220 case IntlDateTimeFormatInternal::numberingSystemIndex: 221 keyLocaleData = numberingSystemsForLocale(locale); 222 222 break; 223 223 default: … … 839 839 840 840 // https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype.resolvedoptions 841 JSObject* IntlDateTimeFormat::resolvedOptions(JSGlobalObject* globalObject) 841 JSObject* IntlDateTimeFormat::resolvedOptions(JSGlobalObject* globalObject) const 842 842 { 843 843 VM& vm = globalObject->vm(); … … 885 885 886 886 // https://tc39.es/ecma402/#sec-formatdatetime 887 JSValue IntlDateTimeFormat::format(JSGlobalObject* globalObject, double value) 887 JSValue IntlDateTimeFormat::format(JSGlobalObject* globalObject, double value) const 888 888 { 889 889 ASSERT(m_dateFormat); … … 972 972 973 973 // https://tc39.es/ecma402/#sec-formatdatetimetoparts 974 JSValue IntlDateTimeFormat::formatToParts(JSGlobalObject* globalObject, double value) 974 JSValue IntlDateTimeFormat::formatToParts(JSGlobalObject* globalObject, double value) const 975 975 { 976 976 ASSERT(m_dateFormat); -
trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormat.h
r260931 r261182 56 56 57 57 void initializeDateTimeFormat(JSGlobalObject*, JSValue locales, JSValue options); 58 JSValue format(JSGlobalObject*, double value) ;59 JSValue formatToParts(JSGlobalObject*, double value) ;60 JSObject* resolvedOptions(JSGlobalObject*) ;58 JSValue format(JSGlobalObject*, double value) const; 59 JSValue formatToParts(JSGlobalObject*, double value) const; 60 JSObject* resolvedOptions(JSGlobalObject*) const; 61 61 62 62 JSBoundFunction* boundFormat() const { return m_boundFormat.get(); } -
trunk/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp
r260984 r261182 341 341 342 342 // https://tc39.es/ecma402/#sec-formatnumber 343 JSValue IntlNumberFormat::format(JSGlobalObject* globalObject, double value) 343 JSValue IntlNumberFormat::format(JSGlobalObject* globalObject, double value) const 344 344 { 345 345 ASSERT(m_numberFormat); … … 363 363 364 364 // https://tc39.es/ecma402/#sec-formatnumber 365 JSValue IntlNumberFormat::format(JSGlobalObject* globalObject, JSBigInt* value) 365 JSValue IntlNumberFormat::format(JSGlobalObject* globalObject, JSBigInt* value) const 366 366 { 367 367 ASSERT(m_numberFormat); … … 419 419 420 420 // https://tc39.es/ecma402/#sec-intl.numberformat.prototype.resolvedoptions 421 JSObject* IntlNumberFormat::resolvedOptions(JSGlobalObject* globalObject) 421 JSObject* IntlNumberFormat::resolvedOptions(JSGlobalObject* globalObject) const 422 422 { 423 423 VM& vm = globalObject->vm(); … … 528 528 529 529 // https://tc39.github.io/ecma402/#sec-formatnumbertoparts 530 JSValue IntlNumberFormat::formatToParts(JSGlobalObject* globalObject, double value) 530 JSValue IntlNumberFormat::formatToParts(JSGlobalObject* globalObject, double value) const 531 531 { 532 532 ASSERT(m_numberFormat); -
trunk/Source/JavaScriptCore/runtime/IntlNumberFormat.h
r260931 r261182 57 57 58 58 void initializeNumberFormat(JSGlobalObject*, JSValue locales, JSValue optionsValue); 59 JSValue format(JSGlobalObject*, double) ;60 JSValue format(JSGlobalObject*, JSBigInt*) ;61 JSValue formatToParts(JSGlobalObject*, double) ;62 JSObject* resolvedOptions(JSGlobalObject*) ;59 JSValue format(JSGlobalObject*, double) const; 60 JSValue format(JSGlobalObject*, JSBigInt*) const; 61 JSValue formatToParts(JSGlobalObject*, double) const; 62 JSObject* resolvedOptions(JSGlobalObject*) const; 63 63 64 64 JSBoundFunction* boundFormat() const { return m_boundFormat.get(); } -
trunk/Source/JavaScriptCore/runtime/IntlPluralRules.cpp
r260931 r261182 183 183 184 184 // https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.resolvedoptions 185 JSObject* IntlPluralRules::resolvedOptions(JSGlobalObject* globalObject) 185 JSObject* IntlPluralRules::resolvedOptions(JSGlobalObject* globalObject) const 186 186 { 187 187 ASSERT(m_pluralRules); … … 225 225 226 226 // https://tc39.es/ecma402/#sec-resolveplural 227 JSValue IntlPluralRules::select(JSGlobalObject* globalObject, double value) 227 JSValue IntlPluralRules::select(JSGlobalObject* globalObject, double value) const 228 228 { 229 229 ASSERT(m_pluralRules); -
trunk/Source/JavaScriptCore/runtime/IntlPluralRules.h
r260931 r261182 55 55 56 56 void initializePluralRules(JSGlobalObject*, JSValue locales, JSValue options); 57 JSValue select(JSGlobalObject*, double value) ;58 JSObject* resolvedOptions(JSGlobalObject*) ;57 JSValue select(JSGlobalObject*, double value) const; 58 JSObject* resolvedOptions(JSGlobalObject*) const; 59 59 60 60 private: -
trunk/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.cpp
r260931 r261182 184 184 185 185 // https://tc39.es/ecma402/#sec-intl.relativetimeformat.prototype.resolvedoptions 186 JSObject* IntlRelativeTimeFormat::resolvedOptions(JSGlobalObject* globalObject) 186 JSObject* IntlRelativeTimeFormat::resolvedOptions(JSGlobalObject* globalObject) const 187 187 { 188 188 VM& vm = globalObject->vm(); … … 226 226 } 227 227 228 String IntlRelativeTimeFormat::formatInternal(JSGlobalObject* globalObject, double value, StringView unit) 228 String IntlRelativeTimeFormat::formatInternal(JSGlobalObject* globalObject, double value, StringView unit) const 229 229 { 230 230 ASSERT(m_relativeDateTimeFormatter); … … 263 263 264 264 // https://tc39.es/ecma402/#sec-FormatRelativeTime 265 JSValue IntlRelativeTimeFormat::format(JSGlobalObject* globalObject, double value, StringView unit) 265 JSValue IntlRelativeTimeFormat::format(JSGlobalObject* globalObject, double value, StringView unit) const 266 266 { 267 267 VM& vm = globalObject->vm(); … … 275 275 276 276 // https://tc39.es/ecma402/#sec-FormatRelativeTimeToParts 277 JSValue IntlRelativeTimeFormat::formatToParts(JSGlobalObject* globalObject, double value, StringView unit) 277 JSValue IntlRelativeTimeFormat::formatToParts(JSGlobalObject* globalObject, double value, StringView unit) const 278 278 { 279 279 VM& vm = globalObject->vm(); -
trunk/Source/JavaScriptCore/runtime/IntlRelativeTimeFormat.h
r260931 r261182 54 54 55 55 void initializeRelativeTimeFormat(JSGlobalObject*, JSValue locales, JSValue options); 56 JSValue format(JSGlobalObject*, double, StringView unitString) ;57 JSValue formatToParts(JSGlobalObject*, double, StringView unitString) ;58 JSObject* resolvedOptions(JSGlobalObject*) ;56 JSValue format(JSGlobalObject*, double, StringView unitString) const; 57 JSValue formatToParts(JSGlobalObject*, double, StringView unitString) const; 58 JSObject* resolvedOptions(JSGlobalObject*) const; 59 59 60 60 private: … … 65 65 static Vector<String> localeData(const String&, size_t); 66 66 67 String formatInternal(JSGlobalObject*, double, StringView unit) ;67 String formatInternal(JSGlobalObject*, double, StringView unit) const; 68 68 69 69 struct URelativeDateTimeFormatterDeleter {
Note: See TracChangeset
for help on using the changeset viewer.