Files
browser/src/html/window.zig
2024-01-17 18:22:01 +01:00

48 lines
1.1 KiB
Zig

const std = @import("std");
const parser = @import("../netsurf.zig");
const EventTarget = @import("../dom/event_target.zig").EventTarget;
// https://dom.spec.whatwg.org/#interface-window-extensions
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#window
pub const Window = struct {
pub const prototype = *EventTarget;
pub const mem_guarantied = true;
document: ?*parser.Document = null,
target: []const u8,
pub fn create(target: ?[]const u8) Window {
return Window{
.target = target orelse "",
};
}
pub fn replaceDocument(self: *Window, doc: *parser.Document) void {
self.document = doc;
}
pub fn get_window(self: *Window) *Window {
return self;
}
pub fn get_self(self: *Window) *Window {
return self;
}
pub fn get_parent(self: *Window) *Window {
return self;
}
pub fn get_document(self: *Window) ?*parser.Document {
return self.document;
}
pub fn get_name(self: *Window) []const u8 {
return self.target;
}
// TODO we need to re-implement EventTarget interface.
};