Title: [132170] trunk/Source
Revision
132170
Author
tk...@chromium.org
Date
2012-10-22 18:22:48 -0700 (Mon, 22 Oct 2012)

Log Message

Introduce Localizer::standAloneMonthLabels
https://bugs.webkit.org/show_bug.cgi?id=99963

Reviewed by Kentaro Hara.

Source/WebCore:

We realized full month names and full stand-alone month names were
necessary for input[type=month] UI. We change the compile-flag for
Localizer::monthLabels from "ENABLE(CALENDAR_PICKER)" to
"ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)," and
introduce Localizer::standAloneMonthLabels.

Tests: Add some test cases to Source/WebKit/chromium/LocaleMacTest.cpp
and LocalizedDateICUTest.cpp.

* platform/text/Localizer.h:
(Localizer):
- Add pure virtual standAloneMonthLabels.
- Change the condition for monthLabels.

* platform/text/LocaleNone.cpp:
(LocaleNone): Declare monthLabels, standAloneMonthLabels, and m_monthLabels.
(WebCore::LocaleNone::monthLabels):
Added. It always returns English month names.
(WebCore::LocaleNone::standAloneMonthLabels):
Added. Just calls monthLabels.

* platform/text/LocaleWin.h:
(LocaleWin):
Declare standAloneMonthLabels, and change the condition for monthLabels.
* platform/text/LocaleWin.cpp:
(WebCore): Change the condition for monthLabels.
(WebCore::LocaleWin::standAloneMonthLabels):
Added. Just calls monthLabels.

* platform/text/mac/LocaleMac.h:
(LocaleMac):
- Add standAloneMonthLabels and m_standAloneMonthLabels
- Change the condition for monthLabels and m_monthLabels.
* platform/text/mac/LocaleMac.mm:
(WebCore): Change the condition for monthLabels.
(WebCore::LocaleMac::standAloneMonthLabels):
Added. Get the information with NSDateFormatter::standaloneMonthSymbols.

* platform/text/LocaleICU.h:
(LocaleICU):
- Add standAloneMonthLabels and m_standAloneMonthLabels
- Change the condition for monthLabels and m_monthLabels.
* platform/text/LocaleICU.cpp:
(WebCore::LocaleICU::initializeCalendar):
Remove m_monthLabels initialization in order to avoid dependecy from monthLabels.
(WebCore):
(WebCore::createFallbackMonthLabels): Change the compile condition.
(WebCore::LocaleICU::monthLabels):
- Change the compile condition.
- Don't depend on initializeCalendar to make the code for
ENABLE(INPUT_MULTIPLE_FIELDS_UI) && !ENABLE(CALENDAR_PICKER) minimal.
(WebCore::LocaleICU::standAloneMonthLabels):
Added. The code is similar to shortStandAloneMonthLabels.

Source/WebKit/chromium:

Note that we don't add tests to LocaleWinTest because new function
LocaleWin::standAloneMonthLabels is equivalent to monthLabels.

* tests/LocaleMacTest.cpp:
(LocaleMacTest::standAloneMonthLabel): Added a helper function.
(TEST_F): Add some tests. We don't test ru_ru locale because it has
different data on OSX versions.
* tests/LocalizedDateICUTest.cpp:
(LocalizedDateICUTest::standAloneMonthLabel): Added a helper function.
(TEST_F): Add some tests.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (132169 => 132170)


--- trunk/Source/WebCore/ChangeLog	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebCore/ChangeLog	2012-10-23 01:22:48 UTC (rev 132170)
@@ -1,3 +1,64 @@
+2012-10-22  Kent Tamura  <tk...@chromium.org>
+
+        Introduce Localizer::standAloneMonthLabels
+        https://bugs.webkit.org/show_bug.cgi?id=99963
+
+        Reviewed by Kentaro Hara.
+
+        We realized full month names and full stand-alone month names were
+        necessary for input[type=month] UI. We change the compile-flag for
+        Localizer::monthLabels from "ENABLE(CALENDAR_PICKER)" to
+        "ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)," and
+        introduce Localizer::standAloneMonthLabels.
+
+        Tests: Add some test cases to Source/WebKit/chromium/LocaleMacTest.cpp
+        and LocalizedDateICUTest.cpp.
+
+        * platform/text/Localizer.h:
+        (Localizer):
+        - Add pure virtual standAloneMonthLabels.
+        - Change the condition for monthLabels.
+
+        * platform/text/LocaleNone.cpp:
+        (LocaleNone): Declare monthLabels, standAloneMonthLabels, and m_monthLabels.
+        (WebCore::LocaleNone::monthLabels):
+        Added. It always returns English month names.
+        (WebCore::LocaleNone::standAloneMonthLabels):
+        Added. Just calls monthLabels.
+
+        * platform/text/LocaleWin.h:
+        (LocaleWin):
+        Declare standAloneMonthLabels, and change the condition for monthLabels.
+        * platform/text/LocaleWin.cpp:
+        (WebCore): Change the condition for monthLabels.
+        (WebCore::LocaleWin::standAloneMonthLabels):
+        Added. Just calls monthLabels.
+
+        * platform/text/mac/LocaleMac.h:
+        (LocaleMac):
+        - Add standAloneMonthLabels and m_standAloneMonthLabels
+        - Change the condition for monthLabels and m_monthLabels.
+        * platform/text/mac/LocaleMac.mm:
+        (WebCore): Change the condition for monthLabels.
+        (WebCore::LocaleMac::standAloneMonthLabels):
+        Added. Get the information with NSDateFormatter::standaloneMonthSymbols.
+
+        * platform/text/LocaleICU.h:
+        (LocaleICU):
+        - Add standAloneMonthLabels and m_standAloneMonthLabels
+        - Change the condition for monthLabels and m_monthLabels.
+        * platform/text/LocaleICU.cpp:
+        (WebCore::LocaleICU::initializeCalendar):
+        Remove m_monthLabels initialization in order to avoid dependecy from monthLabels.
+        (WebCore):
+        (WebCore::createFallbackMonthLabels): Change the compile condition.
+        (WebCore::LocaleICU::monthLabels):
+        - Change the compile condition.
+        - Don't depend on initializeCalendar to make the code for
+        ENABLE(INPUT_MULTIPLE_FIELDS_UI) && !ENABLE(CALENDAR_PICKER) minimal.
+        (WebCore::LocaleICU::standAloneMonthLabels):
+        Added. The code is similar to shortStandAloneMonthLabels.
+
 2012-10-22  Shinya Kawanaka  <shin...@chromium.org>
 
         Refactoring around ContainerNode::attachChildren

Modified: trunk/Source/WebCore/platform/text/LocaleICU.cpp (132169 => 132170)


--- trunk/Source/WebCore/platform/text/LocaleICU.cpp	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebCore/platform/text/LocaleICU.cpp	2012-10-23 01:22:48 UTC (rev 132170)
@@ -287,15 +287,6 @@
     return labels.release();
 }
 
-static PassOwnPtr<Vector<String> > createFallbackMonthLabels()
-{
-    OwnPtr<Vector<String> > labels = adoptPtr(new Vector<String>());
-    labels->reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName));
-    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i)
-        labels->append(WTF::monthFullName[i]);
-    return labels.release();
-}
-
 static PassOwnPtr<Vector<String> > createFallbackWeekDayShortLabels()
 {
     OwnPtr<Vector<String> > labels = adoptPtr(new Vector<String>());
@@ -312,32 +303,47 @@
 
 void LocaleICU::initializeCalendar()
 {
-    if (m_monthLabels && m_weekDayShortLabels)
+    if (m_weekDayShortLabels)
         return;
 
     if (!initializeShortDateFormat()) {
         m_firstDayOfWeek = 0;
-        m_monthLabels = createFallbackMonthLabels();
         m_weekDayShortLabels = createFallbackWeekDayShortLabels();
         return;
     }
     m_firstDayOfWeek = ucal_getAttribute(udat_getCalendar(m_shortDateFormat), UCAL_FIRST_DAY_OF_WEEK) - UCAL_SUNDAY;
 
-    m_monthLabels = createLabelVector(m_shortDateFormat, UDAT_MONTHS, UCAL_JANUARY, 12);
-    if (!m_monthLabels)
-        m_monthLabels = createFallbackMonthLabels();
-
     m_weekDayShortLabels = createLabelVector(m_shortDateFormat, UDAT_SHORT_WEEKDAYS, UCAL_SUNDAY, 7);
     if (!m_weekDayShortLabels)
         m_weekDayShortLabels = createFallbackWeekDayShortLabels();
 }
+#endif
 
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+static PassOwnPtr<Vector<String> > createFallbackMonthLabels()
+{
+    OwnPtr<Vector<String> > labels = adoptPtr(new Vector<String>());
+    labels->reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName));
+    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i)
+        labels->append(WTF::monthFullName[i]);
+    return labels.release();
+}
+
 const Vector<String>& LocaleICU::monthLabels()
 {
-    initializeCalendar();
+    if (m_monthLabels)
+        return *m_monthLabels;
+    if (initializeShortDateFormat()) {
+        m_monthLabels = createLabelVector(m_shortDateFormat, UDAT_MONTHS, UCAL_JANUARY, 12);
+        if (m_monthLabels)
+            return *m_monthLabels;
+    }
+    m_monthLabels = createFallbackMonthLabels();
     return *m_monthLabels;
 }
+#endif
 
+#if ENABLE(CALENDAR_PICKER)
 const Vector<String>& LocaleICU::weekDayShortLabels()
 {
     initializeCalendar();
@@ -457,6 +463,20 @@
     return m_shortMonthLabels;
 }
 
+const Vector<String>& LocaleICU::standAloneMonthLabels()
+{
+    if (!m_standAloneMonthLabels.isEmpty())
+        return m_standAloneMonthLabels;
+    if (initializeShortDateFormat()) {
+        if (OwnPtr<Vector<String> > labels = createLabelVector(m_shortDateFormat, UDAT_STANDALONE_MONTHS, UCAL_JANUARY, 12)) {
+            m_standAloneMonthLabels = *labels;
+            return m_standAloneMonthLabels;
+        }
+    }
+    m_standAloneMonthLabels = monthLabels();
+    return m_standAloneMonthLabels;
+}
+
 const Vector<String>& LocaleICU::shortStandAloneMonthLabels()
 {
     if (!m_shortStandAloneMonthLabels.isEmpty())

Modified: trunk/Source/WebCore/platform/text/LocaleICU.h (132169 => 132170)


--- trunk/Source/WebCore/platform/text/LocaleICU.h	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebCore/platform/text/LocaleICU.h	2012-10-23 01:22:48 UTC (rev 132170)
@@ -54,18 +54,20 @@
 #if ENABLE(CALENDAR_PICKER)
     virtual String dateFormatText() OVERRIDE;
 
-    virtual const Vector<String>& monthLabels() OVERRIDE;
     virtual const Vector<String>& weekDayShortLabels() OVERRIDE;
     virtual unsigned firstDayOfWeek() OVERRIDE;
     virtual bool isRTL() OVERRIDE;
 #endif
-
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+    virtual const Vector<String>& monthLabels() OVERRIDE;
+#endif
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     virtual String dateFormat() OVERRIDE;
     virtual String monthFormat() OVERRIDE;
     virtual String timeFormat() OVERRIDE;
     virtual String shortTimeFormat() OVERRIDE;
     virtual const Vector<String>& shortMonthLabels() OVERRIDE;
+    virtual const Vector<String>& standAloneMonthLabels() OVERRIDE;
     virtual const Vector<String>& shortStandAloneMonthLabels() OVERRIDE;
     virtual const Vector<String>& timeAMPMLabels() OVERRIDE;
 #endif
@@ -103,17 +105,19 @@
 
 #if ENABLE(CALENDAR_PICKER)
     String m_localizedDateFormatText;
-    OwnPtr<Vector<String> > m_monthLabels;
     OwnPtr<Vector<String> > m_weekDayShortLabels;
     unsigned m_firstDayOfWeek;
 #endif
-
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+    OwnPtr<Vector<String> > m_monthLabels;
+#endif
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     String m_dateFormat;
     String m_monthFormat;
     UDateFormat* m_mediumTimeFormat;
     UDateFormat* m_shortTimeFormat;
     Vector<String> m_shortMonthLabels;
+    Vector<String> m_standAloneMonthLabels;
     Vector<String> m_shortStandAloneMonthLabels;
     Vector<String> m_timeAMPMLabels;
     bool m_didCreateTimeFormat;

Modified: trunk/Source/WebCore/platform/text/LocaleNone.cpp (132169 => 132170)


--- trunk/Source/WebCore/platform/text/LocaleNone.cpp	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebCore/platform/text/LocaleNone.cpp	2012-10-23 01:22:48 UTC (rev 132170)
@@ -41,14 +41,21 @@
     virtual String dateFormatText() OVERRIDE;
     virtual bool isRTL() OVERRIDE;
 #endif
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+    virtual const Vector<String>& monthLabels() OVERRIDE;
+#endif
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     virtual String dateFormat() OVERRIDE;
     virtual String monthFormat() OVERRIDE;
     virtual const Vector<String>& shortMonthLabels() OVERRIDE;
+    virtual const Vector<String>& standAloneMonthLabels() OVERRIDE;
     virtual const Vector<String>& shortStandAloneMonthLabels() OVERRIDE;
-#endif
 
     Vector<String> m_shortMonthLabels;
+#endif
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+    Vector<String> m_monthLabels;
+#endif
 };
 
 PassOwnPtr<Localizer> Localizer::create(const AtomicString&)
