Title: [91636] trunk
Revision
91636
Author
[email protected]
Date
2011-07-23 09:21:14 -0700 (Sat, 23 Jul 2011)

Log Message

Source/WebCore: Display number field without using a thousand separator.
https://bugs.webkit.org/show_bug.cgi?id=65064

Patch by Shinya Kawanaka <[email protected]> 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 <[email protected]> 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.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (91635 => 91636)


--- trunk/LayoutTests/ChangeLog	2011-07-23 15:39:47 UTC (rev 91635)
+++ trunk/LayoutTests/ChangeLog	2011-07-23 16:21:14 UTC (rev 91636)
@@ -1,3 +1,13 @@
+2011-07-23  Shinya Kawanaka  <[email protected]>
+
+        Marked fast/speech/input-appearance-numberandspeech.html flaky on Mac and Windows.
+        https://bugs.webkit.org/show_bug.cgi?id=65064
+
+        Reviewed by Kent Tamura.
+
+        * platform/chromium/test_expectations.txt:
+          Mark fast/speech/input-appearance-numberandspeech.html flaky on Mac and Windows.
+
 2011-07-23  Nikolas Zimmermann  <[email protected]>
 
         Move several SVG specific tests out of fast/(backgrounds|borders) into svg/(as-background-image|as-border-image) as

Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (91635 => 91636)


--- trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-07-23 15:39:47 UTC (rev 91635)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt	2011-07-23 16:21:14 UTC (rev 91636)
@@ -3500,6 +3500,7 @@
 BUGCR82891 LINUX : fast/speech/input-appearance-numberandspeech.html = TEXT IMAGE+TEXT PASS
 BUGCR82891 LINUX : fast/speech/input-appearance-searchandspeech.html = FAIL PASS
 BUGCR82891 LINUX : fast/speech/input-appearance-speechbutton.html = TEXT IMAGE+TEXT PASS
+BUGWK65064 WIN MAC : fast/speech/input-appearance-numberandspeech.html = FAIL PASS
 
 // Fails on windows - added in r86693
 BUGCR82950 WIN : http/tests/navigation/post-301-response.html = TEXT

Modified: trunk/LayoutTests/platform/chromium-mac/fast/speech/input-appearance-numberandspeech-expected.txt (91635 => 91636)


--- trunk/LayoutTests/platform/chromium-mac/fast/speech/input-appearance-numberandspeech-expected.txt	2011-07-23 15:39:47 UTC (rev 91635)
+++ trunk/LayoutTests/platform/chromium-mac/fast/speech/input-appearance-numberandspeech-expected.txt	2011-07-23 16:21:14 UTC (rev 91636)
@@ -164,131 +164,131 @@
 layer at (14,48) size 81x10 scrollWidth 172
   RenderBlock {DIV} at (0,0) size 81x10
     RenderText {#text} at (1,0) size 170x10
-      text run at (1,0) width 170: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 170: "12345678901234600000000000000"
 layer at (14,64) size 71x10 scrollWidth 172
   RenderBlock {DIV} at (0,0) size 71x10
     RenderText {#text} at (1,0) size 170x10
-      text run at (1,0) width 170: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 170: "12345678901234600000000000000"
 layer at (14,80) size 83x11 scrollWidth 193
   RenderBlock {DIV} at (0,0) size 83x11
     RenderText {#text} at (1,0) size 191x11
-      text run at (1,0) width 191: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 191: "12345678901234600000000000000"
 layer at (14,97) size 72x11 scrollWidth 193
   RenderBlock {DIV} at (0,0) size 72x11
     RenderText {#text} at (1,0) size 191x11
-      text run at (1,0) width 191: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 191: "12345678901234600000000000000"
 layer at (14,114) size 85x12 scrollWidth 214
   RenderBlock {DIV} at (0,0) size 85x12
     RenderText {#text} at (1,0) size 212x12
-      text run at (1,0) width 212: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 212: "12345678901234600000000000000"
 layer at (14,132) size 73x12 scrollWidth 214
   RenderBlock {DIV} at (0,0) size 73x12
     RenderText {#text} at (1,0) size 212x12
-      text run at (1,0) width 212: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 212: "12345678901234600000000000000"
 layer at (16,152) size 106x13 scrollWidth 236
   RenderBlock {DIV} at (0,0) size 106x13
     RenderText {#text} at (1,0) size 234x13
-      text run at (1,0) width 234: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 234: "12345678901234600000000000000"
 layer at (16,175) size 92x13 scrollWidth 236
   RenderBlock {DIV} at (0,0) size 92x13
     RenderText {#text} at (1,0) size 234x13
-      text run at (1,0) width 234: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 234: "12345678901234600000000000000"
 layer at (16,198) size 108x15 scrollWidth 257
   RenderBlock {DIV} at (0,0) size 108x15
     RenderText {#text} at (1,0) size 255x15
-      text run at (1,0) width 255: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 255: "12345678901234600000000000000"
 layer at (16,223) size 93x15 scrollWidth 257
   RenderBlock {DIV} at (0,0) size 93x15
     RenderText {#text} at (1,0) size 255x15
-      text run at (1,0) width 255: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 255: "12345678901234600000000000000"
 layer at (16,248) size 127x16 scrollWidth 278
   RenderBlock {DIV} at (0,0) size 127x16
     RenderText {#text} at (1,0) size 276x16
-      text run at (1,0) width 276: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 276: "12345678901234600000000000000"
 layer at (16,274) size 111x16 scrollWidth 278
   RenderBlock {DIV} at (0,0) size 111x16
     RenderText {#text} at (1,0) size 276x16
-      text run at (1,0) width 276: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 276: "12345678901234600000000000000"
 layer at (16,300) size 129x17 scrollWidth 299
   RenderBlock {DIV} at (0,0) size 129x17
     RenderText {#text} at (1,0) size 297x17
-      text run at (1,0) width 297: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 297: "12345678901234600000000000000"
 layer at (16,327) size 112x17 scrollWidth 299
   RenderBlock {DIV} at (0,0) size 112x17
     RenderText {#text} at (1,0) size 297x17
-      text run at (1,0) width 297: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 297: "12345678901234600000000000000"
 layer at (174,53) size 149x18 scrollWidth 320
   RenderBlock {DIV} at (0,0) size 149x18
     RenderText {#text} at (1,0) size 318x18
-      text run at (1,0) width 318: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 318: "12345678901234600000000000000"
 layer at (174,81) size 131x18 scrollWidth 320
   RenderBlock {DIV} at (0,0) size 131x18
     RenderText {#text} at (1,0) size 318x18
-      text run at (1,0) width 318: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 318: "12345678901234600000000000000"
 layer at (174,109) size 151x18 scrollWidth 341
   RenderBlock {DIV} at (0,0) size 151x18
     RenderText {#text} at (1,0) size 339x18
-      text run at (1,0) width 339: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 339: "12345678901234600000000000000"
 layer at (174,137) size 131x18 scrollWidth 341
   RenderBlock {DIV} at (0,0) size 131x18
     RenderText {#text} at (1,0) size 339x18
-      text run at (1,0) width 339: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 339: "12345678901234600000000000000"
 layer at (174,165) size 153x20 scrollWidth 363
   RenderBlock {DIV} at (0,0) size 153x20
     RenderText {#text} at (1,0) size 361x20
-      text run at (1,0) width 361: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 361: "12345678901234600000000000000"
 layer at (174,195) size 132x20 scrollWidth 363
   RenderBlock {DIV} at (0,0) size 132x20
     RenderText {#text} at (1,0) size 361x20
-      text run at (1,0) width 361: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 361: "12345678901234600000000000000"
 layer at (174,225) size 170x21 scrollWidth 384
   RenderBlock {DIV} at (0,0) size 170x21
     RenderText {#text} at (1,0) size 382x21
-      text run at (1,0) width 382: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 382: "12345678901234600000000000000"
 layer at (174,256) size 148x21 scrollWidth 384
   RenderBlock {DIV} at (0,0) size 148x21
     RenderText {#text} at (1,0) size 382x21
-      text run at (1,0) width 382: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 382: "12345678901234600000000000000"
 layer at (174,287) size 172x22 scrollWidth 405
   RenderBlock {DIV} at (0,0) size 172x22
     RenderText {#text} at (1,0) size 403x22
-      text run at (1,0) width 403: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 403: "12345678901234600000000000000"
 layer at (174,319) size 149x22 scrollWidth 405
   RenderBlock {DIV} at (0,0) size 149x22
     RenderText {#text} at (1,0) size 403x22
-      text run at (1,0) width 403: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 403: "12345678901234600000000000000"
 layer at (379,62) size 193x23 scrollWidth 426
   RenderBlock {DIV} at (0,0) size 193x23
     RenderText {#text} at (1,0) size 424x23
-      text run at (1,0) width 424: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 424: "12345678901234600000000000000"
 layer at (379,95) size 168x23 scrollWidth 426
   RenderBlock {DIV} at (0,0) size 168x23
     RenderText {#text} at (1,0) size 424x23
-      text run at (1,0) width 424: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 424: "12345678901234600000000000000"
 layer at (379,128) size 195x24 scrollWidth 447
   RenderBlock {DIV} at (0,0) size 195x24
     RenderText {#text} at (1,0) size 445x24
-      text run at (1,0) width 445: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 445: "12345678901234600000000000000"
 layer at (379,162) size 169x24 scrollWidth 447
   RenderBlock {DIV} at (0,0) size 169x24
     RenderText {#text} at (1,0) size 445x24
-      text run at (1,0) width 445: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 445: "12345678901234600000000000000"
 layer at (379,196) size 216x26 scrollWidth 469
   RenderBlock {DIV} at (0,0) size 216x26
     RenderText {#text} at (1,0) size 467x26
-      text run at (1,0) width 467: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 467: "12345678901234600000000000000"
 layer at (379,232) size 189x26 scrollWidth 469
   RenderBlock {DIV} at (0,0) size 189x26
     RenderText {#text} at (1,0) size 467x26
-      text run at (1,0) width 467: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 467: "12345678901234600000000000000"
 layer at (379,268) size 218x27 scrollWidth 490
   RenderBlock {DIV} at (0,0) size 218x27
     RenderText {#text} at (1,0) size 488x27
-      text run at (1,0) width 488: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 488: "12345678901234600000000000000"
 layer at (379,305) size 190x27 scrollWidth 490
   RenderBlock {DIV} at (0,0) size 190x27
     RenderText {#text} at (1,0) size 488x27
-      text run at (1,0) width 488: "12,345,678,901,234,600,000,000,000,000"
+      text run at (1,0) width 488: "12345678901234600000000000000"
 layer at (96,47) size 13x12
   RenderBlock (relative positioned) {DIV} at (82,-1) size 13x12
 layer at (96,63) size 13x12

Modified: trunk/Source/WebCore/ChangeLog (91635 => 91636)


--- trunk/Source/WebCore/ChangeLog	2011-07-23 15:39:47 UTC (rev 91635)
+++ trunk/Source/WebCore/ChangeLog	2011-07-23 16:21:14 UTC (rev 91636)
@@ -1,3 +1,33 @@
+2011-07-23  Shinya Kawanaka  <[email protected]>
+
+        Display number field without using a thousand separator.
+        https://bugs.webkit.org/show_bug.cgi?id=65064
+
+        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.
+
 2011-07-22  James Robinson  <[email protected]>
 
         [chromium] Seperate texture management for contents textures vs render surface textures

Modified: trunk/Source/WebCore/manual-tests/input-number-localization.html (91635 => 91636)


--- trunk/Source/WebCore/manual-tests/input-number-localization.html	2011-07-23 15:39:47 UTC (rev 91635)
+++ trunk/Source/WebCore/manual-tests/input-number-localization.html	2011-07-23 16:21:14 UTC (rev 91636)
@@ -13,19 +13,16 @@
 <div id="console"></div>
 
 <p>Output test: The following text field should have a localized representation for "-1234.5678".
-e.g. "-1,234.5678" for en_US locale, "-1.234,5678" for fr_FR locale.</p>
+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 into the following text field.
+<p>Input test: 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>
 <div><input type=number id=target step=any _oninput_="handleInput()"></div>
 <div>Standard format: <output id=output></output></div>
 
-<p>Input test: Type the number text "1234" into the the followin number field.
-The number string will be "1,234" and the cursor position must be the last position.
-</p>
-<div><input type="number" _onkeyup_="this.value=this.value" /></div>
-
 <script>
 function handleInput() {
   document.getElementById('output').value = document.getElementById('target').value;

Modified: trunk/Source/WebCore/platform/text/LocalizedNumberICU.cpp (91635 => 91636)


--- trunk/Source/WebCore/platform/text/LocalizedNumberICU.cpp	2011-07-23 15:39:47 UTC (rev 91635)
+++ trunk/Source/WebCore/platform/text/LocalizedNumberICU.cpp	2011-07-23 16:21:14 UTC (rev 91636)
@@ -49,19 +49,37 @@
     return U_SUCCESS(status) ? formatter.release() : nullptr;
 }
 
+static PassOwnPtr<NumberFormat> createFormatterForCurrentLocaleToDisplay()
+{
+    OwnPtr<NumberFormat> formatter(createFormatterForCurrentLocale());
+    if (!formatter)
+        return nullptr;
+
+    formatter->setGroupingUsed(FALSE);
+    return formatter.release();
+}
+
 // This might return 0.
-static NumberFormat* numberFormatter()
+static NumberFormat* numberFormatterForParsing()
 {
     ASSERT(isMainThread());
     static NumberFormat* formatter = createFormatterForCurrentLocale().leakPtr();
     return formatter;
 }
 
+// This might return 0.
+static NumberFormat* numberFormatterForDisplay()
+{
+    ASSERT(isMainThread());
+    static NumberFormat* formatter = createFormatterForCurrentLocaleToDisplay().leakPtr();
+    return formatter;
+}
+
 double parseLocalizedNumber(const String& numberString)
 {
     if (numberString.isEmpty())
         return numeric_limits<double>::quiet_NaN();
-    NumberFormat* formatter = numberFormatter();
+    NumberFormat* formatter = numberFormatterForParsing();
     if (!formatter)
         return numeric_limits<double>::quiet_NaN();
     UnicodeString numberUnicodeString(numberString.characters(), numberString.length());
@@ -77,7 +95,7 @@
 
 String formatLocalizedNumber(double number, unsigned fractionDigits)
 {
-    NumberFormat* formatter = numberFormatter();
+    NumberFormat* formatter = numberFormatterForDisplay();
     if (!formatter)
         return String();
     UnicodeString result;

Modified: trunk/Source/WebCore/platform/text/mac/LocalizedNumberMac.mm (91635 => 91636)


--- trunk/Source/WebCore/platform/text/mac/LocalizedNumberMac.mm	2011-07-23 15:39:47 UTC (rev 91635)
+++ trunk/Source/WebCore/platform/text/mac/LocalizedNumberMac.mm	2011-07-23 16:21:14 UTC (rev 91636)
@@ -48,10 +48,24 @@
     return formatter;
 }
 
-static NSNumberFormatter *numberFormatter()
+static RetainPtr<NSNumberFormatter> createFormatterForCurrentLocaleForDisplay()
 {
+    RetainPtr<NSNumberFormatter> formatter = createFormatterForCurrentLocale();
+    [formatter.get() setHasThousandSeparators:NO];
+    return formatter;
+}
+
+static NSNumberFormatter *numberFormatterForParsing()
+{
     ASSERT(isMainThread());
     static NSNumberFormatter *formatter = createFormatterForCurrentLocale().leakRef();
+    return formatter;    
+}
+
+static NSNumberFormatter *numberFormatterForDisplay()
+{
+    ASSERT(isMainThread());
+    static NSNumberFormatter *formatter = createFormatterForCurrentLocaleForDisplay().leakRef();
     return formatter;
 }
 
@@ -59,7 +73,7 @@
 {
     if (numberString.isEmpty())
         return numeric_limits<double>::quiet_NaN();
-    NSNumber *number = [numberFormatter() numberFromString:numberString];
+    NSNumber *number = [numberFormatterForParsing() numberFromString:numberString];
     if (!number)
         return numeric_limits<double>::quiet_NaN();
     return [number doubleValue];
@@ -68,7 +82,7 @@
 String formatLocalizedNumber(double inputNumber, unsigned fractionDigits)
 {
     RetainPtr<NSNumber> number(AdoptNS, [[NSNumber alloc] initWithDouble:inputNumber]);
-    RetainPtr<NSNumberFormatter> formatter = numberFormatter();
+    RetainPtr<NSNumberFormatter> formatter = numberFormatterForDisplay();
     [formatter.get() setMaximumFractionDigits:fractionDigits];
     return String([formatter.get() stringFromNumber:number.get()]);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to