Title: [90385] trunk
Revision
90385
Author
[email protected]
Date
2011-07-05 00:18:01 -0700 (Tue, 05 Jul 2011)

Log Message

2011-07-05  Shinya Kawanaka  <[email protected]>

        Reviewed by Kent Tamura.

        The default step is used when the step attribute of input[type='number'] is "any".
        https://bugs.webkit.org/show_bug.cgi?id=57723

        Changed Layout tests to use the default step when the step attribute of
        input[type='number'] is "any".

        * fast/forms/input-stepup-stepdown-from-renderer-expected.txt: Regenerated.
        * fast/forms/script-tests/input-stepup-stepdown-from-renderer.js:
2011-07-05  Shinya Kawanaka  <[email protected]>

        Reviewed by Kent Tamura.

        The default step is used when attribute step of input[type='number'] is "any".
        https://bugs.webkit.org/show_bug.cgi?id=57723

        When step is "any", 0 was chosen as step, but this is not intuitive.
        So changed to use the default step.

        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::getAllowedValueStep):
          Calls getAllowedValueStepWithDecimalPlaces with RejectAny.
        (WebCore::HTMLInputElement::getAllowedValueStepWithDecimalPlaces):
          Takes a new arugument AnyStepHandling. If it is AnyIsDefaultStep, this method
          allows "step" attribute to take a value "any" to use the default step as step value.
          Otherwise, INVALID_STATE_ERR will be returned if "step" is "any".
        (WebCore::HTMLInputElement::applyStep): ditto.
        (WebCore::HTMLInputElement::stepUp):
          Calls applyStep with RejectAny.
        (WebCore::HTMLInputElement::stepDown): ditto.
        (WebCore::HTMLInputElement::stepUpFromRenderer):
          Removes a check that step is "any". It is checked in getAllowedValueStepWithDecimalPlaces.
        * html/HTMLInputElement.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (90384 => 90385)


--- trunk/LayoutTests/ChangeLog	2011-07-05 04:21:24 UTC (rev 90384)
+++ trunk/LayoutTests/ChangeLog	2011-07-05 07:18:01 UTC (rev 90385)
@@ -1,3 +1,16 @@
+2011-07-05  Shinya Kawanaka  <[email protected]>
+
+        Reviewed by Kent Tamura.
+
+        The default step is used when the step attribute of input[type='number'] is "any".
+        https://bugs.webkit.org/show_bug.cgi?id=57723
+
+        Changed Layout tests to use the default step when the step attribute of
+        input[type='number'] is "any".
+
+        * fast/forms/input-stepup-stepdown-from-renderer-expected.txt: Regenerated.
+        * fast/forms/script-tests/input-stepup-stepdown-from-renderer.js:
+
 2011-07-04  Gavin Barraclough  <[email protected]>
 
         Reviewed by Sam Weinig.

Modified: trunk/LayoutTests/fast/forms/input-stepup-stepdown-from-renderer-expected.txt (90384 => 90385)


--- trunk/LayoutTests/fast/forms/input-stepup-stepdown-from-renderer-expected.txt	2011-07-05 04:21:24 UTC (rev 90384)
+++ trunk/LayoutTests/fast/forms/input-stepup-stepdown-from-renderer-expected.txt	2011-07-05 07:18:01 UTC (rev 90385)
@@ -13,8 +13,8 @@
 PASS stepUp("1970-01-01", "4", null, 2) is "1970-01-09"
 PASS stepDown("1970-01-01", "4", null, 3) is "1969-12-20"
 Step=any
-PASS stepUp("2010-02-10", "any", null) is "2010-02-10"
-PASS stepDown("2010-02-10", "any", null) is "2010-02-10"
+PASS stepUp("2010-02-10", "any", null) is "2010-02-11"
+PASS stepDown("2010-02-10", "any", null) is "2010-02-09"
 Overflow/underflow
 PASS stepUp("2010-02-10", "3.40282346e+38", null) is "275760-09-13"
 PASS stepDown("2010-02-10", "3.40282346e+38", null) is "1970-01-01"
