mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 02:05:07 +02:00
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:
committed by
Tim Flynn
parent
a127f77602
commit
354fd56046
Notes:
github-actions[bot]
2025-08-14 15:06:49 +00:00
Author: https://github.com/skyz1 Commit: https://github.com/LadybirdBrowser/ladybird/commit/354fd560464 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5812 Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/trflynn89
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user