From 700cbc02ec01213bbcf85a9efc0636681adfed5f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 27 Sep 2020 20:31:13 +0200 Subject: [PATCH] LibWeb: Use JS::VM::call() in timer and RAF callback invocation This removes assumptions about having an Interpreter, and also unbreaks requestAnimationFrame which was asserting. --- Libraries/LibWeb/DOM/Window.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Libraries/LibWeb/DOM/Window.cpp b/Libraries/LibWeb/DOM/Window.cpp index 6661639ce6f..1bfce5ad6a4 100644 --- a/Libraries/LibWeb/DOM/Window.cpp +++ b/Libraries/LibWeb/DOM/Window.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -86,6 +85,7 @@ void Window::timer_did_fire(Badge, Timer& timer) { // We should not be here if there's no JS wrapper for the Window object. ASSERT(wrapper()); + auto& vm = wrapper()->vm(); // NOTE: This protector pointer keeps the timer alive until the end of this function no matter what. NonnullRefPtr protector(timer); @@ -94,10 +94,9 @@ void Window::timer_did_fire(Badge, Timer& timer) m_timers.remove(timer.id()); } - auto& interpreter = document().interpreter(); - (void)interpreter.call(timer.callback(), wrapper()); - if (interpreter.exception()) - interpreter.vm().clear_exception(); + (void)vm.call(timer.callback(), wrapper()); + if (vm.exception()) + vm.clear_exception(); } i32 Window::allocate_timer_id(Badge) @@ -122,11 +121,11 @@ i32 Window::request_animation_frame(JS::Function& callback) i32 link_id = GUI::DisplayLink::register_callback([handle = make_handle(&callback)](i32 link_id) { auto& function = const_cast(static_cast(*handle.cell())); - auto& interpreter = function.interpreter(); + auto& vm = function.vm(); fake_timestamp += 10; - (void)interpreter.call(function, {}, JS::Value(fake_timestamp)); - if (interpreter.exception()) - interpreter.vm().clear_exception(); + (void)vm.call(function, {}, JS::Value(fake_timestamp)); + if (vm.exception()) + vm.clear_exception(); GUI::DisplayLink::unregister_callback(link_id); });