mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-17 00:38:59 +00:00
Merge pull request #75 from Browsercore/dom-documenttype
dom: add DocumentType
This commit is contained in:
@@ -13,6 +13,8 @@ const collection = @import("html_collection.zig");
|
||||
const Element = @import("element.zig").Element;
|
||||
const ElementUnion = @import("element.zig").Union;
|
||||
|
||||
const DocumentType = @import("document_type.zig").DocumentType;
|
||||
|
||||
// WEB IDL https://dom.spec.whatwg.org/#document
|
||||
pub const Document = struct {
|
||||
pub const Self = parser.Document;
|
||||
@@ -26,6 +28,10 @@ pub const Document = struct {
|
||||
|
||||
// JS funcs
|
||||
// --------
|
||||
//
|
||||
pub fn get_doctype(self: *parser.Document) ?*parser.DocumentType {
|
||||
return parser.documentGetDoctype(self);
|
||||
}
|
||||
|
||||
pub fn _getElementById(self: *parser.Document, id: []const u8) ?ElementUnion {
|
||||
const e = parser.documentGetElementById(self, id) orelse return null;
|
||||
|
||||
24
src/dom/document_type.zig
Normal file
24
src/dom/document_type.zig
Normal file
@@ -0,0 +1,24 @@
|
||||
const std = @import("std");
|
||||
|
||||
const parser = @import("../netsurf.zig");
|
||||
|
||||
const Node = @import("node.zig").Node;
|
||||
|
||||
// WEB IDL https://dom.spec.whatwg.org/#documenttype
|
||||
pub const DocumentType = struct {
|
||||
pub const Self = parser.DocumentType;
|
||||
pub const prototype = *Node;
|
||||
pub const mem_guarantied = true;
|
||||
|
||||
pub fn get_name(self: *parser.DocumentType) []const u8 {
|
||||
return parser.documentTypeGetName(self);
|
||||
}
|
||||
|
||||
pub fn get_publicId(self: *parser.DocumentType) []const u8 {
|
||||
return parser.documentTypeGetPublicId(self);
|
||||
}
|
||||
|
||||
pub fn get_systemId(self: *parser.DocumentType) []const u8 {
|
||||
return parser.documentTypeGetSystemId(self);
|
||||
}
|
||||
};
|
||||
@@ -14,6 +14,7 @@ const EventTarget = @import("event_target.zig").EventTarget;
|
||||
const CData = @import("character_data.zig");
|
||||
const Element = @import("element.zig").Element;
|
||||
const Document = @import("document.zig").Document;
|
||||
const DocumentType = @import("document_type.zig").DocumentType;
|
||||
const HTMLCollection = @import("html_collection.zig").HTMLCollection;
|
||||
|
||||
// HTML
|
||||
@@ -26,6 +27,7 @@ pub const Interfaces = generate.Tuple(.{
|
||||
CData.Interfaces,
|
||||
Element,
|
||||
Document,
|
||||
DocumentType,
|
||||
HTMLCollection,
|
||||
|
||||
HTML.Interfaces,
|
||||
@@ -46,6 +48,7 @@ pub const Node = struct {
|
||||
.comment => .{ .Comment = @as(*parser.Comment, @ptrCast(node)) },
|
||||
.text => .{ .Text = @as(*parser.Text, @ptrCast(node)) },
|
||||
.document => .{ .HTMLDocument = @as(*parser.DocumentHTML, @ptrCast(node)) },
|
||||
.document_type => .{ .DocumentType = @as(*parser.DocumentType, @ptrCast(node)) },
|
||||
else => @panic("node type not handled"), // TODO
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user