Title: [197261] trunk
Revision
197261
Author
[email protected]
Date
2016-02-27 16:36:01 -0800 (Sat, 27 Feb 2016)

Log Message

Intl.Collator uses POSIX locale (detected by js/intl-collator.html on iOS Simulator)
https://bugs.webkit.org/show_bug.cgi?id=152448

Patch by Andy VanWagoner <[email protected]> on 2016-02-27
Reviewed by Darin Adler.

Source/_javascript_Core:

Add defaultLanguage to the globalObjectMethodTable and use it for the
default locale in Intl object initializations. Fall back to ICU default
locale only if the defaultLanguage function is null, or returns an
empty string.

* jsc.cpp:
* runtime/IntlCollator.cpp:
(JSC::IntlCollator::initializeCollator):
* runtime/IntlDateTimeFormat.cpp:
(JSC::IntlDateTimeFormat::initializeDateTimeFormat):
* runtime/IntlNumberFormat.cpp:
(JSC::IntlNumberFormat::initializeNumberFormat):
* runtime/IntlObject.cpp:
(JSC::defaultLocale):
(JSC::lookupMatcher):
(JSC::bestFitMatcher):
(JSC::resolveLocale):
* runtime/IntlObject.h:
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
* runtime/StringPrototype.cpp:
(JSC::toLocaleCase):

Source/WebCore:

Pass defaultLanguage from Language.h to the globalObjectMethodTable to
ensure Intl objects can be initialized with the correct default locale.

* bindings/js/JSDOMWindowBase.cpp:
* bindings/js/JSWorkerGlobalScopeBase.cpp:

LayoutTests:

Add tests for default locale in test runner to be en-US.

* js/intl-collator-expected.txt:
* js/intl-datetimeformat-expected.txt:
* js/intl-numberformat-expected.txt:
* js/script-tests/intl-collator.js:
* js/script-tests/intl-datetimeformat.js:
* js/script-tests/intl-numberformat.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (197260 => 197261)


--- trunk/LayoutTests/ChangeLog	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/LayoutTests/ChangeLog	2016-02-28 00:36:01 UTC (rev 197261)
@@ -1,3 +1,19 @@
+2016-02-27  Andy VanWagoner  <[email protected]>
+
+        Intl.Collator uses POSIX locale (detected by js/intl-collator.html on iOS Simulator)
+        https://bugs.webkit.org/show_bug.cgi?id=152448
+
+        Reviewed by Darin Adler.
+
+        Add tests for default locale in test runner to be en-US.
+
+        * js/intl-collator-expected.txt:
+        * js/intl-datetimeformat-expected.txt:
+        * js/intl-numberformat-expected.txt:
+        * js/script-tests/intl-collator.js:
+        * js/script-tests/intl-datetimeformat.js:
+        * js/script-tests/intl-numberformat.js:
+
 2016-02-27  Chris Dumez  <[email protected]>
 
         Align HTMLMarqueeElement.scrollAmount / scrollDelay with the specification

Modified: trunk/LayoutTests/js/intl-collator-expected.txt (197260 => 197261)


--- trunk/LayoutTests/js/intl-collator-expected.txt	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/LayoutTests/js/intl-collator-expected.txt	2016-02-28 00:36:01 UTC (rev 197261)
@@ -19,6 +19,7 @@
 PASS class DerivedCollator extends Intl.Collator {};new DerivedCollator().compare('a', 'b') === -1 is true
 PASS class DerivedCollator extends Intl.Collator {};Object.getPrototypeOf(new DerivedCollator) === DerivedCollator.prototype is true
 PASS class DerivedCollator extends Intl.Collator {};Object.getPrototypeOf(Object.getPrototypeOf(new DerivedCollator)) === Intl.Collator.prototype is true
+PASS testCollator(Intl.Collator(), [{locale: 'en-US'}]) is true
 PASS testCollator(Intl.Collator('en'), [{locale: 'en'}]) is true
 PASS testCollator(Intl.Collator('eN-uS'), [{locale: 'en-US'}]) is true
 PASS testCollator(Intl.Collator(['en', 'de']), [{locale: 'en'}]) is true

