LayoutTests/ChangeLog

 12010-11-18 Dai Mikurube <dmikurube@google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 stepUp/stepDown for values in step-mismatching state for input elements
 6 https://bugs.webkit.org/show_bug.cgi?id=48976
 7
 8 * fast/forms/input-stepup-stepdown-expected.txt:
 9 * fast/forms/script-tests/input-stepup-stepdown.js:
 10
1112010-11-14 Mihai Parparita <mihaip@chromium.org>
212
313 Unreviewed Chromium rebaseline and expectations update.

LayoutTests/fast/forms/input-stepup-stepdown-expected.txt

@@PASS stepUp("-1", "1", "0", 2) threw exception Error: INVALID_STATE_ERR: DOM Exc
151151PASS input.value is "-1"
152152PASS stepUp("1", "3.40282346e+38", "", 2) threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
153153stepDown()/stepUp() for stepMismatch values
154 PASS stepUp("1", "2", "") is "4"
155 PASS input.stepDown(); input.value is "2"
156 PASS input.min = "0"; stepUp("9", "10", "", 9) is "100"
157 PASS stepDown("19", "10", "0") is "10"
158 PASS stepUp("89", "10", "99") threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
 154PASS stepUp("1", "2", "") is "3"
 155PASS input.stepDown(); input.value is "1"
 156PASS input.min = "0"; stepUp("9", "10", "", 9) is "99"
 157PASS stepDown("19", "10", "0") is "9"
 158PASS stepUp("89", "10", "99") is "99"
159159Huge value and small step
160160PASS input.min = ""; stepUp("1e+38", "1", "", 999999) is "1e+38"
161161PASS input.max = ""; stepDown("1e+38", "1", "", 999999) is "1e+38"

LayoutTests/fast/forms/script-tests/input-stepup-stepdown.js

@@shouldThrow('stepUp("-1", "1", "0", 2)', invalidStateErr);
206206shouldBe('input.value', '"-1"');
207207shouldThrow('stepUp("1", "3.40282346e+38", "", 2)', invalidStateErr);
208208debug('stepDown()/stepUp() for stepMismatch values');
209 shouldBe('stepUp("1", "2", "")', '"4"');
210 shouldBe('input.stepDown(); input.value', '"2"');
211 shouldBe('input.min = "0"; stepUp("9", "10", "", 9)', '"100"');
212 shouldBe('stepDown("19", "10", "0")', '"10"');
213 // value + step is <= max, but rounded result would be > max.
214 shouldThrow('stepUp("89", "10", "99")', invalidStateErr);
 209shouldBe('stepUp("1", "2", "")', '"3"');
 210shouldBe('input.stepDown(); input.value', '"1"');
 211shouldBe('input.min = "0"; stepUp("9", "10", "", 9)', '"99"');
 212shouldBe('stepDown("19", "10", "0")', '"9"');
 213shouldBe('stepUp("89", "10", "99")', '"99"');
215214debug('Huge value and small step');
216215shouldBe('input.min = ""; stepUp("1e+38", "1", "", 999999)', '"1e+38"');
217216shouldBe('input.max = ""; stepDown("1e+38", "1", "", 999999)', '"1e+38"');

WebCore/ChangeLog

 12010-11-18 Dai Mikurube <dmikurube@google.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 stepUp/stepDown for values in step-mismatching state for input elements
 6 https://bugs.webkit.org/show_bug.cgi?id=48976
 7
 8 Fixed behaviors for already step-mismatched values.
 9
 10 * html/HTMLInputElement.cpp:
 11 (WebCore::HTMLInputElement::applyStep):
 12
1132010-11-14 Ryuan Choi <ryuan.choi@samsung.com>
214
315 Reviewed by Martin Robinson.

WebCore/html/HTMLInputElement.cpp

@@bool HTMLInputElement::getAllowedValueStepWithDecimalPlaces(double* step, unsign
300300void HTMLInputElement::applyStep(double count, ExceptionCode& ec)
301301{
302302 double step;
303  unsigned stepDecimalPlaces;
 303 unsigned stepDecimalPlaces, currentDecimalPlaces;
304304 if (!getAllowedValueStepWithDecimalPlaces(&step, &stepDecimalPlaces)) {
305305 ec = INVALID_STATE_ERR;
306306 return;
307307 }
308308 const double nan = numeric_limits<double>::quiet_NaN();
309  double current = m_inputType->parseToDouble(value(), nan);
 309 double current = m_inputType->parseToDoubleWithDecimalPlaces(value(), nan, &currentDecimalPlaces);
310310 if (!isfinite(current)) {
311311 ec = INVALID_STATE_ERR;
312312 return;

@@void HTMLInputElement::applyStep(double count, ExceptionCode& ec)
327327 double base = m_inputType->stepBaseWithDecimalPlaces(&baseDecimalPlaces);
328328 baseDecimalPlaces = min(baseDecimalPlaces, 16u);
329329 if (newValue < pow(10.0, 21.0)) {
330  double scale = pow(10.0, static_cast<double>(max(stepDecimalPlaces, baseDecimalPlaces)));
331  newValue = round((base + round((newValue - base) / step) * step) * scale) / scale;
 330 if (stepMismatch(value())) {
 331 double scale = pow(10.0, static_cast<double>(max(stepDecimalPlaces, currentDecimalPlaces)));
 332 newValue = round(newValue * scale) / scale;
 333 } else {
 334 double scale = pow(10.0, static_cast<double>(max(stepDecimalPlaces, baseDecimalPlaces)));
 335 newValue = round((base + round((newValue - base) / step) * step) * scale) / scale;
 336 }
332337 }
333338 if (newValue - m_inputType->maximum() > acceptableError) {
334339 ec = INVALID_STATE_ERR;