Title: [107196] trunk
- Revision
- 107196
- Author
- [email protected]
- Date
- 2012-02-09 01:33:54 -0800 (Thu, 09 Feb 2012)
Log Message
Do not localize numbers in scientific notation
https://bugs.webkit.org/show_bug.cgi?id=78208
Reviewed by Hajime Morita.
.:
* ManualTests/input-number-localization.html: Updated for scientific notation.
Source/WebCore:
For a preparation of fixing http://wkb.ug/62939, we stop supporting
localized numbers in scientific notation in <input type=number>.
We're going to change number localization processing so that it replaces
letters one by one. It will be very hard to support scientific notation.
* html/NumberInputType.cpp:
(WebCore::isE): A helper functio for String::find() to detect scientific notation.
(WebCore::NumberInputType::visibleValue): Avoid localization for scientific notation.
(WebCore::NumberInputType::convertFromVisibleValue): ditto.
(WebCore::NumberInputType::isAcceptableValue):
Use convertFromVisibleValue, also stop accepting a standard format as a fallback.
Modified Paths
Diff
Modified: trunk/ChangeLog (107195 => 107196)
--- trunk/ChangeLog 2012-02-09 09:18:37 UTC (rev 107195)
+++ trunk/ChangeLog 2012-02-09 09:33:54 UTC (rev 107196)
@@ -1,3 +1,12 @@
+2012-02-09 Kent Tamura <[email protected]>
+
+ Do not localize numbers in scientific notation
+ https://bugs.webkit.org/show_bug.cgi?id=78208
+
+ Reviewed by Hajime Morita.
+
+ * ManualTests/input-number-localization.html: Updated for scientific notation.
+
2012-02-09 Gyuyoung Kim <[email protected]>
[CMAKE] Change lowercase variable with uppercase's.
Modified: trunk/ManualTests/input-number-localization.html (107195 => 107196)
--- trunk/ManualTests/input-number-localization.html 2012-02-09 09:18:37 UTC (rev 107195)
+++ trunk/ManualTests/input-number-localization.html 2012-02-09 09:33:54 UTC (rev 107196)
@@ -12,14 +12,20 @@
<body>
<div id="console"></div>
-<p>Output test: The following text field should have a localized representation for "-1234.5678".
+<p>Output test 1: The following text field should have a localized representation for "-1234.5678".
e.g. "-1234.5678" for en_US locale, "-1234,5678" for fr_FR locale. The thousand separator is
currently off.</p>
<div><input type=number value="-1234.5678" step=any></div>
-<p>Input test: Type a localized representation of a number (e.g. -1,234.5678 for en_US locale,
+<p>Output test 2: The following text field should have "-1234.5678E+12" in any locale.
+</p>
+<div><input type=number value="-1234.5678E+12" step=any></div>
+
+<p>Input test 1: Type a localized representation of a number (e.g. -1,234.5678 for en_US locale,
-1.234,5678 for fr_FR locale) into the following text field.
You'll see an equivalent number in the standard format on the bottom of the text field.</p>
+<p>Input test 2: Type a number in the scientific notation (e.g. 0.1234e-10.)
+You'll see the same number string on the bottom of the text field.</p>
<div><input type=number id=target step=any _oninput_="handleInput()"></div>
<div>Standard format: <output id=output></output></div>
Modified: trunk/Source/WebCore/ChangeLog (107195 => 107196)
--- trunk/Source/WebCore/ChangeLog 2012-02-09 09:18:37 UTC (rev 107195)
+++ trunk/Source/WebCore/ChangeLog 2012-02-09 09:33:54 UTC (rev 107196)
@@ -1,3 +1,23 @@
+2012-02-09 Kent Tamura <[email protected]>
+
+ Do not localize numbers in scientific notation
+ https://bugs.webkit.org/show_bug.cgi?id=78208
+
+ Reviewed by Hajime Morita.
+
+ For a preparation of fixing http://wkb.ug/62939, we stop supporting
+ localized numbers in scientific notation in <input type=number>.
+
+ We're going to change number localization processing so that it replaces
+ letters one by one. It will be very hard to support scientific notation.
+
+ * html/NumberInputType.cpp:
+ (WebCore::isE): A helper functio for String::find() to detect scientific notation.
+ (WebCore::NumberInputType::visibleValue): Avoid localization for scientific notation.
+ (WebCore::NumberInputType::convertFromVisibleValue): ditto.
+ (WebCore::NumberInputType::isAcceptableValue):
+ Use convertFromVisibleValue, also stop accepting a standard format as a fallback.
+
2012-02-09 Leo Yang <[email protected]>
EntryBase.cpp is missing in CMake build system when turning on ENABLE_FILE_SYSTEM
Modified: trunk/Source/WebCore/html/NumberInputType.cpp (107195 => 107196)
--- trunk/Source/WebCore/html/NumberInputType.cpp 2012-02-09 09:18:37 UTC (rev 107195)
+++ trunk/Source/WebCore/html/NumberInputType.cpp 2012-02-09 09:33:54 UTC (rev 107196)
@@ -283,11 +283,19 @@
element()->updateInnerTextValue();
}
+static bool isE(UChar ch)
+{
+ return ch == 'e' || ch == 'E';
+}
+
String NumberInputType::visibleValue() const
{
String currentValue = element()->value();
if (currentValue.isEmpty())
return currentValue;
+ // We don't localize scientific notations.
+ if (currentValue.find(isE) != notFound)
+ return currentValue;
// FIXME: The following three lines should be removed when we
// remove the second argument of convertToLocalizedNumber().
double doubleValue = numeric_limits<double>::quiet_NaN();
@@ -300,12 +308,16 @@
{
if (visibleValue.isEmpty())
return visibleValue;
+ // We don't localize scientific notations.
+ if (visibleValue.find(isE) != notFound)
+ return visibleValue;
return convertFromLocalizedNumber(visibleValue);
}
bool NumberInputType::isAcceptableValue(const String& proposedValue)
{
- return proposedValue.isEmpty() || parseToDoubleForNumberType(convertFromLocalizedNumber(proposedValue), 0) || parseToDoubleForNumberType(proposedValue, 0);
+ String standardValue = convertFromVisibleValue(proposedValue);
+ return standardValue.isEmpty() || parseToDoubleForNumberType(standardValue, 0);
}
String NumberInputType::sanitizeValue(const String& proposedValue) const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes