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:
Andrew Kaster 2022-09-25 16:38:21 -06:00 committed by Linus Groh
parent a2ccb00e1d
commit f0c5f77f99
Notes: sideshowbarker 2024-07-17 06:28:27 +09:00
122 changed files with 334 additions and 317 deletions

View file

@ -19,7 +19,7 @@ namespace Web::HTML {
HTMLObjectElement::HTMLObjectElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: BrowsingContextContainer(document, move(qualified_name))
{
set_prototype(&window().cached_web_prototype("HTMLObjectElement"));
set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLObjectElement"));
}
HTMLObjectElement::~HTMLObjectElement() = default;
@ -97,7 +97,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps()
// 3. If that failed, fire an event named error at the element, then jump to the step below labeled fallback.
if (!url.is_valid()) {
dispatch_event(*DOM::Event::create(document().window(), HTML::EventNames::error));
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
return run_object_representation_fallback_steps();
}
@ -124,7 +124,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps()
void HTMLObjectElement::resource_did_fail()
{
// 4.7. If the load failed (e.g. there was an HTTP 404 error, there was a DNS error), fire an event named error at the element, then jump to the step below labeled fallback.
dispatch_event(*DOM::Event::create(document().window(), HTML::EventNames::error));
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
run_object_representation_fallback_steps();
}
@ -262,7 +262,7 @@ void HTMLObjectElement::run_object_representation_completed_steps(Representation
// 4.11. If the object element does not represent its nested browsing context, then once the resource is completely loaded, queue an element task on the DOM manipulation task source given the object element to fire an event named load at the element.
if (representation != Representation::NestedBrowsingContext) {
queue_an_element_task(HTML::Task::Source::DOMManipulation, [&]() {
dispatch_event(*DOM::Event::create(document().window(), HTML::EventNames::load));
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load));
});
}