1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 19:35:08 +00:00

LibWeb: Fix up constructing the form entry list

In particular:
- Don't include none submitter buttons.
- Use type_state() instead type() to avoid direct string comparisons
- Support the hidden _charset_ input
- Get form associated element's value directly instead of via the value
  attribute
- Split line break normalization into a separate function so that it
  can also be used by form submission.
This commit is contained in:
Luke Wilde 2023-06-18 15:08:15 +01:00 committed by Andreas Kling
parent f154446a9f
commit c9c1ddd0bb
8 changed files with 101 additions and 30 deletions

View file

@ -1085,4 +1085,24 @@ Optional<ARIA::Role> HTMLInputElement::default_role() const
return {};
}
bool HTMLInputElement::is_button() const
{
// https://html.spec.whatwg.org/multipage/input.html#submit-button-state-(type=submit):concept-button
// https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):concept-button
// https://html.spec.whatwg.org/multipage/input.html#reset-button-state-(type=reset):concept-button
// https://html.spec.whatwg.org/multipage/input.html#button-state-(type=button):concept-button
return type_state() == TypeAttributeState::SubmitButton
|| type_state() == TypeAttributeState::ImageButton
|| type_state() == TypeAttributeState::ResetButton
|| type_state() == TypeAttributeState::Button;
}
bool HTMLInputElement::is_submit_button() const
{
// https://html.spec.whatwg.org/multipage/input.html#submit-button-state-(type=submit):concept-submit-button
// https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):concept-submit-button
return type_state() == TypeAttributeState::SubmitButton
|| type_state() == TypeAttributeState::ImageButton;
}
}