Changeset 91549 in webkit
- Timestamp:
- Jul 21, 2011 8:27:30 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r91547 r91549 1 2011-07-21 Shinya Kawanaka <shinyak@google.com> 2 3 The input[type="number"] with step="any" should not suffer from step mismatch. 4 https://bugs.webkit.org/show_bug.cgi?id=64858 5 6 Reviewed by Kent Tamura. 7 8 Added test cases of input[type="number"] with step="any" 9 10 * fast/forms/input-stepup-stepdown-expected.txt: added the test cases. 11 * fast/forms/input-stepup-stepdown-from-renderer-expected.txt: ditto. 12 * fast/forms/script-tests/input-stepup-stepdown-from-renderer.js: ditto. 13 * fast/forms/script-tests/input-stepup-stepdown.js: ditto. 14 1 15 2011-07-21 Robin Qiu <robin.qiu.dev@gmail.com> 2 16 -
trunk/LayoutTests/fast/forms/input-stepup-stepdown-expected.txt
r72377 r91549 140 140 PASS stepUp("0", "any", null) threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 141 141 PASS stepDown("0", "any", null) threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 142 Step=any corner case 143 PASS stepUpExplicitBounds("0", "100", "any", "1.5", "1") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 144 PASS stepDownExplicitBounds("0", "100", "any", "1.5", "1") threw exception Error: INVALID_STATE_ERR: DOM Exception 11. 142 145 Overflow/underflow 143 146 PASS stepDown("1", "1", "0") is "0" -
trunk/LayoutTests/fast/forms/input-stepup-stepdown-from-renderer-expected.txt
r90385 r91549 117 117 PASS stepUp("0", "any", null) is "1" 118 118 PASS stepDown("0", "any", null) is "-1" 119 Step=any corner case 120 PASS stepUpExplicitBounds("0", "100", "any", "1.5", "1") is "2.5" 121 PASS stepDownExplicitBounds("0", "100", "any", "1.5", "1") is "0.5" 119 122 Overflow/underflow 120 123 PASS stepDown("1", "1", "0") is "0" -
trunk/LayoutTests/fast/forms/script-tests/input-stepup-stepdown-from-renderer.js
r90385 r91549 200 200 shouldBe('stepUp("0", "any", null)', '"1"'); 201 201 shouldBe('stepDown("0", "any", null)', '"-1"'); 202 debug('Step=any corner case'); 203 shouldBe('stepUpExplicitBounds("0", "100", "any", "1.5", "1")', '"2.5"'); 204 shouldBe('stepDownExplicitBounds("0", "100", "any", "1.5", "1")', '"0.5"'); 202 205 debug('Overflow/underflow'); 203 206 shouldBe('stepDown("1", "1", "0")', '"0"'); -
trunk/LayoutTests/fast/forms/script-tests/input-stepup-stepdown.js
r72377 r91549 195 195 shouldThrow('stepUp("0", "any", null)', invalidStateErr); 196 196 shouldThrow('stepDown("0", "any", null)', invalidStateErr); 197 debug('Step=any corner case'); 198 shouldThrow('stepUpExplicitBounds("0", "100", "any", "1.5", "1")', invalidStateErr); 199 shouldThrow('stepDownExplicitBounds("0", "100", "any", "1.5", "1")', invalidStateErr); 197 200 debug('Overflow/underflow'); 198 201 shouldBe('stepDown("1", "1", "0")', '"0"'); -
trunk/Source/WebCore/ChangeLog
r91548 r91549 1 2011-07-21 Shinya Kawanaka <shinyak@google.com> 2 3 The input[type="number"] with step="any" should not suffer from step mismatch. 4 https://bugs.webkit.org/show_bug.cgi?id=64858 5 6 Reviewed by Kent Tamura. 7 8 Added check step="any" not to suffer from step mismatch. 9 10 * html/HTMLInputElement.cpp: 11 (WebCore::HTMLInputElement::applyStep): Added check step="any". 12 (WebCore::HTMLInputElement::alignValueForStep): Added. 13 1 14 2011-07-21 MORITA Hajime <morrita@google.com> 2 15 -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r91404 r91549 416 416 return; 417 417 } 418 418 419 double acceptableError = m_inputType->acceptableError(step); 419 420 if (newValue - m_inputType->minimum() < -acceptableError) { … … 423 424 if (newValue < m_inputType->minimum()) 424 425 newValue = m_inputType->minimum(); 426 427 const AtomicString& stepString = fastGetAttribute(stepAttr); 428 if (!equalIgnoringCase(stepString, "any")) 429 newValue = alignValueForStep(newValue, step, currentDecimalPlaces, stepDecimalPlaces); 430 431 if (newValue - m_inputType->maximum() > acceptableError) { 432 ec = INVALID_STATE_ERR; 433 return; 434 } 435 if (newValue > m_inputType->maximum()) 436 newValue = m_inputType->maximum(); 437 438 setValueAsNumber(newValue, ec); 439 440 if (AXObjectCache::accessibilityEnabled()) 441 document()->axObjectCache()->postNotification(renderer(), AXObjectCache::AXValueChanged, true); 442 } 443 444 double HTMLInputElement::alignValueForStep(double newValue, double step, unsigned currentDecimalPlaces, unsigned stepDecimalPlaces) 445 { 446 if (newValue >= pow(10.0, 21.0)) 447 return newValue; 448 425 449 unsigned baseDecimalPlaces; 426 450 double base = m_inputType->stepBaseWithDecimalPlaces(&baseDecimalPlaces); 427 451 baseDecimalPlaces = min(baseDecimalPlaces, 16u); 428 if (newValue < pow(10.0, 21.0)) { 429 if (stepMismatch(value())) { 430 double scale = pow(10.0, static_cast<double>(max(stepDecimalPlaces, currentDecimalPlaces))); 431 newValue = round(newValue * scale) / scale; 432 } else { 433 double scale = pow(10.0, static_cast<double>(max(stepDecimalPlaces, baseDecimalPlaces))); 434 newValue = round((base + round((newValue - base) / step) * step) * scale) / scale; 435 } 436 } 437 if (newValue - m_inputType->maximum() > acceptableError) { 438 ec = INVALID_STATE_ERR; 439 return; 440 } 441 if (newValue > m_inputType->maximum()) 442 newValue = m_inputType->maximum(); 443 setValueAsNumber(newValue, ec); 444 445 if (AXObjectCache::accessibilityEnabled()) 446 document()->axObjectCache()->postNotification(renderer(), AXObjectCache::AXValueChanged, true); 452 if (stepMismatch(value())) { 453 double scale = pow(10.0, static_cast<double>(max(stepDecimalPlaces, currentDecimalPlaces))); 454 newValue = round(newValue * scale) / scale; 455 } else { 456 double scale = pow(10.0, static_cast<double>(max(stepDecimalPlaces, baseDecimalPlaces))); 457 newValue = round((base + round((newValue - base) / step) * step) * scale) / scale; 458 } 459 460 return newValue; 447 461 } 448 462 -
trunk/Source/WebCore/html/HTMLInputElement.h
r91404 r91549 322 322 // Helper for stepUp()/stepDown(). Adds step value * count to the current value. 323 323 void applyStep(double count, AnyStepHandling, ExceptionCode&); 324 double alignValueForStep(double value, double step, unsigned currentDecimalPlaces, unsigned stepDecimalPlaces); 324 325 325 326 #if ENABLE(DATALIST)
Note: See TracChangeset
for help on using the changeset viewer.