browser: update document parse signature

This commit is contained in:
Pierre Tachoire
2024-01-09 11:14:54 +01:00
parent e625e17597
commit 647fbc6ced
2 changed files with 5 additions and 2 deletions

View File

@@ -208,7 +208,7 @@ pub const Page = struct {
// https://html.spec.whatwg.org/#read-html // https://html.spec.whatwg.org/#read-html
fn loadHTMLDoc(self: *Page, result: *FetchResult) !void { fn loadHTMLDoc(self: *Page, result: *FetchResult) !void {
log.debug("parse html", .{}); log.debug("parse html", .{});
const html_doc = try parser.documentHTMLParseFromStrAlloc(self.allocator, result.body.?); const html_doc = try parser.documentHTMLParseFromStr(result.body.?);
const doc = parser.documentHTMLToDocument(html_doc); const doc = parser.documentHTMLToDocument(html_doc);
// save a document's pointer in the page. // save a document's pointer in the page.

View File

@@ -83,7 +83,10 @@ fn nodeFile(root: *parser.Element, out: File) !void {
// HTMLFileTestFn is run by run_tests.zig // HTMLFileTestFn is run by run_tests.zig
pub fn HTMLFileTestFn(out: File) !void { pub fn HTMLFileTestFn(out: File) !void {
const doc_html = try parser.documentHTMLParseFromFileAlloc(std.testing.allocator, "test.html"); const file = try std.fs.cwd().openFile("test.html", .{});
defer file.close();
const doc_html = try parser.documentHTMLParse(file.reader());
// ignore close error // ignore close error
defer parser.documentHTMLClose(doc_html) catch {}; defer parser.documentHTMLClose(doc_html) catch {};