move window from nav to html

This commit is contained in:
Pierre Tachoire
2024-01-05 11:04:17 +01:00
parent 20b2bfa00e
commit c2ade9061b
6 changed files with 3 additions and 11 deletions

View File

@@ -2,10 +2,12 @@ const generate = @import("../generate.zig");
const HTMLDocument = @import("document.zig").HTMLDocument;
const HTMLElem = @import("elements.zig");
const Window = @import("window.zig").Window;
pub const Interfaces = generate.Tuple(.{
HTMLDocument,
HTMLElem.HTMLElement,
HTMLElem.HTMLMediaElement,
HTMLElem.Interfaces,
Window,
});

44
src/html/window.zig Normal file
View File

@@ -0,0 +1,44 @@
const std = @import("std");
const parser = @import("../netsurf.zig");
// 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 mem_guarantied = true;
document: *parser.Document = undefined,
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.
};