summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-03 10:41:07 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-03 10:45:39 +0100
commit342b787d1c3560e5026d24a17b6acb877ac64e8a (patch)
treef239f77a3924f6fb66d1ee039a26d3a5b0b279f4 /Userland/Libraries/LibWeb/DOM
parentcc2f35badd4bf689632ac1d5d59d717bd3a946c1 (diff)
downloadserenity-342b787d1c3560e5026d24a17b6acb877ac64e8a.zip
LibWeb: Move main thread JavaScript VM to its own file
Instead of being a weird little global function in DOM/Document.cpp, you can now get the main thread JS VM via Bindings::main_thread_vm().
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp17
1 files changed, 3 insertions, 14 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index 83b8a3a2a1..91b89e4bc5 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,7 +33,7 @@
#include <LibJS/Interpreter.h>
#include <LibJS/Parser.h>
#include <LibJS/Runtime/Function.h>
-#include <LibWeb/Bindings/DocumentWrapper.h>
+#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/Bindings/WindowObject.h>
#include <LibWeb/CSS/StyleResolver.h>
#include <LibWeb/DOM/Comment.h>
@@ -534,21 +534,10 @@ Color Document::visited_link_color() const
return page()->palette().visited_link();
}
-JS::VM& main_thread_vm();
-JS::VM& main_thread_vm()
-{
- static RefPtr<JS::VM> vm;
- if (!vm) {
- vm = JS::VM::create();
- vm->set_should_log_exceptions(true);
- }
- return *vm;
-}
-
JS::Interpreter& Document::interpreter()
{
if (!m_interpreter)
- m_interpreter = JS::Interpreter::create<Bindings::WindowObject>(main_thread_vm(), *m_window);
+ m_interpreter = JS::Interpreter::create<Bindings::WindowObject>(Bindings::main_thread_vm(), *m_window);
return *m_interpreter;
}