@@ -34,8 +34,8 @@
 PASS stepUp("1970-01-01T20:13Z", "4", null, 2) is "1970-01-01T20:13:08Z"
 PASS stepDown("1970-01-01T20:13Z", "4", null, 3) is "1970-01-01T20:12:48Z"
 Step=any
-PASS stepUp("2010-02-10T20:13Z", "any", null) is "2010-02-10T20:13Z"
-PASS stepDown("2010-02-10T20:13Z", "any", null) is "2010-02-10T20:13Z"
+PASS stepUp("2010-02-10T20:13Z", "any", null) is "2010-02-10T20:14Z"
+PASS stepDown("2010-02-10T20:13Z", "any", null) is "2010-02-10T20:12Z"
 Overflow/underflow
 PASS stepUp("2010-02-10T20:13Z", "3.40282346e+38", null) is "275760-09-13T00:00:00.000Z"
 PASS stepDown("2010-02-10T20:13Z", "3.40282346e+38", null) is "1970-01-01T00:00:00.000Z"
@@ -55,8 +55,8 @@
 PASS stepUp("1970-01-01T20:13", "4", null, 2) is "1970-01-01T20:13:08"
 PASS stepDown("1970-01-01T20:13", "4", null, 3) is "1970-01-01T20:12:48"
 Step=any
-PASS stepUp("2010-02-10T20:13", "any", null) is "2010-02-10T20:13"
-PASS stepDown("2010-02-10T20:13", "any", null) is "2010-02-10T20:13"
+PASS stepUp("2010-02-10T20:13", "any", null) is "2010-02-10T20:14"
+PASS stepDown("2010-02-10T20:13", "any", null) is "2010-02-10T20:12"
 Overflow/underflow
 PASS stepUp("2010-02-10T20:13", "3.40282346e+38", null) is "275760-09-13T00:00:00.000"
 PASS stepDown("2010-02-10T20:13", "3.40282346e+38", null) is "1970-01-01T00:00:00.000"
@@ -76,8 +76,8 @@
 PASS stepUp("1970-01", "4", null, 2) is "1970-09"
 PASS stepDown("1970-01", "4", null, 3) is "1969-01"
 Step=any
-PASS stepUp("2010-02", "any", null) is "2010-02"
-PASS stepDown("2010-02", "any", null) is "2010-02"
+PASS stepUp("2010-02", "any", null) is "2010-03"
+PASS stepDown("2010-02", "any", null) is "2010-01"
 Overflow/underflow
 PASS stepUp("2010-02", "3.40282346e+38", null) is "275760-09"
 PASS stepDown("2010-02", "3.40282346e+38", null) is "1970-01"
@@ -92,14 +92,14 @@
 Invalid value
 PASS stepUp("", null, null) is "1"
 PASS stepDown("", null, null) is "-1"
-PASS stepUp("", "any", null) is "0"
-PASS stepDown("", "any", null) is "0"
+PASS stepUp("", "any", null) is "1"
+PASS stepDown("", "any", null) is "-1"
 PASS stepUp("", "foo", null) is "1"
 PASS stepDown("", "foo", null) is "-1"
 PASS stepUp("foo", null, null) is "1"
 PASS stepDown("foo", null, null) is "-1"
-PASS stepUp("foo", "any", null) is "0"
-PASS stepDown("foo", "any", null) is "0"
+PASS stepUp("foo", "any", null) is "1"
+PASS stepDown("foo", "any", null) is "-1"
 PASS stepUp("foo", "foo", null) is "1"
 PASS stepDown("foo", "foo", null) is "-1"
 Normal cases
@@ -114,8 +114,8 @@
 PASS stepUp("1", "0", null) is "2"
 PASS stepUp("2", "-1", null) is "3"
 Step=any
-PASS stepUp("0", "any", null) is "0"
-PASS stepDown("0", "any", null) is "0"
+PASS stepUp("0", "any", null) is "1"
+PASS stepDown("0", "any", null) is "-1"
 Overflow/underflow
 PASS stepDown("1", "1", "0") is "0"
 PASS stepDown("0", "1", "0") is "0"
@@ -233,8 +233,8 @@
 PASS stepUp("20:13", "4", null, 2) is "20:13:08"
 PASS stepDown("20:13", "4", null, 3) is "20:12:48"
 Step=any
