Changeset 201066 in webkit
- Timestamp:
- May 17, 2016 7:11:19 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r201051 r201066 1 2016-05-17 Filip Pizlo <fpizlo@apple.com> 2 3 JSC should detect the right default locale even when it's not embedded in WebCore 4 https://bugs.webkit.org/show_bug.cgi?id=157755 5 rdar://problem/24665424 6 7 Reviewed by Keith Miller. 8 9 This makes JSC try to use WTF's platform user preferred language detection if the DOM did 10 not register a defaultLanguage callback. The result is that when JSC runs standalone it 11 will detect the platform user preferred language almost the same way as when it's embedded 12 in WebCore. The only difference is that WebCore may have its own additional overrides via 13 the WK API. But in the absence of overrides, WebCore uses the same WTF logic that JSC falls 14 back to. 15 16 We first found this bug because on iOS, the intl tests would fail because ICU would report 17 a somewhat bogus locale on that platform. Prior to this change, standalone JSC would fall 18 back to ICU's locale detection. It turns out that the ICU default locale is also bogus on 19 OS X, just less so. For example, setting things to Poland did not result in the jsc shell 20 printing dates Polish-style. Now it will print them Polish-style if your system preferences 21 say so. Also, the tests don't fail on iOS anymore. 22 23 * runtime/IntlObject.cpp: 24 (JSC::defaultLocale): 25 1 26 2016-05-17 Dean Jackson <dino@apple.com> 2 27 -
trunk/Source/JavaScriptCore/runtime/IntlObject.cpp
r197539 r201066 2 2 * Copyright (C) 2015 Andy VanWagoner (thetalecrafter@gmail.com) 3 3 * Copyright (C) 2015 Sukolsak Sakshuwong (sukolsak@gmail.com) 4 * Copyright (C) 2016 Apple Inc. All rights reserved. 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 49 50 #include <wtf/Assertions.h> 50 51 #include <wtf/NeverDestroyed.h> 52 #include <wtf/PlatformUserPreferredLanguages.h> 51 53 52 54 namespace JSC { … … 646 648 { 647 649 // 6.2.4 DefaultLocale () 650 651 // WebCore's global objects will have their own ideas of how to determine the language. It may 652 // be determined by WebCore-specific logic like some WK settings. Usually this will return the 653 // same thing as platformUserPreferredLanguages()[0]. 648 654 if (auto defaultLanguage = state.callee()->globalObject()->globalObjectMethodTable()->defaultLanguage) { 649 655 String locale = defaultLanguage(); … … 651 657 return canonicalizeLanguageTag(locale); 652 658 } 659 660 // If WebCore isn't around to tell us how to get the language then fall back to our own way of 661 // doing it, which mostly follows what WebCore would have done. 662 Vector<String> languages = platformUserPreferredLanguages(); 663 if (!languages.isEmpty() && !languages[0].isEmpty()) 664 return canonicalizeLanguageTag(languages[0]); 665 666 // If all else fails, ask ICU. It will probably say something bogus like en_us even if the user 667 // has configured some other language, but being wrong is better than crashing. 653 668 String locale = uloc_getDefault(); 654 669 convertICULocaleToBCP47LanguageTag(locale);
Note: See TracChangeset
for help on using the changeset viewer.