LibWeb/HTML: Step to next value without step mismatch

Inputs now correctly step to the next valid value if they suffer a step
mismatch.
This commit is contained in:
Glenn Skrzypczak 2025-08-11 01:58:50 +02:00 committed by Tim Flynn
commit 354fd56046
Notes: github-actions[bot] 2025-08-14 15:06:49 +00:00
2 changed files with 8 additions and 7 deletions

View file

@ -2822,13 +2822,14 @@ WebIDL::ExceptionOr<void> HTMLInputElement::step_up_or_down(bool is_down, WebIDL
// 7. If value subtracted from the step base is not an integral multiple of the allowed value step, then set value to the nearest value that,
// when subtracted from the step base, is an integral multiple of the allowed value step, and that is less than value if the method invoked was the stepDown() method, and more than value otherwise.
if (fmod(step_base() - value, allowed_value_step) != 0) {
double diff = step_base() - value;
if (is_down) {
value = diff - fmod(diff, allowed_value_step);
value = step_base() + floor((value - step_base()) / allowed_value_step) * allowed_value_step;
} else {
value = diff + fmod(diff, allowed_value_step);
value = step_base() + ceil((value - step_base()) / allowed_value_step) * allowed_value_step;
}
} else {
}
// Otherwise (value subtracted from the step base is an integral multiple of the allowed value step):
else {
// 1. Let n be the argument.
// 2. Let delta be the allowed value step multiplied by n.
double delta = allowed_value_step * n;