mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +00:00
LibJS: Add a helper for calling JS::Function's with arguments
The fact that a `MarkedValueList` had to be created was just annoying, so here's an alternative. This patchset also removes some (now) unneeded MarkedValueList.h includes.
This commit is contained in:
parent
521e730df1
commit
394e4c04cd
15 changed files with 72 additions and 113 deletions
|
@ -28,12 +28,11 @@
|
|||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/MarkedValueList.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/Timer.h>
|
||||
#include <LibWeb/DOM/Window.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/InProcessWebView.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -122,10 +121,8 @@ 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<JS::Function&>(static_cast<const JS::Function&>(*handle.cell()));
|
||||
auto& interpreter = function.interpreter();
|
||||
JS::MarkedValueList arguments(interpreter.heap());
|
||||
arguments.append(JS::Value(fake_timestamp));
|
||||
fake_timestamp += 10;
|
||||
(void)interpreter.call(function, {}, move(arguments));
|
||||
(void)interpreter.call(function, {}, JS::Value(fake_timestamp));
|
||||
if (interpreter.exception())
|
||||
interpreter.clear_exception();
|
||||
GUI::DisplayLink::unregister_callback(link_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue