Changeset 80096 in webkit


Ignore:
Timestamp:
Mar 1, 2011 10:54:56 PM (13 years ago)
Author:
tkent@chromium.org
Message:

Support localized numbers in <input type=number>
https://bugs.webkit.org/show_bug.cgi?id=42484

Reviewed by Dimitri Glazkov.

Source/WebCore:

This change adds support of localized numbers in <input type=number>.
This affects only the UI, and not HTMLInputElement::value.

  • Remove the keyboard input restriction feature because it is hard to retrieve characters usable for localized numbers in ICU.
  • Separate convertFromVisibleValue() from sanitizeValue(). sanitizeValue() is used for not only converting a renderer value to a DOM value.
  • Implement LocalizedNumber functions for ICU and NSNumberFormatter. It is used only in Chromium for now.

Test: manual-tests/input-number-localization.html

  • WebCore.gypi: Use LocalizedNumberICU.cpp.
  • WebCore.xcodeproj/project.pbxproj: Add LocalizedNumberMac.mm and remove LocalizedNumberNone.cpp.
  • dom/InputElement.h: Introduce convertFromVisibleValue().
  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::convertFromVisibleValue):

  • html/HTMLInputElement.h:
  • html/InputType.cpp:

(WebCore::InputType::convertFromVisibleValue):

  • html/InputType.h:
  • html/NumberInputType.cpp: Remove isHTMLNumberCharacter(), isNumberCharacter(), and handleBeforeTextInsertedEvent() because we remove the keyboard input restriction feature for type=number.

(WebCore::NumberInputType::convertFromVisibleValue):
(WebCore::NumberInputType::sanitizeValue):

  • html/NumberInputType.h:
  • manual-tests/input-number-localization.html: Add a manual test because the behavior depends on the current locale.
  • platform/text/LocalizedNumber.h: Remove isLocalizedNumberCharacter().
  • platform/text/LocalizedNumberICU.cpp: Implement LocalizedNumber functions with ICU NumberFormat.

(WebCore::createFormatterForCurrentLocale):
(WebCore::parseLocalizedNumber):
(WebCore::formatLocalizedNumber):

  • platform/text/LocalizedNumberNone.cpp: Remove isLocalizedNumberCharacter().
  • platform/text/mac/LocalizedNumberMac.mm: Implement LocalizedNumber functions with NSNumberFormatter.

(WebCore::parseLocalizedNumber):
(WebCore::formatLocalizedNumber):

  • rendering/RenderTextControlSingleLine.cpp:

(WebCore::RenderTextControlSingleLine::subtreeHasChanged):

  • wml/WMLInputElement.h:

(WebCore::WMLInputElement::convertFromVisibleValue):

Implemented as a function doing nothing.

LayoutTests:

Update an existing test because of removing the keyboard input
restriction feature.

  • fast/forms/input-number-keyoperation-expected.txt:
  • fast/forms/script-tests/input-number-keyoperation.js:
Location:
trunk
Files:
1 added
17 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r80091 r80096  
     12011-03-01  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Support localized numbers in <input type=number>
     6        https://bugs.webkit.org/show_bug.cgi?id=42484
     7
     8        Update an existing test because of removing the keyboard input
     9        restriction feature.
     10
     11        * fast/forms/input-number-keyoperation-expected.txt:
     12        * fast/forms/script-tests/input-number-keyoperation.js:
     13
    1142011-03-01  Victoria Kirst  <vrk@chromium.org>
    215
  • trunk/LayoutTests/fast/forms/input-number-keyoperation-expected.txt

    r76662 r80096  
    55
    66Inserting "ab123cd":
    7 PASS input.value is "123"
     7PASS input.value is ""
    88Press the up arrow key:
    99PASS input.value is "124"
  • trunk/LayoutTests/fast/forms/script-tests/input-number-keyoperation.js

    r76662 r80096  
    88debug('Inserting "ab123cd":');
    99document.execCommand('InsertText', false, 'ab123cd');
    10 shouldBe('input.value', '"123"');
     10shouldBe('input.value', '""');
    1111
    1212debug('Press the up arrow key:');
     13input.valueAsNumber = 123;
    1314eventSender.keyDown('upArrow');
    1415shouldBe('input.value', '"124"');
  • trunk/Source/WebCore/ChangeLog

    r80092 r80096  
     12011-03-01  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Support localized numbers in <input type=number>
     6        https://bugs.webkit.org/show_bug.cgi?id=42484
     7
     8        This change adds support of localized numbers in <input type=number>.
     9        This affects only the UI, and not HTMLInputElement::value.
     10
     11        - Remove the keyboard input restriction feature because it is hard to
     12          retrieve characters usable for localized numbers in ICU.
     13
     14        - Separate convertFromVisibleValue() from sanitizeValue().
     15          sanitizeValue() is used for not only converting a renderer value to a
     16          DOM value.
     17
     18        - Implement LocalizedNumber functions for ICU and NSNumberFormatter.
     19          It is used only in Chromium for now.
     20
     21        Test: manual-tests/input-number-localization.html
     22
     23        * WebCore.gypi: Use LocalizedNumberICU.cpp.
     24        * WebCore.xcodeproj/project.pbxproj:
     25          Add LocalizedNumberMac.mm and remove LocalizedNumberNone.cpp.
     26        * dom/InputElement.h: Introduce convertFromVisibleValue().
     27        * html/HTMLInputElement.cpp:
     28        (WebCore::HTMLInputElement::convertFromVisibleValue):
     29        * html/HTMLInputElement.h:
     30        * html/InputType.cpp:
     31        (WebCore::InputType::convertFromVisibleValue):
     32        * html/InputType.h:
     33        * html/NumberInputType.cpp: Remove isHTMLNumberCharacter(),
     34          isNumberCharacter(), and handleBeforeTextInsertedEvent() because we
     35          remove the keyboard input restriction feature for type=number.
     36        (WebCore::NumberInputType::convertFromVisibleValue):
     37        (WebCore::NumberInputType::sanitizeValue):
     38        * html/NumberInputType.h:
     39        * manual-tests/input-number-localization.html: Add a manual test because
     40          the behavior depends on the current locale.
     41        * platform/text/LocalizedNumber.h: Remove isLocalizedNumberCharacter().
     42        * platform/text/LocalizedNumberICU.cpp:
     43          Implement LocalizedNumber functions with ICU NumberFormat.
     44        (WebCore::createFormatterForCurrentLocale):
     45        (WebCore::parseLocalizedNumber):
     46        (WebCore::formatLocalizedNumber):
     47        * platform/text/LocalizedNumberNone.cpp: Remove isLocalizedNumberCharacter().
     48        * platform/text/mac/LocalizedNumberMac.mm:
     49          Implement LocalizedNumber functions with NSNumberFormatter.
     50        (WebCore::parseLocalizedNumber):
     51        (WebCore::formatLocalizedNumber):
     52        * rendering/RenderTextControlSingleLine.cpp:
     53        (WebCore::RenderTextControlSingleLine::subtreeHasChanged):
     54        * wml/WMLInputElement.h:
     55        (WebCore::WMLInputElement::convertFromVisibleValue):
     56          Implemented as a function doing nothing.
     57
    1582011-03-01  Yuta Kitamura  <yutak@chromium.org>
    259
  • trunk/Source/WebCore/WebCore.gypi

    r80081 r80096  
    33863386            'platform/text/LineEnding.h',
    33873387            'platform/text/LocalizedNumber.h',
    3388             'platform/text/LocalizedNumberNone.cpp',
     3388            'platform/text/LocalizedNumberICU.cpp',
    33893389            'platform/text/ParserUtilities.h',
    33903390            'platform/text/PlatformString.h',
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r80074 r80096  
    56035603                F4EAF4AF10C742B1009100D3 /* OpenTypeSanitizer.h in Headers */ = {isa = PBXBuildFile; fileRef = F4EAF4AD10C742B1009100D3 /* OpenTypeSanitizer.h */; };
    56045604                F5142C69123F12B000F5BD4C /* LocalizedNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = F5142C68123F12B000F5BD4C /* LocalizedNumber.h */; };
    5605                 F5142C6B123F12C500F5BD4C /* LocalizedNumberNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5142C6A123F12C500F5BD4C /* LocalizedNumberNone.cpp */; };
    56065605                F55B3DAD1251F12D003EF269 /* BaseTextInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F55B3D791251F12D003EF269 /* BaseTextInputType.cpp */; };
    56075606                F55B3DAE1251F12D003EF269 /* BaseTextInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = F55B3D7A1251F12D003EF269 /* BaseTextInputType.h */; };
     
    56675666                F5C041E60FFCA96D00839D4A /* JSHTMLDataListElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5C041E10FFCA96D00839D4A /* JSHTMLDataListElement.cpp */; };
    56685667                F5C041E70FFCA96D00839D4A /* JSHTMLDataListElement.h in Headers */ = {isa = PBXBuildFile; fileRef = F5C041E20FFCA96D00839D4A /* JSHTMLDataListElement.h */; };
     5668                F5CC42DC12F801CA00D5F7E3 /* LocalizedNumberMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = F5CC42DB12F801CA00D5F7E3 /* LocalizedNumberMac.mm */; };
    56695669                F5D3A57C106B83B300545297 /* DateComponents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5D3A57A106B83B300545297 /* DateComponents.cpp */; };
    56705670                F5D3A57D106B83B300545297 /* DateComponents.h in Headers */ = {isa = PBXBuildFile; fileRef = F5D3A57B106B83B300545297 /* DateComponents.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1200912009                F4EAF4AD10C742B1009100D3 /* OpenTypeSanitizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OpenTypeSanitizer.h; path = opentype/OpenTypeSanitizer.h; sourceTree = "<group>"; };
    1201012010                F5142C68123F12B000F5BD4C /* LocalizedNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalizedNumber.h; sourceTree = "<group>"; };
    12011                 F5142C6A123F12C500F5BD4C /* LocalizedNumberNone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalizedNumberNone.cpp; sourceTree = "<group>"; };
    1201212011                F523D23B02DE4396018635CA /* HTMLDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLDocument.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    1201312012                F523D23C02DE4396018635CA /* HTMLDocument.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HTMLDocument.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    1209512094                F5C2869402846DCD018635CA /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
    1209612095                F5C2869502846DCD018635CA /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
     12096                F5CC42DB12F801CA00D5F7E3 /* LocalizedNumberMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalizedNumberMac.mm; sourceTree = "<group>"; };
    1209712097                F5D3A57A106B83B300545297 /* DateComponents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DateComponents.cpp; sourceTree = "<group>"; };
    1209812098                F5D3A57B106B83B300545297 /* DateComponents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateComponents.h; sourceTree = "<group>"; };
     
    1759417594                                89B5EAA011E8003D00F2367E /* LineEnding.h */,
    1759517595                                F5142C68123F12B000F5BD4C /* LocalizedNumber.h */,
    17596                                 F5142C6A123F12C500F5BD4C /* LocalizedNumberNone.cpp */,
    1759717596                                BC76AC110DD7AD5C00415F34 /* ParserUtilities.h */,
    1759817597                                B2C3D9FB0D006C1D00EF6F26 /* PlatformString.h */,
     
    1764317642                                B2C3D9FA0D006C1D00EF6F26 /* CharsetData.h */,
    1764417643                                375CD239119D44EA00A2A859 /* HyphenationMac.mm */,
     17644                                F5CC42DB12F801CA00D5F7E3 /* LocalizedNumberMac.mm */,
    1764517645                                B2AFFC860D00A5DF0030074D /* mac-encodings.txt */,
    1764617646                                B2AFFC870D00A5DF0030074D /* make-charset-table.pl */,
     
    2436224362                                06E81EEC0AB5DA9700C87837 /* LocalCurrentGraphicsContext.mm in Sources */,
    2436324363                                89878567122CA064003AABDA /* LocalFileSystem.cpp in Sources */,
    24364                                 F5142C6B123F12C500F5BD4C /* LocalizedNumberNone.cpp in Sources */,
     24364                                F5CC42DC12F801CA00D5F7E3 /* LocalizedNumberMac.mm in Sources */,
    2436524365                                C046E1AC1208A9FE00BA2CF7 /* LocalizedStrings.cpp in Sources */,
    2436624366                                BC25B52A131C6D3900180E10 /* LocalizedStringsMac.mm in Sources */,
  • trunk/Source/WebCore/dom/InputElement.h

    r79954 r80096  
    6262    // The value which is drawn by a renderer.
    6363    virtual String visibleValue() const = 0;
     64    virtual String convertFromVisibleValue(const String&) const = 0;
    6465
    6566    // Returns true if the specified string can be set as the value of InputElement.
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r79777 r80096  
    11511151}
    11521152
     1153String HTMLInputElement::convertFromVisibleValue(const String& visibleValue) const
     1154{
     1155    return m_inputType->convertFromVisibleValue(visibleValue);
     1156}
     1157
    11531158bool HTMLInputElement::isAcceptableValue(const String& proposedValue) const
    11541159{
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r76664 r80096  
    261261
    262262    virtual String visibleValue() const;
     263    virtual String convertFromVisibleValue(const String&) const;
    263264    virtual bool isAcceptableValue(const String&) const;
    264265    virtual String sanitizeValue(const String&) const;
  • trunk/Source/WebCore/html/InputType.cpp

    r77500 r80096  
    516516}
    517517
     518String InputType::convertFromVisibleValue(const String& visibleValue) const
     519{
     520    return visibleValue;
     521}
     522
    518523bool InputType::isAcceptableValue(const String&)
    519524{
  • trunk/Source/WebCore/html/InputType.h

    r79954 r80096  
    150150    virtual bool canSetStringValue() const;
    151151    virtual String visibleValue() const;
     152    virtual String convertFromVisibleValue(const String&) const;
    152153    virtual bool isAcceptableValue(const String&);
    153154    // Returing the null string means "use the default value."
  • trunk/Source/WebCore/html/NumberInputType.cpp

    r79954 r80096  
    5454static const double numberStepScaleFactor = 1.0;
    5555
    56 // Returns true if the specified character can be a part of 'valid floating
    57 // point number' of HTML5.
    58 static bool isHTMLNumberCharacter(UChar ch)
    59 {
    60     return ch == '+' || ch == '-' || ch == '.' || ch == 'e' || ch == 'E' || isASCIIDigit(ch);
    61 }
    62 
    63 static bool isNumberCharacter(UChar ch)
    64 {
    65     return isLocalizedNumberCharacter(ch) || isHTMLNumberCharacter(ch);
    66 }
    67 
    6856PassOwnPtr<InputType> NumberInputType::create(HTMLInputElement* element)
    6957{
     
    184172}
    185173
    186 void NumberInputType::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event)
    187 {
    188     unsigned length = event->text().length();
    189     bool hasInvalidChar = false;
    190     for (unsigned i = 0; i < length; ++i) {
    191         if (!isNumberCharacter(event->text()[i])) {
    192             hasInvalidChar = true;
    193             break;
    194         }
    195     }
    196     if (hasInvalidChar) {
    197         Vector<UChar> stripped;
    198         stripped.reserveCapacity(length);
    199         for (unsigned i = 0; i < length; ++i) {
    200             UChar ch = event->text()[i];
    201             if (!isNumberCharacter(ch))
    202                 continue;
    203             stripped.append(ch);
    204         }
    205         event->setText(String::adopt(stripped));
    206     }
    207     TextFieldInputType::handleBeforeTextInsertedEvent(event);
    208 }
    209 
    210174void NumberInputType::handleWheelEvent(WheelEvent* event)
    211175{
     
    265229}
    266230
     231String NumberInputType::convertFromVisibleValue(const String& visibleValue) const
     232{
     233    if (visibleValue.isEmpty())
     234        return visibleValue;
     235    double parsedNumber = parseLocalizedNumber(visibleValue);
     236    return isfinite(parsedNumber) ? serializeForNumberType(parsedNumber) : visibleValue;
     237}
     238
    267239bool NumberInputType::isAcceptableValue(const String& proposedValue)
    268240{
     
    274246    if (proposedValue.isEmpty())
    275247        return proposedValue;
    276     // Try to parse the value as a localized number, then try to parse it as
    277     // the standard format.
    278     double parsedValue = parseLocalizedNumber(proposedValue);
    279     if (isfinite(parsedValue))
    280         return serializeForNumberType(parsedValue);
    281248    return parseToDoubleForNumberType(proposedValue, 0) ? proposedValue : emptyAtom.string();
    282249}
  • trunk/Source/WebCore/html/NumberInputType.h

    r76661 r80096  
    5858    virtual double stepScaleFactor() const;
    5959    virtual void handleKeydownEvent(KeyboardEvent*);
    60     virtual void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*);
    6160    virtual void handleWheelEvent(WheelEvent*);
    6261    virtual double parseToDouble(const String&, double) const;
     
    6665    virtual void handleBlurEvent();
    6766    virtual String visibleValue() const;
     67    virtual String convertFromVisibleValue(const String&) const;
    6868    virtual bool isAcceptableValue(const String&);
    6969    virtual String sanitizeValue(const String&);
  • trunk/Source/WebCore/platform/text/LocalizedNumber.h

    r76661 r80096  
    5050String formatLocalizedNumber(double);
    5151
    52 // Returns true if the input character can be used to represent a
    53 // number in the browser locale. For example, this should return true for 0-9 .
    54 // , + - for en-US locale.
    55 bool isLocalizedNumberCharacter(UChar32);
    56 
    5752} // namespace WebCore
    5853
  • trunk/Source/WebCore/platform/text/LocalizedNumberICU.cpp

    r80095 r80096  
    2929 */
    3030
    31 #ifndef LocalizedNumber_h
    32 #define LocalizedNumber_h
     31#include "config.h"
     32#include "LocalizedNumber.h"
    3333
    34 #include <wtf/text/WTFString.h>
     34#include <limits>
     35#include <unicode/numfmt.h>
     36#include <wtf/PassOwnPtr.h>
     37
     38using namespace std;
    3539
    3640namespace WebCore {
    3741
    38 // Parses a string representation of a floating point number localized
    39 // for the browser's current locale. If the input string is not valid
    40 // or an implementation doesn't support localized numbers, this
    41 // function returns NaN. This function doesn't need to support
    42 // scientific notation, NaN, +Infinity and -Infinity, and doesn't need
    43 // to support the standard representations of ECMAScript and HTML5.
    44 double parseLocalizedNumber(const String&);
     42static inline PassOwnPtr<NumberFormat> createFormatterForCurrentLocale()
     43{
     44    UErrorCode status = U_ZERO_ERROR;
     45    return adoptPtr(NumberFormat::createInstance(status));
     46}
    4547
    46 // Serializes the specified floating point number for the browser's
    47 // current locale.  If an implementation doesn't support localized
    48 // numbers or the input value is NaN or Infinitiy, the function should
    49 // return an empty string.
    50 String formatLocalizedNumber(double);
     48double parseLocalizedNumber(const String& numberString)
     49{
     50    if (numberString.isEmpty())
     51        return numeric_limits<double>::quiet_NaN();
     52    OwnPtr<NumberFormat> formatter = createFormatterForCurrentLocale();
     53    if (!formatter)
     54        return numeric_limits<double>::quiet_NaN();
     55    UnicodeString numberUnicodeString(numberString.characters(), numberString.length());
     56    UErrorCode status = U_ZERO_ERROR;
     57    Formattable result;
     58    formatter->parse(numberUnicodeString, result, status);
     59    if (status != U_ZERO_ERROR)
     60        return numeric_limits<double>::quiet_NaN();
     61    double numericResult = result.getDouble(status);
     62    return status == U_ZERO_ERROR ? numericResult : numeric_limits<double>::quiet_NaN();
     63}
    5164
    52 // Returns true if the input character can be used to represent a
    53 // number in the browser locale. For example, this should return true for 0-9 .
    54 // , + - for en-US locale.
    55 bool isLocalizedNumberCharacter(UChar32);
     65String formatLocalizedNumber(double number)
     66{
     67    OwnPtr<NumberFormat> formatter = createFormatterForCurrentLocale();
     68    if (!formatter)
     69        return String();
     70    UnicodeString result;
     71    formatter->format(number, result);
     72    return String(result.getBuffer(), result.length());
     73}
    5674
    5775} // namespace WebCore
    58 
    59 #endif // LocalizedNumber_h
  • trunk/Source/WebCore/platform/text/LocalizedNumberNone.cpp

    r76661 r80096  
    4848}
    4949
    50 bool isLocalizedNumberCharacter(UChar32)
    51 {
    52     return false;
    53 }
    54 
    5550} // namespace WebCore
  • trunk/Source/WebCore/platform/text/mac/LocalizedNumberMac.mm

    r80095 r80096  
    3333
    3434#include <limits>
     35#import <Foundation/NSNumberFormatter.h>
     36#include <wtf/RetainPtr.h>
     37#include <wtf/text/CString.h>
    3538
    3639using namespace std;
     
    3841namespace WebCore {
    3942
    40 double parseLocalizedNumber(const String&)
     43double parseLocalizedNumber(const String& numberString)
    4144{
    42     return numeric_limits<double>::quiet_NaN();
     45    if (numberString.isEmpty())
     46        return numeric_limits<double>::quiet_NaN();
     47    RetainPtr<NSNumberFormatter> formatter(AdoptNS, [[NSNumberFormatter alloc] init]);
     48    [formatter.get() setLocalizesFormat:YES];
     49    [formatter.get() setNumberStyle:NSNumberFormatterDecimalStyle];
     50    NSNumber *number = [formatter.get() numberFromString:numberString];
     51    if (!number)
     52        return numeric_limits<double>::quiet_NaN();
     53    return [number doubleValue];
    4354}
    4455
    45 String formatLocalizedNumber(double)
     56String formatLocalizedNumber(double inputNumber)
    4657{
    47     return String();
    48 }
    49 
    50 bool isLocalizedNumberCharacter(UChar32)
    51 {
    52     return false;
     58    RetainPtr<NSNumber> number(AdoptNS, [[NSNumber alloc] initWithDouble:inputNumber]);
     59    RetainPtr<NSNumberFormatter> formatter(AdoptNS, [[NSNumberFormatter alloc] init]);
     60    [formatter.get() setLocalizesFormat:YES];
     61    [formatter.get() setNumberStyle:NSNumberFormatterDecimalStyle];
     62    return String([formatter.get() stringFromNumber:number.get()]);
    5363}
    5464
    5565} // namespace WebCore
     66
  • trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp

    r79978 r80096  
    192192    String value = text();
    193193    if (input->isAcceptableValue(value))
    194         input->setValueFromRenderer(input->sanitizeValue(value));
     194        input->setValueFromRenderer(input->sanitizeValue(input->convertFromVisibleValue(value)));
    195195    if (node()->isHTMLElement()) {
    196196        // Recalc for :invalid and hasUnacceptableValue() change.
  • trunk/Source/WebCore/wml/WMLInputElement.h

    r78232 r80096  
    6565    virtual void setValueForUser(const String&);
    6666    virtual String visibleValue() const { return value(); }
     67    virtual String convertFromVisibleValue(const String& value) const { return value; }
    6768    virtual void setValueFromRenderer(const String&);
    6869
Note: See TracChangeset for help on using the changeset viewer.