mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:57:35 +00:00
LibWeb: Give HTML::EventLoop a pointer to the JS::VM
This will be required for event loop processing.
This commit is contained in:
parent
7bcde2bcfb
commit
e0c7f8dafa
3 changed files with 16 additions and 1 deletions
|
@ -12,8 +12,10 @@ namespace Web::Bindings {
|
||||||
JS::VM& main_thread_vm()
|
JS::VM& main_thread_vm()
|
||||||
{
|
{
|
||||||
static RefPtr<JS::VM> vm;
|
static RefPtr<JS::VM> vm;
|
||||||
if (!vm)
|
if (!vm) {
|
||||||
vm = JS::VM::create(make<WebEngineCustomData>());
|
vm = JS::VM::create(make<WebEngineCustomData>());
|
||||||
|
static_cast<WebEngineCustomData*>(vm->custom_data())->event_loop.set_vm(*vm);
|
||||||
|
}
|
||||||
return *vm;
|
return *vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,12 @@ EventLoop::~EventLoop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventLoop::set_vm(JS::VM& vm)
|
||||||
|
{
|
||||||
|
VERIFY(!m_vm);
|
||||||
|
m_vm = &vm;
|
||||||
|
}
|
||||||
|
|
||||||
EventLoop& main_thread_event_loop()
|
EventLoop& main_thread_event_loop()
|
||||||
{
|
{
|
||||||
return static_cast<Bindings::WebEngineCustomData*>(Bindings::main_thread_vm().custom_data())->event_loop;
|
return static_cast<Bindings::WebEngineCustomData*>(Bindings::main_thread_vm().custom_data())->event_loop;
|
||||||
|
|
|
@ -35,6 +35,11 @@ public:
|
||||||
|
|
||||||
Task const* currently_running_task() const { return m_currently_running_task; }
|
Task const* currently_running_task() const { return m_currently_running_task; }
|
||||||
|
|
||||||
|
JS::VM& vm() { return *m_vm; }
|
||||||
|
JS::VM const& vm() const { return *m_vm; }
|
||||||
|
|
||||||
|
void set_vm(JS::VM&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type m_type { Type::Window };
|
Type m_type { Type::Window };
|
||||||
|
|
||||||
|
@ -42,6 +47,8 @@ private:
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/webappapis.html#currently-running-task
|
// https://html.spec.whatwg.org/multipage/webappapis.html#currently-running-task
|
||||||
Task* m_currently_running_task { nullptr };
|
Task* m_currently_running_task { nullptr };
|
||||||
|
|
||||||
|
JS::VM* m_vm { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
EventLoop& main_thread_event_loop();
|
EventLoop& main_thread_event_loop();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue