Changeset 289465 in webkit


Ignore:
Timestamp:
Feb 9, 2022 2:37:47 AM (5 months ago)
Author:
Ziran Sun
Message:

[Forms] Improving applyStep() to be in line with specs
https://bugs.webkit.org/show_bug.cgi?id=236134

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

  • web-platform-tests/html/semantics/forms/the-input-element/range-expected.txt:

Source/WebCore:

This is to improve applyStep() func to follow specs at
https://html.spec.whatwg.org/multipage/input.html#dom-input-stepup

Since Chromium implementation follows the specs steps, this patch imports the
Chromium implmentation.

This is a further patch after https://bugs.webkit.org/show_bug.cgi?id=235509. It has corrected
some changes on test files in fast/form directory in the previous patch submitted for Bug

  1. With this CL a few more sub-tests are now passing.
  • html/InputType.cpp:

(WebCore::InputType::applyStep):

  • html/StepRange.cpp:

(WebCore::StepRange::stepSnappedMaximum const):

  • html/StepRange.h:

LayoutTests:

Update test expectations.

  • fast/forms/date/date-stepup-stepdown-expected.txt:
  • fast/forms/date/date-stepup-stepdown.html:
  • fast/forms/datetimelocal/datetimelocal-stepup-stepdown-expected.txt:
  • fast/forms/datetimelocal/datetimelocal-stepup-stepdown.html:
  • fast/forms/month/month-stepup-stepdown-expected.txt:
  • fast/forms/month/month-stepup-stepdown.html:
  • fast/forms/number/number-stepup-stepdown-expected.txt:
  • fast/forms/number/number-stepup-stepdown.html:
  • fast/forms/range/range-stepup-stepdown-expected.txt:
  • fast/forms/range/range-stepup-stepdown.html:
  • fast/forms/time/time-stepup-stepdown-expected.txt:
  • fast/forms/time/time-stepup-stepdown.html:
  • fast/forms/week/week-stepup-stepdown-expected.txt:
  • fast/forms/week/week-stepup-stepdown.html:
  • platform/gtk/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-expected.txt:
  • platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-expected.txt:
  • platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-expected.txt:
