LibWeb: Handle “default step”/“step scale factor” for more input types

This change adds “default step” and “step scale factor” handling for all
remaining HTMLInputElement input types for which the spec defines such
and that we didn’t yet have handling for.
This commit is contained in:
sideshowbarker 2025-03-09 04:01:06 +09:00 committed by Tim Ledbetter
parent 55483b0096
commit cfc1fd7305
Notes: github-actions[bot] 2025-04-14 08:44:14 +00:00
13 changed files with 435 additions and 4 deletions

View file

@ -2475,8 +2475,23 @@ double HTMLInputElement::default_step() const
if (type_state() == TypeAttributeState::Time)
return 60;
dbgln("HTMLInputElement::default_step() not implemented for input type {}", type());
return 0;
// https://html.spec.whatwg.org/multipage/input.html#date-state-(type=date):concept-input-step-default
if (type_state() == TypeAttributeState::Date)
return 1;
// https://html.spec.whatwg.org/multipage/input.html#month-state-(type=month):concept-input-step-default
if (type_state() == TypeAttributeState::Month)
return 1;
// https://html.spec.whatwg.org/multipage/input.html#week-state-(type=week):concept-input-step-default
if (type_state() == TypeAttributeState::Week)
return 1;
// https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type=datetime-local):concept-input-step-default
if (type_state() == TypeAttributeState::LocalDateAndTime)
return 60;
VERIFY_NOT_REACHED();
}
// https://html.spec.whatwg.org/multipage/input.html#concept-input-step-scale
@ -2494,8 +2509,23 @@ double HTMLInputElement::step_scale_factor() const
if (type_state() == TypeAttributeState::Time)
return 1000;
dbgln("HTMLInputElement::step_scale_factor() not implemented for input type {}", type());
return 0;
// https://html.spec.whatwg.org/multipage/input.html#date-state-(type=date):concept-input-step-scale
if (type_state() == TypeAttributeState::Date)
return 86400000;
// https://html.spec.whatwg.org/multipage/input.html#month-state-(type=month):concept-input-step-scale
if (type_state() == TypeAttributeState::Month)
return 1;
// https://html.spec.whatwg.org/multipage/input.html#week-state-(type=week):concept-input-step-scale
if (type_state() == TypeAttributeState::Week)
return 604800000;
// https://html.spec.whatwg.org/multipage/input.html#local-date-and-time-state-(type=datetime-local):concept-input-step-scale
if (type_state() == TypeAttributeState::LocalDateAndTime)
return 1000;
VERIFY_NOT_REACHED();
}
// https://html.spec.whatwg.org/multipage/input.html#concept-input-step