Diff
Modified: trunk/Source/WebCore/ChangeLog (118676 => 118677)
--- trunk/Source/WebCore/ChangeLog 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebCore/ChangeLog 2012-05-28 12:50:01 UTC (rev 118677)
@@ -1,3 +1,39 @@
+2012-05-28 Keishi Hattori <[email protected]>
+
+ Expose value localization function of HTMLInputElement
+ https://bugs.webkit.org/show_bug.cgi?id=84356
+
+ Reviewed by Kent Tamura.
+
+ No new tests.
+
+ We want to localize the values that are defined in the datalist element.
+ This adds HTMLInputElement::localizeValue() which will localize a given
+ value.
+
+ * html/BaseDateAndTimeInputType.cpp:
+ (WebCore::BaseDateAndTimeInputType::localizeValue):
+ (WebCore):
+ (WebCore::BaseDateAndTimeInputType::visibleValue):
+ * html/BaseDateAndTimeInputType.h:
+ (BaseDateAndTimeInputType):
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::localizeValue):
+ (WebCore):
+ * html/HTMLInputElement.h:
+ (HTMLInputElement):
+ * html/InputType.cpp:
+ (WebCore::InputType::localizeValue):
+ (WebCore):
+ * html/InputType.h:
+ (InputType):
+ * html/NumberInputType.cpp:
+ (WebCore::NumberInputType::localizeValue):
+ (WebCore):
+ (WebCore::NumberInputType::visibleValue):
+ * html/NumberInputType.h:
+ (NumberInputType):
+
2012-05-28 Yury Semikhatsky <[email protected]>
Unreviewed. Test fix after r118670: saved timeline data may
Modified: trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp (118676 => 118677)
--- trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp 2012-05-28 12:50:01 UTC (rev 118677)
@@ -155,17 +155,21 @@
return serialize(value);
}
-String BaseDateAndTimeInputType::visibleValue() const
+String BaseDateAndTimeInputType::localizeValue(const String& proposedValue) const
{
- String currentValue = element()->value();
DateComponents date;
- if (!parseToDateComponents(currentValue, &date))
- return currentValue;
+ if (!parseToDateComponents(proposedValue, &date))
+ return proposedValue;
String localized = formatLocalizedDate(date);
- return localized.isEmpty() ? currentValue : localized;
+ return localized.isEmpty() ? proposedValue : localized;
}
+String BaseDateAndTimeInputType::visibleValue() const
+{
+ return localizeValue(element()->value());
+}
+
String BaseDateAndTimeInputType::convertFromVisibleValue(const String& visibleValue) const
{
if (visibleValue.isEmpty())
Modified: trunk/Source/WebCore/html/BaseDateAndTimeInputType.h (118676 => 118677)
--- trunk/Source/WebCore/html/BaseDateAndTimeInputType.h 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebCore/html/BaseDateAndTimeInputType.h 2012-05-28 12:50:01 UTC (rev 118677)
@@ -61,6 +61,7 @@
virtual void handleWheelEvent(WheelEvent*) OVERRIDE;
virtual String serialize(double) const OVERRIDE;
virtual String serializeWithMilliseconds(double) const;
+ virtual String localizeValue(const String&) const OVERRIDE;
virtual String visibleValue() const OVERRIDE;
virtual String convertFromVisibleValue(const String&) const OVERRIDE;
virtual String sanitizeValue(const String&) const OVERRIDE;
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (118676 => 118677)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-05-28 12:50:01 UTC (rev 118677)
@@ -1266,6 +1266,13 @@
return m_inputType->sanitizeValue(proposedValue);
}
+String HTMLInputElement::localizeValue(const String& proposedValue) const
+{
+ if (proposedValue.isNull())
+ return proposedValue;
+ return m_inputType->localizeValue(proposedValue);
+}
+
bool HTMLInputElement::hasUnacceptableValue() const
{
return m_inputType->hasUnacceptableValue();
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (118676 => 118677)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2012-05-28 12:50:01 UTC (rev 118677)
@@ -147,6 +147,8 @@
String sanitizeValue(const String&) const;
+ String localizeValue(const String&) const;
+
void updateInnerTextValue();
// The value which is drawn by a renderer.
Modified: trunk/Source/WebCore/html/InputType.cpp (118676 => 118677)
--- trunk/Source/WebCore/html/InputType.cpp 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebCore/html/InputType.cpp 2012-05-28 12:50:01 UTC (rev 118677)
@@ -629,6 +629,11 @@
{
}
+String InputType::localizeValue(const String& proposedValue) const
+{
+ return proposedValue;
+}
+
String InputType::visibleValue() const
{
return element()->value();
Modified: trunk/Source/WebCore/html/InputType.h (118676 => 118677)
--- trunk/Source/WebCore/html/InputType.h 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebCore/html/InputType.h 2012-05-28 12:50:01 UTC (rev 118677)
@@ -167,6 +167,7 @@
virtual String typeMismatchText() const;
virtual String valueMissingText() const;
virtual bool canSetStringValue() const;
+ virtual String localizeValue(const String&) const;
virtual String visibleValue() const;
virtual String convertFromVisibleValue(const String&) const;
virtual bool isAcceptableValue(const String&);
Modified: trunk/Source/WebCore/html/NumberInputType.cpp (118676 => 118677)
--- trunk/Source/WebCore/html/NumberInputType.cpp 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebCore/html/NumberInputType.cpp 2012-05-28 12:50:01 UTC (rev 118677)
@@ -218,23 +218,27 @@
return ch == 'e' || ch == 'E';
}
-String NumberInputType::visibleValue() const
+String NumberInputType::localizeValue(const String& proposedValue) const
{
- String currentValue = element()->value();
- if (currentValue.isEmpty())
- return currentValue;
+ if (proposedValue.isEmpty())
+ return proposedValue;
// We don't localize scientific notations.
- if (currentValue.find(isE) != notFound)
- return currentValue;
+ if (proposedValue.find(isE) != notFound)
+ return proposedValue;
// FIXME: The following three lines should be removed when we
// remove the second argument of convertToLocalizedNumber().
// Note: parseToDoubleForNumberTypeWithDecimalPlaces set zero to decimalPlaces
// if currentValue isn't valid floating pointer number.
unsigned decimalPlace;
- parseToDoubleForNumberTypeWithDecimalPlaces(currentValue, &decimalPlace);
- return convertToLocalizedNumber(currentValue, decimalPlace);
+ parseToDoubleForNumberTypeWithDecimalPlaces(proposedValue, &decimalPlace);
+ return convertToLocalizedNumber(proposedValue, decimalPlace);
}
+String NumberInputType::visibleValue() const
+{
+ return localizeValue(element()->value());
+}
+
String NumberInputType::convertFromVisibleValue(const String& visibleValue) const
{
if (visibleValue.isEmpty())
Modified: trunk/Source/WebCore/html/NumberInputType.h (118676 => 118677)
--- trunk/Source/WebCore/html/NumberInputType.h 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebCore/html/NumberInputType.h 2012-05-28 12:50:01 UTC (rev 118677)
@@ -55,6 +55,7 @@
virtual double parseToDoubleWithDecimalPlaces(const String&, double, unsigned*) const OVERRIDE;
virtual String serialize(double) const OVERRIDE;
virtual void handleBlurEvent() OVERRIDE;
+ virtual String localizeValue(const String&) const OVERRIDE;
virtual String visibleValue() const OVERRIDE;
virtual String convertFromVisibleValue(const String&) const OVERRIDE;
virtual bool isAcceptableValue(const String&) OVERRIDE;
Modified: trunk/Source/WebKit/chromium/ChangeLog (118676 => 118677)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-05-28 12:50:01 UTC (rev 118677)
@@ -1,3 +1,16 @@
+2012-05-28 Keishi Hattori <[email protected]>
+
+ Expose value localization function of HTMLInputElement
+ https://bugs.webkit.org/show_bug.cgi?id=84356
+
+ Reviewed by Kent Tamura.
+
+ * public/WebInputElement.h:
+ (WebInputElement):
+ * src/WebInputElement.cpp:
+ (WebKit::WebInputElement::localizeValue):
+ (WebKit):
+
2012-05-28 MORITA Hajime <[email protected]>
Unreviewed Mac Chromium build fix.
Modified: trunk/Source/WebKit/chromium/public/WebInputElement.h (118676 => 118677)
--- trunk/Source/WebKit/chromium/public/WebInputElement.h 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebKit/chromium/public/WebInputElement.h 2012-05-28 12:50:01 UTC (rev 118677)
@@ -96,6 +96,9 @@
WEBKIT_EXPORT WebNodeCollection dataListOptions() const;
+ // Return the localized value for this input type.
+ WEBKIT_EXPORT WebString localizeValue(const WebString&) const;
+
WEBKIT_EXPORT bool isSpeechInputEnabled() const;
WEBKIT_EXPORT SpeechInputState getSpeechInputState() const;
WEBKIT_EXPORT void startSpeechInput();
Modified: trunk/Source/WebKit/chromium/src/WebInputElement.cpp (118676 => 118677)
--- trunk/Source/WebKit/chromium/src/WebInputElement.cpp 2012-05-28 12:38:44 UTC (rev 118676)
+++ trunk/Source/WebKit/chromium/src/WebInputElement.cpp 2012-05-28 12:50:01 UTC (rev 118677)
@@ -183,6 +183,11 @@
return WebNodeCollection();
}
+WebString WebInputElement::localizeValue(const WebString& proposedValue) const
+{
+ return constUnwrap<HTMLInputElement>()->localizeValue(proposedValue);
+}
+
bool WebInputElement::isSpeechInputEnabled() const
{
#if ENABLE(INPUT_SPEECH)