Diff
Modified: trunk/Source/WebCore/ChangeLog (129911 => 129912)
--- trunk/Source/WebCore/ChangeLog 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/ChangeLog 2012-09-28 16:46:05 UTC (rev 129912)
@@ -1,3 +1,78 @@
+2012-09-28 Kent Tamura <[email protected]>
+
+ Add parseDateTime, formatDateTime, and dateFormatText to Localizer
+ https://bugs.webkit.org/show_bug.cgi?id=97885
+
+ Reviewed by Kentaro Hara.
+
+ This is a preparation to remove LocalizedData.h.
+
+ Add the following pure virtual member functions to Localizer.
+ parseDateTime
+ formatDateTime
+ dateFormatText.
+
+ We rename existing parse/format functions for type=date in Locale*
+ classes, and extend their functionality so that they support other
+ date/time types. They override the new functions of Localizer.
+
+ No new tests. This should not change any behavior.
+
+ * platform/text/Localizer.h:
+ (Localizer): Add parseDateTime, formatDateTime, and dateFormatText.
+
+ * platform/text/LocaleICU.h:
+ (LocaleICU):
+ - Rename parseLocalizedDate to parseDateTime
+ - Add type argument to parseDateTime
+ - Rename formatLocalizedDate to formatDateTime
+ - Rename localizedDateFormatText to dateFormatText
+ - Make parseDateTime/formatDateTime/dateFormatText virtual.
+ * platform/text/LocaleICU.cpp:
+ (WebCore::LocaleICU::parseDateTime):
+ Renamed. Reject non-date types.
+ (WebCore::LocaleICU::formatDateTime): ditto.
+ (WebCore::LocaleICU::dateFormatText): Renamed.
+ * platform/text/LocalizedDateICU.cpp: Moved some code to LocaleICU.cpp.
+ (WebCore::parseLocalizedDate):
+ (WebCore::formatLocalizedDate):
+
+ * platform/text/LocaleNone.cpp:
+ Add empty implementations of parseDateTime, formatDateTime, and
+ dateFormatText.
+ (LocaleNone):
+ (WebCore::LocaleNone::parseDateTime):
+ (WebCore::LocaleNone::formatDateTime):
+ (WebCore::LocaleNone::dateFormatText):
+
+ * platform/text/LocaleWin.h:
+ (LocaleWin):
+ - Rename parseDate to parseDateTime
+ - Add type argument to parseDateTime
+ - Rename formatDate to formatDateTime
+ - Make parseDateTime/formatDateTime/dateFormatText virtual.
+ * platform/text/LocaleWin.cpp:
+ (WebCore::LocaleWin::parseDateTime):
+ Renamed. Reject non-date types.
+ (WebCore::LocaleWin::formatDateTime): ditto.
+ * platform/text/LocalizedDateWin.cpp: Moved some code to LocaleWin.cpp.
+ (WebCore::parseLocalizedDate):
+ (WebCore::formatLocalizedDate):
+
+ * platform/text/mac/LocaleMac.h:
+ (LocaleMac):
+ - Rename parseDate to parseDateTime
+ - Add type argument to parseDateTime
+ - Rename formatDate to formatDateTime
+ - Make parseDateTime/formatDateTime/dateFormatText virtual.
+ * platform/text/mac/LocaleMac.mm:
+ (WebCore::LocaleMac::parseDateTime):
+ Renamed. Reject non-date types.
+ (WebCore::LocaleMac::formatDateTime): ditto.
+ * platform/text/mac/LocalizedDateMac.cpp: Moved some code to LocaleMac.mm.
+ (WebCore::parseLocalizedDate):
+ (WebCore::formatLocalizedDate):
+
2012-09-28 Joshua Bell <[email protected]>
IndexedDB: Run multiple tasks per transaction tick
Modified: trunk/Source/WebCore/platform/text/LocaleICU.cpp (129911 => 129912)
--- trunk/Source/WebCore/platform/text/LocaleICU.cpp 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/platform/text/LocaleICU.cpp 2012-09-28 16:46:05 UTC (rev 129912)
@@ -164,8 +164,10 @@
return udat_open(timeStyle, dateStyle, m_locale.data(), gmtTimezone, WTF_ARRAY_LENGTH(gmtTimezone), 0, -1, &status);
}
-double LocaleICU::parseLocalizedDate(const String& input)
+double LocaleICU::parseDateTime(const String& input, DateComponents::Type type)
{
+ if (type != DateComponents::Date)
+ return std::numeric_limits<double>::quiet_NaN();
if (!initializeShortDateFormat())
return numeric_limits<double>::quiet_NaN();
if (input.length() > static_cast<unsigned>(numeric_limits<int32_t>::max()))
@@ -180,8 +182,10 @@
return date;
}
-String LocaleICU::formatLocalizedDate(const DateComponents& dateComponents)
+String LocaleICU::formatDateTime(const DateComponents& dateComponents)
{
+ if (dateComponents.type() != DateComponents::Date)
+ return String();
if (!initializeShortDateFormat())
return String();
double input = dateComponents.millisecondsSinceEpoch();
@@ -281,7 +285,7 @@
m_localizedDateFormatText = localizeFormat(getDateFormatPattern(m_shortDateFormat));
}
-String LocaleICU::localizedDateFormatText()
+String LocaleICU::dateFormatText()
{
initializeLocalizedDateFormatText();
return m_localizedDateFormatText;
Modified: trunk/Source/WebCore/platform/text/LocaleICU.h (129911 => 129912)
--- trunk/Source/WebCore/platform/text/LocaleICU.h 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/platform/text/LocaleICU.h 2012-09-28 16:46:05 UTC (rev 129912)
@@ -51,10 +51,10 @@
virtual ~LocaleICU();
// For LocalizedDate
- double parseLocalizedDate(const String&);
- String formatLocalizedDate(const DateComponents&);
+ virtual double parseDateTime(const String&, DateComponents::Type) OVERRIDE;
+ virtual String formatDateTime(const DateComponents&) OVERRIDE;
#if ENABLE(CALENDAR_PICKER)
- String localizedDateFormatText();
+ virtual String dateFormatText() OVERRIDE;
virtual const Vector<String>& monthLabels() OVERRIDE;
virtual const Vector<String>& weekDayShortLabels() OVERRIDE;
Modified: trunk/Source/WebCore/platform/text/LocaleNone.cpp (129911 => 129912)
--- trunk/Source/WebCore/platform/text/LocaleNone.cpp 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/platform/text/LocaleNone.cpp 2012-09-28 16:46:05 UTC (rev 129912)
@@ -35,6 +35,11 @@
private:
virtual void initializeLocalizerData() OVERRIDE FINAL;
+ virtual double parseDateTime(const String&, DateComponents::Type) OVERRIDE;
+ virtual String formatDateTime(const DateComponents&) OVERRIDE;
+#if ENABLE(CALENDAR_PICKER)
+ virtual String dateFormatText() OVERRIDE;
+#endif
};
PassOwnPtr<Localizer> Localizer::create(const AtomicString&)
@@ -50,4 +55,21 @@
{
}
+double LocaleNone::parseDateTime(const String&, DateComponents::Type)
+{
+ return std::numeric_limits<double>::quiet_NaN();
+}
+
+String LocaleNone::formatDateTime(const DateComponents&)
+{
+ return String();
+}
+
+#if ENABLE(CALENDAR_PICKER)
+String LocaleNone::dateFormatText()
+{
+ return ASCIILiteral("Year-Month-Day");
+}
+#endif
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/text/LocaleWin.cpp (129911 => 129912)
--- trunk/Source/WebCore/platform/text/LocaleWin.cpp 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/platform/text/LocaleWin.cpp 2012-09-28 16:46:05 UTC (rev 129912)
@@ -354,8 +354,10 @@
return -1;
}
-double LocaleWin::parseDate(const String& input)
+double LocaleWin::parseDateTime(const String& input, DateComponents::Type type)
{
+ if (type != DateComponents::Date)
+ return std::numeric_limits<double>::quiet_NaN();
ensureShortDateTokens();
return parseDate(m_shortDateTokens, m_baseYear, input);
}
@@ -478,8 +480,10 @@
buffer.append(convertToLocalizedNumber(numberBuffer.toString()));
}
-String LocaleWin::formatDate(const DateComponents& dateComponents)
+String LocaleWin::formatDateTime(const DateComponents& dateComponents)
{
+ if (dateComponents.type() != DateComponents::Date)
+ return String();
ensureShortDateTokens();
return formatDate(m_shortDateTokens, m_baseYear, dateComponents.fullYear(), dateComponents.month(), dateComponents.monthDay());
}
Modified: trunk/Source/WebCore/platform/text/LocaleWin.h (129911 => 129912)
--- trunk/Source/WebCore/platform/text/LocaleWin.h 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/platform/text/LocaleWin.h 2012-09-28 16:46:05 UTC (rev 129912)
@@ -47,10 +47,10 @@
static PassOwnPtr<LocaleWin> create(LCID);
static LocaleWin* currentLocale();
~LocaleWin();
- double parseDate(const String&);
- String formatDate(const DateComponents&);
+ virtual double parseDateTime(const String&, DateComponents::Type) OVERRIDE;
+ virtual String formatDateTime(const DateComponents&) OVERRIDE;
#if ENABLE(CALENDAR_PICKER)
- String dateFormatText();
+ virtual String dateFormatText() OVERRIDE;
virtual const Vector<String>& monthLabels() OVERRIDE;
virtual const Vector<String>& weekDayShortLabels() OVERRIDE;
virtual unsigned firstDayOfWeek() OVERRIDE;
Modified: trunk/Source/WebCore/platform/text/LocalizedDateICU.cpp (129911 => 129912)
--- trunk/Source/WebCore/platform/text/LocalizedDateICU.cpp 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/platform/text/LocalizedDateICU.cpp 2012-09-28 16:46:05 UTC (rev 129912)
@@ -40,40 +40,18 @@
double parseLocalizedDate(const String& input, DateComponents::Type type)
{
- switch (type) {
- case DateComponents::Date:
- return LocaleICU::currentLocale()->parseLocalizedDate(input);
- case DateComponents::DateTime:
- case DateComponents::DateTimeLocal:
- case DateComponents::Month:
- case DateComponents::Time:
- case DateComponents::Week:
- case DateComponents::Invalid:
- break;
- }
- return numeric_limits<double>::quiet_NaN();
+ return LocaleICU::currentLocale()->parseDateTime(input, type);
}
String formatLocalizedDate(const DateComponents& dateComponents)
{
- switch (dateComponents.type()) {
- case DateComponents::Date:
- return LocaleICU::currentLocale()->formatLocalizedDate(dateComponents);
- case DateComponents::DateTime:
- case DateComponents::DateTimeLocal:
- case DateComponents::Month:
- case DateComponents::Time:
- case DateComponents::Week:
- case DateComponents::Invalid:
- break;
- }
- return String();
+ return LocaleICU::currentLocale()->formatDateTime(dateComponents);
}
#if ENABLE(CALENDAR_PICKER)
String localizedDateFormatText()
{
- return LocaleICU::currentLocale()->localizedDateFormatText();
+ return LocaleICU::currentLocale()->dateFormatText();
}
#endif
Modified: trunk/Source/WebCore/platform/text/LocalizedDateWin.cpp (129911 => 129912)
--- trunk/Source/WebCore/platform/text/LocalizedDateWin.cpp 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/platform/text/LocalizedDateWin.cpp 2012-09-28 16:46:05 UTC (rev 129912)
@@ -40,34 +40,12 @@
double parseLocalizedDate(const String& input, DateComponents::Type type)
{
- switch (type) {
- case DateComponents::Date:
- return LocaleWin::currentLocale()->parseDate(input);
- case DateComponents::DateTime:
- case DateComponents::DateTimeLocal:
- case DateComponents::Month:
- case DateComponents::Time:
- case DateComponents::Week:
- case DateComponents::Invalid:
- break;
- }
- return numeric_limits<double>::quiet_NaN();
+ return LocaleWin::currentLocale()->parseDateTime(input, type);
}
String formatLocalizedDate(const DateComponents& dateComponents)
{
- switch (dateComponents.type()) {
- case DateComponents::Date:
- return LocaleWin::currentLocale()->formatDate(dateComponents);
- case DateComponents::DateTime:
- case DateComponents::DateTimeLocal:
- case DateComponents::Month:
- case DateComponents::Time:
- case DateComponents::Week:
- case DateComponents::Invalid:
- break;
- }
- return String();
+ return LocaleWin::currentLocale()->formatDateTime(dateComponents);
}
#if ENABLE(CALENDAR_PICKER)
Modified: trunk/Source/WebCore/platform/text/Localizer.h (129911 => 129912)
--- trunk/Source/WebCore/platform/text/Localizer.h 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/platform/text/Localizer.h 2012-09-28 16:46:05 UTC (rev 129912)
@@ -26,6 +26,7 @@
#ifndef Localizer_h
#define Localizer_h
+#include "DateComponents.h"
#include "Language.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/text/WTFString.h>
@@ -83,8 +84,13 @@
// The first day of a week. 0 is Sunday, and 6 is Saturday.
virtual unsigned firstDayOfWeek() = 0;
+
+ virtual String dateFormatText() = 0;
#endif
+ virtual double parseDateTime(const String&, DateComponents::Type) = 0;
+ virtual String formatDateTime(const DateComponents&) = 0;
+
virtual ~Localizer();
protected:
Modified: trunk/Source/WebCore/platform/text/mac/LocaleMac.h (129911 => 129912)
--- trunk/Source/WebCore/platform/text/mac/LocaleMac.h 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/platform/text/mac/LocaleMac.h 2012-09-28 16:46:05 UTC (rev 129912)
@@ -50,11 +50,11 @@
static PassOwnPtr<LocaleMac> create(NSLocale*);
static LocaleMac* currentLocale();
~LocaleMac();
- double parseDate(const String&);
- String formatDate(const DateComponents&);
+ virtual double parseDateTime(const String&, DateComponents::Type) OVERRIDE;
+ virtual String formatDateTime(const DateComponents&) OVERRIDE;
#if ENABLE(CALENDAR_PICKER)
- String dateFormatText();
+ virtual String dateFormatText() OVERRIDE;
virtual const Vector<String>& monthLabels() OVERRIDE;
virtual const Vector<String>& weekDayShortLabels() OVERRIDE;
virtual unsigned firstDayOfWeek() OVERRIDE;
Modified: trunk/Source/WebCore/platform/text/mac/LocaleMac.mm (129911 => 129912)
--- trunk/Source/WebCore/platform/text/mac/LocaleMac.mm 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/platform/text/mac/LocaleMac.mm 2012-09-28 16:46:05 UTC (rev 129912)
@@ -118,8 +118,10 @@
return createDateTimeFormatter(m_locale.get(), NSDateFormatterShortStyle, NSDateFormatterNoStyle);
}
-double LocaleMac::parseDate(const String& input)
+double LocaleMac::parseDateTime(const String& input, DateComponents::Type type)
{
+ if (type != DateComponents::Date)
+ return std::numeric_limits<double>::quiet_NaN();
RetainPtr<NSDateFormatter> formatter(AdoptNS, createShortDateFormatter());
NSDate *date = [formatter.get() dateFromString:input];
if (!date)
@@ -127,8 +129,10 @@
return [date timeIntervalSince1970] * msPerSecond;
}
-String LocaleMac::formatDate(const DateComponents& dateComponents)
+String LocaleMac::formatDateTime(const DateComponents& dateComponents)
{
+ if (dateComponents.type() != DateComponents::Date)
+ return String();
RetainPtr<NSDateFormatter> formatter(AdoptNS, createShortDateFormatter());
NSTimeInterval interval = dateComponents.millisecondsSinceEpoch() / msPerSecond;
return String([formatter.get() stringFromDate:[NSDate dateWithTimeIntervalSince1970:interval]]);
Modified: trunk/Source/WebCore/platform/text/mac/LocalizedDateMac.cpp (129911 => 129912)
--- trunk/Source/WebCore/platform/text/mac/LocalizedDateMac.cpp 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebCore/platform/text/mac/LocalizedDateMac.cpp 2012-09-28 16:46:05 UTC (rev 129912)
@@ -40,34 +40,12 @@
double parseLocalizedDate(const String& input, DateComponents::Type type)
{
- switch (type) {
- case DateComponents::Date:
- return LocaleMac::currentLocale()->parseDate(input);
- case DateComponents::DateTime:
- case DateComponents::DateTimeLocal:
- case DateComponents::Month:
- case DateComponents::Time:
- case DateComponents::Week:
- case DateComponents::Invalid:
- break;
- }
- return numeric_limits<double>::quiet_NaN();
+ return LocaleMac::currentLocale()->parseDateTime(input, type);
}
String formatLocalizedDate(const DateComponents& dateComponents)
{
- switch (dateComponents.type()) {
- case DateComponents::Date:
- return LocaleMac::currentLocale()->formatDate(dateComponents);
- case DateComponents::DateTime:
- case DateComponents::DateTimeLocal:
- case DateComponents::Month:
- case DateComponents::Time:
- case DateComponents::Week:
- case DateComponents::Invalid:
- break;
- }
- return String();
+ return LocaleMac::currentLocale()->formatDateTime(dateComponents);
}
#if ENABLE(CALENDAR_PICKER)
Modified: trunk/Source/WebKit/chromium/ChangeLog (129911 => 129912)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-09-28 16:46:05 UTC (rev 129912)
@@ -1,3 +1,17 @@
+2012-09-28 Kent Tamura <[email protected]>
+
+ Add parseDateTime, formatDateTime, and dateFormatText to Localizer
+ https://bugs.webkit.org/show_bug.cgi?id=97885
+
+ Reviewed by Kentaro Hara.
+
+ * tests/LocaleMacTest.cpp: Follow renaming of LocaleMac functions.
+ (LocaleMacTest::formatDate):
+ (LocaleMacTest::parseDate):
+ * tests/LocaleWinTest.cpp: Follow renaming of LocaleWin functions.
+ (LocaleWinTest::formatDate):
+ (LocaleWinTest::parseDate):
+
2012-09-28 Leandro Gracia Gil <[email protected]>
[Chromium] Fix the find-in-page implementation for detaching frames.
Modified: trunk/Source/WebKit/chromium/tests/LocaleMacTest.cpp (129911 => 129912)
--- trunk/Source/WebKit/chromium/tests/LocaleMacTest.cpp 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebKit/chromium/tests/LocaleMacTest.cpp 2012-09-28 16:46:05 UTC (rev 129912)
@@ -65,13 +65,13 @@
String formatDate(const String& localeString, int year, int month, int day)
{
OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
- return locale->formatDate(dateComponents(year, month, day));
+ return locale->formatDateTime(dateComponents(year, month, day));
}
double parseDate(const String& localeString, const String& dateString)
{
OwnPtr<LocaleMac> locale = LocaleMac::create(localeString);
- return locale->parseDate(dateString);
+ return locale->parseDateTime(dateString, DateComponents::Date);
}
#if ENABLE(CALENDAR_PICKER)
Modified: trunk/Source/WebKit/chromium/tests/LocaleWinTest.cpp (129911 => 129912)
--- trunk/Source/WebKit/chromium/tests/LocaleWinTest.cpp 2012-09-28 16:38:54 UTC (rev 129911)
+++ trunk/Source/WebKit/chromium/tests/LocaleWinTest.cpp 2012-09-28 16:46:05 UTC (rev 129912)
@@ -87,13 +87,13 @@
String formatDate(LCID lcid, int year, int month, int day)
{
OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
- return locale->formatDate(dateComponents(year, month, day));
+ return locale->formatDateTime(dateComponents(year, month, day));
}
double parseDate(LCID lcid, const String& dateString)
{
OwnPtr<LocaleWin> locale = LocaleWin::create(lcid);
- return locale->parseDate(dateString);
+ return locale->parseDateTime(dateString, DateComponents::Date);
}
#if ENABLE(CALENDAR_PICKER)