mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibWeb: Remove unecessary dependence on Window from HTML classes
These classes only needed Window to get at its realm. Pass a realm directly to construct HTML classes.
This commit is contained in:
committed by
Linus Groh
parent
a2ccb00e1d
commit
f0c5f77f99
Notes:
sideshowbarker
2024-07-17 06:28:27 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/f0c5f77f99 Pull-request: https://github.com/SerenityOS/serenity/pull/15349 Reviewed-by: https://github.com/linusg ✅
@@ -24,7 +24,7 @@ HTMLInputElement::HTMLInputElement(DOM::Document& document, DOM::QualifiedName q
|
||||
: HTMLElement(document, move(qualified_name))
|
||||
, m_value(String::empty())
|
||||
{
|
||||
set_prototype(&window().cached_web_prototype("HTMLInputElement"));
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLInputElement"));
|
||||
|
||||
activation_behavior = [this](auto&) {
|
||||
// The activation behavior for input elements are these steps:
|
||||
@@ -99,13 +99,13 @@ 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(document().window(), HTML::EventNames::input);
|
||||
auto input_event = DOM::Event::create(realm(), HTML::EventNames::input);
|
||||
input_event->set_bubbles(true);
|
||||
input_event->set_composed(true);
|
||||
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(document().window(), HTML::EventNames::change);
|
||||
auto change_event = DOM::Event::create(realm(), HTML::EventNames::change);
|
||||
change_event->set_bubbles(true);
|
||||
dispatch_event(*change_event);
|
||||
} else if (type_state() == TypeAttributeState::SubmitButton) {
|
||||
@@ -121,7 +121,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(document().window(), EventNames::change));
|
||||
dispatch_event(*DOM::Event::create(realm(), EventNames::change));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,13 +134,13 @@ 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(document().window(), HTML::EventNames::input);
|
||||
auto input_event = DOM::Event::create(realm(), HTML::EventNames::input);
|
||||
input_event->set_bubbles(true);
|
||||
input_event->set_composed(true);
|
||||
dispatch_event(*input_event);
|
||||
|
||||
// FIXME: This should only fire when the input is "committed", whatever that means.
|
||||
auto change_event = DOM::Event::create(document().window(), HTML::EventNames::change);
|
||||
auto change_event = DOM::Event::create(realm(), HTML::EventNames::change);
|
||||
change_event->set_bubbles(true);
|
||||
dispatch_event(*change_event);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user