Title: [121404] trunk/Source
Revision
121404
Author
yo...@chromium.org
Date
2012-06-27 21:58:07 -0700 (Wed, 27 Jun 2012)

Log Message

[Platform] Implement localizedDecimalSeparator function
https://bugs.webkit.org/show_bug.cgi?id=90036

Reviewed by Kent Tamura.

Source/WebCore:

This patch introduces new function localizedDecimalSeparator() when
ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS). It will be used for
displaying millisecond for time fields UI.

Test: WebKit/chromium/tests/LocalizedNumberICUTest.cpp

* platform/text/LocaleICU.cpp:
(WebCore::LocaleICU::localizedDecimalSeparator): Added
* platform/text/LocaleICU.h:
(LocaleICU): Added localizedDecimalSeparator.
* platform/text/LocalizedNumber.h:
* platform/text/LocalizedNumberICU.cpp:
(WebCore::localizedDecimalSeparator): Added.
* platform/text/LocalizedNumberNone.cpp:
(WebCore::localizedDecimalSeparator): Added.
* platform/text/mac/LocalizedNumberMac.mm:
(WebCore::localizedDecimalSeparator): Added.

Source/WebKit/chromium:

This patch adds test case for localizedDecimalSeparator().

* tests/LocalizedNumberICUTest.cpp:
(testDecimalSeparator):
(TEST):

Modified Paths

Property Changed

Diff

Modified: trunk/Source/WebCore/ChangeLog (121403 => 121404)


--- trunk/Source/WebCore/ChangeLog	2012-06-28 04:49:53 UTC (rev 121403)
+++ trunk/Source/WebCore/ChangeLog	2012-06-28 04:58:07 UTC (rev 121404)
@@ -1,3 +1,28 @@
+2012-06-27  Yoshifumi Inoue  <yo...@chromium.org>
+
+        [Platform] Implement localizedDecimalSeparator function
+        https://bugs.webkit.org/show_bug.cgi?id=90036
+
+        Reviewed by Kent Tamura.
+
+        This patch introduces new function localizedDecimalSeparator() when
+        ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS). It will be used for
+        displaying millisecond for time fields UI.
+
+        Test: WebKit/chromium/tests/LocalizedNumberICUTest.cpp
+
+        * platform/text/LocaleICU.cpp:
+        (WebCore::LocaleICU::localizedDecimalSeparator): Added
+        * platform/text/LocaleICU.h:
+        (LocaleICU): Added localizedDecimalSeparator.
+        * platform/text/LocalizedNumber.h:
+        * platform/text/LocalizedNumberICU.cpp:
+        (WebCore::localizedDecimalSeparator): Added.
+        * platform/text/LocalizedNumberNone.cpp:
+        (WebCore::localizedDecimalSeparator): Added.
+        * platform/text/mac/LocalizedNumberMac.mm:
+        (WebCore::localizedDecimalSeparator): Added.
+
 2012-06-27  Lu Guanqun  <guanqun...@intel.com>
 
         Add OVERRIDE to functions in UnthrottledTextureUploader class
Property changes on: trunk/Source/WebCore/ChangeLog
___________________________________________________________________

Deleted: svn:executable

Modified: trunk/Source/WebCore/platform/text/LocaleICU.cpp (121403 => 121404)


--- trunk/Source/WebCore/platform/text/LocaleICU.cpp	2012-06-28 04:49:53 UTC (rev 121403)
+++ trunk/Source/WebCore/platform/text/LocaleICU.cpp	2012-06-28 04:58:07 UTC (rev 121404)
@@ -493,5 +493,15 @@
 }
 #endif
 
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+
+String LocaleICU::localizedDecimalSeparator()
+{
+    initializeDecimalFormat();
+    return m_decimalSymbols[DecimalSeparatorIndex];
+}
+
+#endif
+
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/platform/text/LocaleICU.h (121403 => 121404)


--- trunk/Source/WebCore/platform/text/LocaleICU.h	2012-06-28 04:49:53 UTC (rev 121403)
+++ trunk/Source/WebCore/platform/text/LocaleICU.h	2012-06-28 04:58:07 UTC (rev 121404)
@@ -52,6 +52,9 @@
     // For LocalizedNumber
     String convertToLocalizedNumber(const String&);
     String convertFromLocalizedNumber(const String&);
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+    String localizedDecimalSeparator();
+#endif
 
     // For LocalizedDate
     double parseLocalizedDate(const String&);

