browser: inject window global object

This commit is contained in:
Pierre Tachoire
2023-12-21 09:44:48 +01:00
parent 6ff121334f
commit 0d32fc62ba
3 changed files with 6 additions and 7 deletions

View File

@@ -143,10 +143,9 @@ pub const Page = struct {
// add global objects // add global objects
log.debug("setup global env", .{}); log.debug("setup global env", .{});
const window = Window.create(doc, null); const window = Window.create(doc, null);
_ = window;
// TODO should'nt we share the same pointer between instances of window? // TODO should'nt we share the same pointer between instances of window?
// try js_env.addObject(apis, window, "self"); try self.env.addObject(apis, window, "self");
// try js_env.addObject(apis, window, "window"); try self.env.addObject(apis, window, "window");
try self.env.addObject(apis, doc, "document"); try self.env.addObject(apis, doc, "document");
} }
}; };

View File

@@ -1,6 +1,6 @@
const generate = @import("../generate.zig"); const generate = @import("../generate.zig");
const Window = @import("window.zig"); const Window = @import("window.zig").Window;
pub const Interfaces = generate.Tuple(.{ pub const Interfaces = generate.Tuple(.{
Window, Window,

View File

@@ -17,15 +17,15 @@ pub const Window = struct {
}; };
} }
pub fn get_window(self: *Window) *parser.Document { pub fn get_window(self: *Window) *Window {
return self; return self;
} }
pub fn get_self(self: *Window) *parser.Document { pub fn get_self(self: *Window) *Window {
return self; return self;
} }
pub fn get_parent(self: *Window) *parser.Document { pub fn get_parent(self: *Window) *Window {
return self; return self;
} }