@@ -81,6 +88,18 @@
 }
 #endif
 
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+const Vector<String>& LocaleNone::monthLabels()
+{
+    if (!m_monthLabels.isEmpty())
+        return m_monthLabels;
+    m_monthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName));
+    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(WTF::monthFullName); ++i)
+        m_monthLabels.append(WTF::monthFullName[i]);
+    return m_monthLabels;
+}
+#endif
+
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
 String LocaleNone::dateFormat()
 {
@@ -106,6 +125,11 @@
 {
     return shortMonthLabels();
 }
+
+const Vector<String>& LocaleNone::standAloneMonthLabels()
+{
+    return monthLabels();
+}
 #endif
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/text/LocaleWin.cpp (132169 => 132170)


--- trunk/Source/WebCore/platform/text/LocaleWin.cpp	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebCore/platform/text/LocaleWin.cpp	2012-10-23 01:22:48 UTC (rev 132170)
@@ -551,13 +551,15 @@
     }
 }
 
-#if ENABLE(CALENDAR_PICKER)
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
 const Vector<String>& LocaleWin::monthLabels()
 {
     ensureMonthLabels();
     return m_monthLabels;
 }
+#endif
 
+#if ENABLE(CALENDAR_PICKER)
 const Vector<String>& LocaleWin::weekDayShortLabels()
 {
     ensureWeekDayShortLabels();
@@ -741,6 +743,12 @@
     return m_shortMonthLabels;
 }
 
+const Vector<String>& LocaleWin::standAloneMonthLabels()
+{
+    // Windows doesn't provide a way to get stand-alone month labels.
+    return monthLabels();
+}
+
 const Vector<String>& LocaleWin::shortStandAloneMonthLabels()
 {
     // Windows doesn't provide a way to get stand-alone month labels.

Modified: trunk/Source/WebCore/platform/text/LocaleWin.h (132169 => 132170)


--- trunk/Source/WebCore/platform/text/LocaleWin.h	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebCore/platform/text/LocaleWin.h	2012-10-23 01:22:48 UTC (rev 132170)
@@ -49,18 +49,20 @@
     virtual double parseDateTime(const String&, DateComponents::Type) OVERRIDE;
 #if ENABLE(CALENDAR_PICKER)
     virtual String dateFormatText() OVERRIDE;
-    virtual const Vector<String>& monthLabels() OVERRIDE;
     virtual const Vector<String>& weekDayShortLabels() OVERRIDE;
     virtual unsigned firstDayOfWeek() OVERRIDE;
     virtual bool isRTL() OVERRIDE;
 #endif
-
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+    virtual const Vector<String>& monthLabels() OVERRIDE;
+#endif
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     virtual String dateFormat() OVERRIDE;
     virtual String monthFormat() OVERRIDE;
     virtual String timeFormat() OVERRIDE;
     virtual String shortTimeFormat() OVERRIDE;
     virtual const Vector<String>& shortMonthLabels() OVERRIDE;
+    virtual const Vector<String>& standAloneMonthLabels() OVERRIDE;
     virtual const Vector<String>& shortStandAloneMonthLabels() OVERRIDE;
     virtual const Vector<String>& timeAMPMLabels() OVERRIDE;
 #endif

Modified: trunk/Source/WebCore/platform/text/Localizer.h (132169 => 132170)


--- trunk/Source/WebCore/platform/text/Localizer.h	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebCore/platform/text/Localizer.h	2012-10-23 01:22:48 UTC (rev 132170)
@@ -88,6 +88,12 @@
     // Dec. These strings should be short.
     virtual const Vector<String>& shortMonthLabels() = 0;
 
+    // Returns a vector of string of which size is 12. The first item is a
+    // stand-alone localized string of January and the last item is a
+    // stand-alone localized string of December. These strings should not be
+    // abbreviations.
+    virtual const Vector<String>& standAloneMonthLabels() = 0;
+
     // Stand-alone month version of shortMonthLabels.
     virtual const Vector<String>& shortStandAloneMonthLabels() = 0;
 
@@ -95,12 +101,14 @@
     virtual const Vector<String>& timeAMPMLabels();
 #endif
 
-#if ENABLE(CALENDAR_PICKER)
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     // Returns a vector of string of which size is 12. The first item is a
     // localized string of January, and the last item is a localized string of
     // December. These strings should not be abbreviations.
     virtual const Vector<String>& monthLabels() = 0;
+#endif
 
+#if ENABLE(CALENDAR_PICKER)
     // Returns a vector of string of which size is 7. The first item is a
     // localized short string of Monday, and the last item is a localized
     // short string of Saturday. These strings should be short.

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


--- trunk/Source/WebCore/platform/text/mac/LocaleMac.h	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebCore/platform/text/mac/LocaleMac.h	2012-10-23 01:22:48 UTC (rev 132170)
@@ -54,11 +54,13 @@
 
 #if ENABLE(CALENDAR_PICKER)
     virtual String dateFormatText() OVERRIDE;
-    virtual const Vector<String>& monthLabels() OVERRIDE;
     virtual const Vector<String>& weekDayShortLabels() OVERRIDE;
     virtual unsigned firstDayOfWeek() OVERRIDE;
     virtual bool isRTL() OVERRIDE;
 #endif
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+    virtual const Vector<String>& monthLabels() OVERRIDE;
+#endif
 
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     virtual String dateFormat() OVERRIDE;
@@ -66,6 +68,7 @@
     virtual String timeFormat() OVERRIDE;
     virtual String shortTimeFormat() OVERRIDE;
     virtual const Vector<String>& shortMonthLabels() OVERRIDE;
+    virtual const Vector<String>& standAloneMonthLabels() OVERRIDE;
     virtual const Vector<String>& shortStandAloneMonthLabels() OVERRIDE;
     virtual const Vector<String>& timeAMPMLabels() OVERRIDE;
 #endif
@@ -79,9 +82,11 @@
     RetainPtr<NSCalendar> m_gregorianCalendar;
 #if ENABLE(CALENDAR_PICKER)
     String m_localizedDateFormatText;
-    Vector<String> m_monthLabels;
     Vector<String> m_weekDayShortLabels;
 #endif
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+    Vector<String> m_monthLabels;
+#endif
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     RetainPtr<NSDateFormatter> timeFormatter();
     RetainPtr<NSDateFormatter> shortTimeFormatter();
@@ -91,6 +96,7 @@
     String m_localizedTimeFormatText;
     String m_localizedShortTimeFormatText;
     Vector<String> m_shortMonthLabels;
+    Vector<String> m_standAloneMonthLabels;
     Vector<String> m_shortStandAloneMonthLabels;
     Vector<String> m_timeAMPMLabels;
 #endif

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


--- trunk/Source/WebCore/platform/text/mac/LocaleMac.mm	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebCore/platform/text/mac/LocaleMac.mm	2012-10-23 01:22:48 UTC (rev 132170)
@@ -178,7 +178,9 @@
     m_localizedDateFormatText = localizeDateFormat([shortDateFormatter().get() dateFormat]);
     return  m_localizedDateFormatText;
 }
