- Revision
- 142122
- Author
- [email protected]
- Date
- 2013-02-07 07:46:58 -0800 (Thu, 07 Feb 2013)
Log Message
Conversion from localized numbers to HTML numbers should accept not only localized numbers but also HTML numbers
https://bugs.webkit.org/show_bug.cgi?id=109160
Reviewed by Kentaro Hara.
Source/WebCore:
For example, A French user needs to specify a number to a number input
field. He might use a local decimal point, like 3,141592, or he might
use the standard decimal point like 3.141592. We had better accept both
of them.
We accepted both last year, but we changed the behavior so that we
accept only localized numbers because we had some cases where an input
string can be recognized as both of a localized number and the standard
number. e.g. 3.141 is 3141 in French locale and 3.141 in the
standard. Now we introduce a simple rule that we don't accept group
separator at all. So users won't confuse even if we accept both of
decimal points.
Test: fast/forms/number/number-l10n-input.html
* platform/text/PlatformLocale.cpp:
(WebCore::Locale::convertFromLocalizedNumber):
If the specified string contains invalid characters including group
separators, just return the specified string.
LayoutTests:
* fast/forms/number/number-l10n-input-expected.txt: Added.
* fast/forms/number/number-l10n-input.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (142121 => 142122)
--- trunk/LayoutTests/ChangeLog 2013-02-07 15:35:27 UTC (rev 142121)
+++ trunk/LayoutTests/ChangeLog 2013-02-07 15:46:58 UTC (rev 142122)
@@ -1,3 +1,13 @@
+2013-02-07 Kent Tamura <[email protected]>
+
+ Conversion from localized numbers to HTML numbers should accept not only localized numbers but also HTML numbers
+ https://bugs.webkit.org/show_bug.cgi?id=109160
+
+ Reviewed by Kentaro Hara.
+
+ * fast/forms/number/number-l10n-input-expected.txt: Added.
+ * fast/forms/number/number-l10n-input.html: Added.
+
2013-02-07 Stephen White <[email protected]>
[chromium] New baselines for GPU-accelerated reference filters tests. Unreviewed.
Added: trunk/LayoutTests/fast/forms/number/number-l10n-input-expected.txt (0 => 142122)
--- trunk/LayoutTests/fast/forms/number/number-l10n-input-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/number/number-l10n-input-expected.txt 2013-02-07 15:46:58 UTC (rev 142122)
@@ -0,0 +1,18 @@
+Putting some ASCII digit strings to a number input using localized digits.
+PASS document.execCommand("InsertText", false, "1234"); arabicInput.value is "1234"
+PASS document.execCommand("InsertText", false, "1.234"); arabicInput.value is "1.234"
+PASS document.execCommand("InsertText", false, "1,234"); arabicInput.value is ""
+
+Putting some digit strings to a French number input.
+PASS document.execCommand("InsertText", false, "1234"); frenchInput.value is "1234"
+PASS document.execCommand("InsertText", false, "1,234"); frenchInput.value is "1.234"
+PASS document.execCommand("InsertText", false, "1.234"); frenchInput.value is "1.234"
+
+Puttting some digit strings to an English number input.
+PASS document.execCommand("InsertText", false, "1234"); englishInput.value is "1234"
+PASS document.execCommand("InsertText", false, "1.234"); englishInput.value is "1.234"
+PASS document.execCommand("InsertText", false, "1,234"); englishInput.value is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/number/number-l10n-input.html (0 => 142122)
--- trunk/LayoutTests/fast/forms/number/number-l10n-input.html (rev 0)
+++ trunk/LayoutTests/fast/forms/number/number-l10n-input.html 2013-02-07 15:46:58 UTC (rev 142122)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<body>
+<script src=""
+<script>
+if (window.internals)
+ internals.settings.setLangAttributeAwareFormControlUIEnabled(true);
+else
+ debug('Require DRT/WRT.');
+</script>
+
+<input id="input-ar" lang="ar-eg" type="number">
+<input id="input-fr" lang="fr-fr" type="number">
+<input id="input-en" lang="en-us" type="number">
+
+<script>
+debug('Putting some ASCII digit strings to a number input using localized digits.');
+var arabicInput = document.getElementById('input-ar');
+arabicInput.focus();
+shouldBeEqualToString('document.execCommand("InsertText", false, "1234"); arabicInput.value', '1234');
+arabicInput.value = '';
+shouldBeEqualToString('document.execCommand("InsertText", false, "1.234"); arabicInput.value', '1.234');
+arabicInput.value = '';
+shouldBeEqualToString('document.execCommand("InsertText", false, "1,234"); arabicInput.value', '');
+
+debug('');
+debug('Putting some digit strings to a French number input.');
+var frenchInput = document.getElementById('input-fr');
+frenchInput.focus();
+shouldBeEqualToString('document.execCommand("InsertText", false, "1234"); frenchInput.value', '1234');
+frenchInput.value = '';
+shouldBeEqualToString('document.execCommand("InsertText", false, "1,234"); frenchInput.value', '1.234');
+frenchInput.value = '';
+shouldBeEqualToString('document.execCommand("InsertText", false, "1.234"); frenchInput.value', '1.234');
+
+debug('');
+debug('Puttting some digit strings to an English number input.');
+var englishInput = document.getElementById('input-en');
+englishInput.focus();
+shouldBeEqualToString('document.execCommand("InsertText", false, "1234"); englishInput.value', '1234');
+englishInput.value = '';
+shouldBeEqualToString('document.execCommand("InsertText", false, "1.234"); englishInput.value', '1.234');
+englishInput.value = '';
+shouldBeEqualToString('document.execCommand("InsertText", false, "1,234"); englishInput.value', '');
+
+
+</script>
+<script src=""
+</body>
Modified: trunk/Source/WebCore/ChangeLog (142121 => 142122)
--- trunk/Source/WebCore/ChangeLog 2013-02-07 15:35:27 UTC (rev 142121)
+++ trunk/Source/WebCore/ChangeLog 2013-02-07 15:46:58 UTC (rev 142122)
@@ -1,3 +1,30 @@
+2013-02-07 Kent Tamura <[email protected]>
+
+ Conversion from localized numbers to HTML numbers should accept not only localized numbers but also HTML numbers
+ https://bugs.webkit.org/show_bug.cgi?id=109160
+
+ Reviewed by Kentaro Hara.
+
+ For example, A French user needs to specify a number to a number input
+ field. He might use a local decimal point, like 3,141592, or he might
+ use the standard decimal point like 3.141592. We had better accept both
+ of them.
+
+ We accepted both last year, but we changed the behavior so that we
+ accept only localized numbers because we had some cases where an input
+ string can be recognized as both of a localized number and the standard
+ number. e.g. 3.141 is 3141 in French locale and 3.141 in the
+ standard. Now we introduce a simple rule that we don't accept group
+ separator at all. So users won't confuse even if we accept both of
+ decimal points.
+
+ Test: fast/forms/number/number-l10n-input.html
+
+ * platform/text/PlatformLocale.cpp:
+ (WebCore::Locale::convertFromLocalizedNumber):
+ If the specified string contains invalid characters including group
+ separators, just return the specified string.
+
2013-02-07 Xiaobo Wang <[email protected]>
[BlackBerry] CHHW - Characters that are using 32 bits encoding get trunked to 16bits
Modified: trunk/Source/WebCore/platform/text/PlatformLocale.cpp (142121 => 142122)
--- trunk/Source/WebCore/platform/text/PlatformLocale.cpp 2013-02-07 15:35:27 UTC (rev 142121)
+++ trunk/Source/WebCore/platform/text/PlatformLocale.cpp 2013-02-07 15:46:58 UTC (rev 142122)
@@ -305,10 +305,8 @@
bool isNegative;
unsigned startIndex;
unsigned endIndex;
- if (!detectSignAndGetDigitRange(input, isNegative, startIndex, endIndex)) {
- // Input is broken. Returning an invalid number string.
- return "*";
- }
+ if (!detectSignAndGetDigitRange(input, isNegative, startIndex, endIndex))
+ return input;
StringBuilder builder;
builder.reserveCapacity(input.length());
@@ -317,13 +315,12 @@
for (unsigned i = startIndex; i < endIndex;) {
unsigned symbolIndex = matchedDecimalSymbolIndex(input, i);
if (symbolIndex >= DecimalSymbolsSize)
- return "*";
+ return input;
if (symbolIndex == DecimalSeparatorIndex)
builder.append('.');
- else if (symbolIndex == GroupSeparatorIndex) {
- // Ignore group separators.
-
- } else
+ else if (symbolIndex == GroupSeparatorIndex)
+ return input;
+ else
builder.append(static_cast<UChar>('0' + symbolIndex));
}
return builder.toString();