Title: [122552] trunk
Revision
122552
Author
[email protected]
Date
2012-07-13 01:56:10 -0700 (Fri, 13 Jul 2012)

Log Message

REGRESSION(r119948): [Forms] Spin button Up/Down actions make value to zero for input type "number" when step mismatched
https://bugs.webkit.org/show_bug.cgi?id=91197

Reviewed by Kent Tamura.

Source/WebCore:

This patch fixes implementation of Decimal::ceiling() and floor().
They return wrong value for small fractional numbers.

The bug is occurred when:
  - Step-able input type, e.g. number, date, datetime, and so on.
  - Current value is step mismatched
  - Current value is smaller than step
  - Step up/down by spin button
because spin button up/down actions are implemented in InputType::setpUpFromRenderer
which calls Decimal::ceiling() and floor() for step mismatched case.

Tests: fast/forms/number/number-stepup-stepdown-from-renderer.html: Added test cases
       WebKit/chromium/tests/DecimalTest.cpp: Added test cases

* platform/Decimal.cpp:
(WebCore::Decimal::ceiling): Changed to return 1 for positive small fractional number.
(WebCore::Decimal::floor): Changed to return -1 for negative small fractional number.

Source/WebKit/chromium:

This patch adds test cases for Decimal::ceiling() and floor() of
positive/negative small fractional numbers.

* tests/DecimalTest.cpp:
(TEST_F):

LayoutTests:

This patch adds new test cases.

* fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt: Updated for new test cases.
* fast/forms/number/number-stepup-stepdown-from-renderer.html: Added new test cases.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (122551 => 122552)


--- trunk/LayoutTests/ChangeLog	2012-07-13 08:23:18 UTC (rev 122551)
+++ trunk/LayoutTests/ChangeLog	2012-07-13 08:56:10 UTC (rev 122552)
@@ -1,3 +1,15 @@
+2012-07-13  Yoshifumi Inoue  <[email protected]>
+
+        REGRESSION(r119948): [Forms] Spin button Up/Down actions make value to zero for input type "number" when step mismatched
+        https://bugs.webkit.org/show_bug.cgi?id=91197
+
+        Reviewed by Kent Tamura.
+
+        This patch adds new test cases.
+
+        * fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt: Updated for new test cases.
+        * fast/forms/number/number-stepup-stepdown-from-renderer.html: Added new test cases.
+
 2012-07-13  Dominic Mazzoni  <[email protected]>
 
         Should be possible to focus elements within canvas fallback content

Modified: trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt (122551 => 122552)


--- trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt	2012-07-13 08:23:18 UTC (rev 122551)
+++ trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt	2012-07-13 08:56:10 UTC (rev 122552)
@@ -49,6 +49,10 @@
 PASS input.min = "0"; stepUp("9", "10", "") is "10"
 PASS stepDown("19", "10", "0") is "10"
 PASS stepUp("89", "10", "99") is "90"
+PASS stepUp("7", "300", "") is "300"
+PASS stepUp("-7", "300", "") is "0"
+PASS stepDown("7", "300", "") is "0"
+PASS stepDown("-7", "300", "") is "-300"
 Huge value and small step
 PASS input.min = ""; stepUp("1e+38", "1", "", 999) is "1e+38"
 PASS input.max = ""; stepDown("1e+38", "1", "", 999) is "1e+38"

Modified: trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html (122551 => 122552)


--- trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html	2012-07-13 08:23:18 UTC (rev 122551)
+++ trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html	2012-07-13 08:56:10 UTC (rev 122552)
@@ -131,6 +131,10 @@
 shouldBe('input.min = "0"; stepUp("9", "10", "")', '"10"');
 shouldBe('stepDown("19", "10", "0")', '"10"');
 shouldBe('stepUp("89", "10", "99")', '"90"');
+shouldBe('stepUp("7", "300", "")', '"300"');
+shouldBe('stepUp("-7", "300", "")', '"0"');
+shouldBe('stepDown("7", "300", "")', '"0"');
+shouldBe('stepDown("-7", "300", "")', '"-300"');
 debug('Huge value and small step');
 shouldBe('input.min = ""; stepUp("1e+38", "1", "", 999)', '"1e+38"');
 shouldBe('input.max = ""; stepDown("1e+38", "1", "", 999)', '"1e+38"');

Modified: trunk/Source/WebCore/ChangeLog (122551 => 122552)


--- trunk/Source/WebCore/ChangeLog	2012-07-13 08:23:18 UTC (rev 122551)
+++ trunk/Source/WebCore/ChangeLog	2012-07-13 08:56:10 UTC (rev 122552)
@@ -1,3 +1,28 @@
+2012-07-13  Yoshifumi Inoue  <[email protected]>
+
+        REGRESSION(r119948): [Forms] Spin button Up/Down actions make value to zero for input type "number" when step mismatched
+        https://bugs.webkit.org/show_bug.cgi?id=91197
+
+        Reviewed by Kent Tamura.
+
+        This patch fixes implementation of Decimal::ceiling() and floor().
+        They return wrong value for small fractional numbers.
+
+        The bug is occurred when:
+          - Step-able input type, e.g. number, date, datetime, and so on.
+          - Current value is step mismatched
+          - Current value is smaller than step
+          - Step up/down by spin button
+        because spin button up/down actions are implemented in InputType::setpUpFromRenderer
+        which calls Decimal::ceiling() and floor() for step mismatched case.
+
+        Tests: fast/forms/number/number-stepup-stepdown-from-renderer.html: Added test cases
+               WebKit/chromium/tests/DecimalTest.cpp: Added test cases
+
+        * platform/Decimal.cpp:
+        (WebCore::Decimal::ceiling): Changed to return 1 for positive small fractional number.
+        (WebCore::Decimal::floor): Changed to return -1 for negative small fractional number.
+
 2012-07-13  Dominic Mazzoni  <[email protected]>
 
         Should be possible to focus elements within canvas fallback content

