mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 01:44:58 +00: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:
parent
a2ccb00e1d
commit
f0c5f77f99
122 changed files with 334 additions and 317 deletions
|
@ -22,7 +22,7 @@ namespace Web::HTML {
|
|||
HTMLScriptElement::HTMLScriptElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: HTMLElement(document, move(qualified_name))
|
||||
{
|
||||
set_prototype(&window().cached_web_prototype("HTMLScriptElement"));
|
||||
set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLScriptElement"));
|
||||
}
|
||||
|
||||
HTMLScriptElement::~HTMLScriptElement() = default;
|
||||
|
@ -57,7 +57,7 @@ void HTMLScriptElement::execute_script()
|
|||
// 3. If the script's script is null for scriptElement, then fire an event named error at scriptElement, and return.
|
||||
if (!m_script) {
|
||||
dbgln("HTMLScriptElement: Refusing to run script because the script's script is null.");
|
||||
dispatch_event(*DOM::Event::create(document().window(), HTML::EventNames::error));
|
||||
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ void HTMLScriptElement::execute_script()
|
|||
|
||||
// 7. If scriptElement is from an external file, then fire an event named load at scriptElement.
|
||||
if (m_from_an_external_file)
|
||||
dispatch_event(*DOM::Event::create(document().window(), HTML::EventNames::load));
|
||||
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::load));
|
||||
}
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match
|
||||
|
@ -268,7 +268,7 @@ void HTMLScriptElement::prepare_script()
|
|||
if (src.is_empty()) {
|
||||
dbgln("HTMLScriptElement: Refusing to run script because the src attribute is empty.");
|
||||
queue_an_element_task(HTML::Task::Source::Unspecified, [this] {
|
||||
dispatch_event(*DOM::Event::create(document().window(), HTML::EventNames::error));
|
||||
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ void HTMLScriptElement::prepare_script()
|
|||
if (!url.is_valid()) {
|
||||
dbgln("HTMLScriptElement: Refusing to run script because the src URL '{}' is invalid.", url);
|
||||
queue_an_element_task(HTML::Task::Source::Unspecified, [this] {
|
||||
dispatch_event(*DOM::Event::create(document().window(), HTML::EventNames::error));
|
||||
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue