Unreviewed, rolling out r128543.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Sep 2012 03:24:03 +0000 (03:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Sep 2012 03:24:03 +0000 (03:24 +0000)
http://trac.webkit.org/changeset/128543
https://bugs.webkit.org/show_bug.cgi?id=96722

Caused LocaleWinTest.localizedNumberRoundTrip to fail
(Requested by keishi on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-09-13

Source/WebCore:

* platform/text/LocaleWin.cpp:
(WebCore::determineCurrentLCID):
(WebCore):
(WebCore::LocaleWin::currentLocale):

Source/WebKit/chromium:

* tests/LocaleWinTest.cpp:
(testNumberIsReversible):
(testNumbers):
(TEST_F):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@128548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/text/LocaleWin.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/LocaleWinTest.cpp

index 65fdc8a..cabb2d9 100644 (file)
@@ -1,5 +1,19 @@
 2012-09-13  Sheriff Bot  <webkit.review.bot@gmail.com>
 
+        Unreviewed, rolling out r128543.
+        http://trac.webkit.org/changeset/128543
+        https://bugs.webkit.org/show_bug.cgi?id=96722
+
+        Caused LocaleWinTest.localizedNumberRoundTrip to fail
+        (Requested by keishi on #webkit).
+
+        * platform/text/LocaleWin.cpp:
+        (WebCore::determineCurrentLCID):
+        (WebCore):
+        (WebCore::LocaleWin::currentLocale):
+
+2012-09-13  Sheriff Bot  <webkit.review.bot@gmail.com>
+
         Unreviewed, rolling out r128531.
         http://trac.webkit.org/changeset/128531
         https://bugs.webkit.org/show_bug.cgi?id=96719
index 164462e..03331c0 100644 (file)
@@ -49,48 +49,6 @@ using namespace std;
 
 namespace WebCore {
 
-typedef LCID (WINAPI* LocaleNameToLCIDPtr)(LPCWSTR, DWORD);
-
-static String extractLanguageCode(const String& locale)
-{
-    size_t dashPosition = locale.find('-');
-    if (dashPosition == notFound)
-        return locale;
-    return locale.left(dashPosition);
-}
-
-static LCID LCIDFromLocaleInternal(LCID userDefaultLCID, const String& userDefaultLanguageCode, LocaleNameToLCIDPtr localeNameToLCID, String& locale)
-{
-    String localeLanguageCode = extractLanguageCode(locale);
-    if (equalIgnoringCase(localeLanguageCode, userDefaultLanguageCode))
-        return userDefaultLCID;
-    return localeNameToLCID(locale.charactersWithNullTermination(), 0);
-}
-
-static LCID LCIDFromLocale(const AtomicString& locale)
-{
-    // LocaleNameToLCID() is available since Windows Vista.
-    LocaleNameToLCIDPtr localeNameToLCID = reinterpret_cast<LocaleNameToLCIDPtr>(::GetProcAddress(::GetModuleHandle(L"kernel32"), "LocaleNameToLCID"));
-    if (!localeNameToLCID)
-        return LOCALE_USER_DEFAULT;
-
-    // According to MSDN, 9 is enough for LOCALE_SISO639LANGNAME.
-    const size_t languageCodeBufferSize = 9;
-    WCHAR lowercaseLanguageCode[languageCodeBufferSize];
-    ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, lowercaseLanguageCode, languageCodeBufferSize);
-    String userDefaultLanguageCode = String(lowercaseLanguageCode);
-
-    LCID lcid = LCIDFromLocaleInternal(LOCALE_USER_DEFAULT, userDefaultLanguageCode, localeNameToLCID, String(locale));
-    if (!lcid)
-        lcid = LCIDFromLocaleInternal(LOCALE_USER_DEFAULT, userDefaultLanguageCode, localeNameToLCID, defaultLanguage());
-    return lcid;
-}
-
-PassOwnPtr<Localizer> Localizer::create(const AtomicString& locale)
-{
-    return LocaleWin::create(LCIDFromLocale(locale));
-}
-
 // Windows doesn't have an API to parse locale-specific date string,
 // and GetDateFormat() and GetDateFormatEx() don't support years older
 // than 1600, which we should support according to the HTML
@@ -119,9 +77,30 @@ PassOwnPtr<LocaleWin> LocaleWin::create(LCID lcid)
     return adoptPtr(new LocaleWin(lcid));
 }
 
+static LCID determineCurrentLCID()
+{
+    LCID lcid = LOCALE_USER_DEFAULT;
+    // LocaleNameToLCID() is available since Windows Vista.
+    typedef LCID (WINAPI* LocaleNameToLCIDPtr)(LPCWSTR, DWORD);
+    LocaleNameToLCIDPtr localeNameToLCID = reinterpret_cast<LocaleNameToLCIDPtr>(::GetProcAddress(::GetModuleHandle(L"kernel32"), "LocaleNameToLCID"));
+    if (!localeNameToLCID)
+        return lcid;
+    // According to MSDN, 9 is enough for LOCALE_SISO639LANGNAME.
+    const size_t languageCodeBufferSize = 9;
+    WCHAR lowercaseLanguageCode[languageCodeBufferSize];
+    ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, lowercaseLanguageCode, languageCodeBufferSize);
+    String browserLanguage = defaultLanguage();
+    size_t dashPosition = browserLanguage.find('-');
+    if (dashPosition != notFound)
+        browserLanguage = browserLanguage.left(dashPosition);
+    if (!equalIgnoringCase(browserLanguage, String(lowercaseLanguageCode)))
+        lcid = localeNameToLCID(defaultLanguage().charactersWithNullTermination(), 0);
+    return lcid;
+}
+
 LocaleWin* LocaleWin::currentLocale()
 {
-    static LocaleWin* currentLocale = LocaleWin::create(LCIDFromLocale(defaultLanguage())).leakPtr();
+    static LocaleWin* currentLocale = LocaleWin::create(determineCurrentLCID()).leakPtr();
     return currentLocale;
 }
 
index 65018da..013742e 100644 (file)
@@ -1,3 +1,17 @@
+2012-09-13  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r128543.
+        http://trac.webkit.org/changeset/128543
+        https://bugs.webkit.org/show_bug.cgi?id=96722
+
+        Caused LocaleWinTest.localizedNumberRoundTrip to fail
+        (Requested by keishi on #webkit).
+
+        * tests/LocaleWinTest.cpp:
+        (testNumberIsReversible):
+        (testNumbers):
+        (TEST_F):
+
 2012-09-13  Keishi Hattori  <keishi@webkit.org>
 
         Create Localizer factory method for LocaleWin
index e91d762..32aaa53 100644 (file)
@@ -358,44 +358,44 @@ TEST_F(LocaleWinTest, decimalSeparator)
 }
 #endif
 
-static void testNumberIsReversible(const AtomicString& locale, const char* original, const char* shouldHave = 0)
+static void testNumberIsReversible(LCID lcid, const char* original, const char* shouldHave = 0)
 {
-    OwnPtr<Localizer> localizer = Localizer::create(locale);
-    String localized = localizer->convertToLocalizedNumber(original);
+    OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
+    String localized = locale->convertToLocalizedNumber(original);
     if (shouldHave)
         EXPECT_TRUE(localized.contains(shouldHave));
-    String converted = localizer->convertFromLocalizedNumber(localized);
+    String converted = locale->convertFromLocalizedNumber(localized);
     EXPECT_STREQ(original, converted.utf8().data());
 }
 
-void testNumbers(const AtomicString& locale)
+void testNumbers(LCID lcid)
 {
-    testNumberIsReversible(locale, "123456789012345678901234567890");
-    testNumberIsReversible(locale, "-123.456");
-    testNumberIsReversible(locale, ".456");
-    testNumberIsReversible(locale, "-0.456");
+    testNumberIsReversible(lcid, "123456789012345678901234567890");
+    testNumberIsReversible(lcid, "-123.456");
+    testNumberIsReversible(lcid, ".456");
+    testNumberIsReversible(lcid, "-0.456");
 }
 
 TEST_F(LocaleWinTest, localizedNumberRoundTrip)
 {
-    testNumberIsReversible("en-us", "123456789012345678901234567890");
-    testNumberIsReversible("en-us", "-123.456", ".");
-    testNumberIsReversible("en-us", ".456", ".");
-    testNumberIsReversible("en-us", "-0.456", ".");
-    
-    testNumberIsReversible("fr", "123456789012345678901234567890");
-    testNumberIsReversible("fr", "-123.456", ",");
-    testNumberIsReversible("fr", ".456", ",");
-    testNumberIsReversible("fr", "-0.456", ",");
+    testNumberIsReversible(EnglishUS, "123456789012345678901234567890");
+    testNumberIsReversible(EnglishUS, "-123.456", ".");
+    testNumberIsReversible(EnglishUS, ".456", ".");
+    testNumberIsReversible(EnglishUS, "-0.456", ".");
+
+    testNumberIsReversible(FrenchFR, "123456789012345678901234567890");
+    testNumberIsReversible(FrenchFR, "-123.456", ",");
+    testNumberIsReversible(FrenchFR, ".456", ",");
+    testNumberIsReversible(FrenchFR, "-0.456", ",");
 
     // Test some of major locales.
-    testNumbers("ar-eg");
-    testNumbers("de");
-    testNumbers("es");
-    testNumbers("fa");
-    testNumbers("ja");
-    testNumbers("ko");
-    testNumbers("zh-cn");
-    testNumbers("zh-hk");
-    testNumbers("zh-tw");
+    testNumbers(ArabicEG);
+    testNumbers(German);
+    testNumbers(Spanish);
+    testNumbers(Persian);
+    testNumbers(JapaneseJP);
+    testNumbers(KoreanKR);
+    testNumbers(ChineseCN);
+    testNumbers(ChineseHK);
+    testNumbers(ChineseTW);
 }