Modified: trunk/Source/WebCore/platform/Decimal.cpp (122551 => 122552)


--- trunk/Source/WebCore/platform/Decimal.cpp	2012-07-13 08:23:18 UTC (rev 122551)
+++ trunk/Source/WebCore/platform/Decimal.cpp	2012-07-13 08:56:10 UTC (rev 122552)
@@ -628,7 +628,7 @@
     const int numberOfDigits = countDigits(result);
     const int numberOfDropDigits = -exponent();
     if (numberOfDigits < numberOfDropDigits)
-        return zero(Positive);
+        return isPositive() ? Decimal(1) : zero(Positive);
 
     result = scaleDown(result, numberOfDropDigits - 1);
     if (sign() == Positive && result % 10 > 0)
@@ -670,7 +670,7 @@
     const int numberOfDigits = countDigits(result);
     const int numberOfDropDigits = -exponent();
     if (numberOfDigits < numberOfDropDigits)
-        return zero(Positive);
+        return isPositive() ? zero(Positive) : Decimal(-1);
 
     result = scaleDown(result, numberOfDropDigits - 1);
     if (isNegative() && result % 10 > 0)

Modified: trunk/Source/WebKit/chromium/ChangeLog (122551 => 122552)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-07-13 08:23:18 UTC (rev 122551)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-07-13 08:56:10 UTC (rev 122552)
@@ -1,3 +1,16 @@
+2012-07-13  Yoshifumi Inoue  <[email protected]>
+
+        REGRESSION(r119948): [Forms] Spin button Up/Down actions make value to zero for input type "number" when step mismatched
+        https://bugs.webkit.org/show_bug.cgi?id=91197
+
+        Reviewed by Kent Tamura.
+
+        This patch adds test cases for Decimal::ceiling() and floor() of
+        positive/negative small fractional numbers.
+
+        * tests/DecimalTest.cpp:
+        (TEST_F):
+
 2012-07-12  Adrienne Walker  <[email protected]>
 
         [chromium] Root invalidations for RTL pages need to be in the right space

Modified: trunk/Source/WebKit/chromium/tests/DecimalTest.cpp (122551 => 122552)


--- trunk/Source/WebKit/chromium/tests/DecimalTest.cpp	2012-07-13 08:23:18 UTC (rev 122551)
+++ trunk/Source/WebKit/chromium/tests/DecimalTest.cpp	2012-07-13 08:56:10 UTC (rev 122552)
@@ -211,12 +211,14 @@
 TEST_F(DecimalTest, Ceiling)
 {
     EXPECT_EQ(Decimal(1), Decimal(1).ceiling());
+    EXPECT_EQ(Decimal(1), encode(1, -10, Positive).ceiling());
     EXPECT_EQ(Decimal(2), encode(11, -1, Positive).ceiling());
     EXPECT_EQ(Decimal(2), encode(13, -1, Positive).ceiling());
     EXPECT_EQ(Decimal(2), encode(15, -1, Positive).ceiling());
     EXPECT_EQ(Decimal(2), encode(19, -1, Positive).ceiling());
 
     EXPECT_EQ(Decimal(-1), Decimal(-1).ceiling());
+    EXPECT_EQ(Decimal(0), encode(1, -10, Negative).ceiling());
     EXPECT_EQ(Decimal(-1), encode(11, -1, Negative).ceiling());
     EXPECT_EQ(Decimal(-1), encode(13, -1, Negative).ceiling());
     EXPECT_EQ(Decimal(-1), encode(15, -1, Negative).ceiling());
@@ -525,12 +527,14 @@
 TEST_F(DecimalTest, Floor)
 {
     EXPECT_EQ(Decimal(1), Decimal(1).floor());
+    EXPECT_EQ(Decimal(0), encode(1, -10, Positive).floor());
     EXPECT_EQ(Decimal(1), encode(11, -1, Positive).floor());
     EXPECT_EQ(Decimal(1), encode(13, -1, Positive).floor());
     EXPECT_EQ(Decimal(1), encode(15, -1, Positive).floor());
     EXPECT_EQ(Decimal(1), encode(19, -1, Positive).floor());
 
     EXPECT_EQ(Decimal(-1), Decimal(-1).floor());
+    EXPECT_EQ(Decimal(-1), encode(1, -10, Negative).floor());
     EXPECT_EQ(Decimal(-2), encode(11, -1, Negative).floor());
     EXPECT_EQ(Decimal(-2), encode(13, -1, Negative).floor());
     EXPECT_EQ(Decimal(-2), encode(15, -1, Negative).floor());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to