Title: [130476] trunk/Source/WebCore
- Revision
- 130476
- Author
- tk...@chromium.org
- Date
- 2012-10-05 00:27:23 -0700 (Fri, 05 Oct 2012)
Log Message
Improve spelling and performance of Localizer.cpp
https://bugs.webkit.org/show_bug.cgi?id=98485
Reviewed by Kentaro Hara.
Some improvements pointed in webkit.org/b/98229#c5.
No new tests because of no behavior change.
* platform/text/Localizer.h:
(Localizer):
- Rename dateTimeFormatWithSecond to dateTimeFormatWithSeconds
- Rename dateTimeFormatWithoutSecond to dateTimeFormatWithoutSeconds
- Add data members: m_dateTimeFormatWithSeconds and m_dateTimeFormatWithoutSeconds.
* platform/text/Localizer.cpp:
(WebCore::Localizer::timeFormat): Check isNull instead of isEmpty
(WebCore::Localizer::shortTimeFormat): Ditto.
(WebCore::Localizer::dateTimeFormatWithSeconds):
- Renamed.
- Cache the concatenation result to a data member.
(WebCore::Localizer::dateTimeFormatWithoutSeconds): Ditto.
* html/DateTimeInputType.cpp:
(WebCore::DateTimeInputType::setupLayoutParameters): Follow the renaming.
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::setupLayoutParameters): Ditto.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (130475 => 130476)
--- trunk/Source/WebCore/ChangeLog 2012-10-05 07:21:26 UTC (rev 130475)
+++ trunk/Source/WebCore/ChangeLog 2012-10-05 07:27:23 UTC (rev 130476)
@@ -1,3 +1,32 @@
+2012-10-05 Kent Tamura <tk...@chromium.org>
+
+ Improve spelling and performance of Localizer.cpp
+ https://bugs.webkit.org/show_bug.cgi?id=98485
+
+ Reviewed by Kentaro Hara.
+
+ Some improvements pointed in webkit.org/b/98229#c5.
+
+ No new tests because of no behavior change.
+
+ * platform/text/Localizer.h:
+ (Localizer):
+ - Rename dateTimeFormatWithSecond to dateTimeFormatWithSeconds
+ - Rename dateTimeFormatWithoutSecond to dateTimeFormatWithoutSeconds
+ - Add data members: m_dateTimeFormatWithSeconds and m_dateTimeFormatWithoutSeconds.
+ * platform/text/Localizer.cpp:
+ (WebCore::Localizer::timeFormat): Check isNull instead of isEmpty
+ (WebCore::Localizer::shortTimeFormat): Ditto.
+ (WebCore::Localizer::dateTimeFormatWithSeconds):
+ - Renamed.
+ - Cache the concatenation result to a data member.
+ (WebCore::Localizer::dateTimeFormatWithoutSeconds): Ditto.
+
+ * html/DateTimeInputType.cpp:
+ (WebCore::DateTimeInputType::setupLayoutParameters): Follow the renaming.
+ * html/DateTimeLocalInputType.cpp:
+ (WebCore::DateTimeLocalInputType::setupLayoutParameters): Ditto.
+
2012-10-04 Kenichi Ishibashi <ba...@chromium.org>
[WebSocket] ExtensionParser should have its own file
Modified: trunk/Source/WebCore/html/DateTimeInputType.cpp (130475 => 130476)
--- trunk/Source/WebCore/html/DateTimeInputType.cpp 2012-10-05 07:21:26 UTC (rev 130475)
+++ trunk/Source/WebCore/html/DateTimeInputType.cpp 2012-10-05 07:27:23 UTC (rev 130476)
@@ -146,10 +146,10 @@
void DateTimeInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& date) const
{
if (shouldHaveSecondField(date)) {
- layoutParameters.dateTimeFormat = layoutParameters.localizer.dateTimeFormatWithSecond();
+ layoutParameters.dateTimeFormat = layoutParameters.localizer.dateTimeFormatWithSeconds();
layoutParameters.fallbackDateTimeFormat = "dd/MM/yyyy HH:mm:ss";
} else {
- layoutParameters.dateTimeFormat = layoutParameters.localizer.dateTimeFormatWithoutSecond();
+ layoutParameters.dateTimeFormat = layoutParameters.localizer.dateTimeFormatWithoutSeconds();
layoutParameters.fallbackDateTimeFormat = "dd/MM/yyyy HH:mm";
}
layoutParameters.minimumYear = fullYear(element()->fastGetAttribute(minAttr));
Modified: trunk/Source/WebCore/html/DateTimeLocalInputType.cpp (130475 => 130476)
--- trunk/Source/WebCore/html/DateTimeLocalInputType.cpp 2012-10-05 07:21:26 UTC (rev 130475)
+++ trunk/Source/WebCore/html/DateTimeLocalInputType.cpp 2012-10-05 07:27:23 UTC (rev 130476)
@@ -152,10 +152,10 @@
void DateTimeLocalInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& date) const
{
if (shouldHaveSecondField(date)) {
- layoutParameters.dateTimeFormat = layoutParameters.localizer.dateTimeFormatWithSecond();
+ layoutParameters.dateTimeFormat = layoutParameters.localizer.dateTimeFormatWithSeconds();
layoutParameters.fallbackDateTimeFormat = "dd/MM/yyyy HH:mm:ss";
} else {
- layoutParameters.dateTimeFormat = layoutParameters.localizer.dateTimeFormatWithoutSecond();
+ layoutParameters.dateTimeFormat = layoutParameters.localizer.dateTimeFormatWithoutSeconds();
layoutParameters.fallbackDateTimeFormat = "dd/MM/yyyy HH:mm";
}
layoutParameters.minimumYear = fullYear(element()->fastGetAttribute(minAttr));
Modified: trunk/Source/WebCore/platform/text/Localizer.cpp (130475 => 130476)
--- trunk/Source/WebCore/platform/text/Localizer.cpp 2012-10-05 07:21:26 UTC (rev 130475)
+++ trunk/Source/WebCore/platform/text/Localizer.cpp 2012-10-05 07:27:23 UTC (rev 130476)
@@ -305,7 +305,7 @@
String Localizer::timeFormat()
{
- if (!m_localizedTimeFormatText.isEmpty())
+ if (!m_localizedTimeFormatText.isNull())
return m_localizedTimeFormatText;
m_localizedTimeFormatText = "hh:mm:ss";
return m_localizedTimeFormatText;
@@ -313,30 +313,36 @@
String Localizer::shortTimeFormat()
{
- if (!m_localizedShortTimeFormatText.isEmpty())
+ if (!m_localizedShortTimeFormatText.isNull())
return m_localizedShortTimeFormatText;
m_localizedTimeFormatText = "hh:mm";
return m_localizedShortTimeFormatText;
}
-String Localizer::dateTimeFormatWithSecond()
+String Localizer::dateTimeFormatWithSeconds()
{
- // FIXME: We should retreive the separator and the order from the system.
+ if (!m_dateTimeFormatWithSeconds.isNull())
+ return m_dateTimeFormatWithSeconds;
+ // FIXME: We should retrieve the separator and the order from the system.
StringBuilder builder;
builder.append(dateFormat());
builder.append(' ');
builder.append(timeFormat());
- return builder.toString();
+ m_dateTimeFormatWithSeconds = builder.toString();
+ return m_dateTimeFormatWithSeconds;
}
-String Localizer::dateTimeFormatWithoutSecond()
+String Localizer::dateTimeFormatWithoutSeconds()
{
- // FIXME: We should retreive the separator and the order from the system.
+ if (!m_dateTimeFormatWithoutSeconds.isNull())
+ return m_dateTimeFormatWithoutSeconds;
+ // FIXME: We should retrieve the separator and the order from the system.
StringBuilder builder;
builder.append(dateFormat());
builder.append(' ');
builder.append(shortTimeFormat());
- return builder.toString();
+ m_dateTimeFormatWithoutSeconds = builder.toString();
+ return m_dateTimeFormatWithoutSeconds;
}
const Vector<String>& Localizer::timeAMPMLabels()
Modified: trunk/Source/WebCore/platform/text/Localizer.h (130475 => 130476)
--- trunk/Source/WebCore/platform/text/Localizer.h 2012-10-05 07:21:26 UTC (rev 130475)
+++ trunk/Source/WebCore/platform/text/Localizer.h 2012-10-05 07:27:23 UTC (rev 130476)
@@ -72,13 +72,13 @@
// Note: Some platforms return same value as timeFormat().
virtual String shortTimeFormat();
- // Returns a date-time format in Unicode TR35 LDML. It should have a second
+ // Returns a date-time format in Unicode TR35 LDML. It should have a seconds
// field.
- String dateTimeFormatWithSecond();
+ String dateTimeFormatWithSeconds();
- // Returns a date-time format in Unicode TR35 LDML. It should have no second
+ // Returns a date-time format in Unicode TR35 LDML. It should have no seconds
// field.
- String dateTimeFormatWithoutSecond();
+ String dateTimeFormatWithoutSeconds();
// Returns localized period field(AM/PM) strings.
virtual const Vector<String>& timeAMPMLabels();
@@ -130,6 +130,8 @@
String m_localizedTimeFormatText;
String m_localizedShortTimeFormatText;
Vector<String> m_timeAMPMLabels;
+ String m_dateTimeFormatWithSeconds;
+ String m_dateTimeFormatWithoutSeconds;
#endif
Localizer() : m_hasLocalizerData(false) { }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes