diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-21 23:49:09 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-21 23:49:09 +0200 |
commit | 54133c683d3c62c1561552b1f7e6b3d262ae8011 (patch) | |
tree | f523dd26be82349264deae1f70bd00b2d2aa6ef9 /Libraries/LibWeb | |
parent | 627fd6374bb4ad31109b9776fdc6cc7b6e840aca (diff) | |
download | serenity-54133c683d3c62c1561552b1f7e6b3d262ae8011.zip |
LibWeb: Hack requestAnimationFrame() to provide a (very fake) timestamp
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r-- | Libraries/LibWeb/DOM/Window.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Libraries/LibWeb/DOM/Window.cpp b/Libraries/LibWeb/DOM/Window.cpp index f5f48e2a5b..22f307a7c9 100644 --- a/Libraries/LibWeb/DOM/Window.cpp +++ b/Libraries/LibWeb/DOM/Window.cpp @@ -29,6 +29,7 @@ #include <LibGUI/MessageBox.h> #include <LibJS/Interpreter.h> #include <LibJS/Runtime/Function.h> +#include <LibJS/Runtime/MarkedValueList.h> #include <LibWeb/DOM/Window.h> namespace Web { @@ -81,10 +82,16 @@ void Window::set_timeout(JS::Function& callback, i32 interval) i32 Window::request_animation_frame(JS::Function& callback) { + // FIXME: This is extremely fake! + static double fake_timestamp = 0; + 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(); - interpreter.call(function); + JS::MarkedValueList arguments(interpreter.heap()); + arguments.append(JS::Value(fake_timestamp)); + fake_timestamp += 10; + interpreter.call(function, {}, move(arguments)); GUI::DisplayLink::unregister_callback(link_id); }); |