- Revision
- 132650
- Author
- [email protected]
- Date
- 2012-10-26 07:22:53 -0700 (Fri, 26 Oct 2012)
Log Message
Refactor Localizer-related classes.
https://bugs.webkit.org/show_bug.cgi?id=100482
Reviewed by Kentaro Hara.
- Localizer has unused code
Localizer should have function implementations only if they are used in
multiple subclasses.
- Some Localizer subclasses hide Localizer data members
- Should use String::isNull to check initialization-or-not
No new tests. This should not change any behavior.
* platform/text/Localizer.h:
(Localizer):
- timeFormat, shortTimeFormat, and timeAMPMLabels should be pure virtual.
- Remove m_localizedDateFormatText, m_localizedShortTimeFormatText, and
m_timeAMPMLabels
* platform/text/Localizer.cpp:
Remove implementations of timeFormat, shortTimeFormat, and timeAMPMLabels.
* platform/text/LocaleICU.h:
(LocaleICU): Introduce m_timeFormatWithSeconds and m_timeFormatWithoutSeconds.
* platform/text/LocaleICU.cpp:
(WebCore::LocaleICU::initializeDateTimeFormat):
Use new data members instead of Localizer data members.
(WebCore::LocaleICU::dateFormat): Use isNull.
* platform/text/LocaleNone.cpp:
(LocaleNone): Add timeFormat, shortTimeFormat, timeAMPMLabels
implementations, and m_timeAMPMLabels.
(WebCore::LocaleNone::timeFormat): Returns the HTML time format.
(WebCore::LocaleNone::shortTimeFormat): Returns the HTML time format.
(WebCore::LocaleNone::timeAMPMLabels): Returns "AM" and "PM".
* platform/text/LocaleWin.h:
(LocaleWin): Add m_timeFormatWithSeconds.
* platform/text/LocaleWin.cpp:
(WebCore::LocaleWin::dateFormat): Use isNull.
(WebCore::LocaleWin::timeFormat): Use m_timeFormatWithSeconds.
* platform/text/mac/LocaleMac.h:
(LocaleMac): Rename m_localized*TimeFormatText to m_timeFormatWith*Seconds.
* platform/text/mac/LocaleMac.mm:
(WebCore::LocaleMac::timeFormat): Follow the renaming.
(WebCore::LocaleMac::shortTimeFormat): Ditto.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (132649 => 132650)
--- trunk/Source/WebCore/ChangeLog 2012-10-26 14:19:47 UTC (rev 132649)
+++ trunk/Source/WebCore/ChangeLog 2012-10-26 14:22:53 UTC (rev 132650)
@@ -1,5 +1,54 @@
2012-10-26 Kent Tamura <[email protected]>
+ Refactor Localizer-related classes.
+ https://bugs.webkit.org/show_bug.cgi?id=100482
+
+ Reviewed by Kentaro Hara.
+
+ - Localizer has unused code
+ Localizer should have function implementations only if they are used in
+ multiple subclasses.
+ - Some Localizer subclasses hide Localizer data members
+ - Should use String::isNull to check initialization-or-not
+
+ No new tests. This should not change any behavior.
+
+ * platform/text/Localizer.h:
+ (Localizer):
+ - timeFormat, shortTimeFormat, and timeAMPMLabels should be pure virtual.
+ - Remove m_localizedDateFormatText, m_localizedShortTimeFormatText, and
+ m_timeAMPMLabels
+ * platform/text/Localizer.cpp:
+ Remove implementations of timeFormat, shortTimeFormat, and timeAMPMLabels.
+
+ * platform/text/LocaleICU.h:
+ (LocaleICU): Introduce m_timeFormatWithSeconds and m_timeFormatWithoutSeconds.
+ * platform/text/LocaleICU.cpp:
+ (WebCore::LocaleICU::initializeDateTimeFormat):
+ Use new data members instead of Localizer data members.
+ (WebCore::LocaleICU::dateFormat): Use isNull.
+
+ * platform/text/LocaleNone.cpp:
+ (LocaleNone): Add timeFormat, shortTimeFormat, timeAMPMLabels
+ implementations, and m_timeAMPMLabels.
+ (WebCore::LocaleNone::timeFormat): Returns the HTML time format.
+ (WebCore::LocaleNone::shortTimeFormat): Returns the HTML time format.
+ (WebCore::LocaleNone::timeAMPMLabels): Returns "AM" and "PM".
+
+ * platform/text/LocaleWin.h:
+ (LocaleWin): Add m_timeFormatWithSeconds.
+ * platform/text/LocaleWin.cpp:
+ (WebCore::LocaleWin::dateFormat): Use isNull.
+ (WebCore::LocaleWin::timeFormat): Use m_timeFormatWithSeconds.
+
+ * platform/text/mac/LocaleMac.h:
+ (LocaleMac): Rename m_localized*TimeFormatText to m_timeFormatWith*Seconds.
+ * platform/text/mac/LocaleMac.mm:
+ (WebCore::LocaleMac::timeFormat): Follow the renaming.
+ (WebCore::LocaleMac::shortTimeFormat): Ditto.
+
+2012-10-26 Kent Tamura <[email protected]>
+
Crash in PagePopupController by events after WebPagePopupImpl::closePopup
https://bugs.webkit.org/show_bug.cgi?id=100454
Modified: trunk/Source/WebCore/platform/text/LocaleICU.cpp (132649 => 132650)
--- trunk/Source/WebCore/platform/text/LocaleICU.cpp 2012-10-26 14:19:47 UTC (rev 132649)
+++ trunk/Source/WebCore/platform/text/LocaleICU.cpp 2012-10-26 14:22:53 UTC (rev 132650)
@@ -382,10 +382,10 @@
// with LDML, because ICU specific pattern character "V" doesn't appear
// in both medium and short time pattern.
m_mediumTimeFormat = openDateFormat(UDAT_MEDIUM, UDAT_NONE);
- m_localizedTimeFormatText = getDateFormatPattern(m_mediumTimeFormat);
+ m_timeFormatWithSeconds = getDateFormatPattern(m_mediumTimeFormat);
m_shortTimeFormat = openDateFormat(UDAT_SHORT, UDAT_NONE);
- m_localizedShortTimeFormatText = getDateFormatPattern(m_shortTimeFormat);
+ m_timeFormatWithoutSeconds = getDateFormatPattern(m_shortTimeFormat);
OwnPtr<Vector<String> > timeAMPMLabels = createLabelVector(m_mediumTimeFormat, UDAT_AM_PMS, UCAL_AM, 2);
if (!timeAMPMLabels)
@@ -397,7 +397,7 @@
String LocaleICU::dateFormat()
{
- if (!m_dateFormat.isEmpty())
+ if (!m_dateFormat.isNull())
return m_dateFormat;
if (!initializeShortDateFormat())
return ASCIILiteral("dd/MM/yyyy");
@@ -438,13 +438,13 @@
String LocaleICU::timeFormat()
{
initializeDateTimeFormat();
- return m_localizedTimeFormatText;
+ return m_timeFormatWithSeconds;
}
String LocaleICU::shortTimeFormat()
{
initializeDateTimeFormat();
- return m_localizedShortTimeFormatText;
+ return m_timeFormatWithoutSeconds;
}
const Vector<String>& LocaleICU::shortMonthLabels()
Modified: trunk/Source/WebCore/platform/text/LocaleICU.h (132649 => 132650)
--- trunk/Source/WebCore/platform/text/LocaleICU.h 2012-10-26 14:19:47 UTC (rev 132649)
+++ trunk/Source/WebCore/platform/text/LocaleICU.h 2012-10-26 14:22:53 UTC (rev 132650)
@@ -114,6 +114,8 @@
#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
String m_dateFormat;
String m_monthFormat;
+ String m_timeFormatWithSeconds;
+ String m_timeFormatWithoutSeconds;
UDateFormat* m_mediumTimeFormat;
UDateFormat* m_shortTimeFormat;
Vector<String> m_shortMonthLabels;
Modified: trunk/Source/WebCore/platform/text/LocaleNone.cpp (132649 => 132650)
--- trunk/Source/WebCore/platform/text/LocaleNone.cpp 2012-10-26 14:19:47 UTC (rev 132649)
+++ trunk/Source/WebCore/platform/text/LocaleNone.cpp 2012-10-26 14:22:53 UTC (rev 132650)
@@ -47,10 +47,14 @@
#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;
+ Vector<String> m_timeAMPMLabels;
Vector<String> m_shortMonthLabels;
#endif
#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
@@ -111,6 +115,16 @@
return ASCIILiteral("yyyy-MM");
}
+String LocaleNone::timeFormat()
+{
+ return ASCIILiteral("HH:mm:ss");
+}
+
+String LocaleNone::shortTimeFormat()
+{
+ return ASCIILiteral("HH:mm");
+}
+
const Vector<String>& LocaleNone::shortMonthLabels()
{
if (!m_shortMonthLabels.isEmpty())
@@ -130,6 +144,17 @@
{
return monthLabels();
}
+
+const Vector<String>& LocaleNone::timeAMPMLabels()
+{
+ if (!m_timeAMPMLabels.isEmpty())
+ return m_timeAMPMLabels;
+ m_timeAMPMLabels.reserveCapacity(2);
+ m_timeAMPMLabels.append("AM");
+ m_timeAMPMLabels.append("PM");
+ return m_timeAMPMLabels;
+}
+
#endif
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/text/LocaleWin.cpp (132649 => 132650)
--- trunk/Source/WebCore/platform/text/LocaleWin.cpp 2012-10-26 14:19:47 UTC (rev 132649)
+++ trunk/Source/WebCore/platform/text/LocaleWin.cpp 2012-10-26 14:22:53 UTC (rev 132650)
@@ -677,7 +677,7 @@
String LocaleWin::dateFormat()
{
- if (!m_dateFormat.isEmpty())
+ if (!m_dateFormat.isNull())
return m_dateFormat;
ensureShortDateTokens();
m_dateFormat = convertWindowsDateFormatToLDML(m_shortDateTokens);
@@ -699,8 +699,8 @@
String LocaleWin::timeFormat()
{
- if (m_localizedTimeFormatText.isEmpty())
- m_localizedTimeFormatText = convertWindowsTimeFormatToLDML(getLocaleInfoString(LOCALE_STIMEFORMAT));
+ if (m_timeFormatWithSeconds.isNull())
+ m_timeFormatWithSeconds = convertWindowsTimeFormatToLDML(getLocaleInfoString(LOCALE_STIMEFORMAT));
return m_localizedTimeFormatText;
}
Modified: trunk/Source/WebCore/platform/text/LocaleWin.h (132649 => 132650)
--- trunk/Source/WebCore/platform/text/LocaleWin.h 2012-10-26 14:19:47 UTC (rev 132649)
+++ trunk/Source/WebCore/platform/text/LocaleWin.h 2012-10-26 14:22:53 UTC (rev 132650)
@@ -104,7 +104,9 @@
#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
String m_dateFormat;
String m_monthFormat;
+ String m_timeFormatWithSeconds;
String m_timeFormatWithoutSeconds;
+ Vector<String> m_timeAMPMLabels;
#endif
#if ENABLE(CALENDAR_PICKER)
Vector<String> m_weekDayShortLabels;
Modified: trunk/Source/WebCore/platform/text/Localizer.cpp (132649 => 132650)
--- trunk/Source/WebCore/platform/text/Localizer.cpp 2012-10-26 14:19:47 UTC (rev 132649)
+++ trunk/Source/WebCore/platform/text/Localizer.cpp 2012-10-26 14:22:53 UTC (rev 132650)
@@ -315,22 +315,6 @@
return m_decimalSymbols[DecimalSeparatorIndex];
}
-String Localizer::timeFormat()
-{
- if (!m_localizedTimeFormatText.isNull())
- return m_localizedTimeFormatText;
- m_localizedTimeFormatText = "hh:mm:ss";
- return m_localizedTimeFormatText;
-}
-
-String Localizer::shortTimeFormat()
-{
- if (!m_localizedShortTimeFormatText.isNull())
- return m_localizedShortTimeFormatText;
- m_localizedTimeFormatText = "hh:mm";
- return m_localizedShortTimeFormatText;
-}
-
String Localizer::dateTimeFormatWithSeconds()
{
if (!m_dateTimeFormatWithSeconds.isNull())
@@ -356,16 +340,6 @@
m_dateTimeFormatWithoutSeconds = builder.toString();
return m_dateTimeFormatWithoutSeconds;
}
-
-const Vector<String>& Localizer::timeAMPMLabels()
-{
- if (!m_timeAMPMLabels.isEmpty())
- return m_timeAMPMLabels;
- m_timeAMPMLabels.reserveCapacity(2);
- m_timeAMPMLabels.append("AM");
- m_timeAMPMLabels.append("PM");
- return m_timeAMPMLabels;
-}
#endif
String Localizer::formatDateTime(const DateComponents& date, FormatType formatType)
Modified: trunk/Source/WebCore/platform/text/Localizer.h (132649 => 132650)
--- trunk/Source/WebCore/platform/text/Localizer.h 2012-10-26 14:19:47 UTC (rev 132649)
+++ trunk/Source/WebCore/platform/text/Localizer.h 2012-10-26 14:22:53 UTC (rev 132650)
@@ -68,12 +68,12 @@
// Returns time format in Unicode TR35 LDML[1] containing hour, minute, and
// second with optional period(AM/PM), e.g. "h:mm:ss a"
// [1] LDML http://unicode.org/reports/tr35/#Date_Format_Patterns
- virtual String timeFormat();
+ virtual String timeFormat() = 0;
// Returns time format in Unicode TR35 LDML containing hour, and minute
// with optional period(AM/PM), e.g. "h:mm a"
// Note: Some platforms return same value as timeFormat().
- virtual String shortTimeFormat();
+ virtual String shortTimeFormat() = 0;
// Returns a date-time format in Unicode TR35 LDML. It should have a seconds
// field.
@@ -98,7 +98,7 @@
virtual const Vector<String>& shortStandAloneMonthLabels() = 0;
// Returns localized period field(AM/PM) strings.
- virtual const Vector<String>& timeAMPMLabels();
+ virtual const Vector<String>& timeAMPMLabels() = 0;
#endif
#if ENABLE(CALENDAR_PICKER) || ENABLE(INPUT_MULTIPLE_FIELDS_UI)
@@ -150,9 +150,6 @@
};
#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
- String m_localizedTimeFormatText;
- String m_localizedShortTimeFormatText;
- Vector<String> m_timeAMPMLabels;
String m_dateTimeFormatWithSeconds;
String m_dateTimeFormatWithoutSeconds;
#endif
Modified: trunk/Source/WebCore/platform/text/mac/LocaleMac.h (132649 => 132650)
--- trunk/Source/WebCore/platform/text/mac/LocaleMac.h 2012-10-26 14:19:47 UTC (rev 132649)
+++ trunk/Source/WebCore/platform/text/mac/LocaleMac.h 2012-10-26 14:22:53 UTC (rev 132650)
@@ -93,8 +93,8 @@
String m_dateFormat;
String m_monthFormat;
- String m_localizedTimeFormatText;
- String m_localizedShortTimeFormatText;
+ String m_timeFormatWithSeconds;
+ String m_timeFormatWithoutSeconds;
Vector<String> m_shortMonthLabels;
Vector<String> m_standAloneMonthLabels;
Vector<String> m_shortStandAloneMonthLabels;
Modified: trunk/Source/WebCore/platform/text/mac/LocaleMac.mm (132649 => 132650)
--- trunk/Source/WebCore/platform/text/mac/LocaleMac.mm 2012-10-26 14:19:47 UTC (rev 132649)
+++ trunk/Source/WebCore/platform/text/mac/LocaleMac.mm 2012-10-26 14:22:53 UTC (rev 132650)
@@ -262,18 +262,18 @@
String LocaleMac::timeFormat()
{
- if (!m_localizedTimeFormatText.isNull())
- return m_localizedTimeFormatText;
- m_localizedTimeFormatText = [timeFormatter().get() dateFormat];
- return m_localizedTimeFormatText;
+ if (!m_timeFormatWithSeconds.isNull())
+ return m_timeFormatWithSeconds;
+ m_timeFormatWithSeconds = [timeFormatter().get() dateFormat];
+ return m_timeFormatWithSeconds;
}
String LocaleMac::shortTimeFormat()
{
- if (!m_localizedShortTimeFormatText.isNull())
- return m_localizedShortTimeFormatText;
- m_localizedShortTimeFormatText = [shortTimeFormatter().get() dateFormat];
- return m_localizedShortTimeFormatText;
+ if (!m_timeFormatWithoutSeconds.isNull())
+ return m_timeFormatWithoutSeconds;
+ m_timeFormatWithoutSeconds = [shortTimeFormatter().get() dateFormat];
+ return m_timeFormatWithoutSeconds;
}
const Vector<String>& LocaleMac::shortMonthLabels()