Location:
trunk
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r289464 r289465  
     12022-02-09  Ziran Sun  <zsun@igalia.com>
     2
     3        [Forms] Improving applyStep() to be in line with specs
     4        https://bugs.webkit.org/show_bug.cgi?id=236134
     5
     6        Reviewed by Chris Dumez.
     7
     8        Update test expectations.
     9        * fast/forms/date/date-stepup-stepdown-expected.txt:
     10        * fast/forms/date/date-stepup-stepdown.html:
     11        * fast/forms/datetimelocal/datetimelocal-stepup-stepdown-expected.txt:
     12        * fast/forms/datetimelocal/datetimelocal-stepup-stepdown.html:
     13        * fast/forms/month/month-stepup-stepdown-expected.txt:
     14        * fast/forms/month/month-stepup-stepdown.html:
     15        * fast/forms/number/number-stepup-stepdown-expected.txt:
     16        * fast/forms/number/number-stepup-stepdown.html:
     17        * fast/forms/range/range-stepup-stepdown-expected.txt:
     18        * fast/forms/range/range-stepup-stepdown.html:
     19        * fast/forms/time/time-stepup-stepdown-expected.txt:
     20        * fast/forms/time/time-stepup-stepdown.html:
     21        * fast/forms/week/week-stepup-stepdown-expected.txt:
     22        * fast/forms/week/week-stepup-stepdown.html:
     23        * platform/gtk/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-expected.txt:
     24        * platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-expected.txt:
     25        * platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-expected.txt:
     26
    1272022-02-09  Diego Pino Garcia  <dpino@igalia.com>
    228
  • trunk/LayoutTests/fast/forms/date/date-stepup-stepdown-expected.txt

    r289075 r289465  
    55
    66Invalid value
    7 PASS stepUp("", null, null) threw exception InvalidStateError: The object is in an invalid state..
    8 PASS stepDown("", null, null) threw exception InvalidStateError: The object is in an invalid state..
     7PASS stepUp("", null, null) is "1970-01-02"
     8PASS stepDown("", null, null) is "1969-12-31"
    99Non-number arguments
    1010PASS stepUp("2010-02-10", null, null, "0") is "2010-02-10"
     
    2626Overflow/underflow
    2727PASS stepUp("2010-02-10", "3.40282346e+38", null) is "2010-02-10"
    28 PASS stepDown("2010-02-10", "3.40282346e+38", null) is "2010-02-10"
     28PASS stepDown("2010-02-10", "3.40282346e+38", null) is "1970-01-01"
    2929PASS stepUp("2010-02-10", "1", "2010-02-10") is "2010-02-10"
    3030PASS stepDown("2010-02-10", "1", "2010-02-10") is "2010-02-10"
  • trunk/LayoutTests/fast/forms/date/date-stepup-stepdown.html

    r289075 r289465  
    3939input.type = 'date';
    4040debug('Invalid value');
    41 shouldThrowErrorName('stepUp("", null, null)', "InvalidStateError");
    42 shouldThrowErrorName('stepDown("", null, null)', "InvalidStateError");
     41shouldBe('stepUp("", null, null)', '"1970-01-02"');
     42shouldBe('stepDown("", null, null)', '"1969-12-31"');
    4343debug('Non-number arguments');
    4444shouldBe('stepUp("2010-02-10", null, null, "0")', '"2010-02-10"');
     
    6060debug('Overflow/underflow');
    6161shouldBe('stepUp("2010-02-10", "3.40282346e+38", null)', '"2010-02-10"');
    62 shouldBe('stepDown("2010-02-10", "3.40282346e+38", null)', '"2010-02-10"');
     62shouldBe('stepDown("2010-02-10", "3.40282346e+38", null)', '"1970-01-01"');
    6363shouldBe('stepUp("2010-02-10", "1", "2010-02-10")', '"2010-02-10"');
    6464shouldBe('stepDown("2010-02-10", "1", "2010-02-10")', '"2010-02-10"');
  • trunk/LayoutTests/fast/forms/datetimelocal/datetimelocal-stepup-stepdown-expected.txt

    r289075 r289465  
    55
    66Invalid value
    7 PASS stepUp("", null, null) threw exception InvalidStateError: The object is in an invalid state..
    8 PASS stepDown("", null, null) threw exception InvalidStateError: The object is in an invalid state..
     7PASS stepUp("", null, null) is "1970-01-01T00:01"
     8PASS stepDown("", null, null) is "1969-12-31T23:59"
    99Non-number arguments
    1010PASS stepUp("2010-02-10T20:13", null, null, "0") is "2010-02-10T20:13"
     
    2626Overflow/underflow
    2727PASS stepUp("2010-02-10T20:13", "3.40282346e+38", null) is "2010-02-10T20:13"
    28 PASS stepDown("2010-02-10T20:13", "3.40282346e+38", null) is "2010-02-10T20:13"
     28PASS stepDown("2010-02-10T20:13", "3.40282346e+38", null) is "1970-01-01T00:00"
    2929PASS stepUp("2010-02-10T20:13", "1", "2010-02-10T20:13") is "2010-02-10T20:13"
    3030PASS stepDown("2010-02-10T20:13", "1", "2010-02-10T20:13") is "2010-02-10T20:13"
  • trunk/LayoutTests/fast/forms/datetimelocal/datetimelocal-stepup-stepdown.html

    r289075 r289465  
    3939input.type = 'datetime-local';
    4040debug('Invalid value');
    41 shouldThrowErrorName('stepUp("", null, null)', "InvalidStateError");
    42 shouldThrowErrorName('stepDown("", null, null)', "InvalidStateError");
     41shouldBe('stepUp("", null, null)', '"1970-01-01T00:01"');
     42shouldBe('stepDown("", null, null)', '"1969-12-31T23:59"');
    4343debug('Non-number arguments');
    4444shouldBe('stepUp("2010-02-10T20:13", null, null, "0")', '"2010-02-10T20:13"');
     
    6060debug('Overflow/underflow');
    6161shouldBe('stepUp("2010-02-10T20:13", "3.40282346e+38", null)', '"2010-02-10T20:13"');
    62 shouldBe('stepDown("2010-02-10T20:13", "3.40282346e+38", null)', '"2010-02-10T20:13"');
     62shouldBe('stepDown("2010-02-10T20:13", "3.40282346e+38", null)', '"1970-01-01T00:00"');
    6363shouldBe('stepUp("2010-02-10T20:13", "1", "2010-02-10T20:13")', '"2010-02-10T20:13"');
    6464shouldBe('stepDown("2010-02-10T20:13", "1", "2010-02-10T20:13")', '"2010-02-10T20:13"');
  • trunk/LayoutTests/fast/forms/month/month-stepup-stepdown-expected.txt

    r289075 r289465  
    55
    66Invalid value
    7 PASS stepUp("", null, null) threw exception InvalidStateError: The object is in an invalid state..
    8 PASS stepDown("", null, null) threw exception InvalidStateError: The object is in an invalid state..
     7PASS stepUp("", null, null) is "1970-02"
     8PASS stepDown("", null, null) is "1969-12"
    99Non-number arguments
    1010PASS stepUp("2010-02", null, null, "0") is "2010-02"
     
    2626Overflow/underflow
    2727PASS stepUp("2010-02", "3.40282346e+38", null) is "2010-02"
    28 PASS stepDown("2010-02", "3.40282346e+38", null) is "2010-02"
     28PASS stepDown("2010-02", "3.40282346e+38", null) is "1970-01"
    2929PASS stepUp("2010-02", "1", "2010-02") is "2010-02"
    3030PASS stepDown("2010-02", "1", "2010-02") is "2010-02"
  • trunk/LayoutTests/fast/forms/month/month-stepup-stepdown.html

    r289075 r289465  
    3939input.type = 'month';
    4040debug('Invalid value');
    41 shouldThrowErrorName('stepUp("", null, null)', "InvalidStateError");
    42 shouldThrowErrorName('stepDown("", null, null)', "InvalidStateError");
     41shouldBe('stepUp("", null, null)', '"1970-02"');
     42shouldBe('stepDown("", null, null)', '"1969-12"');
    4343debug('Non-number arguments');
    4444shouldBe('stepUp("2010-02", null, null, "0")', '"2010-02"');
     
    6060debug('Overflow/underflow');
    6161shouldBe('stepUp("2010-02", "3.40282346e+38", null)', '"2010-02"');
    62 shouldBe('stepDown("2010-02", "3.40282346e+38", null)', '"2010-02"');
     62shouldBe('stepDown("2010-02", "3.40282346e+38", null)', '"1970-01"');
    6363shouldBe('stepUp("2010-02", "1", "2010-02")', '"2010-02"');
    6464shouldBe('stepDown("2010-02", "1", "2010-02")', '"2010-02"');
  • trunk/LayoutTests/fast/forms/number/number-stepup-stepdown-expected.txt

    r289075 r289465  
    77
    88Invalid value
    9 PASS stepUp("", null, null) threw exception InvalidStateError: The object is in an invalid state..
    10 PASS stepDown("", null, null) threw exception InvalidStateError: The object is in an invalid state..
     9PASS stepUp("", null, null) is "1"
     10PASS stepDown("", null, null) is "-1"
    1111
    1212Non-number arguments
     
    143143PASS stepDown("1", "1", "0") is "0"
    144144PASS stepDown("0", "1", "0") is "0"
    145 PASS stepDown("1", "1", "0", 2) is "1"
    146 PASS input.value is "1"
    147 PASS stepDown("1", "3.40282346e+38", "", 2) is "1"
     145PASS stepDown("1", "1", "0", 2) is "0"
     146PASS input.value is "0"
     147PASS stepDown("1", "3.40282346e+38", "", 2) is "-3.40282346e+38"
    148148PASS stepUp("-1", "1", "0") is "0"
    149149PASS stepUp("0", "1", "0") is "0"
    150 PASS stepUp("-1", "1", "0", 2) is "-1"
    151 PASS input.value is "-1"
    152 PASS stepUp("1", "3.40282346e+38", "", 2) is "1"
     150PASS stepUp("-1", "1", "0", 2) is "0"
     151PASS input.value is "0"
     152PASS stepUp("1", "3.40282346e+38", "", 2) is "3.40282346e+38"
    153153
    154154stepDown()/stepUp() for stepMismatch values
  • trunk/LayoutTests/fast/forms/number/number-stepup-stepdown.html

    r289075 r289465  
    5858debug('');
    5959debug('Invalid value');
    60 shouldThrowErrorName('stepUp("", null, null)', "InvalidStateError");
    61 shouldThrowErrorName('stepDown("", null, null)', "InvalidStateError");
     60shouldBe('stepUp("", null, null)', '"1"');
     61shouldBe('stepDown("", null, null)', '"-1"');
    6262
    6363debug('');
     
    222222shouldBe('stepDown("1", "1", "0")', '"0"');
    223223shouldBe('stepDown("0", "1", "0")', '"0"');
    224 shouldBe('stepDown("1", "1", "0", 2)', '"1"');
    225 shouldBe('input.value', '"1"');
    226 shouldBe('stepDown("1", "3.40282346e+38", "", 2)', '"1"');
     224shouldBe('stepDown("1", "1", "0", 2)', '"0"');
     225shouldBe('input.value', '"0"');
     226shouldBe('stepDown("1", "3.40282346e+38", "", 2)', '"-3.40282346e+38"');
    227227shouldBe('stepUp("-1", "1", "0")', '"0"');
    228228shouldBe('stepUp("0", "1", "0")', '"0"');
    229 shouldBe('stepUp("-1", "1", "0", 2)', '"-1"');
    230 shouldBe('input.value', '"-1"');
    231 shouldBe('stepUp("1", "3.40282346e+38", "", 2)', '"1"');
     229shouldBe('stepUp("-1", "1", "0", 2)', '"0"');
     230shouldBe('input.value', '"0"');
     231shouldBe('stepUp("1", "3.40282346e+38", "", 2)', '"3.40282346e+38"');
    232232
    233233debug('');
  • trunk/LayoutTests/fast/forms/range/range-stepup-stepdown-expected.txt

    r289075 r289465  
    142142PASS stepUpExplicitBounds(null, "100", "1", "100") is "100"
    143143PASS input.value is "100"
    144 PASS stepUpExplicitBounds(null, "100", "1", "99", "2") is "99"
    145 PASS input.value is "99"
     144PASS stepUpExplicitBounds(null, "100", "1", "99", "2") is "100"
     145PASS input.value is "100"
    146146PASS stepDownExplicitBounds("0", null, "1", "1") is "0"
    147147PASS stepDownExplicitBounds("0", null, "1", "0") is "0"
    148148PASS input.value is "0"
    149 PASS stepDownExplicitBounds("0", null, "1", "1", "2") is "1"
    150 PASS input.value is "1"
     149PASS stepDownExplicitBounds("0", null, "1", "1", "2") is "0"
     150PASS input.value is "0"
    151151PASS stepDownExplicitBounds(null, null, "3.40282346e+38", "1", "2") is "0"
    152152PASS stepUpExplicitBounds(-100, 0, 1, -1) is "0"
    153153PASS stepUpExplicitBounds(null, 0, 1, 0) is "0"
    154 PASS stepUpExplicitBounds(-100, 0, 1, -1, 2) is "-1"
    155 PASS input.value is "-1"
     154PASS stepUpExplicitBounds(-100, 0, 1, -1, 2) is "0"
     155PASS input.value is "0"
    156156PASS stepUpExplicitBounds(null, null, "3.40282346e+38", "1", "2") is "0"
    157157
  • trunk/LayoutTests/fast/forms/range/range-stepup-stepdown.html

    r289075 r289465  
    232232shouldBe('stepUpExplicitBounds(null, "100", "1", "100")', '"100"');
    233233shouldBe('input.value', '"100"');
    234 shouldBe('stepUpExplicitBounds(null, "100", "1", "99", "2")', '"99"');
    235 shouldBe('input.value', '"99"');
     234shouldBe('stepUpExplicitBounds(null, "100", "1", "99", "2")', '"100"');
     235shouldBe('input.value', '"100"');
    236236shouldBe('stepDownExplicitBounds("0", null, "1", "1")', '"0"');
    237237shouldBe('stepDownExplicitBounds("0", null, "1", "0")', '"0"');
    238238shouldBe('input.value', '"0"');
    239 shouldBe('stepDownExplicitBounds("0", null, "1", "1", "2")', '"1"');
    240 shouldBe('input.value', '"1"');
     239shouldBe('stepDownExplicitBounds("0", null, "1", "1", "2")', '"0"');
     240shouldBe('input.value', '"0"');
    241241shouldBe('stepDownExplicitBounds(null, null, "3.40282346e+38", "1", "2")', '"0"');
    242242shouldBe('stepUpExplicitBounds(-100, 0, 1, -1)', '"0"');
    243243shouldBe('stepUpExplicitBounds(null, 0, 1, 0)', '"0"');
    244 shouldBe('stepUpExplicitBounds(-100, 0, 1, -1, 2)', '"-1"');
    245 shouldBe('input.value', '"-1"');
     244shouldBe('stepUpExplicitBounds(-100, 0, 1, -1, 2)', '"0"');
     245shouldBe('input.value', '"0"');
    246246shouldBe('stepUpExplicitBounds(null, null, "3.40282346e+38", "1", "2")', '"0"');
    247247
  • trunk/LayoutTests/fast/forms/time/time-stepup-stepdown-expected.txt

    r289075 r289465  
    55
    66Invalid value
    7 PASS stepUp("", null, null) threw exception InvalidStateError: The object is in an invalid state..
    8 PASS stepDown("", null, null) threw exception InvalidStateError: The object is in an invalid state..
     7PASS stepUp("", null, null) is "00:01"
     8PASS stepDown("", null, null) is "00:00"
    99Non-number arguments
    1010PASS stepUp("20:13", null, null, "0") is "20:13"
     
    2626Overflow/underflow
    2727PASS stepUp("20:13", "3.40282346e+38", null) is "20:13"
    28 PASS stepDown("20:13", "3.40282346e+38", null) is "20:13"
    29 PASS stepUp("20:13", "1", "20:13") is "20:13"
    30 PASS stepDown("20:13", "1", "20:13") is "20:13"
     28PASS stepDown("20:13", "3.40282346e+38", null) is "00:00:00"
     29PASS stepUp("20:13", "1", "20:13") is "20:13:00"
     30PASS stepDown("20:13", "1", "20:13") is "20:13:00"
    3131PASS stepUp("23:59", null, null) is "23:59"
    3232PASS stepDown("00:00", null, null) is "00:00"
  • trunk/LayoutTests/fast/forms/time/time-stepup-stepdown.html

    r289075 r289465  
    3939input.type = 'time';
    4040debug('Invalid value');
    41 shouldThrowErrorName('stepUp("", null, null)', "InvalidStateError");
    42 shouldThrowErrorName('stepDown("", null, null)', "InvalidStateError");
     41shouldBe('stepUp("", null, null)', '"00:01"');
     42shouldBe('stepDown("", null, null)', '"00:00"');
    4343debug('Non-number arguments');
    4444shouldBe('stepUp("20:13", null, null, "0")', '"20:13"');
     
    6060debug('Overflow/underflow');
    6161shouldBe('stepUp("20:13", "3.40282346e+38", null)', '"20:13"');
    62 shouldBe('stepDown("20:13", "3.40282346e+38", null)', '"20:13"');
    63 shouldBe('stepUp("20:13", "1", "20:13")', '"20:13"');
    64 shouldBe('stepDown("20:13", "1", "20:13")', '"20:13"');
     62shouldBe('stepDown("20:13", "3.40282346e+38", null)', '"00:00:00"');
     63shouldBe('stepUp("20:13", "1", "20:13")', '"20:13:00"');
     64shouldBe('stepDown("20:13", "1", "20:13")', '"20:13:00"');
    6565shouldBe('stepUp("23:59", null, null)', '"23:59"');
    6666shouldBe('stepDown("00:00", null, null)', '"00:00"');
  • trunk/LayoutTests/fast/forms/week/week-stepup-stepdown-expected.txt

    r289075 r289465  
    55
    66Invalid value
    7 PASS stepUp("", null, null) threw exception InvalidStateError: The object is in an invalid state..
    8 PASS stepDown("", null, null) threw exception InvalidStateError: The object is in an invalid state..
     7PASS stepUp("", null, null) is "1970-W02"
     8PASS stepDown("", null, null) is "1969-W52"
    99Non-number arguments
    1010PASS stepUp("2010-W02", null, null, "0") is "2010-W02"
     
    2626Overflow/underflow
    2727PASS stepUp("2010-W02", "3.40282346e+38", null) is "2010-W02"
    28 PASS stepDown("2010-W02", "3.40282346e+38", null) is "2010-W02"
     28PASS stepDown("2010-W02", "3.40282346e+38", null) is "1970-W01"
    2929PASS stepUp("2010-W02", "1", "2010-W02") is "2010-W02"
    3030PASS stepDown("2010-W02", "1", "2010-W02") is "2010-W02"
  • trunk/LayoutTests/fast/forms/week/week-stepup-stepdown.html

    r289075 r289465  
    3939input.type = 'week';
    4040debug('Invalid value');
    41 shouldThrowErrorName('stepUp("", null, null)', "InvalidStateError");
    42 shouldThrowErrorName('stepDown("", null, null)', "InvalidStateError");
     41shouldBe('stepUp("", null, null)', '"1970-W02"');
     42shouldBe('stepDown("", null, null)', '"1969-W52"');
    4343debug('Non-number arguments');
    4444shouldBe('stepUp("2010-W02", null, null, "0")', '"2010-W02"');
     
    6060debug('Overflow/underflow');
    6161shouldBe('stepUp("2010-W02", "3.40282346e+38", null)', '"2010-W02"');
    62 shouldBe('stepDown("2010-W02", "3.40282346e+38", null)', '"2010-W02"');
     62shouldBe('stepDown("2010-W02", "3.40282346e+38", null)', '"1970-W01"');
    6363shouldBe('stepUp("2010-W02", "1", "2010-W02")', '"2010-W02"');
    6464shouldBe('stepDown("2010-W02", "1", "2010-W02")', '"2010-W02"');
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r289454 r289465  
     12022-02-09  Ziran Sun  <zsun@igalia.com>
     2
     3        [Forms] Improving applyStep() to be in line with specs
     4        https://bugs.webkit.org/show_bug.cgi?id=236134
     5
     6        Reviewed by Chris Dumez.
     7
     8        * web-platform-tests/html/semantics/forms/the-input-element/range-expected.txt:
     9
    1102022-02-08  Antoine Quint  <graouts@webkit.org>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/range-expected.txt

    r289209 r289465  
    2222PASS Performing stepUp()
    2323PASS Performing stepDown()
    24 FAIL Performing stepUp() beyond the value of the max attribute assert_equals: expected "12" but got "9"
    25 FAIL Performing stepDown() beyond the value of the min attribute assert_equals: expected "3" but got "6"
     24PASS Performing stepUp() beyond the value of the max attribute
     25PASS Performing stepDown() beyond the value of the min attribute
    2626FAIL Skip ASCII whitespace within input assert_equals: expected "123" but got "50"
    2727PASS Multiply value by ten raised to the exponentth power with `e`
  • trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-expected.txt

    r289075 r289465  
    3030PASS stepUp stop because it exceeds the maximum value
    3131PASS stepDown stop so lower than the minimum value
    32 FAIL stop at border on stepUp assert_in_array: a valid time string representing 1 minute after 3pm value "15:00" not in array ["15:01", "15:01:00", "15:01:00.0", "15:01:00.00", "15:01:00.000"]
    33 FAIL stop at border on stepDown assert_in_array: a valid time string representing 1 minute before 2pm value "13:00" not in array ["12:59", "12:59:00", "12:59:00.0", "12:59:00.00", "12:59:00.000"]
    34 FAIL  empty value of stepUp The object is in an invalid state.
     32PASS stop at border on stepUp
     33PASS stop at border on stepDown
     34PASS  empty value of stepUp
    3535PASS set value on not time format value
    3636
  • trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-expected.txt

    r289075 r289465  
    3030PASS stepUp stop because it exceeds the maximum value
    3131PASS stepDown stop so lower than the minimum value
    32 FAIL stop at border on stepUp assert_in_array: a valid time string representing 1 minute after 3pm value "15:00" not in array ["15:01", "15:01:00", "15:01:00.0", "15:01:00.00", "15:01:00.000"]
    33 FAIL stop at border on stepDown assert_in_array: a valid time string representing 1 minute before 2pm value "13:00" not in array ["12:59", "12:59:00", "12:59:00.0", "12:59:00.00", "12:59:00.000"]
    34 FAIL  empty value of stepUp The object is in an invalid state.
     32PASS stop at border on stepUp
     33PASS stop at border on stepDown
     34PASS  empty value of stepUp
    3535PASS set value on not time format value
    3636
  • trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/time-expected.txt

    r289075 r289465  
    3030PASS stepUp stop because it exceeds the maximum value
    3131PASS stepDown stop so lower than the minimum value
    32 FAIL stop at border on stepUp assert_in_array: a valid time string representing 1 minute after 3pm value "15:00" not in array ["15:01", "15:01:00", "15:01:00.0", "15:01:00.00", "15:01:00.000"]
    33 FAIL stop at border on stepDown assert_in_array: a valid time string representing 1 minute before 2pm value "13:00" not in array ["12:59", "12:59:00", "12:59:00.0", "12:59:00.00", "12:59:00.000"]
    34 FAIL  empty value of stepUp The object is in an invalid state.
     32PASS stop at border on stepUp
     33PASS stop at border on stepDown
     34PASS  empty value of stepUp
    3535PASS set value on not time format value
    3636
  • trunk/Source/WebCore/ChangeLog

    r289462 r289465  
     12022-02-09  Ziran Sun  <zsun@igalia.com>
     2
     3        [Forms] Improving applyStep() to be in line with specs
     4        https://bugs.webkit.org/show_bug.cgi?id=236134
     5
     6        Reviewed by Chris Dumez.
     7
     8        This is to improve applyStep() func to follow specs at
     9        https://html.spec.whatwg.org/multipage/input.html#dom-input-stepup
     10
     11        Since Chromium implementation follows the specs steps, this patch imports the
     12        Chromium implmentation.
     13
     14        This is a further patch after https://bugs.webkit.org/show_bug.cgi?id=235509. It has corrected
     15        some changes on test files in fast/form directory in the previous patch submitted for Bug
     16        235509. With this CL a few more sub-tests are now passing.         
     17                 
     18        * html/InputType.cpp:
     19        (WebCore::InputType::applyStep):
     20        * html/StepRange.cpp:
     21        (WebCore::StepRange::stepSnappedMaximum const):
     22        * html/StepRange.h:
     23
    1242022-02-09  Saam Barati  <sbarati@apple.com>
    225
  • trunk/Source/WebCore/html/InputType.cpp

    r289075 r289465  
    922922ExceptionOr<void> InputType::applyStep(int count, AnyStepHandling anyStepHandling, TextFieldEventBehavior eventBehavior)
    923923{
     924    // https://html.spec.whatwg.org/C/#dom-input-stepup
     925
    924926    StepRange stepRange(createStepRange(anyStepHandling));
    925927    if (!stepRange.hasStep())
    926928        return Exception { InvalidStateError };
    927929
    928     ASSERT(element());
    929     const Decimal current = parseToNumberOrNaN(element()->value());
    930     if (!current.isFinite())
    931         return Exception { InvalidStateError };
    932     Decimal newValue = current + stepRange.step() * count;
    933     if (!newValue.isFinite())
    934         return Exception { InvalidStateError };
    935 
    936     const Decimal acceptableErrorValue = stepRange.acceptableError();
    937     if (newValue - stepRange.minimum() < -acceptableErrorValue)
     930    // 3. If the element has a minimum and a maximum and the minimum is greater than the maximum, then abort these steps.
     931    if (stepRange.minimum() > stepRange.maximum())
    938932        return { };
    939     if (newValue < stepRange.minimum())
    940         newValue = stepRange.minimum();
    941 
    942     if (!equalLettersIgnoringASCIICase(element()->attributeWithoutSynchronization(stepAttr), "any"))
     933   
     934    // 4. If the element has a minimum and a maximum and there is no value greater than or equal to the element's minimum and less than or equal to
     935    // the element's maximum that, when subtracted from the step base, is an integral multiple of the allowed value step, then abort these steps.
     936    Decimal alignedMaximum = stepRange.stepSnappedMaximum();
     937    if (!alignedMaximum.isFinite())
     938        return { };
     939
     940    ASSERT(element());
     941    const Decimal current = parseToNumber(element()->value(), 0);
     942    Decimal base = stepRange.stepBase();
     943    Decimal step = stepRange.step();
     944    Decimal newValue = current;
     945
     946    newValue = newValue + stepRange.step() * Decimal::fromDouble(count);
     947    const AtomString& stepString = element()->getAttribute(HTMLNames::stepAttr);
     948    if (!equalIgnoringASCIICase(stepString, "any"))
    943949        newValue = stepRange.alignValueForStep(current, newValue);
    944950
    945     if (newValue - stepRange.maximum() > acceptableErrorValue)
     951    // 8. If the element has a minimum, and value is less than that minimum, then set value to the smallest value that, when subtracted from the step
     952    // base, is an integral multiple of the allowed value step, and that is more than or equal to minimum.
     953    if (newValue < stepRange.minimum()) {
     954        const Decimal alignedMinimum = base + ((stepRange.minimum() - base) / step).ceiling() * step;
     955        ASSERT(alignedMinimum >= stepRange.minimum());
     956        newValue = alignedMinimum;
     957    }
     958
     959    // 9. If the element has a maximum, and value is greater than that maximum, then set value to the largest value that, when subtracted from the step
     960    // base, is an integral multiple of the allowed value step, and that is less than or equal to maximum.
     961    if (newValue > stepRange.maximum())
     962        newValue = alignedMaximum;
     963
     964    // 10. If either the method invoked was the stepDown() method and value is greater than valueBeforeStepping, or the method invoked was the stepUp()
     965    // method and value is less than valueBeforeStepping, then return.
     966    if ((count < 0 && current < newValue) || (count > 0 && current > newValue))
    946967        return { };
    947     if (newValue > stepRange.maximum())
    948         newValue = stepRange.maximum();
    949 
     968   
    950969    Ref protectedThis { *this };
    951970    auto result = setValueAsDecimal(newValue, eventBehavior);
  • trunk/Source/WebCore/html/StepRange.cpp

    r286581 r289465  
    143143}
    144144
     145Decimal StepRange::stepSnappedMaximum() const
     146{
     147    Decimal base = stepBase();
     148    Decimal step =  m_step;
     149    if (base - step == base || !(base / step).isFinite())
     150        return Decimal::nan();
     151    Decimal alignedMaximum = base + ((maximum() - base) / step).floor() * step;
     152    if (alignedMaximum > maximum())
     153        alignedMaximum -= step;
     154    if (alignedMaximum < minimum())
     155        return Decimal::nan();
     156    return alignedMaximum;
     157}
     158
    145159bool StepRange::stepMismatch(const Decimal& valueForCheck) const
    146160{
  • trunk/Source/WebCore/html/StepRange.h

    r286581 r289465  
    7474    Decimal maximum() const { return m_maximum; }
    7575    Decimal minimum() const { return m_minimum; }
     76    Decimal stepSnappedMaximum() const;
    7677    static Decimal parseStep(AnyStepHandling, const StepDescription&, const String&);
    7778    Decimal step() const { return m_step; }
Note: See TracChangeset for help on using the changeset viewer.