mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
add nav web api
This commit is contained in:
@@ -4,6 +4,7 @@ const Console = @import("jsruntime").Console;
|
||||
|
||||
const DOM = @import("dom/dom.zig");
|
||||
const HTML = @import("html/html.zig");
|
||||
const nav = @import("nav/nav.zig");
|
||||
|
||||
pub const HTMLDocument = @import("html/document.zig").HTMLDocument;
|
||||
|
||||
@@ -12,4 +13,5 @@ pub const Interfaces = generate.Tuple(.{
|
||||
Console,
|
||||
DOM.Interfaces,
|
||||
HTML.Interfaces,
|
||||
nav.Interfaces,
|
||||
});
|
||||
@@ -3,9 +3,9 @@ const std = @import("std");
|
||||
const jsruntime = @import("jsruntime");
|
||||
|
||||
const parser = @import("netsurf.zig");
|
||||
const DOM = @import("dom.zig");
|
||||
const apiweb = @import("apiweb.zig");
|
||||
|
||||
pub const Types = jsruntime.reflect(DOM.Interfaces);
|
||||
pub const Types = jsruntime.reflect(apiweb.Interfaces);
|
||||
|
||||
const socket_path = "/tmp/browsercore-server.sock";
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ const std = @import("std");
|
||||
const jsruntime = @import("jsruntime");
|
||||
|
||||
const parser = @import("netsurf.zig");
|
||||
const DOM = @import("dom.zig");
|
||||
const apiweb = @import("apiweb.zig");
|
||||
|
||||
const html_test = @import("html_test.zig").html;
|
||||
|
||||
pub const Types = jsruntime.reflect(DOM.Interfaces);
|
||||
pub const Types = jsruntime.reflect(apiweb.Interfaces);
|
||||
|
||||
var doc: *parser.DocumentHTML = undefined;
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ const Suite = @import("wpt/testcase.zig").Suite;
|
||||
const FileLoader = @import("wpt/fileloader.zig").FileLoader;
|
||||
const wpt = @import("wpt/run.zig");
|
||||
|
||||
const DOM = @import("dom.zig");
|
||||
const apiweb = @import("apiweb.zig");
|
||||
const nav = @import("nav/nav.zig");
|
||||
const HTMLElem = @import("html/elements.zig");
|
||||
|
||||
const wpt_dir = "tests/wpt";
|
||||
@@ -29,7 +30,7 @@ const Out = enum {
|
||||
text,
|
||||
};
|
||||
|
||||
pub const Types = jsruntime.reflect(DOM.Interfaces);
|
||||
pub const Types = jsruntime.reflect(apiweb.Interfaces);
|
||||
|
||||
// TODO For now the WPT tests run is specific to WPT.
|
||||
// It manually load js framwork libs, and run the first script w/ js content in
|
||||
|
||||
7
src/nav/nav.zig
Normal file
7
src/nav/nav.zig
Normal file
@@ -0,0 +1,7 @@
|
||||
const generate = @import("../generate.zig");
|
||||
|
||||
const Window = @import("window.zig");
|
||||
|
||||
pub const Interfaces = generate.Tuple(.{
|
||||
Window,
|
||||
});
|
||||
41
src/nav/window.zig
Normal file
41
src/nav/window.zig
Normal file
@@ -0,0 +1,41 @@
|
||||
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,
|
||||
target: []const u8,
|
||||
|
||||
pub fn create(doc: *parser.Document, target: ?[]const u8) Window {
|
||||
return Window{
|
||||
.document = doc,
|
||||
.target = target orelse "",
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_window(self: *Window) *parser.Document {
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn get_self(self: *Window) *parser.Document {
|
||||
return self;
|
||||
}
|
||||
|
||||
pub fn get_parent(self: *Window) *parser.Document {
|
||||
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.
|
||||
};
|
||||
@@ -5,7 +5,7 @@ const jsruntime = @import("jsruntime");
|
||||
const generate = @import("generate.zig");
|
||||
|
||||
const parser = @import("netsurf.zig");
|
||||
const DOM = @import("dom.zig");
|
||||
const apiweb = @import("apiweb.zig");
|
||||
|
||||
const documentTestExecFn = @import("dom/document.zig").testExecFn;
|
||||
const HTMLDocumentTestExecFn = @import("html/document.zig").testExecFn;
|
||||
@@ -21,7 +21,7 @@ const DOMTokenListExecFn = @import("dom/token_list.zig").testExecFn;
|
||||
const NodeListTestExecFn = @import("dom/nodelist.zig").testExecFn;
|
||||
const AttrTestExecFn = @import("dom/attribute.zig").testExecFn;
|
||||
|
||||
pub const Types = jsruntime.reflect(DOM.Interfaces);
|
||||
pub const Types = jsruntime.reflect(apiweb.Interfaces);
|
||||
|
||||
var doc: *parser.DocumentHTML = undefined;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user