Modified: trunk/LayoutTests/js/intl-datetimeformat-expected.txt (197260 => 197261)


--- trunk/LayoutTests/js/intl-datetimeformat-expected.txt	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/LayoutTests/js/intl-datetimeformat-expected.txt	2016-02-28 00:36:01 UTC (rev 197261)
@@ -83,6 +83,7 @@
 PASS Intl.DateTimeFormat.prototype.resolvedOptions.call(5) threw exception TypeError: Intl.DateTimeFormat.prototype.resolvedOptions called on value that's not an object initialized as a DateTimeFormat.
 PASS Intl.DateTimeFormat('$') threw exception RangeError: invalid language tag: $.
 PASS Intl.DateTimeFormat('en', null) threw exception TypeError: null is not an object (evaluating 'Intl.DateTimeFormat('en', null)').
+PASS Intl.DateTimeFormat().resolvedOptions().locale is 'en-US'
 PASS Intl.DateTimeFormat('en').resolvedOptions().weekday is undefined
 PASS Intl.DateTimeFormat('en').resolvedOptions().era is undefined
 PASS Intl.DateTimeFormat('en').resolvedOptions().month is 'numeric'

Modified: trunk/LayoutTests/js/intl-numberformat-expected.txt (197260 => 197261)


--- trunk/LayoutTests/js/intl-numberformat-expected.txt	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/LayoutTests/js/intl-numberformat-expected.txt	2016-02-28 00:36:01 UTC (rev 197261)
@@ -12,6 +12,7 @@
 PASS class DerivedNumberFormat extends Intl.NumberFormat {};new DerivedNumberFormat().format(1) === '1' is true
 PASS class DerivedNumberFormat extends Intl.NumberFormat {};Object.getPrototypeOf(new DerivedNumberFormat) === DerivedNumberFormat.prototype is true
 PASS class DerivedNumberFormat extends Intl.NumberFormat {};Object.getPrototypeOf(Object.getPrototypeOf(new DerivedNumberFormat)) === Intl.NumberFormat.prototype is true
+PASS testNumberFormat(Intl.NumberFormat(), [{locale: 'en-US'}]) is true
 PASS testNumberFormat(Intl.NumberFormat('en'), [{locale: 'en'}]) is true
 PASS testNumberFormat(Intl.NumberFormat('eN-uS'), [{locale: 'en-US'}]) is true
 PASS testNumberFormat(Intl.NumberFormat(['en', 'de']), [{locale: 'en'}]) is true

Modified: trunk/LayoutTests/js/script-tests/intl-collator.js (197260 => 197261)


--- trunk/LayoutTests/js/script-tests/intl-collator.js	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/LayoutTests/js/script-tests/intl-collator.js	2016-02-28 00:36:01 UTC (rev 197261)
@@ -43,6 +43,7 @@
 }
 
 // Locale is processed correctly.
+shouldBeTrue("testCollator(Intl.Collator(), [{locale: 'en-US'}])");
 shouldBeTrue("testCollator(Intl.Collator('en'), [{locale: 'en'}])");
 shouldBeTrue("testCollator(Intl.Collator('eN-uS'), [{locale: 'en-US'}])");
 shouldBeTrue("testCollator(Intl.Collator(['en', 'de']), [{locale: 'en'}])");

Modified: trunk/LayoutTests/js/script-tests/intl-datetimeformat.js (197260 => 197261)


--- trunk/LayoutTests/js/script-tests/intl-datetimeformat.js	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/LayoutTests/js/script-tests/intl-datetimeformat.js	2016-02-28 00:36:01 UTC (rev 197261)
@@ -164,6 +164,9 @@
 shouldThrow("Intl.DateTimeFormat('$')", "'RangeError: invalid language tag: $'");
 shouldThrow("Intl.DateTimeFormat('en', null)", '"TypeError: null is not an object (evaluating \'Intl.DateTimeFormat(\'en\', null)\')"');
 
+// Defaults to en-US locale in test runner
+shouldBe("Intl.DateTimeFormat().resolvedOptions().locale", "'en-US'");
+
 // Defaults to month, day, year.
 shouldBe("Intl.DateTimeFormat('en').resolvedOptions().weekday", "undefined");
 shouldBe("Intl.DateTimeFormat('en').resolvedOptions().era", "undefined");

Modified: trunk/LayoutTests/js/script-tests/intl-numberformat.js (197260 => 197261)


--- trunk/LayoutTests/js/script-tests/intl-numberformat.js	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/LayoutTests/js/script-tests/intl-numberformat.js	2016-02-28 00:36:01 UTC (rev 197261)
@@ -41,6 +41,7 @@
 }
 
 // Locale is processed correctly.
+shouldBeTrue("testNumberFormat(Intl.NumberFormat(), [{locale: 'en-US'}])");
 shouldBeTrue("testNumberFormat(Intl.NumberFormat('en'), [{locale: 'en'}])");
 shouldBeTrue("testNumberFormat(Intl.NumberFormat('eN-uS'), [{locale: 'en-US'}])");
 shouldBeTrue("testNumberFormat(Intl.NumberFormat(['en', 'de']), [{locale: 'en'}])");

Modified: trunk/Source/_javascript_Core/ChangeLog (197260 => 197261)


--- trunk/Source/_javascript_Core/ChangeLog	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-02-28 00:36:01 UTC (rev 197261)
@@ -1,3 +1,33 @@
+2016-02-27  Andy VanWagoner  <[email protected]>
+
+        Intl.Collator uses POSIX locale (detected by js/intl-collator.html on iOS Simulator)
+        https://bugs.webkit.org/show_bug.cgi?id=152448
+
+        Reviewed by Darin Adler.
+
+        Add defaultLanguage to the globalObjectMethodTable and use it for the
+        default locale in Intl object initializations. Fall back to ICU default
+        locale only if the defaultLanguage function is null, or returns an
+        empty string.
+
+        * jsc.cpp:
+        * runtime/IntlCollator.cpp:
+        (JSC::IntlCollator::initializeCollator):
+        * runtime/IntlDateTimeFormat.cpp:
+        (JSC::IntlDateTimeFormat::initializeDateTimeFormat):
+        * runtime/IntlNumberFormat.cpp:
+        (JSC::IntlNumberFormat::initializeNumberFormat):
+        * runtime/IntlObject.cpp:
+        (JSC::defaultLocale):
+        (JSC::lookupMatcher):
+        (JSC::bestFitMatcher):
+        (JSC::resolveLocale):
+        * runtime/IntlObject.h:
+        * runtime/JSGlobalObject.cpp:
+        * runtime/JSGlobalObject.h:
+        * runtime/StringPrototype.cpp:
+        (JSC::toLocaleCase):
+
 2016-02-27  Oliver Hunt  <[email protected]>
 
         CLoop build fix.

Modified: trunk/Source/_javascript_Core/jsc.cpp (197260 => 197261)


--- trunk/Source/_javascript_Core/jsc.cpp	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/_javascript_Core/jsc.cpp	2016-02-28 00:36:01 UTC (rev 197261)
@@ -779,7 +779,7 @@
 };
 
 const ClassInfo GlobalObject::s_info = { "global", &JSGlobalObject::s_info, nullptr, CREATE_METHOD_TABLE(GlobalObject) };
-const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &_javascript_RuntimeFlags, 0, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr, nullptr };
+const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &_javascript_RuntimeFlags, 0, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr, nullptr, nullptr };
 
 
 GlobalObject::GlobalObject(VM& vm, Structure* structure)

Modified: trunk/Source/_javascript_Core/runtime/IntlCollator.cpp (197260 => 197261)


--- trunk/Source/_javascript_Core/runtime/IntlCollator.cpp	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/_javascript_Core/runtime/IntlCollator.cpp	2016-02-28 00:36:01 UTC (rev 197261)
@@ -250,7 +250,7 @@
     // 17. Let relevantExtensionKeys be the value of %Collator%.[[relevantExtensionKeys]].
     // 18. Let r be ResolveLocale(%Collator%.[[availableLocales]], requestedLocales, opt, relevantExtensionKeys, localeData).
     auto& availableLocales = state.callee()->globalObject()->intlCollatorAvailableLocales();
-    auto result = resolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);
+    auto result = resolveLocale(state, availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);
 
     // 19. Set collator.[[locale]] to the value of r.[[locale]].
     m_locale = result.get(ASCIILiteral("locale"));

Modified: trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp (197260 => 197261)


--- trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/_javascript_Core/runtime/IntlDateTimeFormat.cpp	2016-02-28 00:36:01 UTC (rev 197261)
@@ -449,8 +449,8 @@
 
     // 11. Let localeData be the value of %DateTimeFormat%.[[localeData]].
     // 12. Let r be ResolveLocale( %DateTimeFormat%.[[availableLocales]], requestedLocales, opt, %DateTimeFormat%.[[relevantExtensionKeys]], localeData).
-    const HashSet<String> availableLocales = exec.lexicalGlobalObject()->intlDateTimeFormatAvailableLocales();
-    HashMap<String, String> resolved = resolveLocale(availableLocales, requestedLocales, localeOpt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);
+    const HashSet<String> availableLocales = exec.callee()->globalObject()->intlDateTimeFormatAvailableLocales();
+    HashMap<String, String> resolved = resolveLocale(exec, availableLocales, requestedLocales, localeOpt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);
 
     // 13. Set dateTimeFormat.[[locale]] to the value of r.[[locale]].
     m_locale = resolved.get(vm.propertyNames->locale.string());

Modified: trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp (197260 => 197261)


--- trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/_javascript_Core/runtime/IntlNumberFormat.cpp	2016-02-28 00:36:01 UTC (rev 197261)
@@ -196,7 +196,7 @@
     // 11. Let localeData be %NumberFormat%.[[localeData]].
     // 12. Let r be ResolveLocale(%NumberFormat%.[[availableLocales]], requestedLocales, opt, %NumberFormat%.[[relevantExtensionKeys]], localeData).
     auto& availableLocales = state.callee()->globalObject()->intlNumberFormatAvailableLocales();
-    auto result = resolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);
+    auto result = resolveLocale(state, availableLocales, requestedLocales, opt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);
 
     // 13. Set numberFormat.[[locale]] to the value of r.[[locale]].
     m_locale = result.get(ASCIILiteral("locale"));

Modified: trunk/Source/_javascript_Core/runtime/IntlObject.cpp (197260 => 197261)


--- trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2016-02-28 00:36:01 UTC (rev 197261)
@@ -114,14 +114,6 @@
     return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
 }
 
-String defaultLocale()
-{
-    // 6.2.4 DefaultLocale ()
-    String locale = uloc_getDefault();
-    convertICULocaleToBCP47LanguageTag(locale);
-    return locale;
-}
-
 void convertICULocaleToBCP47LanguageTag(String& locale)
 {
     locale.replace('_', '-');
@@ -650,6 +642,19 @@
     return String();
 }
 
+String defaultLocale(ExecState& state)
+{
+    // 6.2.4 DefaultLocale ()
+    if (auto defaultLanguage = state.callee()->globalObject()->globalObjectMethodTable()->defaultLanguage) {
+        String locale = defaultLanguage();
+        if (!locale.isEmpty())
+            return canonicalizeLanguageTag(locale);
+    }
+    String locale = uloc_getDefault();
+    convertICULocaleToBCP47LanguageTag(locale);
+    return locale;
+}
+
 String removeUnicodeLocaleExtension(const String& locale)
 {
     Vector<String> parts;
@@ -672,7 +677,7 @@
     return builder.toString();
 }
 
-static MatcherResult lookupMatcher(const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)
+static MatcherResult lookupMatcher(ExecState& state, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)
 {
     // 9.2.3 LookupMatcher (availableLocales, requestedLocales) (ECMA-402 2.0)
     String locale;
@@ -709,25 +714,25 @@
             result.extensionIndex = extensionIndex;
         }
     } else
-        result.locale = defaultLocale();
+        result.locale = defaultLocale(state);
     return result;
 }
 
-static MatcherResult bestFitMatcher(const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)
+static MatcherResult bestFitMatcher(ExecState& state, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales)
 {
     // 9.2.4 BestFitMatcher (availableLocales, requestedLocales) (ECMA-402 2.0)
     // FIXME: Implement something better than lookup.
-    return lookupMatcher(availableLocales, requestedLocales);
+    return lookupMatcher(state, availableLocales, requestedLocales);
 }
 
-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))
+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))
 {
     // 9.2.5 ResolveLocale (availableLocales, requestedLocales, options, relevantExtensionKeys, localeData) (ECMA-402 2.0)
     // 1. Let matcher be the value of options.[[localeMatcher]].
     const String& matcher = options.get(ASCIILiteral("localeMatcher"));
 
     // 2. If matcher is "lookup", then
-    MatcherResult (*matcherOperation)(const HashSet<String>&, const Vector<String>&);
+    MatcherResult (*matcherOperation)(ExecState&, const HashSet<String>&, const Vector<String>&);
     if (matcher == "lookup") {
         // a. Let MatcherOperation be the abstract operation LookupMatcher.
         matcherOperation = lookupMatcher;
@@ -737,7 +742,7 @@
     }
 
     // 4. Let r be MatcherOperation(availableLocales, requestedLocales).
-    MatcherResult matcherResult = matcherOperation(availableLocales, requestedLocales);
+    MatcherResult matcherResult = matcherOperation(state, availableLocales, requestedLocales);
 
     // 5. Let foundLocale be the value of r.[[locale]].
     String foundLocale = matcherResult.locale;

Modified: trunk/Source/_javascript_Core/runtime/IntlObject.h (197260 => 197261)


--- trunk/Source/_javascript_Core/runtime/IntlObject.h	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.h	2016-02-28 00:36:01 UTC (rev 197261)
@@ -57,13 +57,13 @@
     IntlObject(VM&, Structure*);
 };
 
-String defaultLocale();
+String defaultLocale(ExecState&);
 void convertICULocaleToBCP47LanguageTag(String& locale);
 bool intlBooleanOption(ExecState&, JSValue options, PropertyName, bool& usesFallback);
 String intlStringOption(ExecState&, JSValue options, PropertyName, std::initializer_list<const char*> values, const char* notFound, const char* fallback);
 unsigned intlNumberOption(ExecState&, JSValue options, PropertyName, unsigned minimum, unsigned maximum, unsigned fallback);
 Vector<String> canonicalizeLocaleList(ExecState&, JSValue locales);
-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));
+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));
 JSValue supportedLocales(ExecState&, const HashSet<String>& availableLocales, const Vector<String>& requestedLocales, JSValue options);
 String removeUnicodeLocaleExtension(const String& locale);
 String bestAvailableLocale(const HashSet<String>& availableLocales, const String& requestedLocale);

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp (197260 => 197261)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.cpp	2016-02-28 00:36:01 UTC (rev 197261)
@@ -176,7 +176,7 @@
 
 const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &Base::s_info, &globalObjectTable, CREATE_METHOD_TABLE(JSGlobalObject) };
 
-const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &_javascript_RuntimeFlags, nullptr, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr };
+const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &_javascript_RuntimeFlags, nullptr, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
 
 /* Source for JSGlobalObject.lut.h
 @begin globalObjectTable

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (197260 => 197261)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h	2016-02-28 00:36:01 UTC (rev 197261)
@@ -173,6 +173,9 @@
 
     typedef JSValue (*ModuleLoaderEvaluatePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue);
     ModuleLoaderEvaluatePtr moduleLoaderEvaluate;
+
+    typedef String (*DefaultLanguageFunctionPtr)();
+    DefaultLanguageFunctionPtr defaultLanguage;
 };
 
 class JSGlobalObject : public JSSegmentedVariableObject {

Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (197260 => 197261)


--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2016-02-28 00:36:01 UTC (rev 197261)
@@ -1500,7 +1500,7 @@
     // a. Let requestedLocale be the first element of requestedLocales.
     // 8. Else
     // a. Let requestedLocale be DefaultLocale().
-    String requestedLocale = len > 0 ? requestedLocales.first() : defaultLocale();
+    String requestedLocale = len > 0 ? requestedLocales.first() : defaultLocale(*state);
 
     // 9. Let noExtensionsLocale be the String value that is requestedLocale with all Unicode locale extension sequences (6.2.1) removed.
     String noExtensionsLocale = removeUnicodeLocaleExtension(requestedLocale);

Modified: trunk/Source/WebCore/ChangeLog (197260 => 197261)


--- trunk/Source/WebCore/ChangeLog	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/WebCore/ChangeLog	2016-02-28 00:36:01 UTC (rev 197261)
@@ -1,3 +1,16 @@
+2016-02-27  Andy VanWagoner  <[email protected]>
+
+        Intl.Collator uses POSIX locale (detected by js/intl-collator.html on iOS Simulator)
+        https://bugs.webkit.org/show_bug.cgi?id=152448
+
+        Reviewed by Darin Adler.
+
+        Pass defaultLanguage from Language.h to the globalObjectMethodTable to
+        ensure Intl objects can be initialized with the correct default locale.
+
+        * bindings/js/JSDOMWindowBase.cpp:
+        * bindings/js/JSWorkerGlobalScopeBase.cpp:
+
 2016-02-27  Chris Dumez  <[email protected]>
 
         Align HTMLMarqueeElement.scrollAmount / scrollDelay with the specification

Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp (197260 => 197261)


--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp	2016-02-28 00:36:01 UTC (rev 197261)
@@ -34,6 +34,7 @@
 #include "JSMainThreadExecState.h"
 #include "JSModuleLoader.h"
 #include "JSNode.h"
+#include "Language.h"
 #include "Logging.h"
 #include "Page.h"
 #include "RuntimeApplicationChecks.h"
@@ -63,7 +64,7 @@
 
 const ClassInfo JSDOMWindowBase::s_info = { "Window", &JSDOMGlobalObject::s_info, 0, CREATE_METHOD_TABLE(JSDOMWindowBase) };
 
-const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &_javascript_RuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr, &moduleLoaderEvaluate };
+const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &_javascript_RuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr, &moduleLoaderEvaluate, &defaultLanguage };
 
 JSDOMWindowBase::JSDOMWindowBase(VM& vm, Structure* structure, PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell)
     : JSDOMGlobalObject(vm, structure, &shell->world(), &s_globalObjectMethodTable)

Modified: trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp (197260 => 197261)


--- trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp	2016-02-28 00:35:18 UTC (rev 197260)
+++ trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp	2016-02-28 00:36:01 UTC (rev 197261)
@@ -33,6 +33,7 @@
 #include "JSDOMGlobalObjectTask.h"
 #include "JSDedicatedWorkerGlobalScope.h"
 #include "JSWorkerGlobalScope.h"
+#include "Language.h"
 #include "WorkerGlobalScope.h"
 #include <runtime/JSCJSValueInlines.h>
 #include <runtime/Microtask.h>
@@ -43,7 +44,7 @@
 
 const ClassInfo JSWorkerGlobalScopeBase::s_info = { "WorkerGlobalScope", &JSDOMGlobalObject::s_info, 0, CREATE_METHOD_TABLE(JSWorkerGlobalScopeBase) };
 
-const GlobalObjectMethodTable JSWorkerGlobalScopeBase::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &_javascript_RuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr };
+const GlobalObjectMethodTable JSWorkerGlobalScopeBase::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsLegacyProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &_javascript_RuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr, &defaultLanguage };
 
 JSWorkerGlobalScopeBase::JSWorkerGlobalScopeBase(JSC::VM& vm, JSC::Structure* structure, PassRefPtr<WorkerGlobalScope> impl)
     : JSDOMGlobalObject(vm, structure, &normalWorld(vm), &s_globalObjectMethodTable)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to