mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:07:44 +00:00
LibWeb: Hack requestAnimationFrame() to provide a (very fake) timestamp
This commit is contained in:
parent
627fd6374b
commit
54133c683d
1 changed files with 8 additions and 1 deletions
|
@ -29,6 +29,7 @@
|
||||||
#include <LibGUI/MessageBox.h>
|
#include <LibGUI/MessageBox.h>
|
||||||
#include <LibJS/Interpreter.h>
|
#include <LibJS/Interpreter.h>
|
||||||
#include <LibJS/Runtime/Function.h>
|
#include <LibJS/Runtime/Function.h>
|
||||||
|
#include <LibJS/Runtime/MarkedValueList.h>
|
||||||
#include <LibWeb/DOM/Window.h>
|
#include <LibWeb/DOM/Window.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
@ -81,10 +82,16 @@ void Window::set_timeout(JS::Function& callback, i32 interval)
|
||||||
|
|
||||||
i32 Window::request_animation_frame(JS::Function& callback)
|
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) {
|
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* function = const_cast<JS::Function*>(static_cast<const JS::Function*>(handle.cell()));
|
||||||
auto& interpreter = function->interpreter();
|
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);
|
GUI::DisplayLink::unregister_callback(link_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue