mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-18 22:19:50 +00: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:
parent
a127f77602
commit
354fd56046
Notes:
github-actions[bot]
2025-08-14 15:06:49 +00:00
Author: https://github.com/skyz1
Commit: 354fd56046
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5812
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/trflynn89
2 changed files with 8 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue