Changeset 90385 in webkit
- Timestamp:
- Jul 5, 2011 12:18:01 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r90383 r90385 1 2011-07-05 Shinya Kawanaka <shinyak@google.com> 2 3 Reviewed by Kent Tamura. 4 5 The default step is used when the step attribute of input[type='number'] is "any". 6 https://bugs.webkit.org/show_bug.cgi?id=57723 7 8 Changed Layout tests to use the default step when the step attribute of 9 input[type='number'] is "any". 10 11 * fast/forms/input-stepup-stepdown-from-renderer-expected.txt: Regenerated. 12 * fast/forms/script-tests/input-stepup-stepdown-from-renderer.js: 13 1 14 2011-07-04 Gavin Barraclough <barraclough@apple.com> 2 15 -
trunk/LayoutTests/fast/forms/input-stepup-stepdown-from-renderer-expected.txt
r86650 r90385 14 14 PASS stepDown("1970-01-01", "4", null, 3) is "1969-12-20" 15 15 Step=any 16 PASS stepUp("2010-02-10", "any", null) is "2010-02-1 0"17 PASS stepDown("2010-02-10", "any", null) is "2010-02- 10"16 PASS stepUp("2010-02-10", "any", null) is "2010-02-11" 17 PASS stepDown("2010-02-10", "any", null) is "2010-02-09" 18 18 Overflow/underflow 19 19 PASS stepUp("2010-02-10", "3.40282346e+38", null) is "275760-09-13" … … 35 35 PASS stepDown("1970-01-01T20:13Z", "4", null, 3) is "1970-01-01T20:12:48Z" 36 36 Step=any 37 PASS stepUp("2010-02-10T20:13Z", "any", null) is "2010-02-10T20:1 3Z"38 PASS stepDown("2010-02-10T20:13Z", "any", null) is "2010-02-10T20:1 3Z"37 PASS stepUp("2010-02-10T20:13Z", "any", null) is "2010-02-10T20:14Z" 38 PASS stepDown("2010-02-10T20:13Z", "any", null) is "2010-02-10T20:12Z" 39 39 Overflow/underflow 40 40 PASS stepUp("2010-02-10T20:13Z", "3.40282346e+38", null) is "275760-09-13T00:00:00.000Z" … … 56 56 PASS stepDown("1970-01-01T20:13", "4", null, 3) is "1970-01-01T20:12:48" 57 57 Step=any 58 PASS stepUp("2010-02-10T20:13", "any", null) is "2010-02-10T20:1 3"59 PASS stepDown("2010-02-10T20:13", "any", null) is "2010-02-10T20:1 3"58 PASS stepUp("2010-02-10T20:13", "any", null) is "2010-02-10T20:14" 59 PASS stepDown("2010-02-10T20:13", "any", null) is "2010-02-10T20:12" 60 60 Overflow/underflow 61 61 PASS stepUp("2010-02-10T20:13", "3.40282346e+38", null) is "275760-09-13T00:00:00.000" … … 77 77 PASS stepDown("1970-01", "4", null, 3) is "1969-01" 78 78 Step=any 79 PASS stepUp("2010-02", "any", null) is "2010-0 2"80 PASS stepDown("2010-02", "any", null) is "2010-0 2"79 PASS stepUp("2010-02", "any", null) is "2010-03" 80 PASS stepDown("2010-02", "any", null) is "2010-01" 81 81 Overflow/underflow 82 82 PASS stepUp("2010-02", "3.40282346e+38", null) is "275760-09" … … 93 93 PASS stepUp("", null, null) is "1" 94 94 PASS stepDown("", null, null) is "-1" 95 PASS stepUp("", "any", null) is " 0"96 PASS stepDown("", "any", null) is " 0"95 PASS stepUp("", "any", null) is "1" 96 PASS stepDown("", "any", null) is "-1" 97 97 PASS stepUp("", "foo", null) is "1" 98 98 PASS stepDown("", "foo", null) is "-1" 99 99 PASS stepUp("foo", null, null) is "1" 100 100 PASS stepDown("foo", null, null) is "-1" 101 PASS stepUp("foo", "any", null) is " 0"102 PASS stepDown("foo", "any", null) is " 0"101 PASS stepUp("foo", "any", null) is "1" 102 PASS stepDown("foo", "any", null) is "-1" 103 103 PASS stepUp("foo", "foo", null) is "1" 104 104 PASS stepDown("foo", "foo", null) is "-1" … … 115 115 PASS stepUp("2", "-1", null) is "3" 116 116 Step=any 117 PASS stepUp("0", "any", null) is " 0"118 PASS stepDown("0", "any", null) is " 0"117 PASS stepUp("0", "any", null) is "1" 118 PASS stepDown("0", "any", null) is "-1" 119 119 Overflow/underflow 120 120 PASS stepDown("1", "1", "0") is "0" … … 234 234 PASS stepDown("20:13", "4", null, 3) is "20:12:48" 235 235 Step=any 236 PASS stepUp("20:13", "any", null) is "20:1 3"237 PASS stepDown("20:13", "any", null) is "20:1 3"236 PASS stepUp("20:13", "any", null) is "20:14" 237 PASS stepDown("20:13", "any", null) is "20:12" 238 238 Overflow/underflow 239 239 PASS stepUp("20:13", "3.40282346e+38", null) is "23:59:59.999" … … 257 257 PASS stepDown("1970-W01", "4", null, 3) is "1969-W41" 258 258 Step=any 259 PASS stepUp("2010-W02", "any", null) is "2010-W0 2"260 PASS stepDown("2010-W02", "any", null) is "2010-W0 2"259 PASS stepUp("2010-W02", "any", null) is "2010-W03" 260 PASS stepDown("2010-W02", "any", null) is "2010-W01" 261 261 Overflow/underflow 262 262 PASS stepUp("2010-W02", "3.40282346e+38", null) is "275760-W37" -
trunk/LayoutTests/fast/forms/script-tests/input-stepup-stepdown-from-renderer.js
r86650 r90385 89 89 shouldBe('stepDown("1970-01-01", "4", null, 3)', '"1969-12-20"'); 90 90 debug('Step=any'); 91 shouldBe('stepUp("2010-02-10", "any", null)', '"2010-02-1 0"');92 shouldBe('stepDown("2010-02-10", "any", null)', '"2010-02- 10"');91 shouldBe('stepUp("2010-02-10", "any", null)', '"2010-02-11"'); 92 shouldBe('stepDown("2010-02-10", "any", null)', '"2010-02-09"'); 93 93 debug('Overflow/underflow'); 94 94 shouldBe('stepUp("2010-02-10", "3.40282346e+38", null)','"275760-09-13"'); … … 112 112 shouldBe('stepDown("1970-01-01T20:13Z", "4", null, 3)', '"1970-01-01T20:12:48Z"'); 113 113 debug('Step=any'); 114 shouldBe('stepUp("2010-02-10T20:13Z", "any", null)', '"2010-02-10T20:1 3Z"');115 shouldBe('stepDown("2010-02-10T20:13Z", "any", null)', '"2010-02-10T20:1 3Z"');114 shouldBe('stepUp("2010-02-10T20:13Z", "any", null)', '"2010-02-10T20:14Z"'); 115 shouldBe('stepDown("2010-02-10T20:13Z", "any", null)', '"2010-02-10T20:12Z"'); 116 116 debug('Overflow/underflow'); 117 117 shouldBe('stepUp("2010-02-10T20:13Z", "3.40282346e+38", null)', '"275760-09-13T00:00:00.000Z"'); … … 135 135 shouldBe('stepDown("1970-01-01T20:13", "4", null, 3)', '"1970-01-01T20:12:48"'); 136 136 debug('Step=any'); 137 shouldBe('stepUp("2010-02-10T20:13", "any", null)', '"2010-02-10T20:1 3"');138 shouldBe('stepDown("2010-02-10T20:13", "any", null)', '"2010-02-10T20:1 3"');137 shouldBe('stepUp("2010-02-10T20:13", "any", null)', '"2010-02-10T20:14"'); 138 shouldBe('stepDown("2010-02-10T20:13", "any", null)', '"2010-02-10T20:12"'); 139 139 debug('Overflow/underflow'); 140 140 shouldBe('stepUp("2010-02-10T20:13", "3.40282346e+38", null)', '"275760-09-13T00:00:00.000"'); … … 158 158 shouldBe('stepDown("1970-01", "4", null, 3)', '"1969-01"'); 159 159 debug('Step=any'); 160 shouldBe('stepUp("2010-02", "any", null)', '"2010-0 2"');161 shouldBe('stepDown("2010-02", "any", null)', '"2010-0 2"');160 shouldBe('stepUp("2010-02", "any", null)', '"2010-03"'); 161 shouldBe('stepDown("2010-02", "any", null)', '"2010-01"'); 162 162 debug('Overflow/underflow'); 163 163 shouldBe('stepUp("2010-02", "3.40282346e+38", null)', '"275760-09"'); … … 176 176 shouldBe('stepUp("", null, null)', '"1"'); 177 177 shouldBe('stepDown("", null, null)', '"-1"'); 178 shouldBe('stepUp("", "any", null)', '" 0"');179 shouldBe('stepDown("", "any", null)', '" 0"');178 shouldBe('stepUp("", "any", null)', '"1"'); 179 shouldBe('stepDown("", "any", null)', '"-1"'); 180 180 shouldBe('stepUp("", "foo", null)', '"1"'); 181 181 shouldBe('stepDown("", "foo", null)', '"-1"'); 182 182 shouldBe('stepUp("foo", null, null)', '"1"'); 183 183 shouldBe('stepDown("foo", null, null)', '"-1"'); 184 shouldBe('stepUp("foo", "any", null)', '" 0"');185 shouldBe('stepDown("foo", "any", null)', '" 0"');184 shouldBe('stepUp("foo", "any", null)', '"1"'); 185 shouldBe('stepDown("foo", "any", null)', '"-1"'); 186 186 shouldBe('stepUp("foo", "foo", null)', '"1"'); 187 187 shouldBe('stepDown("foo", "foo", null)', '"-1"'); … … 198 198 shouldBe('stepUp("2", "-1", null)', '"3"'); 199 199 debug('Step=any'); 200 shouldBe('stepUp("0", "any", null)', '" 0"');201 shouldBe('stepDown("0", "any", null)', '" 0"');200 shouldBe('stepUp("0", "any", null)', '"1"'); 201 shouldBe('stepDown("0", "any", null)', '"-1"'); 202 202 debug('Overflow/underflow'); 203 203 shouldBe('stepDown("1", "1", "0")', '"0"'); … … 321 321 shouldBe('stepDown("20:13", "4", null, 3)', '"20:12:48"'); 322 322 debug('Step=any'); 323 shouldBe('stepUp("20:13", "any", null)', '"20:1 3"');324 shouldBe('stepDown("20:13", "any", null)', '"20:1 3"');323 shouldBe('stepUp("20:13", "any", null)', '"20:14"'); 324 shouldBe('stepDown("20:13", "any", null)', '"20:12"'); 325 325 debug('Overflow/underflow'); 326 326 shouldBe('stepUp("20:13", "3.40282346e+38", null)', '"23:59:59.999"'); … … 346 346 shouldBe('stepDown("1970-W01", "4", null, 3)', '"1969-W41"'); 347 347 debug('Step=any'); 348 shouldBe('stepUp("2010-W02", "any", null)', '"2010-W0 2"');349 shouldBe('stepDown("2010-W02", "any", null)', '"2010-W0 2"');348 shouldBe('stepUp("2010-W02", "any", null)', '"2010-W03"'); 349 shouldBe('stepDown("2010-W02", "any", null)', '"2010-W01"'); 350 350 debug('Overflow/underflow'); 351 351 shouldBe('stepUp("2010-W02", "3.40282346e+38", null)', '"275760-W37"'); -
trunk/Source/WebCore/ChangeLog
r90384 r90385 1 2011-07-05 Shinya Kawanaka <shinyak@google.com> 2 3 Reviewed by Kent Tamura. 4 5 The default step is used when attribute step of input[type='number'] is "any". 6 https://bugs.webkit.org/show_bug.cgi?id=57723 7 8 When step is "any", 0 was chosen as step, but this is not intuitive. 9 So changed to use the default step. 10 11 * html/HTMLInputElement.cpp: 12 (WebCore::HTMLInputElement::getAllowedValueStep): 13 Calls getAllowedValueStepWithDecimalPlaces with RejectAny. 14 (WebCore::HTMLInputElement::getAllowedValueStepWithDecimalPlaces): 15 Takes a new arugument AnyStepHandling. If it is AnyIsDefaultStep, this method 16 allows "step" attribute to take a value "any" to use the default step as step value. 17 Otherwise, INVALID_STATE_ERR will be returned if "step" is "any". 18 (WebCore::HTMLInputElement::applyStep): ditto. 19 (WebCore::HTMLInputElement::stepUp): 20 Calls applyStep with RejectAny. 21 (WebCore::HTMLInputElement::stepDown): ditto. 22 (WebCore::HTMLInputElement::stepUpFromRenderer): 23 Removes a check that step is "any". It is checked in getAllowedValueStepWithDecimalPlaces. 24 * html/HTMLInputElement.h: 25 1 26 2011-07-04 Dominic Cooney <dominicc@chromium.org> 2 27 -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r90101 r90385 339 339 bool HTMLInputElement::getAllowedValueStep(double* step) const 340 340 { 341 return getAllowedValueStepWithDecimalPlaces( step, 0);342 } 343 344 bool HTMLInputElement::getAllowedValueStepWithDecimalPlaces( double* step, unsigned* decimalPlaces) const341 return getAllowedValueStepWithDecimalPlaces(RejectAny, step, 0); 342 } 343 344 bool HTMLInputElement::getAllowedValueStepWithDecimalPlaces(AnyStepHandling anyStepHandling, double* step, unsigned* decimalPlaces) const 345 345 { 346 346 ASSERT(step); … … 356 356 return true; 357 357 } 358 if (equalIgnoringCase(stepString, "any")) 359 return false; 358 359 if (equalIgnoringCase(stepString, "any")) { 360 switch (anyStepHandling) { 361 case RejectAny: 362 return false; 363 case AnyIsDefaultStep: 364 *step = defaultStep * stepScaleFactor; 365 if (decimalPlaces) 366 *decimalPlaces = 0; 367 return true; 368 default: 369 ASSERT_NOT_REACHED(); 370 } 371 } 372 360 373 double parsed; 361 374 if (!decimalPlaces) { … … 383 396 } 384 397 385 void HTMLInputElement::applyStep(double count, ExceptionCode& ec)398 void HTMLInputElement::applyStep(double count, AnyStepHandling anyStepHandling, ExceptionCode& ec) 386 399 { 387 400 double step; 388 401 unsigned stepDecimalPlaces, currentDecimalPlaces; 389 if (!getAllowedValueStepWithDecimalPlaces( &step, &stepDecimalPlaces)) {402 if (!getAllowedValueStepWithDecimalPlaces(anyStepHandling, &step, &stepDecimalPlaces)) { 390 403 ec = INVALID_STATE_ERR; 391 404 return; 392 405 } 406 393 407 const double nan = numeric_limits<double>::quiet_NaN(); 394 408 double current = m_inputType->parseToDoubleWithDecimalPlaces(value(), nan, ¤tDecimalPlaces); … … 435 449 void HTMLInputElement::stepUp(int n, ExceptionCode& ec) 436 450 { 437 applyStep(n, ec);451 applyStep(n, RejectAny, ec); 438 452 } 439 453 440 454 void HTMLInputElement::stepDown(int n, ExceptionCode& ec) 441 455 { 442 applyStep(-n, ec);456 applyStep(-n, RejectAny, ec); 443 457 } 444 458 … … 1510 1524 unsigned stepDecimalPlaces, baseDecimalPlaces; 1511 1525 double step, base; 1512 // The value will be the default value after stepping for <input value=(empty/invalid) step="any" />1513 1526 // FIXME: Not any changes after stepping, even if it is an invalid value, may be better. 1514 1527 // (e.g. Stepping-up for <input type="number" value="foo" step="any" /> => "foo") 1515 if (equalIgnoringCase(fastGetAttribute(stepAttr), "any")) 1516 step = 0; 1517 else if (!getAllowedValueStepWithDecimalPlaces(&step, &stepDecimalPlaces)) 1518 return; 1528 if (!getAllowedValueStepWithDecimalPlaces(AnyIsDefaultStep, &step, &stepDecimalPlaces)) 1529 return; 1519 1530 base = m_inputType->stepBaseWithDecimalPlaces(&baseDecimalPlaces); 1520 1531 baseDecimalPlaces = min(baseDecimalPlaces, 16u); … … 1565 1576 current = newValue; 1566 1577 if (n > 1) 1567 applyStep(n - 1, ec);1578 applyStep(n - 1, AnyIsDefaultStep, ec); 1568 1579 else if (n < -1) 1569 applyStep(n + 1, ec);1580 applyStep(n + 1, AnyIsDefaultStep, ec); 1570 1581 } else 1571 applyStep(n, ec);1582 applyStep(n, AnyIsDefaultStep, ec); 1572 1583 } 1573 1584 -
trunk/Source/WebCore/html/HTMLInputElement.h
r90089 r90385 63 63 // Returns false if there is no "allowed value step." 64 64 bool getAllowedValueStep(double*) const; 65 bool getAllowedValueStepWithDecimalPlaces(double*, unsigned*) const; 65 66 66 // For ValidityState. 67 67 bool stepMismatch(const String&) const; … … 241 241 private: 242 242 enum AutoCompleteSetting { Uninitialized, On, Off }; 243 enum AnyStepHandling { RejectAny, AnyIsDefaultStep }; 243 244 244 245 virtual void willMoveToNewOwnerDocument(); … … 317 318 void updateType(); 318 319 320 bool getAllowedValueStepWithDecimalPlaces(AnyStepHandling, double*, unsigned*) const; 321 319 322 // Helper for stepUp()/stepDown(). Adds step value * count to the current value. 320 void applyStep(double count, ExceptionCode&);323 void applyStep(double count, AnyStepHandling, ExceptionCode&); 321 324 322 325 #if ENABLE(DATALIST)
Note: See TracChangeset
for help on using the changeset viewer.