mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
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:
committed by
Tim Ledbetter
parent
55483b0096
commit
cfc1fd7305
Notes:
github-actions[bot]
2025-04-14 08:44:14 +00:00
Author: https://github.com/sideshowbarker Commit: https://github.com/LadybirdBrowser/ladybird/commit/cfc1fd73055 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4346 Reviewed-by: https://github.com/tcl3 ✅
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user