-PASS stepUp("20:13", "any", null) is "20:13"
-PASS stepDown("20:13", "any", null) is "20:13"
+PASS stepUp("20:13", "any", null) is "20:14"
+PASS stepDown("20:13", "any", null) is "20:12"
 Overflow/underflow
 PASS stepUp("20:13", "3.40282346e+38", null) is "23:59:59.999"
 PASS stepDown("20:13", "3.40282346e+38", null) is "00:00:00.000"
@@ -256,8 +256,8 @@
 PASS stepUp("1970-W01", "4", null, 2) is "1970-W09"
 PASS stepDown("1970-W01", "4", null, 3) is "1969-W41"
 Step=any
-PASS stepUp("2010-W02", "any", null) is "2010-W02"
-PASS stepDown("2010-W02", "any", null) is "2010-W02"
+PASS stepUp("2010-W02", "any", null) is "2010-W03"
+PASS stepDown("2010-W02", "any", null) is "2010-W01"
 Overflow/underflow
 PASS stepUp("2010-W02", "3.40282346e+38", null) is "275760-W37"
 PASS stepDown("2010-W02", "3.40282346e+38", null) is "1970-W01"

Modified: trunk/LayoutTests/fast/forms/script-tests/input-stepup-stepdown-from-renderer.js (90384 => 90385)


--- trunk/LayoutTests/fast/forms/script-tests/input-stepup-stepdown-from-renderer.js	2011-07-05 04:21:24 UTC (rev 90384)
+++ trunk/LayoutTests/fast/forms/script-tests/input-stepup-stepdown-from-renderer.js	2011-07-05 07:18:01 UTC (rev 90385)
@@ -88,8 +88,8 @@
 shouldBe('stepUp("1970-01-01", "4", null, 2)', '"1970-01-09"');
 shouldBe('stepDown("1970-01-01", "4", null, 3)', '"1969-12-20"');
 debug('Step=any');
-shouldBe('stepUp("2010-02-10", "any", null)', '"2010-02-10"');
-shouldBe('stepDown("2010-02-10", "any", null)', '"2010-02-10"');
+shouldBe('stepUp("2010-02-10", "any", null)', '"2010-02-11"');
+shouldBe('stepDown("2010-02-10", "any", null)', '"2010-02-09"');
 debug('Overflow/underflow');
 shouldBe('stepUp("2010-02-10", "3.40282346e+38", null)','"275760-09-13"');
 shouldBe('stepDown("2010-02-10", "3.40282346e+38", null)', '"1970-01-01"');
@@ -111,8 +111,8 @@
 shouldBe('stepUp("1970-01-01T20:13Z", "4", null, 2)', '"1970-01-01T20:13:08Z"');
 shouldBe('stepDown("1970-01-01T20:13Z", "4", null, 3)', '"1970-01-01T20:12:48Z"');
 debug('Step=any');
-shouldBe('stepUp("2010-02-10T20:13Z", "any", null)', '"2010-02-10T20:13Z"');
-shouldBe('stepDown("2010-02-10T20:13Z", "any", null)', '"2010-02-10T20:13Z"');
+shouldBe('stepUp("2010-02-10T20:13Z", "any", null)', '"2010-02-10T20:14Z"');
+shouldBe('stepDown("2010-02-10T20:13Z", "any", null)', '"2010-02-10T20:12Z"');
 debug('Overflow/underflow');
 shouldBe('stepUp("2010-02-10T20:13Z", "3.40282346e+38", null)', '"275760-09-13T00:00:00.000Z"');
 shouldBe('stepDown("2010-02-10T20:13Z", "3.40282346e+38", null)', '"1970-01-01T00:00:00.000Z"');
@@ -134,8 +134,8 @@
 shouldBe('stepUp("1970-01-01T20:13", "4", null, 2)', '"1970-01-01T20:13:08"');
 shouldBe('stepDown("1970-01-01T20:13", "4", null, 3)', '"1970-01-01T20:12:48"');
 debug('Step=any');
-shouldBe('stepUp("2010-02-10T20:13", "any", null)', '"2010-02-10T20:13"');
-shouldBe('stepDown("2010-02-10T20:13", "any", null)', '"2010-02-10T20:13"');
+shouldBe('stepUp("2010-02-10T20:13", "any", null)', '"2010-02-10T20:14"');
+shouldBe('stepDown("2010-02-10T20:13", "any", null)', '"2010-02-10T20:12"');
 debug('Overflow/underflow');
 shouldBe('stepUp("2010-02-10T20:13", "3.40282346e+38", null)', '"275760-09-13T00:00:00.000"');
 shouldBe('stepDown("2010-02-10T20:13", "3.40282346e+38", null)', '"1970-01-01T00:00:00.000"');
@@ -157,8 +157,8 @@
 shouldBe('stepUp("1970-01", "4", null, 2)', '"1970-09"');
 shouldBe('stepDown("1970-01", "4", null, 3)', '"1969-01"');
 debug('Step=any');
-shouldBe('stepUp("2010-02", "any", null)', '"2010-02"');
-shouldBe('stepDown("2010-02", "any", null)', '"2010-02"');
+shouldBe('stepUp("2010-02", "any", null)', '"2010-03"');
+shouldBe('stepDown("2010-02", "any", null)', '"2010-01"');
 debug('Overflow/underflow');
 shouldBe('stepUp("2010-02", "3.40282346e+38", null)', '"275760-09"');
 shouldBe('stepDown("2010-02", "3.40282346e+38", null)', '"1970-01"');
@@ -175,14 +175,14 @@
 debug('Invalid value');
 shouldBe('stepUp("", null, null)', '"1"');
 shouldBe('stepDown("", null, null)', '"-1"');
-shouldBe('stepUp("", "any", null)', '"0"');
-shouldBe('stepDown("", "any", null)', '"0"');
+shouldBe('stepUp("", "any", null)', '"1"');
+shouldBe('stepDown("", "any", null)', '"-1"');
 shouldBe('stepUp("", "foo", null)', '"1"');
 shouldBe('stepDown("", "foo", null)', '"-1"');
 shouldBe('stepUp("foo", null, null)', '"1"');
 shouldBe('stepDown("foo", null, null)', '"-1"');
-shouldBe('stepUp("foo", "any", null)', '"0"');
-shouldBe('stepDown("foo", "any", null)', '"0"');
+shouldBe('stepUp("foo", "any", null)', '"1"');
+shouldBe('stepDown("foo", "any", null)', '"-1"');
 shouldBe('stepUp("foo", "foo", null)', '"1"');
 shouldBe('stepDown("foo", "foo", null)', '"-1"');
 debug('Normal cases');
@@ -197,8 +197,8 @@
 shouldBe('stepUp("1", "0", null)', '"2"');
 shouldBe('stepUp("2", "-1", null)', '"3"');
 debug('Step=any');
-shouldBe('stepUp("0", "any", null)', '"0"');
-shouldBe('stepDown("0", "any", null)', '"0"');
+shouldBe('stepUp("0", "any", null)', '"1"');
+shouldBe('stepDown("0", "any", null)', '"-1"');
 debug('Overflow/underflow');
 shouldBe('stepDown("1", "1", "0")', '"0"');
 shouldBe('stepDown("0", "1", "0")', '"0"');
@@ -320,8 +320,8 @@
 shouldBe('stepUp("20:13", "4", null, 2)', '"20:13:08"');
 shouldBe('stepDown("20:13", "4", null, 3)', '"20:12:48"');
 debug('Step=any');
-shouldBe('stepUp("20:13", "any", null)', '"20:13"');
-shouldBe('stepDown("20:13", "any", null)', '"20:13"');
+shouldBe('stepUp("20:13", "any", null)', '"20:14"');
+shouldBe('stepDown("20:13", "any", null)', '"20:12"');
 debug('Overflow/underflow');
 shouldBe('stepUp("20:13", "3.40282346e+38", null)', '"23:59:59.999"');
 shouldBe('stepDown("20:13", "3.40282346e+38", null)', '"00:00:00.000"');
@@ -345,8 +345,8 @@
 shouldBe('stepUp("1970-W01", "4", null, 2)', '"1970-W09"');
 shouldBe('stepDown("1970-W01", "4", null, 3)', '"1969-W41"');
 debug('Step=any');
-shouldBe('stepUp("2010-W02", "any", null)', '"2010-W02"');
-shouldBe('stepDown("2010-W02", "any", null)', '"2010-W02"');
+shouldBe('stepUp("2010-W02", "any", null)', '"2010-W03"');
+shouldBe('stepDown("2010-W02", "any", null)', '"2010-W01"');
 debug('Overflow/underflow');
 shouldBe('stepUp("2010-W02", "3.40282346e+38", null)', '"275760-W37"');
 shouldBe('stepDown("2010-W02", "3.40282346e+38", null)', '"1970-W01"');

Modified: trunk/Source/WebCore/ChangeLog (90384 => 90385)


--- trunk/Source/WebCore/ChangeLog	2011-07-05 04:21:24 UTC (rev 90384)
+++ trunk/Source/WebCore/ChangeLog	2011-07-05 07:18:01 UTC (rev 90385)
@@ -1,3 +1,28 @@
+2011-07-05  Shinya Kawanaka  <[email protected]>
+
+        Reviewed by Kent Tamura.
+
+        The default step is used when attribute step of input[type='number'] is "any".
+        https://bugs.webkit.org/show_bug.cgi?id=57723
+
+        When step is "any", 0 was chosen as step, but this is not intuitive.
+        So changed to use the default step.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::getAllowedValueStep):
+          Calls getAllowedValueStepWithDecimalPlaces with RejectAny.
+        (WebCore::HTMLInputElement::getAllowedValueStepWithDecimalPlaces):
+          Takes a new arugument AnyStepHandling. If it is AnyIsDefaultStep, this method
+          allows "step" attribute to take a value "any" to use the default step as step value.
+          Otherwise, INVALID_STATE_ERR will be returned if "step" is "any".
+        (WebCore::HTMLInputElement::applyStep): ditto.
+        (WebCore::HTMLInputElement::stepUp):
+          Calls applyStep with RejectAny.
+        (WebCore::HTMLInputElement::stepDown): ditto.
+        (WebCore::HTMLInputElement::stepUpFromRenderer):
+          Removes a check that step is "any". It is checked in getAllowedValueStepWithDecimalPlaces.
+        * html/HTMLInputElement.h:
+
 2011-07-04  Dominic Cooney   <[email protected]>
 
         Simplify <progress> element's isDeterminate logic.

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (90384 => 90385)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2011-07-05 04:21:24 UTC (rev 90384)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2011-07-05 07:18:01 UTC (rev 90385)
@@ -338,10 +338,10 @@
 
 bool HTMLInputElement::getAllowedValueStep(double* step) const
 {
-    return getAllowedValueStepWithDecimalPlaces(step, 0);
+    return getAllowedValueStepWithDecimalPlaces(RejectAny, step, 0);
 }
 
-bool HTMLInputElement::getAllowedValueStepWithDecimalPlaces(double* step, unsigned* decimalPlaces) const
+bool HTMLInputElement::getAllowedValueStepWithDecimalPlaces(AnyStepHandling anyStepHandling, double* step, unsigned* decimalPlaces) const
 {
     ASSERT(step);
     double defaultStep = m_inputType->defaultStep();
@@ -355,8 +355,21 @@
             *decimalPlaces = 0;
         return true;
     }
-    if (equalIgnoringCase(stepString, "any"))
-        return false;
+
+    if (equalIgnoringCase(stepString, "any")) {
+        switch (anyStepHandling) {
+        case RejectAny:
+            return false;
+        case AnyIsDefaultStep:
+            *step = defaultStep * stepScaleFactor;
+            if (decimalPlaces)
+                *decimalPlaces = 0;
+            return true;
+        default:
+            ASSERT_NOT_REACHED();
+        }
+    }
+
     double parsed;
     if (!decimalPlaces) {
         if (!parseToDoubleForNumberType(stepString, &parsed) || parsed <= 0.0) {
@@ -382,14 +395,15 @@
     return true;
 }
 
-void HTMLInputElement::applyStep(double count, ExceptionCode& ec)
+void HTMLInputElement::applyStep(double count, AnyStepHandling anyStepHandling, ExceptionCode& ec)
 {
     double step;
     unsigned stepDecimalPlaces, currentDecimalPlaces;
-    if (!getAllowedValueStepWithDecimalPlaces(&step, &stepDecimalPlaces)) {
+    if (!getAllowedValueStepWithDecimalPlaces(anyStepHandling, &step, &stepDecimalPlaces)) {
         ec = INVALID_STATE_ERR;
         return;
     }
+
     const double nan = numeric_limits<double>::quiet_NaN();
     double current = m_inputType->parseToDoubleWithDecimalPlaces(value(), nan, &currentDecimalPlaces);
     if (!isfinite(current)) {
@@ -434,12 +448,12 @@
 
 void HTMLInputElement::stepUp(int n, ExceptionCode& ec)
 {
-    applyStep(n, ec);
+    applyStep(n, RejectAny, ec);
 }
 
 void HTMLInputElement::stepDown(int n, ExceptionCode& ec)
 {
-    applyStep(-n, ec);
+    applyStep(-n, RejectAny, ec);
 }
 
 bool HTMLInputElement::isKeyboardFocusable(KeyboardEvent* event) const
@@ -1509,13 +1523,10 @@
 
     unsigned stepDecimalPlaces, baseDecimalPlaces;
     double step, base;
-    // The value will be the default value after stepping for <input value=(empty/invalid) step="any" />
     // FIXME: Not any changes after stepping, even if it is an invalid value, may be better.
     // (e.g. Stepping-up for <input type="number" value="foo" step="any" /> => "foo")
-    if (equalIgnoringCase(fastGetAttribute(stepAttr), "any"))
-        step = 0;
-    else if (!getAllowedValueStepWithDecimalPlaces(&step, &stepDecimalPlaces))
-        return;
+    if (!getAllowedValueStepWithDecimalPlaces(AnyIsDefaultStep, &step, &stepDecimalPlaces))
+      return;
     base = m_inputType->stepBaseWithDecimalPlaces(&baseDecimalPlaces);
     baseDecimalPlaces = min(baseDecimalPlaces, 16u);
 
@@ -1564,11 +1575,11 @@
             setValueAsNumber(newValue, ec);
             current = newValue;
             if (n > 1)
-                applyStep(n - 1, ec);
+                applyStep(n - 1, AnyIsDefaultStep, ec);
             else if (n < -1)
-                applyStep(n + 1, ec);
+                applyStep(n + 1, AnyIsDefaultStep, ec);
         } else
-            applyStep(n, ec);
+            applyStep(n, AnyIsDefaultStep, ec);
     }
 
     if (currentStringValue != value()) {

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (90384 => 90385)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2011-07-05 04:21:24 UTC (rev 90384)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2011-07-05 07:18:01 UTC (rev 90385)
@@ -62,7 +62,7 @@
     // Sets the "allowed value step" defined in the HTML spec to the specified double pointer.
     // Returns false if there is no "allowed value step."
     bool getAllowedValueStep(double*) const;
-    bool getAllowedValueStepWithDecimalPlaces(double*, unsigned*) const;
+
     // For ValidityState.
     bool stepMismatch(const String&) const;
     String minimumString() const;
@@ -240,6 +240,7 @@
 
 private:
     enum AutoCompleteSetting { Uninitialized, On, Off };
+    enum AnyStepHandling { RejectAny, AnyIsDefaultStep };
 
     virtual void willMoveToNewOwnerDocument();
     virtual void didMoveToNewOwnerDocument();
@@ -316,8 +317,10 @@
 
     void updateType();
 
+    bool getAllowedValueStepWithDecimalPlaces(AnyStepHandling, double*, unsigned*) const;
+
     // Helper for stepUp()/stepDown().  Adds step value * count to the current value.
-    void applyStep(double count, ExceptionCode&);
+    void applyStep(double count, AnyStepHandling, ExceptionCode&);
 
 #if ENABLE(DATALIST)
     HTMLDataListElement* dataList() const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to