Modified: trunk/Source/WebCore/platform/text/LocalizedNumber.h (121403 => 121404)


--- trunk/Source/WebCore/platform/text/LocalizedNumber.h	2012-06-28 04:49:53 UTC (rev 121403)
+++ trunk/Source/WebCore/platform/text/LocalizedNumber.h	2012-06-28 04:58:07 UTC (rev 121404)
@@ -50,6 +50,12 @@
 // responsible to check the format of the resultant string.
 String convertFromLocalizedNumber(const String&);
 
+
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+// Returns localized decimal separator, e.g. "." for English, "," for French.
+String localizedDecimalSeparator();
+#endif
+
 } // namespace WebCore
 
 #endif // LocalizedNumber_h

Modified: trunk/Source/WebCore/platform/text/LocalizedNumberICU.cpp (121403 => 121404)


--- trunk/Source/WebCore/platform/text/LocalizedNumberICU.cpp	2012-06-28 04:49:53 UTC (rev 121403)
+++ trunk/Source/WebCore/platform/text/LocalizedNumberICU.cpp	2012-06-28 04:58:07 UTC (rev 121404)
@@ -45,4 +45,12 @@
     return LocaleICU::currentLocale()->convertFromLocalizedNumber(localizedNumberString);
 }
 
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+
+String localizedDecimalSeparator()
+{
+    return LocaleICU::currentLocale()->localizedDecimalSeparator();
+}
+
+#endif
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/text/LocalizedNumberNone.cpp (121403 => 121404)


--- trunk/Source/WebCore/platform/text/LocalizedNumberNone.cpp	2012-06-28 04:49:53 UTC (rev 121403)
+++ trunk/Source/WebCore/platform/text/LocalizedNumberNone.cpp	2012-06-28 04:58:07 UTC (rev 121404)
@@ -47,4 +47,13 @@
     return localizedNumberString;
 }
 
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+
+UChar localizedDecimalSeparator()
+{
+    return '.';
+}
+
+#endif
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/text/mac/LocalizedNumberMac.mm (121403 => 121404)


--- trunk/Source/WebCore/platform/text/mac/LocalizedNumberMac.mm	2012-06-28 04:49:53 UTC (rev 121403)
+++ trunk/Source/WebCore/platform/text/mac/LocalizedNumberMac.mm	2012-06-28 04:58:07 UTC (rev 121404)
@@ -116,5 +116,15 @@
     return String(numberToString(doubleValue, buffer));
 }
 
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+
+String localizedDecimalSeparator()
+{
+    RetainPtr<NSNumberFormatter> formatter = numberFormatterForDisplay();
+    return String([formatter.get() decimalSeparator]);
+}
+
+#endif
+
 } // namespace WebCore
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (121403 => 121404)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-06-28 04:49:53 UTC (rev 121403)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-06-28 04:58:07 UTC (rev 121404)
@@ -1,3 +1,16 @@
+2012-06-27  Yoshifumi Inoue  <yo...@chromium.org>
+
+        [Platform] Implement localizedDecimalSeparator function
+        https://bugs.webkit.org/show_bug.cgi?id=90036
+
+        Reviewed by Kent Tamura.
+
+        This patch adds test case for localizedDecimalSeparator().
+
+        * tests/LocalizedNumberICUTest.cpp:
+        (testDecimalSeparator):
+        (TEST):
+
 2012-06-27  Yusuke Sato  <yusu...@chromium.org>
 
         [chromium] Improve keyboardEvent() so a web page could receive a DOM3 spec compliant keyboard event.

Modified: trunk/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp (121403 => 121404)


--- trunk/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp	2012-06-28 04:49:53 UTC (rev 121403)
+++ trunk/Source/WebKit/chromium/tests/LocalizedNumberICUTest.cpp	2012-06-28 04:58:07 UTC (rev 121404)
@@ -79,3 +79,19 @@
     testNumbers("zh_HK");
     testNumbers("zh_TW");
 }
+
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+
+static String testDecimalSeparator(const char* localeString)
+{
+    OwnPtr<LocaleICU> locale = LocaleICU::create(localeString);
+    return locale->localizedDecimalSeparator();
+}
+
+TEST(LocalizedNumberICUTest, localizedDecimalSeparator)
+{
+    EXPECT_EQ(String("."), testDecimalSeparator("en_US"));
+    EXPECT_EQ(String(","), testDecimalSeparator("fr"));
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to