Changeset 197261 in webkit
- Timestamp:
- Feb 27, 2016 4:36:01 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r197260 r197261 1 2016-02-27 Andy VanWagoner <thetalecrafter@gmail.com> 2 3 Intl.Collator uses POSIX locale (detected by js/intl-collator.html on iOS Simulator) 4 https://bugs.webkit.org/show_bug.cgi?id=152448 5 6 Reviewed by Darin Adler. 7 8 Add tests for default locale in test runner to be en-US. 9 10 * js/intl-collator-expected.txt: 11 * js/intl-datetimeformat-expected.txt: 12 * js/intl-numberformat-expected.txt: 13 * js/script-tests/intl-collator.js: 14 * js/script-tests/intl-datetimeformat.js: 15 * js/script-tests/intl-numberformat.js: 16 1 17 2016-02-27 Chris Dumez <cdumez@apple.com> 2 18 -
trunk/LayoutTests/js/intl-collator-expected.txt
r194253 r197261 20 20 PASS class DerivedCollator extends Intl.Collator {};Object.getPrototypeOf(new DerivedCollator) === DerivedCollator.prototype is true 21 21 PASS class DerivedCollator extends Intl.Collator {};Object.getPrototypeOf(Object.getPrototypeOf(new DerivedCollator)) === Intl.Collator.prototype is true 22 PASS testCollator(Intl.Collator(), [{locale: 'en-US'}]) is true 22 23 PASS testCollator(Intl.Collator('en'), [{locale: 'en'}]) is true 23 24 PASS testCollator(Intl.Collator('eN-uS'), [{locale: 'en-US'}]) is true -
trunk/LayoutTests/js/intl-datetimeformat-expected.txt
r195138 r197261 84 84 PASS Intl.DateTimeFormat('$') threw exception RangeError: invalid language tag: $. 85 85 PASS Intl.DateTimeFormat('en', null) threw exception TypeError: null is not an object (evaluating 'Intl.DateTimeFormat('en', null)'). 86 PASS Intl.DateTimeFormat().resolvedOptions().locale is 'en-US' 86 87 PASS Intl.DateTimeFormat('en').resolvedOptions().weekday is undefined 87 88 PASS Intl.DateTimeFormat('en').resolvedOptions().era is undefined -
trunk/LayoutTests/js/intl-numberformat-expected.txt
r196850 r197261 13 13 PASS class DerivedNumberFormat extends Intl.NumberFormat {};Object.getPrototypeOf(new DerivedNumberFormat) === DerivedNumberFormat.prototype is true 14 14 PASS class DerivedNumberFormat extends Intl.NumberFormat {};Object.getPrototypeOf(Object.getPrototypeOf(new DerivedNumberFormat)) === Intl.NumberFormat.prototype is true 15 PASS testNumberFormat(Intl.NumberFormat(), [{locale: 'en-US'}]) is true 15 16 PASS testNumberFormat(Intl.NumberFormat('en'), [{locale: 'en'}]) is true 16 17 PASS testNumberFormat(Intl.NumberFormat('eN-uS'), [{locale: 'en-US'}]) is true -
trunk/LayoutTests/js/script-tests/intl-collator.js
r194253 r197261 44 44 45 45 // Locale is processed correctly. 46 shouldBeTrue("testCollator(Intl.Collator(), [{locale: 'en-US'}])"); 46 47 shouldBeTrue("testCollator(Intl.Collator('en'), [{locale: 'en'}])"); 47 48 shouldBeTrue("testCollator(Intl.Collator('eN-uS'), [{locale: 'en-US'}])"); -
trunk/LayoutTests/js/script-tests/intl-datetimeformat.js
r195138 r197261 164 164 shouldThrow("Intl.DateTimeFormat('$')", "'RangeError: invalid language tag: $'"); 165 165 shouldThrow("Intl.DateTimeFormat('en', null)", '"TypeError: null is not an object (evaluating \'Intl.DateTimeFormat(\'en\', null)\')"'); 166 167 // Defaults to en-US locale in test runner 168 shouldBe("Intl.DateTimeFormat().resolvedOptions().locale", "'en-US'"); 166 169 167 170 // Defaults to month, day, year. -
trunk/LayoutTests/js/script-tests/intl-numberformat.js
r196850 r197261 42 42 43 43 // Locale is processed correctly. 44 shouldBeTrue("testNumberFormat(Intl.NumberFormat(), [{locale: 'en-US'}])"); 44 45 shouldBeTrue("testNumberFormat(Intl.NumberFormat('en'), [{locale: 'en'}])"); 45 46 shouldBeTrue("testNumberFormat(Intl.NumberFormat('eN-uS'), [{locale: 'en-US'}])"); -
trunk/Source/JavaScriptCore/ChangeLog
r197256 r197261 1 2016-02-27 Andy VanWagoner <thetalecrafter@gmail.com> 2 3 Intl.Collator uses POSIX locale (detected by js/intl-collator.html on iOS Simulator) 4 https://bugs.webkit.org/show_bug.cgi?id=152448 5 6 Reviewed by Darin Adler. 7 8 Add defaultLanguage to the globalObjectMethodTable and use it for the 9 default locale in Intl object initializations. Fall back to ICU default 10 locale only if the defaultLanguage function is null, or returns an 11 empty string. 12 13 * jsc.cpp: 14 * runtime/IntlCollator.cpp: 15 (JSC::IntlCollator::initializeCollator): 16 * runtime/IntlDateTimeFormat.cpp: 17 (JSC::IntlDateTimeFormat::initializeDateTimeFormat): 18 * runtime/IntlNumberFormat.cpp: 19 (JSC::IntlNumberFormat::initializeNumberFormat): 20 * runtime/IntlObject.cpp: 21 (JSC::defaultLocale): 22 (JSC::lookupMatcher): 23 (JSC::bestFitMatcher): 24 (JSC::resolveLocale): 25 * runtime/IntlObject.h: 26 * runtime/JSGlobalObject.cpp: 27 * runtime/JSGlobalObject.h: 28 * runtime/StringPrototype.cpp: 29 (JSC::toLocaleCase): 30 1 31 2016-02-27 Oliver Hunt <oliver@apple.com> 2 32 -
trunk/Source/JavaScriptCore/jsc.cpp
r196948 r197261 780 780 781 781 const ClassInfo GlobalObject::s_info = { "global", &JSGlobalObject::s_info, nullptr, CREATE_METHOD_TABLE(GlobalObject) }; 782 const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, 0, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr, nullptr };782 const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, 0, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr, nullptr, nullptr }; 783 783 784 784 -
trunk/Source/JavaScriptCore/runtime/IntlCollator.cpp
r196887 r197261 251 251 // 18. Let r be ResolveLocale(%Collator%.[[availableLocales]], requestedLocales, opt, relevantExtensionKeys, localeData). 252 252 auto& availableLocales = state.callee()->globalObject()->intlCollatorAvailableLocales(); 253 auto result = resolveLocale( availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);253 auto result = resolveLocale(state, availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData); 254 254 255 255 // 19. Set collator.[[locale]] to the value of r.[[locale]]. -
trunk/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp
r196887 r197261 450 450 // 11. Let localeData be the value of %DateTimeFormat%.[[localeData]]. 451 451 // 12. Let r be ResolveLocale( %DateTimeFormat%.[[availableLocales]], requestedLocales, opt, %DateTimeFormat%.[[relevantExtensionKeys]], localeData). 452 const HashSet<String> availableLocales = exec. lexicalGlobalObject()->intlDateTimeFormatAvailableLocales();453 HashMap<String, String> resolved = resolveLocale( availableLocales, requestedLocales, localeOpt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);452 const HashSet<String> availableLocales = exec.callee()->globalObject()->intlDateTimeFormatAvailableLocales(); 453 HashMap<String, String> resolved = resolveLocale(exec, availableLocales, requestedLocales, localeOpt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData); 454 454 455 455 // 13. Set dateTimeFormat.[[locale]] to the value of r.[[locale]]. -
trunk/Source/JavaScriptCore/runtime/IntlNumberFormat.cpp
r196850 r197261 197 197 // 12. Let r be ResolveLocale(%NumberFormat%.[[availableLocales]], requestedLocales, opt, %NumberFormat%.[[relevantExtensionKeys]], localeData). 198 198 auto& availableLocales = state.callee()->globalObject()->intlNumberFormatAvailableLocales(); 199 auto result = resolveLocale( availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);199 auto result = resolveLocale(state, availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData); 200 200 201 201 // 13. Set numberFormat.[[locale]] to the value of r.[[locale]]. -
trunk/Source/JavaScriptCore/runtime/IntlObject.cpp
r196887 r197261 113 113 { 114 114 return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); 115 }116 117 String defaultLocale()118 {119 // 6.2.4 DefaultLocale ()120 String locale = uloc_getDefault();121 convertICULocaleToBCP47LanguageTag(locale);122 return locale;123 115 } 124 116 … … 651 643 } 652 644 645 String defaultLocale(ExecState& state) 646 { 647 // 6.2.4 DefaultLocale () 648 if (auto defaultLanguage = state.callee()->globalObject()->globalObjectMethodTable()->defaultLanguage) { 649 String locale = defaultLanguage(); 650 if (!locale.isEmpty()) 651 return canonicalizeLanguageTag(locale); 652 } 653 String locale = uloc_getDefault(); 654 convertICULocaleToBCP47LanguageTag(locale); 655 return locale; 656 } 657 653 658 String removeUnicodeLocaleExtension(const String& locale) 654 659 { … … 673 678 } 674 679 675 static MatcherResult lookupMatcher( const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)680 static MatcherResult lookupMatcher(ExecState& state, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales) 676 681 { 677 682 // 9.2.3 LookupMatcher (availableLocales, requestedLocales) (ECMA-402 2.0) … … 710 715 } 711 716 } else 712 result.locale = defaultLocale( );717 result.locale = defaultLocale(state); 713 718 return result; 714 719 } 715 720 716 static MatcherResult bestFitMatcher( const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)721 static MatcherResult bestFitMatcher(ExecState& state, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales) 717 722 { 718 723 // 9.2.4 BestFitMatcher (availableLocales, requestedLocales) (ECMA-402 2.0) 719 724 // FIXME: Implement something better than lookup. 720 return lookupMatcher( availableLocales, requestedLocales);721 } 722 723 HashMap<String, String> resolveLocale( const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, const HashMap<String, String>& options, const char* const relevantExtensionKeys[], size_t relevantExtensionKeyCount, Vector<String> (*localeData)(const String&, size_t))725 return lookupMatcher(state, availableLocales, requestedLocales); 726 } 727 728 HashMap<String, String> resolveLocale(ExecState& state, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, const HashMap<String, String>& options, const char* const relevantExtensionKeys[], size_t relevantExtensionKeyCount, Vector<String> (*localeData)(const String&, size_t)) 724 729 { 725 730 // 9.2.5 ResolveLocale (availableLocales, requestedLocales, options, relevantExtensionKeys, localeData) (ECMA-402 2.0) … … 728 733 729 734 // 2. If matcher is "lookup", then 730 MatcherResult (*matcherOperation)( const HashSet<String>&, const Vector<String>&);735 MatcherResult (*matcherOperation)(ExecState&, const HashSet<String>&, const Vector<String>&); 731 736 if (matcher == "lookup") { 732 737 // a. Let MatcherOperation be the abstract operation LookupMatcher. … … 738 743 739 744 // 4. Let r be MatcherOperation(availableLocales, requestedLocales). 740 MatcherResult matcherResult = matcherOperation( availableLocales, requestedLocales);745 MatcherResult matcherResult = matcherOperation(state, availableLocales, requestedLocales); 741 746 742 747 // 5. Let foundLocale be the value of r.[[locale]]. -
trunk/Source/JavaScriptCore/runtime/IntlObject.h
r196434 r197261 58 58 }; 59 59 60 String defaultLocale( );60 String defaultLocale(ExecState&); 61 61 void convertICULocaleToBCP47LanguageTag(String& locale); 62 62 bool intlBooleanOption(ExecState&, JSValue options, PropertyName, bool& usesFallback); … … 64 64 unsigned intlNumberOption(ExecState&, JSValue options, PropertyName, unsigned minimum, unsigned maximum, unsigned fallback); 65 65 Vector<String> canonicalizeLocaleList(ExecState&, JSValue locales); 66 HashMap<String, String> resolveLocale( const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, const HashMap<String, String>& options, const char* const relevantExtensionKeys[], size_t relevantExtensionKeyCount, Vector<String> (*localeData)(const String&, size_t));66 HashMap<String, String> resolveLocale(ExecState&, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, const HashMap<String, String>& options, const char* const relevantExtensionKeys[], size_t relevantExtensionKeyCount, Vector<String> (*localeData)(const String&, size_t)); 67 67 JSValue supportedLocales(ExecState&, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, JSValue options); 68 68 String removeUnicodeLocaleExtension(const String& locale); -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r196967 r197261 177 177 const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &Base::s_info, &globalObjectTable, CREATE_METHOD_TABLE(JSGlobalObject) }; 178 178 179 const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, nullptr, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr };179 const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, nullptr, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }; 180 180 181 181 /* Source for JSGlobalObject.lut.h -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r196966 r197261 174 174 typedef JSValue (*ModuleLoaderEvaluatePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue); 175 175 ModuleLoaderEvaluatePtr moduleLoaderEvaluate; 176 177 typedef String (*DefaultLanguageFunctionPtr)(); 178 DefaultLanguageFunctionPtr defaultLanguage; 176 179 }; 177 180 -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r196721 r197261 1501 1501 // 8. Else 1502 1502 // a. Let requestedLocale be DefaultLocale(). 1503 String requestedLocale = len > 0 ? requestedLocales.first() : defaultLocale( );1503 String requestedLocale = len > 0 ? requestedLocales.first() : defaultLocale(*state); 1504 1504 1505 1505 // 9. Let noExtensionsLocale be the String value that is requestedLocale with all Unicode locale extension sequences (6.2.1) removed. -
trunk/Source/WebCore/ChangeLog
r197260 r197261 1 2016-02-27 Andy VanWagoner <thetalecrafter@gmail.com> 2 3 Intl.Collator uses POSIX locale (detected by js/intl-collator.html on iOS Simulator) 4 https://bugs.webkit.org/show_bug.cgi?id=152448 5 6 Reviewed by Darin Adler. 7 8 Pass defaultLanguage from Language.h to the globalObjectMethodTable to 9 ensure Intl objects can be initialized with the correct default locale. 10 11 * bindings/js/JSDOMWindowBase.cpp: 12 * bindings/js/JSWorkerGlobalScopeBase.cpp: 13 1 14 2016-02-27 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp
r196165 r197261 35 35 #include "JSModuleLoader.h" 36 36 #include "JSNode.h" 37 #include "Language.h" 37 38 #include "Logging.h" 38 39 #include "Page.h" … … 64 65 const ClassInfo JSDOMWindowBase::s_info = { "Window", &JSDOMGlobalObject::s_info, 0, CREATE_METHOD_TABLE(JSDOMWindowBase) }; 65 66 66 const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr, &moduleLoaderEvaluate };67 const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr, &moduleLoaderEvaluate, &defaultLanguage }; 67 68 68 69 JSDOMWindowBase::JSDOMWindowBase(VM& vm, Structure* structure, PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell) -
trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp
r196165 r197261 34 34 #include "JSDedicatedWorkerGlobalScope.h" 35 35 #include "JSWorkerGlobalScope.h" 36 #include "Language.h" 36 37 #include "WorkerGlobalScope.h" 37 38 #include <runtime/JSCJSValueInlines.h> … … 44 45 const ClassInfo JSWorkerGlobalScopeBase::s_info = { "WorkerGlobalScope", &JSDOMGlobalObject::s_info, 0, CREATE_METHOD_TABLE(JSWorkerGlobalScopeBase) }; 45 46 46 const GlobalObjectMethodTable JSWorkerGlobalScopeBase::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr };47 const GlobalObjectMethodTable JSWorkerGlobalScopeBase::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr, &defaultLanguage }; 47 48 48 49 JSWorkerGlobalScopeBase::JSWorkerGlobalScopeBase(JSC::VM& vm, JSC::Structure* structure, PassRefPtr<WorkerGlobalScope> impl)
Note: See TracChangeset
for help on using the changeset viewer.