Title: [124721] trunk/Source/WebCore
- Revision
- 124721
- Author
- [email protected]
- Date
- 2012-08-05 18:12:43 -0700 (Sun, 05 Aug 2012)
Log Message
[Chromium-win] Use the default locale only if the browser locale matches to it
https://bugs.webkit.org/show_bug.cgi?id=93083
Reviewed by Hajime Morita.
For a calendar picker, we have used month names and day-of-week names
obtained from the OS default locale. However, the year-month format and
[Today] [Clear] labels are decided with the browser locale. It made
calendar pickers with mixed languages.
To make calendar pickers with a single language, we use the OS default
locale only if the browser locale matches to it.
This patch changes the behavior for Windows Vista or later. No change
for Windows XP because of API support limitation.
No new tests. Behavior for locale setting is not testable in WebKit.
* platform/text/LocaleWin.cpp:
(determineCurrentLCID):
Added. If the system has no LocaleNameToLCID API, just returns
LOCALE_USER_DEFAULT. Otherwise, if the system locale matches to the
browser locale, it returns LOCALE_USER_DEFAULT, otherwise it returns the
LCID for the browser locale.
(WebCore::LocaleWin::currentLocale): Uses determineCurrentLCID().
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (124720 => 124721)
--- trunk/Source/WebCore/ChangeLog 2012-08-05 21:03:42 UTC (rev 124720)
+++ trunk/Source/WebCore/ChangeLog 2012-08-06 01:12:43 UTC (rev 124721)
@@ -1,3 +1,30 @@
+2012-08-03 Kent Tamura <[email protected]>
+
+ [Chromium-win] Use the default locale only if the browser locale matches to it
+ https://bugs.webkit.org/show_bug.cgi?id=93083
+
+ Reviewed by Hajime Morita.
+
+ For a calendar picker, we have used month names and day-of-week names
+ obtained from the OS default locale. However, the year-month format and
+ [Today] [Clear] labels are decided with the browser locale. It made
+ calendar pickers with mixed languages.
+
+ To make calendar pickers with a single language, we use the OS default
+ locale only if the browser locale matches to it.
+ This patch changes the behavior for Windows Vista or later. No change
+ for Windows XP because of API support limitation.
+
+ No new tests. Behavior for locale setting is not testable in WebKit.
+
+ * platform/text/LocaleWin.cpp:
+ (determineCurrentLCID):
+ Added. If the system has no LocaleNameToLCID API, just returns
+ LOCALE_USER_DEFAULT. Otherwise, if the system locale matches to the
+ browser locale, it returns LOCALE_USER_DEFAULT, otherwise it returns the
+ LCID for the browser locale.
+ (WebCore::LocaleWin::currentLocale): Uses determineCurrentLCID().
+
2012-08-05 Antti Koivisto <[email protected]>
Don't reuse cached stylesheet with failed or canceled resource loads
Modified: trunk/Source/WebCore/platform/text/LocaleWin.cpp (124720 => 124721)
--- trunk/Source/WebCore/platform/text/LocaleWin.cpp 2012-08-05 21:03:42 UTC (rev 124720)
+++ trunk/Source/WebCore/platform/text/LocaleWin.cpp 2012-08-06 01:12:43 UTC (rev 124721)
@@ -35,6 +35,7 @@
#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
#include "DateTimeFormat.h"
#endif
+#include "Language.h"
#include "LocalizedStrings.h"
#include <limits>
#include <windows.h>
@@ -75,11 +76,30 @@
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()
{
- // Ideally we should make LCID from defaultLanguage(). But
- // ::LocaleNameToLCID() is available since Windows Vista.
- static LocaleWin* currentLocale = LocaleWin::create(LOCALE_USER_DEFAULT).leakPtr();
+ static LocaleWin* currentLocale = LocaleWin::create(determineCurrentLCID()).leakPtr();
return currentLocale;
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes