mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-04 10:18:51 +00:00
LibWeb: Respect the trusted state of input events when submitting forms
This involves passing the UserNavigationInvolvement from each form associated element that triggers a submit through to the methods that perform the actual navigation. While here, refactor HTMLFormElement to use the new Bindings::NavigationHistoryBehavior enum.
This commit is contained in:
parent
a5e1364938
commit
7d2635355d
Notes:
sideshowbarker
2024-07-16 23:08:48 +09:00
Author: https://github.com/ADKaster
Commit: 7d2635355d
Pull-request: https://github.com/SerenityOS/serenity/pull/22850
5 changed files with 70 additions and 79 deletions
|
@ -70,40 +70,40 @@ bool HTMLButtonElement::has_activation_behavior() const
|
|||
return true;
|
||||
}
|
||||
|
||||
void HTMLButtonElement::activation_behavior(DOM::Event const&)
|
||||
void HTMLButtonElement::activation_behavior(DOM::Event const& event)
|
||||
{
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element:activation-behaviour
|
||||
// 1. If element is disabled, then return.
|
||||
if (!enabled())
|
||||
return;
|
||||
|
||||
// 2. If element does not have a form owner, then return.
|
||||
if (!form())
|
||||
return;
|
||||
|
||||
// 3. If element's node document is not fully active, then return.
|
||||
// 2. If element's node document is not fully active, then return.
|
||||
if (!this->document().is_fully_active())
|
||||
return;
|
||||
|
||||
// 4. Switch on element's type attribute's state:
|
||||
switch (type_state()) {
|
||||
case TypeAttributeState::Submit:
|
||||
// Submit Button
|
||||
// Submit element's form owner from element.
|
||||
form()->submit_form(*this).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
case TypeAttributeState::Reset:
|
||||
// Reset Button
|
||||
// Reset element's form owner.
|
||||
form()->reset_form();
|
||||
break;
|
||||
case TypeAttributeState::Button:
|
||||
// Button
|
||||
// Do nothing.
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
// 3. If element has a form owner then switch on element's type attribute's state, then:
|
||||
if (form() != nullptr) {
|
||||
switch (type_state()) {
|
||||
case TypeAttributeState::Submit:
|
||||
// Submit Button
|
||||
// Submit element's form owner from element with userInvolvement set to event's user navigation involvement.
|
||||
form()->submit_form(*this, { .user_involvement = user_navigation_involvement(event) }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
case TypeAttributeState::Reset:
|
||||
// Reset Button
|
||||
// Reset element's form owner.
|
||||
form()->reset_form();
|
||||
break;
|
||||
case TypeAttributeState::Button:
|
||||
// Button
|
||||
// Do nothing.
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
// 4. FIXME: Run the popover target attribute activation behavior given element.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue