mirror of
				https://github.com/lightpanda-io/browser.git
				synced 2025-10-30 15:41:48 +00:00 
			
		
		
		
	netsurf: remove deprecated API for parsing HTML
This commit is contained in:
		| @@ -61,7 +61,10 @@ pub fn main() !void { | ||||
|     defer arena.deinit(); | ||||
|  | ||||
|     // document | ||||
|     doc = try parser.documentHTMLParseFromFileAlloc(arena.allocator(), "test.html"); | ||||
|     const file = try std.fs.cwd().openFile("test.html", .{}); | ||||
|     defer file.close(); | ||||
|  | ||||
|     doc = try parser.documentHTMLParseFromFile(file); | ||||
|     defer parser.documentHTMLClose(doc) catch |err| { | ||||
|         std.debug.print("documentHTMLClose error: {s}\n", .{@errorName(err)}); | ||||
|     }; | ||||
|   | ||||
| @@ -42,7 +42,10 @@ pub fn main() !void { | ||||
|     defer arena.deinit(); | ||||
|  | ||||
|     // document | ||||
|     doc = try parser.documentHTMLParseFromFileAlloc(arena.allocator(), "test.html"); | ||||
|     const file = try std.fs.cwd().openFile("test.html", .{}); | ||||
|     defer file.close(); | ||||
|  | ||||
|     doc = try parser.documentHTMLParseFromFile(file); | ||||
|     defer parser.documentHTMLClose(doc) catch |err| { | ||||
|         std.debug.print("documentHTMLClose error: {s}\n", .{@errorName(err)}); | ||||
|     }; | ||||
|   | ||||
| @@ -1281,21 +1281,9 @@ fn documentHTMLVtable(doc_html: *DocumentHTML) c.dom_html_document_vtable { | ||||
|     return getVtable(c.dom_html_document_vtable, DocumentHTML, doc_html); | ||||
| } | ||||
|  | ||||
| // documentHTMLParseFromFileAlloc parses the file. | ||||
| // The allocator is required to create a null terminated string from filename. | ||||
| // The buffer is freed by the function. | ||||
| // The caller is responsible for closing the document. | ||||
| // DEPRECATED | ||||
| pub fn documentHTMLParseFromFileAlloc(_: std.mem.Allocator, filename: []const u8) !*DocumentHTML { | ||||
|     return documentHTMLParseFromFile(filename); | ||||
| } | ||||
|  | ||||
| // documentHTMLParseFromFile parses the given HTML file. | ||||
| // The caller is responsible for closing the document. | ||||
| pub fn documentHTMLParseFromFile(filename: []const u8) !*DocumentHTML { | ||||
|     const file = try std.fs.openFileAbsolute(filename, .{}); | ||||
|     defer file.close(); | ||||
|  | ||||
| pub fn documentHTMLParseFromFile(file: std.fs.File) !*DocumentHTML { | ||||
|     var parser: ?*c.dom_hubbub_parser = undefined; | ||||
|     var doc: ?*c.dom_document = undefined; | ||||
|     var err: c.hubbub_error = undefined; | ||||
| @@ -1334,15 +1322,6 @@ pub fn documentHTMLParseFromFile(filename: []const u8) !*DocumentHTML { | ||||
|     return @as(*DocumentHTML, @ptrCast(doc.?)); | ||||
| } | ||||
|  | ||||
| // documentHTMLParseFromStrAlloc the given string. | ||||
| // The allocator is required to create a null terminated string. | ||||
| // The c string allocated is freed by the function. | ||||
| // The caller is responsible for closing the document. | ||||
| // DEPRECATED | ||||
| pub fn documentHTMLParseFromStrAlloc(_: std.mem.Allocator, str: []const u8) !*DocumentHTML { | ||||
|     return documentHTMLParseFromStr(str); | ||||
| } | ||||
|  | ||||
| // documentHTMLParseFromStr parses the given HTML string. | ||||
| // The caller is responsible for closing the document. | ||||
| pub fn documentHTMLParseFromStr(str: []const u8) !*DocumentHTML { | ||||
|   | ||||
| @@ -37,7 +37,10 @@ fn testExecFn( | ||||
|     try js_env.attachObject(try js_env.getGlobal(), "window", null); | ||||
|  | ||||
|     // document | ||||
|     doc = try parser.documentHTMLParseFromFileAlloc(std.testing.allocator, "test.html"); | ||||
|     const file = try std.fs.cwd().openFile("test.html", .{}); | ||||
|     defer file.close(); | ||||
|  | ||||
|     doc = try parser.documentHTMLParseFromFile(file); | ||||
|     defer parser.documentHTMLClose(doc) catch |err| { | ||||
|         std.debug.print("documentHTMLClose error: {s}\n", .{@errorName(err)}); | ||||
|     }; | ||||
|   | ||||
| @@ -17,7 +17,10 @@ pub fn run(arena: *std.heap.ArenaAllocator, comptime apis: []jsruntime.API, comp | ||||
|     const alloc = arena.allocator(); | ||||
|  | ||||
|     // document | ||||
|     const html_doc = try parser.documentHTMLParseFromFileAlloc(alloc, f); | ||||
|     const file = try std.fs.cwd().openFile(f, .{}); | ||||
|     defer file.close(); | ||||
|  | ||||
|     const html_doc = try parser.documentHTMLParseFromFile(file); | ||||
|     const doc = parser.documentHTMLToDocument(html_doc); | ||||
|  | ||||
|     const dirname = fspath.dirname(f[dir.len..]) orelse unreachable; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Pierre Tachoire
					Pierre Tachoire