Merge pull request #75 from Browsercore/dom-documenttype

dom: add DocumentType
This commit is contained in:
Francis Bouvier
2023-11-23 14:33:25 +01:00
committed by GitHub
6 changed files with 102 additions and 0 deletions

View File

@@ -743,6 +743,31 @@ pub const DocumentPosition = enum(u2) {
implementation_specific = c.DOM_DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC,
};
// DocumentType
pub const DocumentType = c.dom_document_type;
fn documentTypeVtable(dt: *DocumentType) c.dom_document_type_vtable {
return getVtable(c.dom_document_type_vtable, DocumentType, dt);
}
pub inline fn documentTypeGetName(dt: *DocumentType) []const u8 {
var s: ?*String = undefined;
_ = documentTypeVtable(dt).dom_document_type_get_name.?(dt, &s);
return stringToData(s.?);
}
pub inline fn documentTypeGetPublicId(dt: *DocumentType) []const u8 {
var s: ?*String = undefined;
_ = documentTypeVtable(dt).dom_document_type_get_public_id.?(dt, &s);
return stringToData(s.?);
}
pub inline fn documentTypeGetSystemId(dt: *DocumentType) []const u8 {
var s: ?*String = undefined;
_ = documentTypeVtable(dt).dom_document_type_get_system_id.?(dt, &s);
return stringToData(s.?);
}
// Document
pub const Document = c.dom_document;
@@ -781,6 +806,12 @@ pub inline fn documentCreateElementNS(doc: *Document, ns: []const u8, tag_name:
return elem.?;
}
pub inline fn documentGetDoctype(doc: *Document) ?*DocumentType {
var dt: ?*DocumentType = undefined;
_ = documentVtable(doc).dom_document_get_doctype.?(doc, &dt);
return dt;
}
// DocumentHTML
pub const DocumentHTML = c.dom_html_document;