+#endif
 
+#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
 const Vector<String>& LocaleMac::monthLabels()
 {
     if (!m_monthLabels.isEmpty())
@@ -194,7 +196,9 @@
         m_monthLabels.append(WTF::monthFullName[i]);
     return m_monthLabels;
 }
+#endif
 
+#if ENABLE(CALENDAR_PICKER)
 const Vector<String>& LocaleMac::weekDayShortLabels()
 {
     if (!m_weekDayShortLabels.isEmpty())
@@ -288,6 +292,21 @@
     return m_shortMonthLabels;
 }
 
+const Vector<String>& LocaleMac::standAloneMonthLabels()
+{
+    if (!m_standAloneMonthLabels.isEmpty())
+        return m_standAloneMonthLabels;
+    NSArray *array = [shortDateFormatter().get() standaloneMonthSymbols];
+    if ([array count] == 12) {
+        m_standAloneMonthLabels.reserveCapacity(12);
+        for (unsigned i = 0; i < 12; ++i)
+            m_standAloneMonthLabels.append([array objectAtIndex:i]);
+        return m_standAloneMonthLabels;
+    }
+    m_standAloneMonthLabels = shortMonthLabels();
+    return m_standAloneMonthLabels;
+}
+
 const Vector<String>& LocaleMac::shortStandAloneMonthLabels()
 {
     if (!m_shortStandAloneMonthLabels.isEmpty())

Modified: trunk/Source/WebKit/chromium/ChangeLog (132169 => 132170)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-10-23 01:22:48 UTC (rev 132170)
@@ -1,3 +1,21 @@
+2012-10-22  Kent Tamura  <tk...@chromium.org>
+
+        Introduce Localizer::standAloneMonthLabels
+        https://bugs.webkit.org/show_bug.cgi?id=99963
+
+        Reviewed by Kentaro Hara.
+
+        Note that we don't add tests to LocaleWinTest because new function
+        LocaleWin::standAloneMonthLabels is equivalent to monthLabels.
+
+        * tests/LocaleMacTest.cpp:
+        (LocaleMacTest::standAloneMonthLabel): Added a helper function.
+        (TEST_F): Add some tests. We don't test ru_ru locale because it has
+        different data on OSX versions.
+        * tests/LocalizedDateICUTest.cpp:
+        (LocalizedDateICUTest::standAloneMonthLabel): Added a helper function.
+        (TEST_F): Add some tests.
+
 2012-10-22  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r132119.

Modified: trunk/Source/WebKit/chromium/tests/LocaleMacTest.cpp (132169 => 132170)


--- trunk/Source/WebKit/chromium/tests/LocaleMacTest.cpp	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebKit/chromium/tests/LocaleMacTest.cpp	2012-10-23 01:22:48 UTC (rev 132170)
@@ -144,6 +144,12 @@
         return locale->shortMonthLabels()[index];
     }
 
+    String standAloneMonthLabel(const String& localeString, unsigned index)
+    {
+        OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
+        return locale->standAloneMonthLabels()[index];
+    }
+
     String shortStandAloneMonthLabel(const String& localeString, unsigned index)
     {
         OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
@@ -278,6 +284,21 @@
     EXPECT_STREQ("H:mm", shortTimeFormat("ja_JP").utf8().data());
 }
 
+TEST_F(LocaleMacTest, standAloneMonthLabels)
+{
+    EXPECT_STREQ("January", standAloneMonthLabel("en_US", January).utf8().data());
+    EXPECT_STREQ("June", standAloneMonthLabel("en_US", June).utf8().data());
+    EXPECT_STREQ("December", standAloneMonthLabel("en_US", December).utf8().data());
+
+    EXPECT_STREQ("janvier", standAloneMonthLabel("fr_FR", January).utf8().data());
+    EXPECT_STREQ("juin", standAloneMonthLabel("fr_FR", June).utf8().data());
+    EXPECT_STREQ("d\xC3\xA9" "cembre", standAloneMonthLabel("fr_FR", December).utf8().data());
+
+    EXPECT_STREQ("1\xE6\x9C\x88", standAloneMonthLabel("ja_JP", January).utf8().data());
+    EXPECT_STREQ("6\xE6\x9C\x88", standAloneMonthLabel("ja_JP", June).utf8().data());
+    EXPECT_STREQ("12\xE6\x9C\x88", standAloneMonthLabel("ja_JP", December).utf8().data());
+}
+
 TEST_F(LocaleMacTest, shortMonthLabels)
 {
     EXPECT_STREQ("Jan", shortMonthLabel("en_US", 0).utf8().data());

Modified: trunk/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp (132169 => 132170)


--- trunk/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp	2012-10-23 00:58:14 UTC (rev 132169)
+++ trunk/Source/WebKit/chromium/tests/LocalizedDateICUTest.cpp	2012-10-23 01:22:48 UTC (rev 132170)
@@ -118,6 +118,12 @@
         return locale->shortStandAloneMonthLabels()[index];
     }
 
+    String standAloneMonthLabel(const char* localeString, unsigned index)
+    {
+        OwnPtr<LocaleICU> locale = LocaleICU::create(localeString);
+        return locale->standAloneMonthLabels()[index];
+    }
+
     Labels timeAMPMLabels(const char* localeString)
     {
         OwnPtr<LocaleICU> locale = LocaleICU::create(localeString);
@@ -166,6 +172,24 @@
     EXPECT_STREQ("H:mm", localizedShortDateFormatText("ja").utf8().data());
 }
 
+TEST_F(LocalizedDateICUTest, standAloneMonthLabels)
+{
+    EXPECT_STREQ("January", standAloneMonthLabel("en_US", 0).utf8().data());
+    EXPECT_STREQ("June", standAloneMonthLabel("en_US", 5).utf8().data());
+    EXPECT_STREQ("December", standAloneMonthLabel("en_US", 11).utf8().data());
+
+    EXPECT_STREQ("janvier", standAloneMonthLabel("fr_FR", 0).utf8().data());
+    EXPECT_STREQ("juin", standAloneMonthLabel("fr_FR", 5).utf8().data());
+    EXPECT_STREQ("d\xC3\xA9" "cembre", standAloneMonthLabel("fr_FR", 11).utf8().data());
+
+    EXPECT_STREQ("1\xE6\x9C\x88", standAloneMonthLabel("ja_JP", 0).utf8().data());
+    EXPECT_STREQ("6\xE6\x9C\x88", standAloneMonthLabel("ja_JP", 5).utf8().data());
+    EXPECT_STREQ("12\xE6\x9C\x88", standAloneMonthLabel("ja_JP", 11).utf8().data());
+
+    EXPECT_STREQ("\xD0\x9C\xD0\xB0\xD1\x80\xD1\x82", standAloneMonthLabel("ru_RU", 2).utf8().data());
+    EXPECT_STREQ("\xD0\x9C\xD0\xB0\xD0\xB9", standAloneMonthLabel("ru_RU", 4).utf8().data());
+}
+
 TEST_F(LocalizedDateICUTest, shortMonthLabels)
 {
     EXPECT_STREQ("Jan", shortMonthLabel("en_US", 0).utf8().data());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to