Changeset 142122 in webkit


Ignore:
Timestamp:
Feb 7, 2013 7:46:58 AM (11 years ago)
Author:
tkent@chromium.org
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.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r142119 r142122  
     12013-02-07  Kent Tamura  <tkent@chromium.org>
     2
     3        Conversion from localized numbers to HTML numbers should accept not only localized numbers but also HTML numbers
     4        https://bugs.webkit.org/show_bug.cgi?id=109160
     5
     6        Reviewed by Kentaro Hara.
     7
     8        * fast/forms/number/number-l10n-input-expected.txt: Added.
     9        * fast/forms/number/number-l10n-input.html: Added.
     10
    1112013-02-07  Stephen White  <senorblanco@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r142120 r142122  
     12013-02-07  Kent Tamura  <tkent@chromium.org>
     2
     3        Conversion from localized numbers to HTML numbers should accept not only localized numbers but also HTML numbers
     4        https://bugs.webkit.org/show_bug.cgi?id=109160
     5
     6        Reviewed by Kentaro Hara.
     7
     8        For example, A French user needs to specify a number to a number input
     9        field. He might use a local decimal point, like 3,141592, or he might
     10        use the standard decimal point like 3.141592. We had better accept both
     11        of them.
     12
     13        We accepted both last year, but we changed the behavior so that we
     14        accept only localized numbers because we had some cases where an input
     15        string can be recognized as both of a localized number and the standard
     16        number. e.g. 3.141 is 3141 in French locale and 3.141 in the
     17        standard. Now we introduce a simple rule that we don't accept group
     18        separator at all. So users won't confuse even if we accept both of
     19        decimal points.
     20
     21        Test: fast/forms/number/number-l10n-input.html
     22
     23        * platform/text/PlatformLocale.cpp:
     24        (WebCore::Locale::convertFromLocalizedNumber):
     25        If the specified string contains invalid characters including group
     26        separators, just return the specified string.
     27
    1282013-02-07  Xiaobo Wang  <xbwang@torchmobile.com.cn>
    229
  • trunk/Source/WebCore/platform/text/PlatformLocale.cpp

    r135355 r142122  
    306306    unsigned startIndex;
    307307    unsigned endIndex;
    308     if (!detectSignAndGetDigitRange(input, isNegative, startIndex, endIndex)) {
    309         // Input is broken. Returning an invalid number string.
    310         return "*";
    311     }
     308    if (!detectSignAndGetDigitRange(input, isNegative, startIndex, endIndex))
     309        return input;
    312310
    313311    StringBuilder builder;
     
    318316        unsigned symbolIndex = matchedDecimalSymbolIndex(input, i);
    319317        if (symbolIndex >= DecimalSymbolsSize)
    320             return "*";
     318            return input;
    321319        if (symbolIndex == DecimalSeparatorIndex)
    322320            builder.append('.');
    323         else if (symbolIndex == GroupSeparatorIndex) {
    324             // Ignore group separators.
    325 
    326         } else
     321        else if (symbolIndex == GroupSeparatorIndex)
     322            return input;
     323        else
    327324            builder.append(static_cast<UChar>('0' + symbolIndex));
    328325    }
Note: See TracChangeset for help on using the changeset viewer.