dom: first draft for window setTimeout

This commit is contained in:
Pierre Tachoire
2024-04-25 10:49:43 +02:00
parent 89f898cfa9
commit 0559fb9365

View File

@@ -19,6 +19,10 @@
const std = @import("std"); const std = @import("std");
const parser = @import("netsurf"); const parser = @import("netsurf");
const jsruntime = @import("jsruntime");
const Callback = jsruntime.Callback;
const CallbackArg = jsruntime.CallbackArg;
const Loop = jsruntime.Loop;
const EventTarget = @import("../dom/event_target.zig").EventTarget; const EventTarget = @import("../dom/event_target.zig").EventTarget;
@@ -82,4 +86,16 @@ pub const Window = struct {
if (self.storageShelf == null) return parser.DOMError.NotSupported; if (self.storageShelf == null) return parser.DOMError.NotSupported;
return &self.storageShelf.?.bucket.session; return &self.storageShelf.?.bucket.session;
} }
// TODO handle callback arguments.
pub fn _setTimeout(_: *Window, loop: *Loop, cbk: Callback, delay: ?u32) !u32 {
const ddelay: u63 = delay orelse 0;
loop.timeout(ddelay * std.time.ns_per_ms, cbk);
// TODO handle timeout ID
return 1;
}
pub fn _clearTimeout(_: *Window, _: *Loop, id: u32) !void {
_ = id;
}
}; };