Skip to content

Commit 39fc5a7

Browse files
committed
init default HTML doc and Image w/ HTML Elements
1 parent 8cd3bbd commit 39fc5a7

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/browser/netsurf.zig

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,20 +2062,20 @@ pub inline fn domImplementationCreateHTMLDocument(title: ?[]const u8) !*Document
20622062
const doc = documentHTMLToDocument(doc_html);
20632063

20642064
// add hierarchy: html, head, body.
2065-
const html = try documentCreateElement(doc, "html");
2065+
const html = try documentCreateHTMLElement(doc, "html");
20662066
_ = try nodeAppendChild(documentToNode(doc), elementToNode(html));
20672067

2068-
const head = try documentCreateElement(doc, "head");
2068+
const head = try documentCreateHTMLElement(doc, "head");
20692069
_ = try nodeAppendChild(elementToNode(html), elementToNode(head));
20702070

20712071
if (title) |t| {
2072-
const htitle = try documentCreateElement(doc, "title");
2072+
const htitle = try documentCreateHTMLElement(doc, "title");
20732073
const txt = try documentCreateTextNode(doc, t);
20742074
_ = try nodeAppendChild(elementToNode(htitle), @as(*Node, @alignCast(@ptrCast(txt))));
20752075
_ = try nodeAppendChild(elementToNode(head), elementToNode(htitle));
20762076
}
20772077

2078-
const body = try documentCreateElement(doc, "body");
2078+
const body = try documentCreateHTMLElement(doc, "body");
20792079
_ = try nodeAppendChild(elementToNode(html), elementToNode(body));
20802080

20812081
return doc_html;
@@ -2156,13 +2156,32 @@ pub inline fn documentCreateDocument(title: ?[]const u8) !*DocumentHTML {
21562156
return doc_html;
21572157
}
21582158

2159+
pub inline fn documentCreateHTMLElement(doc: *Document, tag_name: []const u8) !*Element {
2160+
var elem: ?*Element = undefined;
2161+
const err = c._dom_html_document_create_element(doc, try strFromData(tag_name), &elem);
2162+
try DOMErr(err);
2163+
return elem.?;
2164+
}
2165+
21592166
pub inline fn documentCreateElement(doc: *Document, tag_name: []const u8) !*Element {
21602167
var elem: ?*Element = undefined;
21612168
const err = documentVtable(doc).dom_document_create_element.?(doc, try strFromData(tag_name), &elem);
21622169
try DOMErr(err);
21632170
return elem.?;
21642171
}
21652172

2173+
pub inline fn documentCreateHTMLElementNS(doc: *Document, ns: []const u8, tag_name: []const u8) !*Element {
2174+
var elem: ?*Element = undefined;
2175+
const err = c._dom_html_document_create_element_ns(
2176+
doc,
2177+
try strFromData(ns),
2178+
try strFromData(tag_name),
2179+
&elem,
2180+
);
2181+
try DOMErr(err);
2182+
return elem.?;
2183+
}
2184+
21662185
pub inline fn documentCreateElementNS(doc: *Document, ns: []const u8, tag_name: []const u8) !*Element {
21672186
var elem: ?*Element = undefined;
21682187
const err = documentVtable(doc).dom_document_create_element_ns.?(

0 commit comments

Comments
 (0)