haikuwebkit/ManualTests/input-number-localization.html

39 lines
1.3 KiB
HTML
Raw Permalink Normal View History

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: Canonical link: https://commits.webkit.org/69993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80096 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-03-02 06:54:56 +00:00
<!DOCTYPE html>
<html>
<head>
<title>Number type input shows and accepts localized numbers</title>
<style>
:invalid {
border-color: red;
-webkit-box-shadow: 4px 4px 8px #ff8888;
}
</style>
</head>
<body>
<div id="console"></div>
<p>Output test 1: The following text field should have a localized representation for "-1234.5678".
Source/WebCore: Display number field without using a thousand separator. https://bugs.webkit.org/show_bug.cgi?id=65064 Patch by Shinya Kawanaka <shinyak@google.com> on 2011-07-23 Reviewed by Kent Tamura. Separated formatters for parsing and displaying. Removed a test for thousand separator. * manual-tests/input-number-localization.html: Removed a test for thousand separator. Made the test description more specific. * platform/text/LocalizedNumberICU.cpp: (WebCore::createFormatterForCurrentLocaleToDisplay): Added to introduce a formatter for display. (WebCore::numberFormatterForParsing): Changed the name to be clear. (WebCore::numberFormatterForDisplay): Added. (WebCore::parseLocalizedNumber): Used numberFormatterForParsing. (WebCore::formatLocalizedNumber): Used numberFormatterForDisplay. * platform/text/mac/LocalizedNumberMac.mm: (WebCore::createFormatterForCurrentLocaleForDisplay): Added to introduce a formatter for display. (WebCore::numberFormatterForParsing): Changed the name to be clear. (WebCore::numberFormatterForDisplay): Added. (WebCore::parseLocalizedNumber): Used numberFormatterForParsing. (WebCore::formatLocalizedNumber): Used numberFormatterForDisplay. LayoutTests: Marked fast/speech/input-appearance-numberandspeech.html flaky on Mac and Windows. https://bugs.webkit.org/show_bug.cgi?id=65064 Patch by Shinya Kawanaka <shinyak@google.com> on 2011-07-23 Reviewed by Kent Tamura. * platform/chromium/test_expectations.txt: Mark fast/speech/input-appearance-numberandspeech.html flaky on Mac and Windows. Canonical link: https://commits.webkit.org/80814@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@91636 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-07-23 16:21:14 +00:00
e.g. "-1234.5678" for en_US locale, "-1234,5678" for fr_FR locale. The thousand separator is
currently off.</p>
2011-03-22 Kent Tamura <tkent@chromium.org> Reviewed by Eric Seidel. REGRESSION(r80096): Number type input unexpectedly rounds fractional values https://bugs.webkit.org/show_bug.cgi?id=56367 Introduce clampToInteger(unsigned). * wtf/MathExtras.h: (clampToInteger): Added. 2011-03-22 Kent Tamura <tkent@chromium.org> Reviewed by Eric Seidel. REGRESSION(r80096): Number type input unexpectedly rounds fractional values https://bugs.webkit.org/show_bug.cgi?id=56367 Because the default value of the maximum fractional digits of NSNumberFormatter and ICU NumberFormat is 3, the value 0.55555 is rounded to 0.556 in a localized representation. This bug affects only in Mac and Chromium. To fix this bug, - Add "maximum fractional digits" parameter to formatLocalizedNumber(), and - NumberInputType::visibleValue uses parseToDoubleForNumberTypeWithDecimalPlaces() instead of parseToDoubleForNumberType(). No automated tests because the behavior is locale-dependent. This change updates a manual test. * html/NumberInputType.cpp: (WebCore::NumberInputType::visibleValue): Use parseToDoubleForNumberTypeWithDecimalPlaces() and passing fractional part length to formatLocalizedNumber(). * manual-tests/input-number-localization.html: Update the test to cover this change. * platform/text/LocalizedNumber.h: Add a parameter to formatLocalizedNumber(). * platform/text/LocalizedNumberICU.cpp: (WebCore::formatLocalizedNumber): Call setMaximumFractionalDigits(). * platform/text/LocalizedNumberNone.cpp: (WebCore::formatLocalizedNumber): * platform/text/mac/LocalizedNumberMac.mm: (WebCore::formatLocalizedNumber): Call setMaximumFractionalDigits(). Canonical link: https://commits.webkit.org/71481@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@81649 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-03-22 07:43:21 +00:00
<div><input type=number value="-1234.5678" step=any></div>
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: Canonical link: https://commits.webkit.org/69993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80096 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-03-02 06:54:56 +00:00
<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,
Source/WebCore: Display number field without using a thousand separator. https://bugs.webkit.org/show_bug.cgi?id=65064 Patch by Shinya Kawanaka <shinyak@google.com> on 2011-07-23 Reviewed by Kent Tamura. Separated formatters for parsing and displaying. Removed a test for thousand separator. * manual-tests/input-number-localization.html: Removed a test for thousand separator. Made the test description more specific. * platform/text/LocalizedNumberICU.cpp: (WebCore::createFormatterForCurrentLocaleToDisplay): Added to introduce a formatter for display. (WebCore::numberFormatterForParsing): Changed the name to be clear. (WebCore::numberFormatterForDisplay): Added. (WebCore::parseLocalizedNumber): Used numberFormatterForParsing. (WebCore::formatLocalizedNumber): Used numberFormatterForDisplay. * platform/text/mac/LocalizedNumberMac.mm: (WebCore::createFormatterForCurrentLocaleForDisplay): Added to introduce a formatter for display. (WebCore::numberFormatterForParsing): Changed the name to be clear. (WebCore::numberFormatterForDisplay): Added. (WebCore::parseLocalizedNumber): Used numberFormatterForParsing. (WebCore::formatLocalizedNumber): Used numberFormatterForDisplay. LayoutTests: Marked fast/speech/input-appearance-numberandspeech.html flaky on Mac and Windows. https://bugs.webkit.org/show_bug.cgi?id=65064 Patch by Shinya Kawanaka <shinyak@google.com> on 2011-07-23 Reviewed by Kent Tamura. * platform/chromium/test_expectations.txt: Mark fast/speech/input-appearance-numberandspeech.html flaky on Mac and Windows. Canonical link: https://commits.webkit.org/80814@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@91636 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-07-23 16:21:14 +00:00
-1.234,5678 for fr_FR locale) into the following text field.
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: Canonical link: https://commits.webkit.org/69993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80096 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-03-02 06:54:56 +00:00
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>
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: Canonical link: https://commits.webkit.org/69993@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@80096 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2011-03-02 06:54:56 +00:00
<div><input type=number id=target step=any oninput="handleInput()"></div>
<div>Standard format: <output id=output></output></div>
<script>
function handleInput() {
document.getElementById('output').value = document.getElementById('target').value;
}
</script>
</body>
</html>