Changeset 121415 in webkit
- Timestamp:
- Jun 28, 2012 12:30:11 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r121412 r121415 1 2012-06-28 Yoshifumi Inoue <yosin@chromium.org> 2 3 [Platform] Implement functions for localized time format information 4 https://bugs.webkit.org/show_bug.cgi?id=89965 5 6 Reviewed by Kent Tamura. 7 8 This patch introduces three functions for time format: 9 1. localizedTimeFormatText() 10 2. localizedShortTimeFormatText() 11 2. timeAMPMLabels() 12 for input type "time" if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS) is true. 13 14 Having both localizedTimeFormat and localizedShortTimeFormat is for 15 displaying only two fields hour and minute when step >= 60. There is 16 no way to remove second field from "h:m:s" pattern string. We don't 17 know whether ":" after "m" belongs minute or second field. 18 19 Test: WebKit/chromium/tests/LocalizedDateICUTest.cpp 20 21 * platform/text/LocaleICU.cpp: 22 (WebCore::LocaleICU::LocaleICU): 23 (WebCore::createFallbackAMPMLabels): Added. 24 (WebCore::LocaleICU::initializeDateTimeFormat): Added. 25 (WebCore::LocaleICU::localizedTimeFormatText): Added. 26 (WebCore::LocaleICU::localizedShortTimeFormatText): Added. 27 (WebCore::LocaleICU::timeAMPMLabels): Added. 28 * platform/text/LocaleICU.h: 29 (LocaleICU): 30 * platform/text/LocalizedDate.h: 31 * platform/text/LocalizedDateICU.cpp: 32 (WebCore::localizedTimeFormatText): Added. 33 (WebCore::localizedShortTimeFormatText): Added. 34 (WebCore::timeAMPMLabels): Added. 35 1 36 2012-06-27 Kentaro Hara <haraken@chromium.org> 2 37 -
trunk/Source/WebCore/platform/text/LocaleICU.cpp
r121404 r121415 52 52 , m_firstDayOfWeek(0) 53 53 #endif 54 #if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS) 55 , m_mediumTimeFormat(0) 56 , m_shortTimeFormat(0) 57 , m_didCreateTimeFormat(false) 58 #endif 54 59 { 55 60 } … … 318 323 } 319 324 320 #if ENABLE(CALENDAR_PICKER) 325 #if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS) 321 326 static String getDateFormatPattern(const UDateFormat* dateFormat) 322 327 { … … 335 340 return String::adopt(buffer); 336 341 } 337 342 #endif 343 344 #if ENABLE(CALENDAR_PICKER) 338 345 static inline bool isICUYearSymbol(UChar letter) 339 346 { … … 502 509 } 503 510 511 static PassOwnPtr<Vector<String> > createFallbackAMPMLabels() 512 { 513 OwnPtr<Vector<String> > labels = adoptPtr(new Vector<String>()); 514 labels->reserveCapacity(2); 515 labels->append("AM"); 516 labels->append("PM"); 517 return labels.release(); 518 } 519 520 void LocaleICU::initializeDateTimeFormat() 521 { 522 if (m_didCreateTimeFormat) 523 return; 524 525 // We assume ICU medium time pattern and short time pattern are compatible 526 // with LDML, because ICU specific pattern character "V" doesn't appear 527 // in both medium and short time pattern. 528 m_mediumTimeFormat = openDateFormat(UDAT_MEDIUM, UDAT_NONE); 529 m_localizedTimeFormatText = getDateFormatPattern(m_mediumTimeFormat); 530 531 m_shortTimeFormat = openDateFormat(UDAT_SHORT, UDAT_NONE); 532 m_localizedShortTimeFormatText = getDateFormatPattern(m_shortTimeFormat); 533 534 m_timeAMPMLabels = createLabelVector(m_mediumTimeFormat, UDAT_AM_PMS, UCAL_AM, 2); 535 if (!m_timeAMPMLabels) 536 m_timeAMPMLabels = createFallbackAMPMLabels(); 537 538 m_didCreateTimeFormat = true; 539 } 540 541 String LocaleICU::localizedTimeFormatText() 542 { 543 initializeDateTimeFormat(); 544 return m_localizedTimeFormatText; 545 } 546 547 String LocaleICU::localizedShortTimeFormatText() 548 { 549 initializeDateTimeFormat(); 550 return m_localizedShortTimeFormatText; 551 } 552 553 const Vector<String>& LocaleICU::timeAMPMLabels() 554 { 555 initializeDateTimeFormat(); 556 return *m_timeAMPMLabels; 557 } 558 504 559 #endif 505 560 -
trunk/Source/WebCore/platform/text/LocaleICU.h
r121404 r121415 68 68 #endif 69 69 70 #if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS) 71 String localizedTimeFormatText(); 72 String localizedShortTimeFormatText(); 73 const Vector<String>& timeAMPMLabels(); 74 #endif 75 70 76 private: 71 77 static PassOwnPtr<LocaleICU> createForCurrentLocale(); … … 83 89 #if ENABLE(CALENDAR_PICKER) 84 90 void initializeLocalizedDateFormatText(); 91 void initializeCalendar(); 92 #endif 93 94 #if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS) 85 95 PassOwnPtr<Vector<String> > createLabelVector(const UDateFormat*, UDateFormatSymbolType, int32_t startIndex, int32_t size); 86 void initializeCalendar(); 96 #endif 97 98 #if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS) 99 void initializeDateTimeFormat(); 87 100 #endif 88 101 … … 110 123 unsigned m_firstDayOfWeek; 111 124 #endif 125 126 #if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS) 127 UDateFormat* m_mediumTimeFormat; 128 UDateFormat* m_shortTimeFormat; 129 String m_localizedTimeFormatText; 130 String m_localizedShortTimeFormatText; 131 OwnPtr<Vector<String> > m_timeAMPMLabels; 132 bool m_didCreateTimeFormat; 133 #endif 112 134 }; 113 135 -
trunk/Source/WebCore/platform/text/LocalizedDate.h
r115038 r121415 61 61 // The first day of a week. 0 is Sunday, and 6 is Saturday. 62 62 unsigned firstDayOfWeek(); 63 64 #endif 65 66 #if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS) 67 // Returns time format in Unicode TR35 LDML[1] containing hour, minute, and 68 // second with optional period(AM/PM), e.g. "h:mm:ss a" 69 // [1] LDML http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns 70 String localizedTimeFormatText(); 71 72 // Returns time format in Unicode TR35 LDML containing hour, and minute 73 // with optional period(AM/PM), e.g. "h:mm a" 74 // Note: Some platforms return same value as localizedTimeFormatText(). 75 String localizedShortTimeFormatText(); 76 77 // Returns localized period field(AM/PM) strings. 78 const Vector<String>& timeAMPMLabels(); 63 79 #endif 64 80 } // namespace WebCore -
trunk/Source/WebCore/platform/text/LocalizedDateICU.cpp
r116243 r121415 93 93 #endif 94 94 95 #if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS) 96 String localizedTimeFormatText() 97 { 98 return LocaleICU::currentLocale()->localizedTimeFormatText(); 95 99 } 100 101 String localizedShortTimeFormatText() 102 { 103 return LocaleICU::currentLocale()->localizedShortTimeFormatText(); 104 } 105 106 const Vector<String>& timeAMPMLabels() 107 { 108 return LocaleICU::currentLocale()->timeAMPMLabels(); 109 } 110 #endif 111 112 } -
trunk/Source/WebKit/chromium/ChangeLog
r121408 r121415 1 2012-06-28 Yoshifumi Inoue <yosin@chromium.org> 2 3 [Platform] Implement functions for localized time format information 4 https://bugs.webkit.org/show_bug.cgi?id=89965 5 6 Reviewed by Kent Tamura. 7 8 This patch adds new test LocalizedDateICUTest if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS) 9 is true. 10 11 * WebKit.gypi: 12 * tests/LocalizedDateICUTest.cpp: Added. 13 (LocalizedDateICUTest): 14 (Labels): 15 (LocalizedDateICUTest::Labels::Labels): 16 (LocalizedDateICUTest::Labels::operator==): 17 (LocalizedDateICUTest::Labels::toString): 18 (LocalizedDateICUTest::labels): 19 (LocalizedDateICUTest::localizedDateFormatText): 20 (LocalizedDateICUTest::localizedShortDateFormatText): 21 (LocalizedDateICUTest::timeAMPMLabels): 22 (operator<<): 23 (TEST_F): 24 1 25 2012-06-27 Sheriff Bot <webkit.review.bot@gmail.com> 2 26 -
trunk/Source/WebKit/chromium/WebKit.gypi
r121408 r121415 124 124 'tests/LinkHighlightTest.cpp', 125 125 'tests/ListenerLeakTest.cpp', 126 'tests/LocalizedDateICUTest.cpp', 126 127 'tests/LocalizedNumberICUTest.cpp', 127 128 'tests/MockCCQuadCuller.h',
Note: See TracChangeset
for help on using the changeset viewer.