mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:38:11 +00:00
LibWeb: Introduce the Environment Settings Object
The environment settings object is effectively the context a piece of script is running under, for example, it contains the origin, responsible document, realm, global object and event loop for the current context. This effectively replaces ScriptExecutionContext, but it cannot be removed in this commit as EventTarget still depends on it. https://html.spec.whatwg.org/multipage/webappapis.html#environment-settings-object
This commit is contained in:
parent
4db5406d62
commit
f71f404e0c
29 changed files with 883 additions and 86 deletions
|
@ -41,6 +41,7 @@
|
|||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/HTML/EventHandler.h>
|
||||
#include <LibWeb/HTML/Scripting/ClassicScript.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/WebAssembly/WebAssemblyObject.h>
|
||||
|
@ -232,7 +233,8 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::set_interval)
|
|||
// using a NativeFunction for the latter is a workaround so that we can reuse the
|
||||
// DOM::Timer API unaltered (always expects a JS::FunctionObject).
|
||||
callback = JS::NativeFunction::create(global_object, "", [impl, script_source = move(script_source)](auto&, auto&) mutable {
|
||||
auto script = HTML::ClassicScript::create(impl->associated_document().url().to_string(), script_source, impl->associated_document().realm(), AK::URL());
|
||||
auto& settings_object = verify_cast<HTML::EnvironmentSettingsObject>(*impl->associated_document().realm().host_defined());
|
||||
auto script = HTML::ClassicScript::create(impl->associated_document().url().to_string(), script_source, settings_object, AK::URL());
|
||||
return script->run();
|
||||
});
|
||||
}
|
||||
|
@ -265,7 +267,8 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::set_timeout)
|
|||
// using a NativeFunction for the latter is a workaround so that we can reuse the
|
||||
// DOM::Timer API unaltered (always expects a JS::FunctionObject).
|
||||
callback = JS::NativeFunction::create(global_object, "", [impl, script_source = move(script_source)](auto&, auto&) mutable {
|
||||
auto script = HTML::ClassicScript::create(impl->associated_document().url().to_string(), script_source, impl->associated_document().realm(), AK::URL());
|
||||
auto& settings_object = verify_cast<HTML::EnvironmentSettingsObject>(*impl->associated_document().realm().host_defined());
|
||||
auto script = HTML::ClassicScript::create(impl->associated_document().url().to_string(), script_source, settings_object, AK::URL());
|
||||
return script->run();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue