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

LibWeb: Make DOM::Event and all its subclasses GC-allocated

This commit is contained in:
Andreas Kling 2022-08-08 22:29:40 +02:00
parent a4ddb0ef87
commit 7c3db526b0
76 changed files with 892 additions and 565 deletions

View file

@ -90,15 +90,15 @@ void HTMLInputElement::run_input_activation_behavior()
return;
// 2. Fire an event named input at the element with the bubbles and composed attributes initialized to true.
auto input_event = DOM::Event::create(HTML::EventNames::input);
auto input_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::input);
input_event->set_bubbles(true);
input_event->set_composed(true);
dispatch_event(move(input_event));
dispatch_event(*input_event);
// 3. Fire an event named change at the element with the bubbles attribute initialized to true.
auto change_event = DOM::Event::create(HTML::EventNames::change);
auto change_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::change);
change_event->set_bubbles(true);
dispatch_event(move(change_event));
dispatch_event(*change_event);
} else if (type_state() == TypeAttributeState::SubmitButton) {
RefPtr<HTMLFormElement> form;
// 1. If the element does not have a form owner, then return.
@ -112,7 +112,7 @@ void HTMLInputElement::run_input_activation_behavior()
// 3. Submit the form owner from the element.
form->submit_form(this);
} else {
dispatch_event(DOM::Event::create(EventNames::change));
dispatch_event(*DOM::Event::create(document().preferred_window_object(), EventNames::change));
}
}
@ -125,15 +125,15 @@ void HTMLInputElement::did_edit_text_node(Badge<BrowsingContext>)
// NOTE: This is a bit ad-hoc, but basically implements part of "4.10.5.5 Common event behaviors"
// https://html.spec.whatwg.org/multipage/input.html#common-input-element-events
queue_an_element_task(HTML::Task::Source::UserInteraction, [this] {
auto input_event = DOM::Event::create(HTML::EventNames::input);
auto input_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::input);
input_event->set_bubbles(true);
input_event->set_composed(true);
dispatch_event(move(input_event));
dispatch_event(*input_event);
// FIXME: This should only fire when the input is "committed", whatever that means.
auto change_event = DOM::Event::create(HTML::EventNames::change);
auto change_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::change);
change_event->set_bubbles(true);
dispatch_event(move(change_event));
dispatch_event(*change_event);
});
}