Title: [129480] trunk/Source/WebCore
Revision
129480
Author
[email protected]
Date
2012-09-25 02:39:31 -0700 (Tue, 25 Sep 2012)

Log Message

REGRESSION(r129448): multiple fields time input UI doesn't use system time format settings on Chromium-Mac
https://bugs.webkit.org/show_bug.cgi?id=97517

Reviewed by Kent Tamura.

We need to locale [NSLocale currentLocale] if browser language/@lang equals [[NSLocal currentLocale] localeIdentifier]. Otherwise it won't use the custom time format that the user has set.

No new tests. Unable to test because we need to change system locale settings.

* platform/text/mac/LocaleMac.h:
(LocaleMac):
* platform/text/mac/LocaleMac.mm:
(WebCore::languageFromLocale): Moved to top.
(WebCore):
(WebCore::determineLocale): Modified so it takes a locale as an argument.
(WebCore::Localizer::create):
(WebCore::LocaleMac::LocaleMac): Added checks for invalid locales to this constructor and removed the other one so we don't have duplicated code.
(WebCore::LocaleMac::create):
(WebCore::LocaleMac::currentLocale):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (129479 => 129480)


--- trunk/Source/WebCore/ChangeLog	2012-09-25 09:19:57 UTC (rev 129479)
+++ trunk/Source/WebCore/ChangeLog	2012-09-25 09:39:31 UTC (rev 129480)
@@ -1,3 +1,25 @@
+2012-09-25  Keishi Hattori  <[email protected]>
+
+        REGRESSION(r129448): multiple fields time input UI doesn't use system time format settings on Chromium-Mac
+        https://bugs.webkit.org/show_bug.cgi?id=97517
+
+        Reviewed by Kent Tamura.
+
+        We need to locale [NSLocale currentLocale] if browser language/@lang equals [[NSLocal currentLocale] localeIdentifier]. Otherwise it won't use the custom time format that the user has set.
+
+        No new tests. Unable to test because we need to change system locale settings.
+
+        * platform/text/mac/LocaleMac.h:
+        (LocaleMac):
+        * platform/text/mac/LocaleMac.mm:
+        (WebCore::languageFromLocale): Moved to top.
+        (WebCore):
+        (WebCore::determineLocale): Modified so it takes a locale as an argument.
+        (WebCore::Localizer::create):
+        (WebCore::LocaleMac::LocaleMac): Added checks for invalid locales to this constructor and removed the other one so we don't have duplicated code.
+        (WebCore::LocaleMac::create):
+        (WebCore::LocaleMac::currentLocale):
+
 2012-09-20  Alexander Pavlov  <[email protected]>
 
         Web Inspector: Relative URL Link Tooltips do not respect <base>

Modified: trunk/Source/WebCore/platform/text/mac/LocaleMac.h (129479 => 129480)


--- trunk/Source/WebCore/platform/text/mac/LocaleMac.h	2012-09-25 09:19:57 UTC (rev 129479)
+++ trunk/Source/WebCore/platform/text/mac/LocaleMac.h	2012-09-25 09:39:31 UTC (rev 129480)
@@ -47,6 +47,7 @@
 class LocaleMac : public Localizer {
 public:
     static PassOwnPtr<LocaleMac> create(const String&);
+    static PassOwnPtr<LocaleMac> create(NSLocale*);
     static LocaleMac* currentLocale();
     ~LocaleMac();
     double parseDate(const String&);
@@ -67,7 +68,6 @@
 
 private:
     explicit LocaleMac(NSLocale*);
-    explicit LocaleMac(const String&);
     NSDateFormatter *createShortDateFormatter();
     virtual void initializeLocalizerData() OVERRIDE;
 

Modified: trunk/Source/WebCore/platform/text/mac/LocaleMac.mm (129479 => 129480)


--- trunk/Source/WebCore/platform/text/mac/LocaleMac.mm	2012-09-25 09:19:57 UTC (rev 129479)
+++ trunk/Source/WebCore/platform/text/mac/LocaleMac.mm	2012-09-25 09:39:31 UTC (rev 129480)
@@ -45,9 +45,30 @@
 
 namespace WebCore {
 
+static inline String languageFromLocale(const String& locale)
+{
+    String normalizedLocale = locale;
+    normalizedLocale.replace('-', '_');
+    size_t separatorPosition = normalizedLocale.find('_');
+    if (separatorPosition == notFound)
+        return normalizedLocale;
+    return normalizedLocale.left(separatorPosition);
+}
+
+static NSLocale* determineLocale(const String& locale)
+{
+    NSLocale* currentLocale = [NSLocale currentLocale];
+    String currentLocaleLanguage = languageFromLocale(String([currentLocale localeIdentifier]));
+    String localeLanguage = languageFromLocale(locale);
+    if (equalIgnoringCase(currentLocaleLanguage, localeLanguage))
+        return currentLocale;
+    // It seems initWithLocaleIdentifier accepts dash-separated locale identifier.
+    return [[NSLocale alloc] initWithLocaleIdentifier:locale];
+}
+
 PassOwnPtr<Localizer> Localizer::create(const AtomicString& locale)
 {
-    return LocaleMac::create(locale.string());
+    return LocaleMac::create(determineLocale(locale.string()));
 }
 
 static NSDateFormatter* createDateTimeFormatter(NSLocale* locale, NSDateFormatterStyle dateStyle, NSDateFormatterStyle timeStyle)
@@ -65,12 +86,6 @@
     : m_locale(locale)
     , m_didInitializeNumberData(false)
 {
-}
-
-LocaleMac::LocaleMac(const String& localeIdentifier)
-    : m_locale([[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier])
-    , m_didInitializeNumberData(false)
-{
     NSArray* availableLanguages = [NSLocale ISOLanguageCodes];
     // NSLocale returns a lower case NSLocaleLanguageCode so we don't have care about case.
     NSString* language = [m_locale.get() objectForKey:NSLocaleLanguageCode];
@@ -84,33 +99,17 @@
 
 PassOwnPtr<LocaleMac> LocaleMac::create(const String& localeIdentifier)
 {
-    return adoptPtr(new LocaleMac(localeIdentifier));
+    return adoptPtr(new LocaleMac([[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier]));
 }
 
-static inline String languageFromLocale(const String& locale)
+PassOwnPtr<LocaleMac> LocaleMac::create(NSLocale* locale)
 {
-    String normalizedLocale = locale;
-    normalizedLocale.replace('-', '_');
-    size_t separatorPosition = normalizedLocale.find('_');
-    if (separatorPosition == notFound)
-        return normalizedLocale;
-    return normalizedLocale.left(separatorPosition);
+    return adoptPtr(new LocaleMac(locale));
 }
 
-static NSLocale* determineLocale()
-{
-    NSLocale* currentLocale = [NSLocale currentLocale];
-    String currentLocaleLanguage = languageFromLocale(String([currentLocale localeIdentifier]));
-    String browserLanguage = languageFromLocale(defaultLanguage());
-    if (equalIgnoringCase(currentLocaleLanguage, browserLanguage))
-        return currentLocale;
-    // It seems initWithLocaleIdentifier accepts dash-separated locale identifier.
-    return [[NSLocale alloc] initWithLocaleIdentifier:defaultLanguage()];
-}
-
 LocaleMac* LocaleMac::currentLocale()
 {
-    static LocaleMac* currentLocale = new LocaleMac(determineLocale());
+    static LocaleMac* currentLocale = new LocaleMac(determineLocale(defaultLanguage()));
     return currentLocale;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to