Skip to content

Commit 0559fb9

Browse files
committed
dom: first draft for window setTimeout
1 parent 89f898c commit 0559fb9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/html/window.zig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
const std = @import("std");
2020

2121
const parser = @import("netsurf");
22+
const jsruntime = @import("jsruntime");
23+
const Callback = jsruntime.Callback;
24+
const CallbackArg = jsruntime.CallbackArg;
25+
const Loop = jsruntime.Loop;
2226

2327
const EventTarget = @import("../dom/event_target.zig").EventTarget;
2428

@@ -82,4 +86,16 @@ pub const Window = struct {
8286
if (self.storageShelf == null) return parser.DOMError.NotSupported;
8387
return &self.storageShelf.?.bucket.session;
8488
}
89+
90+
// TODO handle callback arguments.
91+
pub fn _setTimeout(_: *Window, loop: *Loop, cbk: Callback, delay: ?u32) !u32 {
92+
const ddelay: u63 = delay orelse 0;
93+
loop.timeout(ddelay * std.time.ns_per_ms, cbk);
94+
// TODO handle timeout ID
95+
return 1;
96+
}
97+
98+
pub fn _clearTimeout(_: *Window, _: *Loop, id: u32) !void {
99+
_ = id;
100+
}
85101
};

0 commit comments

Comments
 (0)